Merge branch 'raysan5:master' into master
This commit is contained in:
commit
9f5abf21e3
|
|
@ -12,6 +12,7 @@ Some people ported raylib to other languages in form of bindings or wrappers to
|
||||||
| Raylib-CsLo | **4.2** | [C#](https://en.wikipedia.org/wiki/C_Sharp_(programming_language)) | MPL-2.0 | https://github.com/NotNotTech/Raylib-CsLo |
|
| Raylib-CsLo | **4.2** | [C#](https://en.wikipedia.org/wiki/C_Sharp_(programming_language)) | MPL-2.0 | https://github.com/NotNotTech/Raylib-CsLo |
|
||||||
| cl-raylib | **4.0** | [Common Lisp](https://common-lisp.net/) | MIT | https://github.com/longlene/cl-raylib |
|
| cl-raylib | **4.0** | [Common Lisp](https://common-lisp.net/) | MIT | https://github.com/longlene/cl-raylib |
|
||||||
| raylib-cr | **4.0** | [Crystal](https://crystal-lang.org/) | Apache-2.0 | https://github.com/sol-vin/raylib-cr |
|
| raylib-cr | **4.0** | [Crystal](https://crystal-lang.org/) | Apache-2.0 | https://github.com/sol-vin/raylib-cr |
|
||||||
|
| raylib-c3 | **4.5-dev** | [C3](https://c3-lang.org/) | MIT | https://github.com/Its-Kenta/Raylib-C3 |
|
||||||
| dart-raylib | **4.0** | [Dart](https://dart.dev/) | MIT | https://gitlab.com/wolfenrain/dart-raylib |
|
| dart-raylib | **4.0** | [Dart](https://dart.dev/) | MIT | https://gitlab.com/wolfenrain/dart-raylib |
|
||||||
| bindbc-raylib3 | **4.0** | [D](https://dlang.org/) | BSL-1.0 | https://github.com/o3o/bindbc-raylib3 |
|
| bindbc-raylib3 | **4.0** | [D](https://dlang.org/) | BSL-1.0 | https://github.com/o3o/bindbc-raylib3 |
|
||||||
| dray | **4.0** | [D](https://dlang.org/) | Apache-2.0 | https://github.com/xdrie/dray |
|
| dray | **4.0** | [D](https://dlang.org/) | Apache-2.0 | https://github.com/xdrie/dray |
|
||||||
|
|
@ -53,6 +54,7 @@ Some people ported raylib to other languages in form of bindings or wrappers to
|
||||||
| raylib-swift | **4.0** | [Swift](https://swift.org/) | MIT | https://github.com/STREGAsGate/Raylib |
|
| raylib-swift | **4.0** | [Swift](https://swift.org/) | MIT | https://github.com/STREGAsGate/Raylib |
|
||||||
| raylib-scopes | auto | [Scopes](http://scopes.rocks) | MIT | https://github.com/salotz/raylib-scopes |
|
| raylib-scopes | auto | [Scopes](http://scopes.rocks) | MIT | https://github.com/salotz/raylib-scopes |
|
||||||
| raylib-smallBasic | 4.1-dev | [SmallBASIC](https://github.com/smallbasic/SmallBASIC) | GPLv3 | https://github.com/smallbasic/smallbasic.plugins/tree/master/raylib |
|
| raylib-smallBasic | 4.1-dev | [SmallBASIC](https://github.com/smallbasic/SmallBASIC) | GPLv3 | https://github.com/smallbasic/smallbasic.plugins/tree/master/raylib |
|
||||||
|
| raylib-umka | **4.2** | [Umka](https://github.com/vtereshkov/umka-lang) | Zlib | https://github.com/robloach/raylib-umka |
|
||||||
| raylib.v | **4.2** | [V](https://vlang.io/) | Zlib | https://github.com/irishgreencitrus/raylib.v |
|
| raylib.v | **4.2** | [V](https://vlang.io/) | Zlib | https://github.com/irishgreencitrus/raylib.v |
|
||||||
| raylib-wren | **4.0** | [Wren](http://wren.io/) | ISC | https://github.com/TSnake41/raylib-wren |
|
| raylib-wren | **4.0** | [Wren](http://wren.io/) | ISC | https://github.com/TSnake41/raylib-wren |
|
||||||
| raylib-zig | **4.2** | [Zig](https://ziglang.org/) | MIT | https://github.com/Not-Nik/raylib-zig |
|
| raylib-zig | **4.2** | [Zig](https://ziglang.org/) | MIT | https://github.com/Not-Nik/raylib-zig |
|
||||||
|
|
|
||||||
|
|
@ -66,6 +66,9 @@ int main(void)
|
||||||
DrawCylinder((Vector3){1.0f, 0.0f, -4.0f}, 0.0f, 1.5f, 3.0f, 8, GOLD);
|
DrawCylinder((Vector3){1.0f, 0.0f, -4.0f}, 0.0f, 1.5f, 3.0f, 8, GOLD);
|
||||||
DrawCylinderWires((Vector3){1.0f, 0.0f, -4.0f}, 0.0f, 1.5f, 3.0f, 8, PINK);
|
DrawCylinderWires((Vector3){1.0f, 0.0f, -4.0f}, 0.0f, 1.5f, 3.0f, 8, PINK);
|
||||||
|
|
||||||
|
DrawCapsule ((Vector3){-3.0f, 1.5f, -4.0f}, (Vector3){-4.0f, -1.0f, -4.0f}, 1.2f, 8, 8, VIOLET);
|
||||||
|
DrawCapsuleWires((Vector3){-3.0f, 1.5f, -4.0f}, (Vector3){-4.0f, -1.0f, -4.0f}, 1.2f, 8, 8, PURPLE);
|
||||||
|
|
||||||
DrawGrid(10, 1.0f); // Draw a grid
|
DrawGrid(10, 1.0f); // Draw a grid
|
||||||
|
|
||||||
EndMode3D();
|
EndMode3D();
|
||||||
|
|
|
||||||
Binary file not shown.
|
Before Width: | Height: | Size: 33 KiB After Width: | Height: | Size: 22 KiB |
|
|
@ -1244,6 +1244,7 @@ RLAPI Image GenImageChecked(int width, int height, int checksX, int checksY, Col
|
||||||
RLAPI Image GenImageWhiteNoise(int width, int height, float factor); // Generate image: white noise
|
RLAPI Image GenImageWhiteNoise(int width, int height, float factor); // Generate image: white noise
|
||||||
RLAPI Image GenImagePerlinNoise(int width, int height, int offsetX, int offsetY, float scale); // Generate image: perlin noise
|
RLAPI Image GenImagePerlinNoise(int width, int height, int offsetX, int offsetY, float scale); // Generate image: perlin noise
|
||||||
RLAPI Image GenImageCellular(int width, int height, int tileSize); // Generate image: cellular algorithm, bigger tileSize means bigger cells
|
RLAPI Image GenImageCellular(int width, int height, int tileSize); // Generate image: cellular algorithm, bigger tileSize means bigger cells
|
||||||
|
RLAPI Image GenImageText(int width, int height, const char *text); // Generate image: grayscale image from text data
|
||||||
|
|
||||||
// Image manipulation functions
|
// Image manipulation functions
|
||||||
RLAPI Image ImageCopy(Image image); // Create an image duplicate (useful for transformations)
|
RLAPI Image ImageCopy(Image image); // Create an image duplicate (useful for transformations)
|
||||||
|
|
@ -1422,6 +1423,8 @@ RLAPI void DrawCylinder(Vector3 position, float radiusTop, float radiusBottom, f
|
||||||
RLAPI void DrawCylinderEx(Vector3 startPos, Vector3 endPos, float startRadius, float endRadius, int sides, Color color); // Draw a cylinder with base at startPos and top at endPos
|
RLAPI void DrawCylinderEx(Vector3 startPos, Vector3 endPos, float startRadius, float endRadius, int sides, Color color); // Draw a cylinder with base at startPos and top at endPos
|
||||||
RLAPI void DrawCylinderWires(Vector3 position, float radiusTop, float radiusBottom, float height, int slices, Color color); // Draw a cylinder/cone wires
|
RLAPI void DrawCylinderWires(Vector3 position, float radiusTop, float radiusBottom, float height, int slices, Color color); // Draw a cylinder/cone wires
|
||||||
RLAPI void DrawCylinderWiresEx(Vector3 startPos, Vector3 endPos, float startRadius, float endRadius, int sides, Color color); // Draw a cylinder wires with base at startPos and top at endPos
|
RLAPI void DrawCylinderWiresEx(Vector3 startPos, Vector3 endPos, float startRadius, float endRadius, int sides, Color color); // Draw a cylinder wires with base at startPos and top at endPos
|
||||||
|
RLAPI void DrawCapsule(Vector3 startPos, Vector3 endPos, float radius, int slices, int rings, Color color); // Draw a capsule with the center of its sphere caps at startPos and endPos
|
||||||
|
RLAPI void DrawCapsuleWires(Vector3 startPos, Vector3 endPos, float radius, int slices, int rings, Color color); // Draw capsule wireframe with the center of its sphere caps at startPos and endPos
|
||||||
RLAPI void DrawPlane(Vector3 centerPos, Vector2 size, Color color); // Draw a plane XZ
|
RLAPI void DrawPlane(Vector3 centerPos, Vector2 size, Color color); // Draw a plane XZ
|
||||||
RLAPI void DrawRay(Ray ray, Color color); // Draw a ray line
|
RLAPI void DrawRay(Ray ray, Color color); // Draw a ray line
|
||||||
RLAPI void DrawGrid(int slices, float spacing); // Draw a grid (centered at (0, 0, 0))
|
RLAPI void DrawGrid(int slices, float spacing); // Draw a grid (centered at (0, 0, 0))
|
||||||
|
|
|
||||||
278
src/rmodels.c
278
src/rmodels.c
|
|
@ -817,6 +817,284 @@ void DrawCylinderWiresEx(Vector3 startPos, Vector3 endPos, float startRadius, fl
|
||||||
rlEnd();
|
rlEnd();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Draw a capsule with the center of its sphere caps at startPos and endPos
|
||||||
|
void DrawCapsule(Vector3 startPos, Vector3 endPos, float radius, int slices, int rings, Color color)
|
||||||
|
{
|
||||||
|
if (slices < 3) slices = 3;
|
||||||
|
|
||||||
|
Vector3 direction = { endPos.x - startPos.x, endPos.y - startPos.y, endPos.z - startPos.z };
|
||||||
|
|
||||||
|
// draw a sphere if start and end points are the same
|
||||||
|
bool sphereCase = (direction.x == 0) && (direction.y == 0) && (direction.z == 0);
|
||||||
|
if (sphereCase) direction = (Vector3){0.0f, 1.0f, 0.0f};
|
||||||
|
|
||||||
|
// Construct a basis of the base and the caps:
|
||||||
|
Vector3 b0 = Vector3Normalize(direction);
|
||||||
|
Vector3 b1 = Vector3Normalize(Vector3Perpendicular(direction));
|
||||||
|
Vector3 b2 = Vector3Normalize(Vector3CrossProduct(b1, direction));
|
||||||
|
Vector3 capCenter = endPos;
|
||||||
|
|
||||||
|
float baseSliceAngle = (2.0f*PI)/slices;
|
||||||
|
float baseRingAngle = PI * 0.5 / rings;
|
||||||
|
|
||||||
|
rlBegin(RL_TRIANGLES);
|
||||||
|
rlColor4ub(color.r, color.g, color.b, color.a);
|
||||||
|
|
||||||
|
// render both caps
|
||||||
|
for (int c = 0; c < 2; c++)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < rings; i++)
|
||||||
|
{
|
||||||
|
for (int j = 0; j < slices; j++)
|
||||||
|
{
|
||||||
|
|
||||||
|
// we build up the rings from capCenter in the direction of the 'direction' vector we computed earlier
|
||||||
|
|
||||||
|
// as we iterate through the rings they must be placed higher above the center, the height we need is sin(angle(i))
|
||||||
|
// as we iterate through the rings they must get smaller by the cos(angle(i))
|
||||||
|
|
||||||
|
// compute the four vertices
|
||||||
|
float ringSin1 = sinf(baseSliceAngle*(j + 0))*cosf(baseRingAngle * ( i + 0 ));
|
||||||
|
float ringCos1 = cosf(baseSliceAngle*(j + 0))*cosf(baseRingAngle * ( i + 0 ));
|
||||||
|
Vector3 w1 = (Vector3){
|
||||||
|
capCenter.x + (sinf(baseRingAngle * ( i + 0 ))*b0.x + ringSin1*b1.x + ringCos1*b2.x) * radius,
|
||||||
|
capCenter.y + (sinf(baseRingAngle * ( i + 0 ))*b0.y + ringSin1*b1.y + ringCos1*b2.y) * radius,
|
||||||
|
capCenter.z + (sinf(baseRingAngle * ( i + 0 ))*b0.z + ringSin1*b1.z + ringCos1*b2.z) * radius
|
||||||
|
};
|
||||||
|
float ringSin2 = sinf(baseSliceAngle*(j + 1))*cosf(baseRingAngle * ( i + 0 ));
|
||||||
|
float ringCos2 = cosf(baseSliceAngle*(j + 1))*cosf(baseRingAngle * ( i + 0 ));
|
||||||
|
Vector3 w2 = (Vector3){
|
||||||
|
capCenter.x + (sinf(baseRingAngle * ( i + 0 ))*b0.x + ringSin2*b1.x + ringCos2*b2.x) * radius,
|
||||||
|
capCenter.y + (sinf(baseRingAngle * ( i + 0 ))*b0.y + ringSin2*b1.y + ringCos2*b2.y) * radius,
|
||||||
|
capCenter.z + (sinf(baseRingAngle * ( i + 0 ))*b0.z + ringSin2*b1.z + ringCos2*b2.z) * radius
|
||||||
|
};
|
||||||
|
|
||||||
|
float ringSin3 = sinf(baseSliceAngle*(j + 0))*cosf(baseRingAngle * ( i + 1 ));
|
||||||
|
float ringCos3 = cosf(baseSliceAngle*(j + 0))*cosf(baseRingAngle * ( i + 1 ));
|
||||||
|
Vector3 w3 = (Vector3){
|
||||||
|
capCenter.x + (sinf(baseRingAngle * ( i + 1 ))*b0.x + ringSin3*b1.x + ringCos3*b2.x) * radius,
|
||||||
|
capCenter.y + (sinf(baseRingAngle * ( i + 1 ))*b0.y + ringSin3*b1.y + ringCos3*b2.y) * radius,
|
||||||
|
capCenter.z + (sinf(baseRingAngle * ( i + 1 ))*b0.z + ringSin3*b1.z + ringCos3*b2.z) * radius
|
||||||
|
};
|
||||||
|
float ringSin4 = sinf(baseSliceAngle*(j + 1))*cosf(baseRingAngle * ( i + 1 ));
|
||||||
|
float ringCos4 = cosf(baseSliceAngle*(j + 1))*cosf(baseRingAngle * ( i + 1 ));
|
||||||
|
Vector3 w4 = (Vector3){
|
||||||
|
capCenter.x + (sinf(baseRingAngle * ( i + 1 ))*b0.x + ringSin4*b1.x + ringCos4*b2.x) * radius,
|
||||||
|
capCenter.y + (sinf(baseRingAngle * ( i + 1 ))*b0.y + ringSin4*b1.y + ringCos4*b2.y) * radius,
|
||||||
|
capCenter.z + (sinf(baseRingAngle * ( i + 1 ))*b0.z + ringSin4*b1.z + ringCos4*b2.z) * radius
|
||||||
|
};
|
||||||
|
|
||||||
|
// make sure cap triangle normals are facing outwards
|
||||||
|
if(c == 0)
|
||||||
|
{
|
||||||
|
rlVertex3f(w1.x, w1.y, w1.z);
|
||||||
|
rlVertex3f(w2.x, w2.y, w2.z);
|
||||||
|
rlVertex3f(w3.x, w3.y, w3.z);
|
||||||
|
|
||||||
|
rlVertex3f(w2.x, w2.y, w2.z);
|
||||||
|
rlVertex3f(w4.x, w4.y, w4.z);
|
||||||
|
rlVertex3f(w3.x, w3.y, w3.z);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
rlVertex3f(w1.x, w1.y, w1.z);
|
||||||
|
rlVertex3f(w3.x, w3.y, w3.z);
|
||||||
|
rlVertex3f(w2.x, w2.y, w2.z);
|
||||||
|
|
||||||
|
rlVertex3f(w2.x, w2.y, w2.z);
|
||||||
|
rlVertex3f(w3.x, w3.y, w3.z);
|
||||||
|
rlVertex3f(w4.x, w4.y, w4.z);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
capCenter = startPos;
|
||||||
|
b0 = Vector3Scale(b0, -1.0f);
|
||||||
|
}
|
||||||
|
// render middle
|
||||||
|
if (!sphereCase)
|
||||||
|
{
|
||||||
|
for (int j = 0; j < slices; j++)
|
||||||
|
{
|
||||||
|
// compute the four vertices
|
||||||
|
float ringSin1 = sinf(baseSliceAngle*(j + 0))*radius;
|
||||||
|
float ringCos1 = cosf(baseSliceAngle*(j + 0))*radius;
|
||||||
|
Vector3 w1 = {
|
||||||
|
startPos.x + ringSin1*b1.x + ringCos1*b2.x,
|
||||||
|
startPos.y + ringSin1*b1.y + ringCos1*b2.y,
|
||||||
|
startPos.z + ringSin1*b1.z + ringCos1*b2.z
|
||||||
|
};
|
||||||
|
float ringSin2 = sinf(baseSliceAngle*(j + 1))*radius;
|
||||||
|
float ringCos2 = cosf(baseSliceAngle*(j + 1))*radius;
|
||||||
|
Vector3 w2 = {
|
||||||
|
startPos.x + ringSin2*b1.x + ringCos2*b2.x,
|
||||||
|
startPos.y + ringSin2*b1.y + ringCos2*b2.y,
|
||||||
|
startPos.z + ringSin2*b1.z + ringCos2*b2.z
|
||||||
|
};
|
||||||
|
|
||||||
|
float ringSin3 = sinf(baseSliceAngle*(j + 0))*radius;
|
||||||
|
float ringCos3 = cosf(baseSliceAngle*(j + 0))*radius;
|
||||||
|
Vector3 w3 = {
|
||||||
|
endPos.x + ringSin3*b1.x + ringCos3*b2.x,
|
||||||
|
endPos.y + ringSin3*b1.y + ringCos3*b2.y,
|
||||||
|
endPos.z + ringSin3*b1.z + ringCos3*b2.z
|
||||||
|
};
|
||||||
|
float ringSin4 = sinf(baseSliceAngle*(j + 1))*radius;
|
||||||
|
float ringCos4 = cosf(baseSliceAngle*(j + 1))*radius;
|
||||||
|
Vector3 w4 = {
|
||||||
|
endPos.x + ringSin4*b1.x + ringCos4*b2.x,
|
||||||
|
endPos.y + ringSin4*b1.y + ringCos4*b2.y,
|
||||||
|
endPos.z + ringSin4*b1.z + ringCos4*b2.z
|
||||||
|
};
|
||||||
|
// w2 x.-----------x startPos
|
||||||
|
rlVertex3f(w1.x, w1.y, w1.z); // | |\'. T0 /
|
||||||
|
rlVertex3f(w2.x, w2.y, w2.z); // T1 | \ '. /
|
||||||
|
rlVertex3f(w3.x, w3.y, w3.z); // | |T \ '. /
|
||||||
|
// | 2 \ T 'x w1
|
||||||
|
rlVertex3f(w2.x, w2.y, w2.z); // | w4 x.---\-1-|---x endPos
|
||||||
|
rlVertex3f(w4.x, w4.y, w4.z); // T2 '. \ |T3/
|
||||||
|
rlVertex3f(w3.x, w3.y, w3.z); // | '. \ | /
|
||||||
|
// '.\|/
|
||||||
|
// 'x w3
|
||||||
|
}
|
||||||
|
}
|
||||||
|
rlEnd();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Draw capsule wires with the center of its sphere caps at startPos and endPos
|
||||||
|
void DrawCapsuleWires(Vector3 startPos, Vector3 endPos, float radius, int slices, int rings, Color color)
|
||||||
|
{
|
||||||
|
if (slices < 3) slices = 3;
|
||||||
|
|
||||||
|
Vector3 direction = { endPos.x - startPos.x, endPos.y - startPos.y, endPos.z - startPos.z };
|
||||||
|
|
||||||
|
// draw a sphere if start and end points are the same
|
||||||
|
bool sphereCase = (direction.x == 0) && (direction.y == 0) && (direction.z == 0);
|
||||||
|
if (sphereCase) direction = (Vector3){0.0f, 1.0f, 0.0f};
|
||||||
|
|
||||||
|
// Construct a basis of the base and the caps:
|
||||||
|
Vector3 b0 = Vector3Normalize(direction);
|
||||||
|
Vector3 b1 = Vector3Normalize(Vector3Perpendicular(direction));
|
||||||
|
Vector3 b2 = Vector3Normalize(Vector3CrossProduct(b1, direction));
|
||||||
|
Vector3 capCenter = endPos;
|
||||||
|
|
||||||
|
float baseSliceAngle = (2.0f*PI)/slices;
|
||||||
|
float baseRingAngle = PI * 0.5 / rings;
|
||||||
|
|
||||||
|
rlBegin(RL_LINES);
|
||||||
|
rlColor4ub(color.r, color.g, color.b, color.a);
|
||||||
|
|
||||||
|
// render both caps
|
||||||
|
for (int c = 0; c < 2; c++)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < rings; i++)
|
||||||
|
{
|
||||||
|
for (int j = 0; j < slices; j++)
|
||||||
|
{
|
||||||
|
|
||||||
|
// we build up the rings from capCenter in the direction of the 'direction' vector we computed earlier
|
||||||
|
|
||||||
|
// as we iterate through the rings they must be placed higher above the center, the height we need is sin(angle(i))
|
||||||
|
// as we iterate through the rings they must get smaller by the cos(angle(i))
|
||||||
|
|
||||||
|
// compute the four vertices
|
||||||
|
float ringSin1 = sinf(baseSliceAngle*(j + 0))*cosf(baseRingAngle * ( i + 0 ));
|
||||||
|
float ringCos1 = cosf(baseSliceAngle*(j + 0))*cosf(baseRingAngle * ( i + 0 ));
|
||||||
|
Vector3 w1 = (Vector3){
|
||||||
|
capCenter.x + (sinf(baseRingAngle * ( i + 0 ))*b0.x + ringSin1*b1.x + ringCos1*b2.x) * radius,
|
||||||
|
capCenter.y + (sinf(baseRingAngle * ( i + 0 ))*b0.y + ringSin1*b1.y + ringCos1*b2.y) * radius,
|
||||||
|
capCenter.z + (sinf(baseRingAngle * ( i + 0 ))*b0.z + ringSin1*b1.z + ringCos1*b2.z) * radius
|
||||||
|
};
|
||||||
|
float ringSin2 = sinf(baseSliceAngle*(j + 1))*cosf(baseRingAngle * ( i + 0 ));
|
||||||
|
float ringCos2 = cosf(baseSliceAngle*(j + 1))*cosf(baseRingAngle * ( i + 0 ));
|
||||||
|
Vector3 w2 = (Vector3){
|
||||||
|
capCenter.x + (sinf(baseRingAngle * ( i + 0 ))*b0.x + ringSin2*b1.x + ringCos2*b2.x) * radius,
|
||||||
|
capCenter.y + (sinf(baseRingAngle * ( i + 0 ))*b0.y + ringSin2*b1.y + ringCos2*b2.y) * radius,
|
||||||
|
capCenter.z + (sinf(baseRingAngle * ( i + 0 ))*b0.z + ringSin2*b1.z + ringCos2*b2.z) * radius
|
||||||
|
};
|
||||||
|
|
||||||
|
float ringSin3 = sinf(baseSliceAngle*(j + 0))*cosf(baseRingAngle * ( i + 1 ));
|
||||||
|
float ringCos3 = cosf(baseSliceAngle*(j + 0))*cosf(baseRingAngle * ( i + 1 ));
|
||||||
|
Vector3 w3 = (Vector3){
|
||||||
|
capCenter.x + (sinf(baseRingAngle * ( i + 1 ))*b0.x + ringSin3*b1.x + ringCos3*b2.x) * radius,
|
||||||
|
capCenter.y + (sinf(baseRingAngle * ( i + 1 ))*b0.y + ringSin3*b1.y + ringCos3*b2.y) * radius,
|
||||||
|
capCenter.z + (sinf(baseRingAngle * ( i + 1 ))*b0.z + ringSin3*b1.z + ringCos3*b2.z) * radius
|
||||||
|
};
|
||||||
|
float ringSin4 = sinf(baseSliceAngle*(j + 1))*cosf(baseRingAngle * ( i + 1 ));
|
||||||
|
float ringCos4 = cosf(baseSliceAngle*(j + 1))*cosf(baseRingAngle * ( i + 1 ));
|
||||||
|
Vector3 w4 = (Vector3){
|
||||||
|
capCenter.x + (sinf(baseRingAngle * ( i + 1 ))*b0.x + ringSin4*b1.x + ringCos4*b2.x) * radius,
|
||||||
|
capCenter.y + (sinf(baseRingAngle * ( i + 1 ))*b0.y + ringSin4*b1.y + ringCos4*b2.y) * radius,
|
||||||
|
capCenter.z + (sinf(baseRingAngle * ( i + 1 ))*b0.z + ringSin4*b1.z + ringCos4*b2.z) * radius
|
||||||
|
};
|
||||||
|
|
||||||
|
rlVertex3f(w1.x, w1.y, w1.z);
|
||||||
|
rlVertex3f(w2.x, w2.y, w2.z);
|
||||||
|
|
||||||
|
rlVertex3f(w2.x, w2.y, w2.z);
|
||||||
|
rlVertex3f(w3.x, w3.y, w3.z);
|
||||||
|
|
||||||
|
rlVertex3f(w1.x, w1.y, w1.z);
|
||||||
|
rlVertex3f(w3.x, w3.y, w3.z);
|
||||||
|
|
||||||
|
rlVertex3f(w2.x, w2.y, w2.z);
|
||||||
|
rlVertex3f(w4.x, w4.y, w4.z);
|
||||||
|
|
||||||
|
rlVertex3f(w3.x, w3.y, w3.z);
|
||||||
|
rlVertex3f(w4.x, w4.y, w4.z);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
capCenter = startPos;
|
||||||
|
b0 = Vector3Scale(b0, -1.0f);
|
||||||
|
}
|
||||||
|
// render middle
|
||||||
|
if (!sphereCase)
|
||||||
|
{
|
||||||
|
for (int j = 0; j < slices; j++)
|
||||||
|
{
|
||||||
|
// compute the four vertices
|
||||||
|
float ringSin1 = sinf(baseSliceAngle*(j + 0))*radius;
|
||||||
|
float ringCos1 = cosf(baseSliceAngle*(j + 0))*radius;
|
||||||
|
Vector3 w1 = {
|
||||||
|
startPos.x + ringSin1*b1.x + ringCos1*b2.x,
|
||||||
|
startPos.y + ringSin1*b1.y + ringCos1*b2.y,
|
||||||
|
startPos.z + ringSin1*b1.z + ringCos1*b2.z
|
||||||
|
};
|
||||||
|
float ringSin2 = sinf(baseSliceAngle*(j + 1))*radius;
|
||||||
|
float ringCos2 = cosf(baseSliceAngle*(j + 1))*radius;
|
||||||
|
Vector3 w2 = {
|
||||||
|
startPos.x + ringSin2*b1.x + ringCos2*b2.x,
|
||||||
|
startPos.y + ringSin2*b1.y + ringCos2*b2.y,
|
||||||
|
startPos.z + ringSin2*b1.z + ringCos2*b2.z
|
||||||
|
};
|
||||||
|
|
||||||
|
float ringSin3 = sinf(baseSliceAngle*(j + 0))*radius;
|
||||||
|
float ringCos3 = cosf(baseSliceAngle*(j + 0))*radius;
|
||||||
|
Vector3 w3 = {
|
||||||
|
endPos.x + ringSin3*b1.x + ringCos3*b2.x,
|
||||||
|
endPos.y + ringSin3*b1.y + ringCos3*b2.y,
|
||||||
|
endPos.z + ringSin3*b1.z + ringCos3*b2.z
|
||||||
|
};
|
||||||
|
float ringSin4 = sinf(baseSliceAngle*(j + 1))*radius;
|
||||||
|
float ringCos4 = cosf(baseSliceAngle*(j + 1))*radius;
|
||||||
|
Vector3 w4 = {
|
||||||
|
endPos.x + ringSin4*b1.x + ringCos4*b2.x,
|
||||||
|
endPos.y + ringSin4*b1.y + ringCos4*b2.y,
|
||||||
|
endPos.z + ringSin4*b1.z + ringCos4*b2.z
|
||||||
|
};
|
||||||
|
|
||||||
|
rlVertex3f(w1.x, w1.y, w1.z);
|
||||||
|
rlVertex3f(w3.x, w3.y, w3.z);
|
||||||
|
|
||||||
|
rlVertex3f(w2.x, w2.y, w2.z);
|
||||||
|
rlVertex3f(w4.x, w4.y, w4.z);
|
||||||
|
|
||||||
|
rlVertex3f(w2.x, w2.y, w2.z);
|
||||||
|
rlVertex3f(w3.x, w3.y, w3.z);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
rlEnd();
|
||||||
|
}
|
||||||
|
|
||||||
// Draw a plane
|
// Draw a plane
|
||||||
void DrawPlane(Vector3 centerPos, Vector2 size, Color color)
|
void DrawPlane(Vector3 centerPos, Vector2 size, Color color)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -893,6 +893,25 @@ Image GenImageCellular(int width, int height, int tileSize)
|
||||||
|
|
||||||
return image;
|
return image;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Generate image: grayscale image from text data
|
||||||
|
Image GenImageText(int width, int height, const char *text)
|
||||||
|
{
|
||||||
|
Image image = { 0 };
|
||||||
|
|
||||||
|
int textLength = TextLength(text);
|
||||||
|
int imageViewSize = width*height;
|
||||||
|
|
||||||
|
image.width = width;
|
||||||
|
image.height = height;
|
||||||
|
image.format = PIXELFORMAT_UNCOMPRESSED_GRAYSCALE;
|
||||||
|
image.data = RL_CALLOC(imageViewSize, 1);
|
||||||
|
image.mipmaps = 1;
|
||||||
|
|
||||||
|
memcpy(image.data, text, (textLength > imageViewSize)? imageViewSize : textLength);
|
||||||
|
|
||||||
|
return image;
|
||||||
|
}
|
||||||
#endif // SUPPORT_IMAGE_GENERATION
|
#endif // SUPPORT_IMAGE_GENERATION
|
||||||
|
|
||||||
//------------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------------
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user