diff --git a/include/vsg/nodes/CoordinateFrame.h b/include/vsg/nodes/CoordinateFrame.h index 36fef0cec..29a996eb8 100644 --- a/include/vsg/nodes/CoordinateFrame.h +++ b/include/vsg/nodes/CoordinateFrame.h @@ -26,6 +26,7 @@ namespace vsg std::string name; dvec3 origin; + dquat rotation; dmat4 transform(const dmat4& mv) const override; diff --git a/src/vsg/app/RecordTraversal.cpp b/src/vsg/app/RecordTraversal.cpp index 1c06fc9ed..2ecf91a5a 100644 --- a/src/vsg/app/RecordTraversal.cpp +++ b/src/vsg/app/RecordTraversal.cpp @@ -446,7 +446,7 @@ void RecordTraversal::apply(const CoordinateFrame& cf) if (viewMatrix) { - _state->modelviewMatrixStack.push(viewMatrix->transform(cf.origin)); + _state->modelviewMatrixStack.push(viewMatrix->transform(cf.origin) * vsg::rotate(cf.rotation)); } else { diff --git a/src/vsg/nodes/CoordinateFrame.cpp b/src/vsg/nodes/CoordinateFrame.cpp index 0a996b0ab..d8bee299c 100644 --- a/src/vsg/nodes/CoordinateFrame.cpp +++ b/src/vsg/nodes/CoordinateFrame.cpp @@ -24,7 +24,8 @@ CoordinateFrame::CoordinateFrame() CoordinateFrame::CoordinateFrame(const CoordinateFrame& rhs, const CopyOp& copyop) : Inherit(rhs, copyop), name(rhs.name), - origin(rhs.origin) + origin(rhs.origin), + rotation(rhs.rotation) { } @@ -35,7 +36,8 @@ int CoordinateFrame::compare(const Object& rhs_object) const const auto& rhs = static_cast(rhs_object); if ((result = compare_value(name, rhs.name)) != 0) return result; - return compare_value(origin, rhs.origin); + if ((result = compare_value(origin, rhs.origin)) != 0) return result; + return compare_value(rotation, rhs.rotation); } void CoordinateFrame::read(Input& input) @@ -43,6 +45,7 @@ void CoordinateFrame::read(Input& input) Node::read(input); input.read("name", name); input.read("origin", origin); + input.read("rotation", rotation); input.read("subgraphRequiresLocalFrustum", subgraphRequiresLocalFrustum); input.readObjects("children", children); } @@ -52,11 +55,12 @@ void CoordinateFrame::write(Output& output) const Node::write(output); output.write("name", name); output.write("origin", origin); + output.write("rotation", rotation); output.write("subgraphRequiresLocalFrustum", subgraphRequiresLocalFrustum); output.writeObjects("children", children); } dmat4 CoordinateFrame::transform(const dmat4& mv) const { - return mv * translate(dvec3(origin)); + return mv * translate(dvec3(origin)) * rotate(rotation); }