diff --git a/src/gndview/gndview.odin b/src/gndview/gndview.odin index 8f2f8d8..6cf65ff 100644 --- a/src/gndview/gndview.odin +++ b/src/gndview/gndview.odin @@ -627,16 +627,18 @@ runGame :: proc(window: ^sdl.Window, device: ^sdl.GPUDevice, pipeline: ^sdl.GPUG modelIndex := len(models) append_elem(&models, parsed) - T := linalg.matrix4_translate(object.transform.position) + p := object.transform.position + + T := linalg.matrix4_translate([3]f32{p.x,p.y,-p.z}) S := linalg.matrix4_scale(object.transform.scale) - Rx := linalg.matrix4_rotate_f32(linalg.to_radians(object.transform.rotation_deg[0]), {1,0,0}) - Ry := linalg.matrix4_rotate_f32(linalg.to_radians(object.transform.rotation_deg[1]), {0,1,0}) - Rz := linalg.matrix4_rotate_f32(linalg.to_radians(object.transform.rotation_deg[2]), {0,0,1}) + Rx := linalg.matrix4_rotate_f32(linalg.to_radians(object.transform.rotation_deg.x), {1,0,0}) + Ry := linalg.matrix4_rotate_f32(linalg.to_radians(object.transform.rotation_deg.y), {0,1,0}) + Rz := linalg.matrix4_rotate_f32(linalg.to_radians(-object.transform.rotation_deg.z), {0,0,1}) R := Rz * Ry * Rx - M := T * R * S + M := T * R * S loadRsmModel(device, &parsed, modelIndex, &rsmNodes, &textures, &rsmVbufs, &rsmIbufs, M, &files) } @@ -915,7 +917,7 @@ renderModel :: proc(models: ^[dynamic]format.RSM_Model, elapsed_ms: f64, nodes: current_frame := u32(f32(elapsed_ms) / frame_delay) % total_frames node := mesh.node - R := linalg.matrix4_rotate(node.rotation_angle, node.rotation_axis) + R := linalg.matrix4_rotate(linalg.to_radians(node.rotation_angle), node.rotation_axis) if len(node.rotation_keyframes) > 0 { keyframe_idx := 0 @@ -962,7 +964,7 @@ renderModel :: proc(models: ^[dynamic]format.RSM_Model, elapsed_ms: f64, nodes: } } - T := linalg.matrix4_translate(-(node.translation1 + node.translation2 + translation)) + T := linalg.matrix4_translate((node.translation1 + node.translation2 + translation)) // T = linalg.identity(matrix[4,4]f32) @@ -974,27 +976,12 @@ renderModel :: proc(models: ^[dynamic]format.RSM_Model, elapsed_ms: f64, nodes: // fmt.println(node.rotation_axis) } - flip_zy := matrix[4,4]f32{ - 1, 0, 0, 0, - 0, 1, 0, 0, - 0, 0, -1, 0, - 0, 0, 0, 1, - } - - - model_mat := flip_zy * T * R * O * S + model_mat := T * R * O * S pc := Push_Constants{} - - globalScaleCuzFuckit := matrix[4,4]f32{ - 0.8, 0,0,0, - 0,0.8,0,0, - 0,0,.8,0, - 0,0,0,1 - } - pc.mvp = vp_mat *flip_zy* mesh.transform * model_mat + pc.mvp = vp_mat * mesh.transform * model_mat pc.color = [4]f32{1, 0, 0, 1.0} sdl.BindGPUFragmentSamplers(rp, 0, &(sdl.GPUTextureSamplerBinding{ texture = textures[mesh.texture].texture,