simple ubershader system, reflection debugging
[laserbrain_demo] / src / snode.cc
index b171f35..fb2877d 100644 (file)
@@ -164,17 +164,17 @@ const Vec3 &SceneNode::get_node_scaling() const
 
 Vec3 SceneNode::get_position() const
 {
-       return xform * Vec3(0, 0, 0);
+       return xform.get_translation();
 }
 
 Quat SceneNode::get_rotation() const
 {
-       return rot;     // TODO
+       return xform.get_rotation();
 }
 
 Vec3 SceneNode::get_scaling() const
 {
-       return scale;   // TODO
+       return xform.get_scaling();
 }
 
 const Mat4 &SceneNode::get_matrix() const
@@ -220,6 +220,36 @@ void SceneNode::update(float dt)
 
                        ImGui::NextColumn();
                        ImGui::Checkbox("##vis", &visible);
+                       ImGui::SameLine();
+                       if(ImGui::Button("xform")) {
+                               ImGui::OpenPopup("xform_popup");
+                       }
+                       if(ImGui::BeginPopup("xform_popup")) {
+                               ImGui::Text("Local transform");
+                               Vec3 p = get_node_position();
+                               ImGui::BulletText("P: %g %g %g", p.x, p.y, p.z);
+                               Quat q = get_node_rotation();
+                               ImGui::BulletText("R: %g %g %g %g", q.x, q.y, q.z, q.w);
+                               Vec3 s = get_node_scaling();
+                               ImGui::BulletText("S: %g %g %g", s.x, s.y, s.z);
+
+                               ImGui::Separator();
+                               ImGui::Text("Global transform");
+                               p = get_position();
+                               ImGui::BulletText("P: %g %g %g", p.x, p.y, p.z);
+                               q = get_rotation();
+                               ImGui::BulletText("R: %g %g %g %g", q.x, q.y, q.z, q.w);
+                               s = get_scaling();
+                               ImGui::BulletText("S: %g %g %g", s.x, s.y, s.z);
+
+                               const Mat4 &mat = get_matrix();
+                               ImGui::BulletText("| %3.3f %3.3f %3.3f %3.3f |", mat[0][0], mat[0][1], mat[0][2], mat[0][3]);
+                               ImGui::BulletText("| %3.3f %3.3f %3.3f %3.3f |", mat[1][0], mat[1][1], mat[1][2], mat[1][3]);
+                               ImGui::BulletText("| %3.3f %3.3f %3.3f %3.3f |", mat[2][0], mat[2][1], mat[2][2], mat[2][3]);
+                               ImGui::BulletText("| %3.3f %3.3f %3.3f %3.3f |", mat[3][0], mat[3][1], mat[3][2], mat[3][3]);
+
+                               ImGui::EndPopup();
+                       }
                        ImGui::NextColumn();
                        ImGui::PopID();
                }