aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRay <raysan5@gmail.com>2014-11-24 20:14:58 +0100
committerRay <raysan5@gmail.com>2014-11-24 20:14:58 +0100
commit0c606092689d7a1823f7acd5e8b849052e297b7a (patch)
tree0623e6f7c0ada0319c6b8bd8febd48d0e17c9973 /src
parentfcff83e65cebb0c9767f076e8ccfaf6b6bfb8d95 (diff)
parent63ed471ed24ed1b328cc90f03a88130511725e88 (diff)
downloadraylib-0c606092689d7a1823f7acd5e8b849052e297b7a.tar.gz
raylib-0c606092689d7a1823f7acd5e8b849052e297b7a.zip
Merge pull request #11 from raysan5/develop
Develop branch integration
Diffstat (limited to 'src')
-rw-r--r--src/models.c32
1 files changed, 15 insertions, 17 deletions
diff --git a/src/models.c b/src/models.c
index d69322a8..2d2af038 100644
--- a/src/models.c
+++ b/src/models.c
@@ -1145,7 +1145,6 @@ void DrawModelWires(Model model, Vector3 position, float scale, Color color)
}
// Draw a billboard
-// TODO: Math review...
void DrawBillboard(Camera camera, Texture2D texture, Vector3 center, float size, Color tint)
{
// NOTE: Billboard size will maintain texture aspect ratio, size will be billboard width
@@ -1157,11 +1156,11 @@ void DrawBillboard(Camera camera, Texture2D texture, Vector3 center, float size,
Vector3 right = { viewMatrix.m0, viewMatrix.m4, viewMatrix.m8 };
Vector3 up = { viewMatrix.m1, viewMatrix.m5, viewMatrix.m9 };
/*
- d-------c
+ a-------b
| |
| * |
| |
- a-------b
+ d-------c
*/
VectorScale(&right, sizeRatio.x/2);
VectorScale(&up, sizeRatio.y/2);
@@ -1178,18 +1177,17 @@ void DrawBillboard(Camera camera, Texture2D texture, Vector3 center, float size,
rlBegin(RL_QUADS);
rlColor4ub(tint.r, tint.g, tint.b, tint.a);
- rlNormal3f(0.0f, 1.0f, 0.0f);
+
rlTexCoord2f(0.0f, 0.0f); rlVertex3f(a.x, a.y, a.z);
- rlTexCoord2f(1.0f, 0.0f); rlVertex3f(b.x, b.y, b.z);
- rlTexCoord2f(1.0f, 1.0f); rlVertex3f(c.x, c.y, c.z);
rlTexCoord2f(0.0f, 1.0f); rlVertex3f(d.x, d.y, d.z);
+ rlTexCoord2f(1.0f, 1.0f); rlVertex3f(c.x, c.y, c.z);
+ rlTexCoord2f(1.0f, 0.0f); rlVertex3f(b.x, b.y, b.z);
rlEnd();
rlDisableTexture();
}
// Draw a billboard (part of a texture defined by a rectangle)
-// TODO: Math review...
void DrawBillboardRec(Camera camera, Texture2D texture, Rectangle sourceRec, Vector3 center, float size, Color tint)
{
// NOTE: Billboard size will maintain sourceRec aspect ratio, size will represent billboard width
@@ -1201,11 +1199,11 @@ void DrawBillboardRec(Camera camera, Texture2D texture, Rectangle sourceRec, Vec
Vector3 right = { viewMatrix.m0, viewMatrix.m4, viewMatrix.m8 };
Vector3 up = { viewMatrix.m1, viewMatrix.m5, viewMatrix.m9 };
/*
- d-------c
+ a-------b
| |
| * |
| |
- a-------b
+ d-------c
*/
VectorScale(&right, sizeRatio.x/2);
VectorScale(&up, sizeRatio.y/2);
@@ -1226,18 +1224,18 @@ void DrawBillboardRec(Camera camera, Texture2D texture, Rectangle sourceRec, Vec
// Bottom-left corner for texture and quad
rlTexCoord2f((float)sourceRec.x / texture.width, (float)sourceRec.y / texture.height);
rlVertex3f(a.x, a.y, a.z);
-
- // Bottom-right corner for texture and quad
- rlTexCoord2f((float)(sourceRec.x + sourceRec.width) / texture.width, (float)sourceRec.y / texture.height);
- rlVertex3f(b.x, b.y, b.z);
-
+
+ // Top-left corner for texture and quad
+ rlTexCoord2f((float)sourceRec.x / texture.width, (float)(sourceRec.y + sourceRec.height) / texture.height);
+ rlVertex3f(d.x, d.y, d.z);
+
// Top-right corner for texture and quad
rlTexCoord2f((float)(sourceRec.x + sourceRec.width) / texture.width, (float)(sourceRec.y + sourceRec.height) / texture.height);
rlVertex3f(c.x, c.y, c.z);
- // Top-left corner for texture and quad
- rlTexCoord2f((float)sourceRec.x / texture.width, (float)(sourceRec.y + sourceRec.height) / texture.height);
- rlVertex3f(d.x, d.y, d.z);
+ // Bottom-right corner for texture and quad
+ rlTexCoord2f((float)(sourceRec.x + sourceRec.width) / texture.width, (float)sourceRec.y / texture.height);
+ rlVertex3f(b.x, b.y, b.z);
rlEnd();
rlDisableTexture();