Corrected issue with LoadMesh()
This commit is contained in:
parent
a728376cdf
commit
38a13b76d1
2 changed files with 16 additions and 16 deletions
|
@ -59,7 +59,7 @@ int main()
|
||||||
DrawGizmo(position); // Draw gizmo
|
DrawGizmo(position); // Draw gizmo
|
||||||
|
|
||||||
EndMode3D();
|
EndMode3D();
|
||||||
|
|
||||||
DrawText("(c) Castle 3D model by Alberto Cano", screenWidth - 200, screenHeight - 20, 10, GRAY);
|
DrawText("(c) Castle 3D model by Alberto Cano", screenWidth - 200, screenHeight - 20, 10, GRAY);
|
||||||
|
|
||||||
DrawFPS(10, 10);
|
DrawFPS(10, 10);
|
||||||
|
|
|
@ -28,11 +28,11 @@ int main()
|
||||||
Model model = LoadModel("resources/models/turret.obj"); // Load default model obj
|
Model model = LoadModel("resources/models/turret.obj"); // Load default model obj
|
||||||
Texture2D texture = LoadTexture("resources/models/turret_diffuse.png"); // Load default model texture
|
Texture2D texture = LoadTexture("resources/models/turret_diffuse.png"); // Load default model texture
|
||||||
model.materials[0].maps[MAP_DIFFUSE].texture = texture; // Bind texture to model
|
model.materials[0].maps[MAP_DIFFUSE].texture = texture; // Bind texture to model
|
||||||
|
|
||||||
Vector3 position = { 0.0, 0.0, 0.0 }; // Set model position
|
Vector3 position = { 0.0, 0.0, 0.0 }; // Set model position
|
||||||
BoundingBox bounds = MeshBoundingBox(model.meshes[0]); // Set model bounds
|
BoundingBox bounds = MeshBoundingBox(model.meshes[0]); // Set model bounds
|
||||||
bool selected = false; // Selected object flag
|
bool selected = false; // Selected object flag
|
||||||
|
|
||||||
SetCameraMode(camera, CAMERA_FREE); // Set a free camera mode
|
SetCameraMode(camera, CAMERA_FREE); // Set a free camera mode
|
||||||
|
|
||||||
char objFilename[64] = "turret.obj";
|
char objFilename[64] = "turret.obj";
|
||||||
|
@ -49,13 +49,13 @@ int main()
|
||||||
{
|
{
|
||||||
int count = 0;
|
int count = 0;
|
||||||
char **droppedFiles = GetDroppedFiles(&count);
|
char **droppedFiles = GetDroppedFiles(&count);
|
||||||
|
|
||||||
if (count == 1)
|
if (count == 1)
|
||||||
{
|
{
|
||||||
if (IsFileExtension(droppedFiles[0], ".obj"))
|
if (IsFileExtension(droppedFiles[0], ".obj"))
|
||||||
{
|
{
|
||||||
UnloadMesh(&model.meshes[0]);
|
for (int i = 0; i < model.meshCount; i++) UnloadMesh(&model.meshes[i]);
|
||||||
model.meshes[0] = LoadMesh(droppedFiles[0]);
|
model.meshes = LoadMeshes(droppedFiles[0], &model.meshCount);
|
||||||
bounds = MeshBoundingBox(model.meshes[0]);
|
bounds = MeshBoundingBox(model.meshes[0]);
|
||||||
}
|
}
|
||||||
else if (IsFileExtension(droppedFiles[0], ".png"))
|
else if (IsFileExtension(droppedFiles[0], ".png"))
|
||||||
|
@ -67,12 +67,12 @@ int main()
|
||||||
|
|
||||||
strcpy(objFilename, GetFileName(droppedFiles[0]));
|
strcpy(objFilename, GetFileName(droppedFiles[0]));
|
||||||
}
|
}
|
||||||
|
|
||||||
ClearDroppedFiles(); // Clear internal buffers
|
ClearDroppedFiles(); // Clear internal buffers
|
||||||
}
|
}
|
||||||
|
|
||||||
UpdateCamera(&camera);
|
UpdateCamera(&camera);
|
||||||
|
|
||||||
// Select model on mouse click
|
// Select model on mouse click
|
||||||
if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON))
|
if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON))
|
||||||
{
|
{
|
||||||
|
@ -93,21 +93,21 @@ int main()
|
||||||
DrawModel(model, position, 1.0f, WHITE); // Draw 3d model with texture
|
DrawModel(model, position, 1.0f, WHITE); // Draw 3d model with texture
|
||||||
|
|
||||||
DrawGrid(20.0, 10.0); // Draw a grid
|
DrawGrid(20.0, 10.0); // Draw a grid
|
||||||
|
|
||||||
if (selected) DrawBoundingBox(bounds, GREEN);
|
if (selected) DrawBoundingBox(bounds, GREEN);
|
||||||
|
|
||||||
EndMode3D();
|
EndMode3D();
|
||||||
|
|
||||||
DrawText("Free camera default controls:", 10, 20, 10, DARKGRAY);
|
DrawText("Free camera default controls:", 10, 20, 10, DARKGRAY);
|
||||||
DrawText("- Mouse Wheel to Zoom in-out", 20, 40, 10, GRAY);
|
DrawText("- Mouse Wheel to Zoom in-out", 20, 40, 10, GRAY);
|
||||||
DrawText("- Mouse Wheel Pressed to Pan", 20, 60, 10, GRAY);
|
DrawText("- Mouse Wheel Pressed to Pan", 20, 60, 10, GRAY);
|
||||||
DrawText("- Alt + Mouse Wheel Pressed to Rotate", 20, 80, 10, GRAY);
|
DrawText("- Alt + Mouse Wheel Pressed to Rotate", 20, 80, 10, GRAY);
|
||||||
DrawText("- Alt + Ctrl + Mouse Wheel Pressed for Smooth Zoom", 20, 100, 10, GRAY);
|
DrawText("- Alt + Ctrl + Mouse Wheel Pressed for Smooth Zoom", 20, 100, 10, GRAY);
|
||||||
|
|
||||||
DrawText("Drag & drop .obj/.png to load mesh/texture.", 10, GetScreenHeight() - 20, 10, DARKGRAY);
|
DrawText("Drag & drop .obj/.png to load mesh/texture.", 10, GetScreenHeight() - 20, 10, DARKGRAY);
|
||||||
DrawText(FormatText("Current file: %s", objFilename), 250, GetScreenHeight() - 20, 10, GRAY);
|
DrawText(FormatText("Current file: %s", objFilename), 250, GetScreenHeight() - 20, 10, GRAY);
|
||||||
if (selected) DrawText("MODEL SELECTED", GetScreenWidth() - 110, 10, 10, GREEN);
|
if (selected) DrawText("MODEL SELECTED", GetScreenWidth() - 110, 10, 10, GREEN);
|
||||||
|
|
||||||
DrawText("(c) Turret 3D model by Alberto Cano", screenWidth - 200, screenHeight - 20, 10, GRAY);
|
DrawText("(c) Turret 3D model by Alberto Cano", screenWidth - 200, screenHeight - 20, 10, GRAY);
|
||||||
|
|
||||||
EndDrawing();
|
EndDrawing();
|
||||||
|
@ -119,7 +119,7 @@ int main()
|
||||||
UnloadModel(model); // Unload model
|
UnloadModel(model); // Unload model
|
||||||
|
|
||||||
ClearDroppedFiles(); // Clear internal buffers
|
ClearDroppedFiles(); // Clear internal buffers
|
||||||
|
|
||||||
CloseWindow(); // Close window and OpenGL context
|
CloseWindow(); // Close window and OpenGL context
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue