render_cpp: render an array of nodes

This commit is contained in:
Zack Buhman 2026-01-04 21:55:17 -06:00
parent 07df5d9a1d
commit 32cc14106d
3 changed files with 10 additions and 6 deletions

View File

@ -34,7 +34,7 @@ struct Node {
struct Skin { struct Skin {
const D3DXMATRIX * inverse_bind_matrices; // accessor const D3DXMATRIX * inverse_bind_matrices; // accessor
const Node ** joints; const int * joints;
DWORD joints_length; DWORD joints_length;
}; };
@ -59,5 +59,4 @@ struct AnimationChannel {
} target; } target;
}; };
#ifndef GLTF_HPP_ #endif
#define GLTF_HPP_

View File

@ -2,7 +2,6 @@
#define GLTF_INSTANCE_HPP_ #define GLTF_INSTANCE_HPP_
struct NodeInstance { struct NodeInstance {
const Node * node;
D3DXVECTOR3 translation; D3DXVECTOR3 translation;
D3DXQUATERNION rotation; D3DXQUATERNION rotation;
D3DXVECTOR3 scale; D3DXVECTOR3 scale;

View File

@ -127,11 +127,17 @@ def render_nodes(gltf):
yield f"{render_value(scale, 'D3DXVECTOR3')}, // scale" yield f"{render_value(scale, 'D3DXVECTOR3')}, // scale"
yield "};" yield "};"
yield "const Node * nodes[] = {"
for node_ix in range(len(gltf.json["nodes"])):
yield f"&node_{node_ix},"
yield "};"
yield f"const int nodes_length = (sizeof (nodes)) / (sizeof (nodes[0]));"
def render_skins(gltf): def render_skins(gltf):
for skin_ix, skin in enumerate(gltf.json["skins"]): for skin_ix, skin in enumerate(gltf.json["skins"]):
yield f"const Node * skin_{skin_ix}__joints[] = {{" yield f"const int skin_{skin_ix}__joints[] = {{"
for joint in skin["joints"]: for joint in skin["joints"]:
yield f"&node_{joint}," yield f"{joint},"
yield "};" yield "};"
for skin_ix, skin in enumerate(gltf.json["skins"]): for skin_ix, skin in enumerate(gltf.json["skins"]):