Skip to content

Commit

Permalink
fix transform on skinned meshes
Browse files Browse the repository at this point in the history
  • Loading branch information
skyfloogle committed Aug 23, 2024
1 parent 01bf983 commit 36d6895
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 16 deletions.
4 changes: 2 additions & 2 deletions gm82gltf.gej
Original file line number Diff line number Diff line change
Expand Up @@ -638,10 +638,10 @@
"returntype": 2
},
{
"name": "gltf_node_Matrix_pointer",
"name": "gltf_node_matrix_pointer",
"extname": "",
"calltype": 12,
"helpline": "gltf_node_Matrix_pointer(gltf,node)",
"helpline": "gltf_node_matrix_pointer(gltf,node)",
"hidden": false,
"argtypes": [
2,
Expand Down
21 changes: 7 additions & 14 deletions gm82gltf.gml
Original file line number Diff line number Diff line change
Expand Up @@ -242,27 +242,23 @@

__mesh_id=gltf_node_mesh(argument0,__node)

// reversed from gltf spec because dx9 is left-handed
if (d3d_transform_get_determinant()>0) __cullmode=cull_clockwise
else __cullmode=cull_counterclockwise

__skin=gltf_node_skin(argument0,__node)
if (__skin>=0) {
__joints=gltf_skin_joints(argument0,__skin)
__jointsize=4*4*4*gltf_skin_joint_count(argument0,__skin)
}

d3d_transform_stack_push()
d3d_transform_set_scaling(gltf_node_sx(argument0,__node),gltf_node_sy(argument0,__node),gltf_node_sz(argument0,__node))
d3d_transform_add_rotation_axis(gltf_node_rx(argument0,__node),gltf_node_ry(argument0,__node),gltf_node_rz(argument0,__node),-2*darccos(gltf_node_rw(argument0,__node)))
d3d_transform_add_translation(gltf_node_tx(argument0,__node),gltf_node_ty(argument0,__node),gltf_node_tz(argument0,__node))
__gm82dx9_set_matrix_from_buffer(gltf_node_matrix_pointer(argument0,__node))
d3d_transform_add_stack_top()

// reversed from gltf spec because dx9 is left-handed
if (d3d_transform_get_determinant()>0) __cullmode=cull_clockwise
else __cullmode=cull_counterclockwise

// "Only the joint transforms are applied to the skinned mesh; the transform of the skinned mesh node MUST be ignored."
// see after for loop
if (__skin>=0) {
d3d_transform_stack_push()
d3d_transform_set_identity()
d3d_transform_stack_top()
}

texture_set_repeat(true)
Expand Down Expand Up @@ -406,8 +402,7 @@
}
}

// see before for loop
if (__skin>=0) d3d_transform_stack_pop()
d3d_transform_stack_pop()

shader_reset()

Expand All @@ -416,7 +411,5 @@
__i+=1
}

d3d_transform_stack_pop()

//
//

0 comments on commit 36d6895

Please sign in to comment.