Added more DrawPlane and DrawGrid functions
This commit is contained in:
parent
c1ea32655a
commit
7ac7fc697f
|
|
@ -1524,9 +1524,12 @@ RLAPI void DrawCylinderWires(Vector3 position, float radiusTop, float radiusBott
|
||||||
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 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 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 DrawPlaneXZ(Vector3 centerPos, Vector2 size, Color color); // Draw a plane XZ
|
||||||
|
RLAPI void DrawPlaneXY(Vector3 centerPos, Vector2 size, Color color); // Draw a plane XY
|
||||||
|
RLAPI void DrawPlaneYZ(Vector3 centerPos, Vector2 size, Color color); // Draw a plane YZ
|
||||||
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 DrawGridXZ(int slices, float spacing); // Draw a grid (centered at (0, 0, 0)) on the XZ plane
|
||||||
|
RLAPI void DrawGridXY(int slices, float spacing); // Draw a grid (centered at (0, 0, 0)) on the XY plane
|
||||||
|
|
||||||
//------------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------------
|
||||||
// Model 3d Loading and Drawing Functions (Module: models)
|
// Model 3d Loading and Drawing Functions (Module: models)
|
||||||
|
|
|
||||||
|
|
@ -977,8 +977,8 @@ void DrawCapsuleWires(Vector3 startPos, Vector3 endPos, float radius, int slices
|
||||||
rlEnd();
|
rlEnd();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Draw a plane
|
// Draw an XZ plane
|
||||||
void DrawPlane(Vector3 centerPos, Vector2 size, Color color)
|
void DrawPlaneXZ(Vector3 centerPos, Vector2 size, Color color)
|
||||||
{
|
{
|
||||||
// NOTE: Plane is always created on XZ ground
|
// NOTE: Plane is always created on XZ ground
|
||||||
rlPushMatrix();
|
rlPushMatrix();
|
||||||
|
|
@ -996,6 +996,53 @@ void DrawPlane(Vector3 centerPos, Vector2 size, Color color)
|
||||||
rlEnd();
|
rlEnd();
|
||||||
rlPopMatrix();
|
rlPopMatrix();
|
||||||
}
|
}
|
||||||
|
// Might want to add this to raylib
|
||||||
|
|
||||||
|
void DrawPlaneXY(Vector3 centerPos, Vector2 size, Color color)
|
||||||
|
{
|
||||||
|
// Draw rectangle
|
||||||
|
rlPushMatrix();
|
||||||
|
rlBegin(RL_QUADS);
|
||||||
|
rlColor4ub(color.r, color.g, color.b, color.a);
|
||||||
|
rlNormal3f(0.0f, 0.0f, 1.0f);
|
||||||
|
|
||||||
|
rlTexCoord2f(0.0f, 0.0f);
|
||||||
|
rlVertex3f(centerPos.x - size.x/2, centerPos.y - size.y/2, centerPos.z);
|
||||||
|
|
||||||
|
rlTexCoord2f(1.0f, 0.0f);
|
||||||
|
rlVertex3f(centerPos.x + size.x/2, centerPos.y - size.y/2, centerPos.z);
|
||||||
|
|
||||||
|
rlTexCoord2f(1.0f, 1.0f);
|
||||||
|
rlVertex3f(centerPos.x + size.x/2, centerPos.y + size.y/2, centerPos.z);
|
||||||
|
|
||||||
|
rlTexCoord2f(0.0f, 1.0f);
|
||||||
|
rlVertex3f(centerPos.x - size.x/2, centerPos.y + size.y/2, centerPos.z);
|
||||||
|
rlEnd();
|
||||||
|
rlPopMatrix();
|
||||||
|
}
|
||||||
|
|
||||||
|
void DrawPlaneYZ(Vector3 centerPos, Vector2 size, Color color)
|
||||||
|
{
|
||||||
|
rlPushMatrix();
|
||||||
|
rlBegin(RL_QUADS);
|
||||||
|
|
||||||
|
rlColor4ub(color.r, color.g, color.b, color.a);
|
||||||
|
rlNormal3f(1.0f, 0.0f, 0.0f);
|
||||||
|
|
||||||
|
rlTexCoord2f(0.0f, 0.0f);
|
||||||
|
rlVertex3f(centerPos.x, centerPos.y - size.y/2, centerPos.z - size.x/2);
|
||||||
|
|
||||||
|
rlTexCoord2f(1.0f, 0.0f);
|
||||||
|
rlVertex3f(centerPos.x, centerPos.y - size.y/2, centerPos.z + size.x/2);
|
||||||
|
|
||||||
|
rlTexCoord2f(1.0f, 1.0f);
|
||||||
|
rlVertex3f(centerPos.x, centerPos.y + size.y/2, centerPos.z + size.x/2);
|
||||||
|
|
||||||
|
rlTexCoord2f(0.0f, 1.0f);
|
||||||
|
rlVertex3f(centerPos.x, centerPos.y + size.y/2, centerPos.z - size.x/2);
|
||||||
|
rlEnd();
|
||||||
|
rlPopMatrix();
|
||||||
|
}
|
||||||
|
|
||||||
// Draw a ray line
|
// Draw a ray line
|
||||||
void DrawRay(Ray ray, Color color)
|
void DrawRay(Ray ray, Color color)
|
||||||
|
|
@ -1011,8 +1058,8 @@ void DrawRay(Ray ray, Color color)
|
||||||
rlEnd();
|
rlEnd();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Draw a grid centered at (0, 0, 0)
|
// Draw a grid centered at (0, 0, 0) on XZ plane
|
||||||
void DrawGrid(int slices, float spacing)
|
void DrawGridXZ(int slices, float spacing)
|
||||||
{
|
{
|
||||||
int halfSlices = slices/2;
|
int halfSlices = slices/2;
|
||||||
|
|
||||||
|
|
@ -1043,6 +1090,30 @@ void DrawGrid(int slices, float spacing)
|
||||||
rlEnd();
|
rlEnd();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Draw a grid centered at (0, 0, 0) on XY plane
|
||||||
|
void DrawGridXY(int slice, float spacing)
|
||||||
|
{
|
||||||
|
int halfSlices = slice/2;
|
||||||
|
|
||||||
|
rlPushMatrix();
|
||||||
|
rlBegin(RL_LINES);
|
||||||
|
|
||||||
|
for (int i = -halfSlices; i <= halfSlices; ++i)
|
||||||
|
{
|
||||||
|
if (i == 0) rlColor4ub(255, 255, 255, 255);
|
||||||
|
else rlColor4ub(100, 100, 100, 255);
|
||||||
|
|
||||||
|
rlVertex3f(-halfSlices*spacing, i*spacing, 0.0f);
|
||||||
|
rlVertex3f(halfSlices*spacing, i*spacing, 0.0f);
|
||||||
|
|
||||||
|
rlVertex3f(i*spacing, -halfSlices*spacing, 0.0f);
|
||||||
|
rlVertex3f(i*spacing, halfSlices*spacing, 0.0f);
|
||||||
|
}
|
||||||
|
|
||||||
|
rlEnd();
|
||||||
|
rlPopMatrix();
|
||||||
|
}
|
||||||
|
|
||||||
// Load model from files (mesh and material)
|
// Load model from files (mesh and material)
|
||||||
Model LoadModel(const char *fileName)
|
Model LoadModel(const char *fileName)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user