Skip to content

Commit

Permalink
simple viewmat.
Browse files Browse the repository at this point in the history
  • Loading branch information
syoyo committed Oct 17, 2023
1 parent 9a906d1 commit 151b65b
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion examples/openglviewer/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -838,11 +838,22 @@ static bool ProcScene(const example::shader &gl_shader, const tinyusdz::Stage& s
gl_node.gl_mesh_state = gl_mesh;

// FIXME:
tinyusdz::value::double3 scene_center;
scene_center[0] = scene_bmin[0] + 0.5 * (scene_bmax[0] - scene_bmin[0]);
scene_center[1] = scene_bmin[1] + 0.5 * (scene_bmax[1] - scene_bmin[1]);
scene_center[2] = scene_bmin[2] + 0.5 * (scene_bmax[2] - scene_bmin[2]);

tinyusdz::value::matrix4d identm = tinyusdz::value::matrix4d::identity();
tinyusdz::value::double3 trans = {scene_center[0], scene_center[1], scene_center[2]};
tinyusdz::value::double3 rotate = {90.0, 0.0, 0.0};
tinyusdz::value::double3 scale = {1.0, 1.0, -1.0};
tinyusdz::value::matrix4d rotm = tinyusdz::trs_angle_xyz(trans, rotate, scale);

tinyusdz::value::matrix4d modelm = rotm * identm;


std::cout << "global matrix: " << identm << "\n";
SetupVertexUniforms(gl_node.gl_v_uniform_state, identm, viewproj);
SetupVertexUniforms(gl_node.gl_v_uniform_state, modelm, viewproj);
SetupGLUniforms(gl_shader.get_program(), gl_node.gl_v_uniform_state);

scene->gl_nodes.emplace_back(gl_node);
Expand Down

0 comments on commit 151b65b

Please sign in to comment.