Fixed issue with some matrix, added rotate_camera(..)
This commit is contained in:
@@ -99,24 +99,25 @@ render_frame :: proc(renderer: ^Renderer) {
|
||||
set_clear_color(renderer, pass.clear_color)
|
||||
clear_screen(renderer, pass.should_clear_depth)
|
||||
enable_depth_testing(renderer, pass.should_test_depth)
|
||||
|
||||
|
||||
for i in 0..<pass.draw_command_count {
|
||||
command := &pass.draw_commands[i]
|
||||
|
||||
model_matrix := linalg.identity(linalg.Matrix4x4f32)
|
||||
|
||||
scale := linalg.matrix4_scale(command.scale)
|
||||
rotation := linalg.matrix4_rotate(linalg.to_radians(f32(0.0)), [3]f32 { 1, 0, 0 })
|
||||
translation := linalg.matrix4_translate(command.position)
|
||||
|
||||
// Scale.
|
||||
model_matrix *= scale
|
||||
|
||||
// Rotate.
|
||||
model_matrix *= rotation
|
||||
|
||||
// Translate.
|
||||
model_matrix *= translation
|
||||
translation := linalg.matrix4_translate(command.position)
|
||||
|
||||
// Rotate.
|
||||
rot_x := linalg.matrix4_rotate(linalg.to_radians(command.rotation.x), [3]f32 { 1, 0, 0 })
|
||||
rot_y := linalg.matrix4_rotate(linalg.to_radians(command.rotation.y), [3]f32 { 0, 1, 0 })
|
||||
rot_z := linalg.matrix4_rotate(linalg.to_radians(command.rotation.z), [3]f32 { 0, 0, 1 })
|
||||
rotation := rot_z * rot_y * rot_x
|
||||
|
||||
// Scale.
|
||||
scale := linalg.matrix4_scale(command.scale)
|
||||
|
||||
model_matrix *= translation * rotation * scale
|
||||
|
||||
activate_material(&command.material, model_matrix, view_matrix, projection_matrix)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user