Added another Draw Model method that can be drawn using Matrices

This commit is contained in:
Nikhil 2024-02-29 22:25:16 -08:00
parent 449f7d3fa6
commit e975a5b5f2
2 changed files with 22 additions and 0 deletions

View File

@ -1529,6 +1529,7 @@ RLAPI BoundingBox GetModelBoundingBox(Model model);
// Model drawing functions // Model drawing functions
RLAPI void DrawModel(Model model, Vector3 position, float scale, Color tint); // Draw a model (with texture if set) RLAPI void DrawModel(Model model, Vector3 position, float scale, Color tint); // Draw a model (with texture if set)
RLAPI void DrawModelEx(Model model, Vector3 position, Vector3 rotationAxis, float rotationAngle, Vector3 scale, Color tint); // Draw a model with extended parameters RLAPI void DrawModelEx(Model model, Vector3 position, Vector3 rotationAxis, float rotationAngle, Vector3 scale, Color tint); // Draw a model with extended parameters
RLAPI void DrawModelEx2(Model* model, const Matrix* transform, Color tint); // Draw a model with extended parameters
RLAPI void DrawModelWires(Model model, Vector3 position, float scale, Color tint); // Draw a model wires (with texture if set) RLAPI void DrawModelWires(Model model, Vector3 position, float scale, Color tint); // Draw a model wires (with texture if set)
RLAPI void DrawModelWiresEx(Model model, Vector3 position, Vector3 rotationAxis, float rotationAngle, Vector3 scale, Color tint); // Draw a model wires (with texture if set) with extended parameters RLAPI void DrawModelWiresEx(Model model, Vector3 position, Vector3 rotationAxis, float rotationAngle, Vector3 scale, Color tint); // Draw a model wires (with texture if set) with extended parameters
RLAPI void DrawBoundingBox(BoundingBox box, Color color); // Draw bounding box (wires) RLAPI void DrawBoundingBox(BoundingBox box, Color color); // Draw bounding box (wires)

View File

@ -3545,6 +3545,27 @@ void DrawModelEx(Model model, Vector3 position, Vector3 rotationAxis, float rota
} }
} }
void DrawModelEx2(Model* model, const Matrix* transform, Color tint)
{
// Combine model transformation matrix (model.transform) with matrix generated by function parameters (matTransform)
model->transform = MatrixMultiply(model->transform, *transform);
for (int i = 0; i < model->meshCount; i++)
{
Color color = model->materials[model->meshMaterial[i]].maps[MATERIAL_MAP_DIFFUSE].color;
Color colorTint = WHITE;
colorTint.r = (unsigned char)((((float)color.r / 255.0f) * ((float)tint.r / 255.0f)) * 255.0f);
colorTint.g = (unsigned char)((((float)color.g / 255.0f) * ((float)tint.g / 255.0f)) * 255.0f);
colorTint.b = (unsigned char)((((float)color.b / 255.0f) * ((float)tint.b / 255.0f)) * 255.0f);
colorTint.a = (unsigned char)((((float)color.a / 255.0f) * ((float)tint.a / 255.0f)) * 255.0f);
model->materials[model->meshMaterial[i]].maps[MATERIAL_MAP_DIFFUSE].color = colorTint;
DrawMesh(model->meshes[i], model->materials[model->meshMaterial[i]], model->transform);
model->materials[model->meshMaterial[i]].maps[MATERIAL_MAP_DIFFUSE].color = color;
}
}
// Draw a model wires (with texture if set) // Draw a model wires (with texture if set)
void DrawModelWires(Model model, Vector3 position, float scale, Color tint) void DrawModelWires(Model model, Vector3 position, float scale, Color tint)
{ {