From 29d8b48503f3064cdc1f3a87c01b4264e716a220 Mon Sep 17 00:00:00 2001 From: Palaui Date: Tue, 9 Dec 2014 13:10:05 +0100 Subject: Corrected some bugs... [core] Added SetMousePosition() [models] LoadHeightmap() - Corrected textures bug [raymath] Functions renaming [WEB] Prepare environment for emscripten! --- src/models.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/models.c') diff --git a/src/models.c b/src/models.c index 2d2af038..f59a7b43 100644 --- a/src/models.c +++ b/src/models.c @@ -743,7 +743,7 @@ Model LoadHeightmap(Image heightmap, float maxHeight) vData.texcoords[tcCounter + 7] = vData.texcoords[tcCounter + 5]; vData.texcoords[tcCounter + 8] = vData.texcoords[tcCounter + 2]; - vData.texcoords[tcCounter + 9] = vData.texcoords[tcCounter + 1]; + vData.texcoords[tcCounter + 9] = vData.texcoords[tcCounter + 3]; vData.texcoords[tcCounter + 10] = (float)(x+1) / (mapX-1); vData.texcoords[tcCounter + 11] = (float)(z+1) / (mapZ-1); -- cgit v1.2.3 From a2c8ddca1345722603637bddc3421f64025d7e5e Mon Sep 17 00:00:00 2001 From: Palaui Date: Tue, 9 Dec 2014 13:10:28 +0100 Subject: Revert "Corrected some bugs..." This reverts commit 29d8b48503f3064cdc1f3a87c01b4264e716a220. --- src/models.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/models.c') diff --git a/src/models.c b/src/models.c index f59a7b43..2d2af038 100644 --- a/src/models.c +++ b/src/models.c @@ -743,7 +743,7 @@ Model LoadHeightmap(Image heightmap, float maxHeight) vData.texcoords[tcCounter + 7] = vData.texcoords[tcCounter + 5]; vData.texcoords[tcCounter + 8] = vData.texcoords[tcCounter + 2]; - vData.texcoords[tcCounter + 9] = vData.texcoords[tcCounter + 3]; + vData.texcoords[tcCounter + 9] = vData.texcoords[tcCounter + 1]; vData.texcoords[tcCounter + 10] = (float)(x+1) / (mapX-1); vData.texcoords[tcCounter + 11] = (float)(z+1) / (mapZ-1); -- cgit v1.2.3 From d3cf316e40b531542b6f55b965f3369d4aca28d6 Mon Sep 17 00:00:00 2001 From: raysan5 Date: Tue, 9 Dec 2014 13:21:55 +0100 Subject: Added features and corrected bugs... [core] Added SetMousePosition() [models] LoadHeightmap() - Corrected textures bug [raymath] Functions renaming [WEB] Prepare environment for emscripten! --- src/models.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/models.c') diff --git a/src/models.c b/src/models.c index 2d2af038..f59a7b43 100644 --- a/src/models.c +++ b/src/models.c @@ -743,7 +743,7 @@ Model LoadHeightmap(Image heightmap, float maxHeight) vData.texcoords[tcCounter + 7] = vData.texcoords[tcCounter + 5]; vData.texcoords[tcCounter + 8] = vData.texcoords[tcCounter + 2]; - vData.texcoords[tcCounter + 9] = vData.texcoords[tcCounter + 1]; + vData.texcoords[tcCounter + 9] = vData.texcoords[tcCounter + 3]; vData.texcoords[tcCounter + 10] = (float)(x+1) / (mapX-1); vData.texcoords[tcCounter + 11] = (float)(z+1) / (mapZ-1); -- cgit v1.2.3 From 2e5f58255a391323fef54afc895a1d5a8ba06344 Mon Sep 17 00:00:00 2001 From: raysan5 Date: Tue, 16 Dec 2014 11:15:56 +0100 Subject: Working on rotation math... [models] Added DrawQuad() --- src/models.c | 47 +++++++++++++++++++++++++++++++++++++---------- 1 file changed, 37 insertions(+), 10 deletions(-) (limited to 'src/models.c') diff --git a/src/models.c b/src/models.c index f59a7b43..1ae95f23 100644 --- a/src/models.c +++ b/src/models.c @@ -66,14 +66,14 @@ static VertexData LoadOBJ(const char *fileName); // NOTE: Cube position is the center position void DrawCube(Vector3 position, float width, float height, float lenght, Color color) { - float x = position.x; - float y = position.y; - float z = position.z; + float x = 0.0f; + float y = 0.0f; + float z = 0.0f; rlPushMatrix(); // NOTE: Be careful! Function order matters (rotate -> scale -> translate) - //rlTranslatef(0.0f, 0.0f, 0.0f); + rlTranslatef(position.x, position.y, position.z); //rlScalef(2.0f, 2.0f, 2.0f); //rlRotatef(45, 0, 1, 0); @@ -146,12 +146,13 @@ void DrawCubeV(Vector3 position, Vector3 size, Color color) // Draw cube wires void DrawCubeWires(Vector3 position, float width, float height, float lenght, Color color) { - float x = position.x; - float y = position.y; - float z = position.z; + float x = 0.0f; + float y = 0.0f; + float z = 0.0f; rlPushMatrix(); + rlTranslatef(position.x, position.y, position.z); //rlRotatef(45, 0, 1, 0); rlBegin(RL_LINES); @@ -445,11 +446,37 @@ void DrawCylinderWires(Vector3 position, float radiusTop, float radiusBottom, fl rlPopMatrix(); } +// Draw a quad +void DrawQuad(Vector3 vertices[4], Vector2 textcoords[4], Vector3 normals[4], Color colors[4]) +{ + rlBegin(RL_QUADS); + rlColor4ub(colors[0].r, colors[0].g, colors[0].b, colors[0].a); + rlNormal3f(normals[0].x, normals[0].y, normals[0].z); + rlTexCoord2f(textcoords[0].x, textcoords[0].y); + rlVertex3f(vertices[0].x, vertices[0].y, vertices[0].z); + + rlColor4ub(colors[1].r, colors[1].g, colors[1].b, colors[1].a); + rlNormal3f(normals[1].x, normals[1].y, normals[1].z); + rlTexCoord2f(textcoords[1].x, textcoords[1].y); + rlVertex3f(vertices[1].x, vertices[1].y, vertices[1].z); + + rlColor4ub(colors[2].r, colors[2].g, colors[2].b, colors[2].a); + rlNormal3f(normals[2].x, normals[2].y, normals[2].z); + rlTexCoord2f(textcoords[2].x, textcoords[2].y); + rlVertex3f(vertices[2].x, vertices[2].y, vertices[2].z); + + rlColor4ub(colors[3].r, colors[3].g, colors[3].b, colors[3].a); + rlNormal3f(normals[3].x, normals[3].y, normals[3].z); + rlTexCoord2f(textcoords[3].x, textcoords[3].y); + rlVertex3f(vertices[3].x, vertices[3].y, vertices[3].z); + rlEnd(); +} + // Draw a plane void DrawPlane(Vector3 centerPos, Vector2 size, Vector3 rotation, Color color) { // NOTE: QUADS usage require defining a texture on OpenGL 3.3+ - rlEnableTexture(1); // Default white texture + if (rlGetVersion() != OPENGL_11) rlEnableTexture(1); // Default white texture // NOTE: Plane is always created on XZ ground and then rotated rlPushMatrix(); @@ -471,7 +498,7 @@ void DrawPlane(Vector3 centerPos, Vector2 size, Vector3 rotation, Color color) rlEnd(); rlPopMatrix(); - rlDisableTexture(); + if (rlGetVersion() != OPENGL_11) rlDisableTexture(); } // Draw a plane with divisions @@ -1041,7 +1068,7 @@ Model LoadCubesmap(Image cubesmap) // Move data from mapVertices temp arays to vertices float array vData.vertexCount = vCounter; - printf("Vertex count: %i\n", vCounter); + //printf("Vertex count: %i\n", vCounter); vData.vertices = (float *)malloc(vData.vertexCount * 3 * sizeof(float)); vData.normals = (float *)malloc(vData.vertexCount * 3 * sizeof(float)); -- cgit v1.2.3 From db1ad74ef21dbe48fafc3afc9ba6751832f22b77 Mon Sep 17 00:00:00 2001 From: raysan5 Date: Wed, 17 Dec 2014 19:32:54 +0100 Subject: [models] file open error check --- src/models.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/models.c') diff --git a/src/models.c b/src/models.c index 1ae95f23..539af3f9 100644 --- a/src/models.c +++ b/src/models.c @@ -1290,6 +1290,12 @@ static VertexData LoadOBJ(const char *fileName) FILE *objFile; objFile = fopen(fileName, "rt"); + + if (objFile == NULL) + { + TraceLog(WARNING, "[%s] OBJ file could not be opened", fileName); + return vData; + } // First reading pass: Get numVertex, numNormals, numTexCoords, numTriangles // NOTE: vertex, texcoords and normals could be optimized (to be used indexed on faces definition) -- cgit v1.2.3 From 905b6ec53df01a4f660c12c08c32e2cc301f7ad6 Mon Sep 17 00:00:00 2001 From: raysan5 Date: Wed, 31 Dec 2014 18:03:32 +0100 Subject: Added full support for HTML5 (emscripten) Corrected some bugs on the way... Automatically convert textures to POT on RPI and WEB --- src/models.c | 42 ++++++++++++++++++++++++++++++++++++------ 1 file changed, 36 insertions(+), 6 deletions(-) (limited to 'src/models.c') diff --git a/src/models.c b/src/models.c index 539af3f9..e8e4f635 100644 --- a/src/models.c +++ b/src/models.c @@ -50,7 +50,7 @@ //---------------------------------------------------------------------------------- // Global Variables Definition //---------------------------------------------------------------------------------- -// It's lonely here... +extern unsigned int whiteTexture; //---------------------------------------------------------------------------------- // Module specific Functions Declaration @@ -476,7 +476,7 @@ void DrawQuad(Vector3 vertices[4], Vector2 textcoords[4], Vector3 normals[4], Co void DrawPlane(Vector3 centerPos, Vector2 size, Vector3 rotation, Color color) { // NOTE: QUADS usage require defining a texture on OpenGL 3.3+ - if (rlGetVersion() != OPENGL_11) rlEnableTexture(1); // Default white texture + if (rlGetVersion() != OPENGL_11) rlEnableTexture(whiteTexture); // Default white texture // NOTE: Plane is always created on XZ ground and then rotated rlPushMatrix(); @@ -812,7 +812,7 @@ Model LoadHeightmap(Image heightmap, float maxHeight) } // Load a map image as a 3d model (cubes based) -Model LoadCubesmap(Image cubesmap) +Model LoadCubicmap(Image cubesmap) { VertexData vData; @@ -1068,8 +1068,6 @@ Model LoadCubesmap(Image cubesmap) // Move data from mapVertices temp arays to vertices float array vData.vertexCount = vCounter; - //printf("Vertex count: %i\n", vCounter); - vData.vertices = (float *)malloc(vData.vertexCount * 3 * sizeof(float)); vData.normals = (float *)malloc(vData.vertexCount * 3 * sizeof(float)); vData.texcoords = (float *)malloc(vData.vertexCount * 2 * sizeof(float)); @@ -1523,4 +1521,36 @@ static VertexData LoadOBJ(const char *fileName) TraceLog(INFO, "[%s] Model loaded successfully in RAM (CPU)", fileName); return vData; -} \ No newline at end of file +} + +bool CheckCollisionSpheres(Vector3 centerA, float radiusA, Vector3 centerB, float radiusB) +{ + + return false; +} + +bool CheckCollisionBoxes(Vector3 minBBox1, Vector3 maxBBox1, Vector3 minBBox2, Vector3 maxBBox2) +{ + /* + // Get min and max vertex to construct bounds (AABB) + Vector3 minVertex = tempVertices[0]; + Vector3 maxVertex = tempVertices[0]; + + for (int i = 1; i < tempVertices.Count; i++) + { + minVertex = Vector3.Min(minVertex, tempVertices[i]); + maxVertex = Vector3.Max(maxVertex, tempVertices[i]); + } + + bounds = new BoundingBox(minVertex, maxVertex); + */ + return false; +} + +bool CheckCollisionBoxSphere(Vector3 minBBox, Vector3 maxBBox, Vector3 centerSphere, Vector3 radiusSphere) +{ + + return false; +} + +//BoundingBox GetCollisionArea(BoundingBox box1, BoundingBox box2) \ No newline at end of file -- cgit v1.2.3