added GetRandomFloat and SetGridColours
This commit is contained in:
parent
3c9f7263e5
commit
4007be29af
11
src/core.c
11
src/core.c
|
|
@ -1958,6 +1958,17 @@ int GetRandomValue(int min, int max)
|
||||||
return (rand()%(abs(max - min) + 1) + min);
|
return (rand()%(abs(max - min) + 1) + min);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float GetRandomFloat(float min, float max)
|
||||||
|
{
|
||||||
|
if (min > max) {
|
||||||
|
float tmp = max;
|
||||||
|
max = min;
|
||||||
|
min = tmp;
|
||||||
|
}
|
||||||
|
|
||||||
|
return rand()/(RAND_MAX/(max-min))+min;
|
||||||
|
}
|
||||||
|
|
||||||
// Check if the file exists
|
// Check if the file exists
|
||||||
bool FileExists(const char *fileName)
|
bool FileExists(const char *fileName)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
32
src/models.c
32
src/models.c
|
|
@ -652,9 +652,25 @@ void DrawRay(Ray ray, Color color)
|
||||||
rlEnd();
|
rlEnd();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static float GridMajor[] = { 0.5f, 0.5f, 0.5f };
|
||||||
|
static float GridMinor[] = { 0.75f, 0.75f, 0.75f };
|
||||||
|
|
||||||
|
void SetGridColours(Color major, Color minor)
|
||||||
|
{
|
||||||
|
GridMajor[0] = major.r / 256.0;
|
||||||
|
GridMajor[1] = major.g / 256.0;
|
||||||
|
GridMajor[2] = major.b / 256.0;
|
||||||
|
|
||||||
|
GridMinor[0] = minor.r / 256.0;
|
||||||
|
GridMinor[1] = minor.g / 256.0;
|
||||||
|
GridMinor[2] = minor.b / 256.0;
|
||||||
|
}
|
||||||
|
|
||||||
// Draw a grid centered at (0, 0, 0)
|
// Draw a grid centered at (0, 0, 0)
|
||||||
void DrawGrid(int slices, float spacing)
|
void DrawGrid(int slices, float spacing)
|
||||||
{
|
{
|
||||||
|
|
||||||
int halfSlices = slices/2;
|
int halfSlices = slices/2;
|
||||||
|
|
||||||
if (rlCheckBufferLimit(slices*4)) rlglDraw();
|
if (rlCheckBufferLimit(slices*4)) rlglDraw();
|
||||||
|
|
@ -664,17 +680,17 @@ void DrawGrid(int slices, float spacing)
|
||||||
{
|
{
|
||||||
if (i == 0)
|
if (i == 0)
|
||||||
{
|
{
|
||||||
rlColor3f(0.5f, 0.5f, 0.5f);
|
rlColor3f(GridMinor[0], GridMinor[1], GridMinor[2]);
|
||||||
rlColor3f(0.5f, 0.5f, 0.5f);
|
rlColor3f(GridMinor[0], GridMinor[1], GridMinor[2]);
|
||||||
rlColor3f(0.5f, 0.5f, 0.5f);
|
rlColor3f(GridMinor[0], GridMinor[1], GridMinor[2]);
|
||||||
rlColor3f(0.5f, 0.5f, 0.5f);
|
rlColor3f(GridMinor[0], GridMinor[1], GridMinor[2]);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
rlColor3f(0.75f, 0.75f, 0.75f);
|
rlColor3f(GridMajor[0], GridMajor[1], GridMajor[2]);
|
||||||
rlColor3f(0.75f, 0.75f, 0.75f);
|
rlColor3f(GridMajor[0], GridMajor[1], GridMajor[2]);
|
||||||
rlColor3f(0.75f, 0.75f, 0.75f);
|
rlColor3f(GridMajor[0], GridMajor[1], GridMajor[2]);
|
||||||
rlColor3f(0.75f, 0.75f, 0.75f);
|
rlColor3f(GridMajor[0], GridMajor[1], GridMajor[2]);
|
||||||
}
|
}
|
||||||
|
|
||||||
rlVertex3f((float)i*spacing, 0.0f, (float)-halfSlices*spacing);
|
rlVertex3f((float)i*spacing, 0.0f, (float)-halfSlices*spacing);
|
||||||
|
|
|
||||||
|
|
@ -948,6 +948,7 @@ RLAPI void SetTraceLogCallback(TraceLogCallback callback); // Set a trace
|
||||||
RLAPI void TraceLog(int logType, const char *text, ...); // Show trace log messages (LOG_DEBUG, LOG_INFO, LOG_WARNING, LOG_ERROR)
|
RLAPI void TraceLog(int logType, const char *text, ...); // Show trace log messages (LOG_DEBUG, LOG_INFO, LOG_WARNING, LOG_ERROR)
|
||||||
RLAPI void TakeScreenshot(const char *fileName); // Takes a screenshot of current screen (saved a .png)
|
RLAPI void TakeScreenshot(const char *fileName); // Takes a screenshot of current screen (saved a .png)
|
||||||
RLAPI int GetRandomValue(int min, int max); // Returns a random value between min and max (both included)
|
RLAPI int GetRandomValue(int min, int max); // Returns a random value between min and max (both included)
|
||||||
|
RLAPI float GetRandomFloat(float min, float max);
|
||||||
|
|
||||||
// Files management functions
|
// Files management functions
|
||||||
RLAPI unsigned char *LoadFileData(const char *fileName, unsigned int *bytesRead); // Load file data as byte array (read)
|
RLAPI unsigned char *LoadFileData(const char *fileName, unsigned int *bytesRead); // Load file data as byte array (read)
|
||||||
|
|
@ -1285,7 +1286,8 @@ RLAPI void DrawSphereWires(Vector3 centerPos, float radius, int rings, int slice
|
||||||
RLAPI void DrawCylinder(Vector3 position, float radiusTop, float radiusBottom, float height, int slices, Color color); // Draw a cylinder/cone
|
RLAPI void DrawCylinder(Vector3 position, float radiusTop, float radiusBottom, float height, int slices, Color color); // Draw a cylinder/cone
|
||||||
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 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);
|
||||||
|
RLAPI void SetGridColours(Color major, Color minor); // 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))
|
||||||
RLAPI void DrawGizmo(Vector3 position); // Draw simple gizmo
|
RLAPI void DrawGizmo(Vector3 position); // Draw simple gizmo
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user