asdf
This commit is contained in:
parent
6fdb938524
commit
294e1dd919
1 changed files with 11 additions and 24 deletions
|
|
@ -627,16 +627,18 @@ runGame :: proc(window: ^sdl.Window, device: ^sdl.GPUDevice, pipeline: ^sdl.GPUG
|
||||||
modelIndex := len(models)
|
modelIndex := len(models)
|
||||||
append_elem(&models, parsed)
|
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)
|
S := linalg.matrix4_scale(object.transform.scale)
|
||||||
|
|
||||||
Rx := linalg.matrix4_rotate_f32(linalg.to_radians(object.transform.rotation_deg[0]), {1,0,0})
|
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[1]), {0,1,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[2]), {0,0,1})
|
Rz := linalg.matrix4_rotate_f32(linalg.to_radians(-object.transform.rotation_deg.z), {0,0,1})
|
||||||
|
|
||||||
R := Rz * Ry * Rx
|
R := Rz * Ry * Rx
|
||||||
|
|
||||||
M := T * R * S
|
M := T * R * S
|
||||||
|
|
||||||
loadRsmModel(device, &parsed, modelIndex, &rsmNodes, &textures, &rsmVbufs, &rsmIbufs, M, &files)
|
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
|
current_frame := u32(f32(elapsed_ms) / frame_delay) % total_frames
|
||||||
|
|
||||||
node := mesh.node
|
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 {
|
if len(node.rotation_keyframes) > 0 {
|
||||||
keyframe_idx := 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)
|
// 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)
|
// fmt.println(node.rotation_axis)
|
||||||
}
|
}
|
||||||
|
|
||||||
flip_zy := matrix[4,4]f32{
|
model_mat := T * R * O * S
|
||||||
1, 0, 0, 0,
|
|
||||||
0, 1, 0, 0,
|
|
||||||
0, 0, -1, 0,
|
|
||||||
0, 0, 0, 1,
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
model_mat := flip_zy * T * R * O * S
|
|
||||||
|
|
||||||
|
|
||||||
pc := Push_Constants{}
|
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}
|
pc.color = [4]f32{1, 0, 0, 1.0}
|
||||||
sdl.BindGPUFragmentSamplers(rp, 0, &(sdl.GPUTextureSamplerBinding{
|
sdl.BindGPUFragmentSamplers(rp, 0, &(sdl.GPUTextureSamplerBinding{
|
||||||
texture = textures[mesh.texture].texture,
|
texture = textures[mesh.texture].texture,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue