aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorvictorfisac <victorfisac@gmail.com>2016-05-30 19:18:11 +0200
committervictorfisac <victorfisac@gmail.com>2016-05-30 19:18:11 +0200
commit2e26ce235d00fdc633559f9404ddd8ec70c96df7 (patch)
tree69aa39306bf42ddd92de8cc3bec5c2f4d98aa81f /src
parentae2d0d4cd8739c49b1a4e230e6f1ca4a8bdab319 (diff)
downloadraylib-2e26ce235d00fdc633559f9404ddd8ec70c96df7.tar.gz
raylib-2e26ce235d00fdc633559f9404ddd8ec70c96df7.zip
Add Draw3DCircle function and update raylib and rlgl header
Draw3DCircle is useful to draw point lights radius.
Diffstat (limited to 'src')
-rw-r--r--src/models.c19
-rw-r--r--src/raylib.h3
-rw-r--r--src/rlgl.h2
3 files changed, 22 insertions, 2 deletions
diff --git a/src/models.c b/src/models.c
index 07dee720..6ffb561e 100644
--- a/src/models.c
+++ b/src/models.c
@@ -75,6 +75,25 @@ void Draw3DLine(Vector3 startPos, Vector3 endPos, Color color)
rlEnd();
}
+// Draw a circle in 3D world space
+void Draw3DCircle(Vector3 center, float radius, float rotationAngle, Vector3 rotation, Color color)
+{
+ rlPushMatrix();
+ rlTranslatef(center.x, center.y, center.z);
+ rlRotatef(rotationAngle, rotation.x, rotation.y, rotation.z);
+
+ rlBegin(RL_LINES);
+ for (int i = 0; i < 360; i += 10)
+ {
+ rlColor4ub(color.r, color.g, color.b, color.a);
+
+ rlVertex3f(sin(DEG2RAD*i)*radius, cos(DEG2RAD*i)*radius, 0.0f);
+ rlVertex3f(sin(DEG2RAD*(i + 10)) * radius, cos(DEG2RAD*(i + 10)) * radius, 0.0f);
+ }
+ rlEnd();
+ rlPopMatrix();
+}
+
// Draw cube
// NOTE: Cube position is the center position
void DrawCube(Vector3 position, float width, float height, float length, Color color)
diff --git a/src/raylib.h b/src/raylib.h
index d0231be2..0af7ef31 100644
--- a/src/raylib.h
+++ b/src/raylib.h
@@ -437,7 +437,7 @@ typedef struct LightData {
Vector3 position;
Vector3 target; // Used on LIGHT_DIRECTIONAL and LIGHT_SPOT (cone direction target)
- float attenuation; // Lost of light intensity with distance (world distance)
+ float radius; // Lost of light intensity with distance (world distance)
Color diffuse; // Light color
float intensity; // Light intensity level
@@ -803,6 +803,7 @@ const char *SubText(const char *text, int position, int length);
// Basic 3d Shapes Drawing Functions (Module: models)
//------------------------------------------------------------------------------------
void Draw3DLine(Vector3 startPos, Vector3 endPos, Color color); // Draw a line in 3D world space
+void Draw3DCircle(Vector3 center, float radius, float rotationAngle, Vector3 rotation, Color color); // Draw a circle in 3D world space
void DrawCube(Vector3 position, float width, float height, float lenght, Color color); // Draw cube
void DrawCubeV(Vector3 position, Vector3 size, Color color); // Draw cube (Vector version)
void DrawCubeWires(Vector3 position, float width, float height, float lenght, Color color); // Draw cube wires
diff --git a/src/rlgl.h b/src/rlgl.h
index a3ba6cd5..d4a2dabe 100644
--- a/src/rlgl.h
+++ b/src/rlgl.h
@@ -218,7 +218,7 @@ typedef enum { OPENGL_11 = 1, OPENGL_33, OPENGL_ES_20 } GlVersion;
Vector3 position;
Vector3 target; // Used on LIGHT_DIRECTIONAL and LIGHT_SPOT (cone direction target)
- float attenuation; // Lost of light intensity with distance (world distance)
+ float radius; // Lost of light intensity with distance (world distance)
Color diffuse; // Use Vector3 diffuse
float intensity;