diff options
author | Xanadu <none@none> | 2010-07-17 22:58:24 +0200 |
---|---|---|
committer | Xanadu <none@none> | 2010-07-17 22:58:24 +0200 |
commit | b5f8bfd66561e4a63fa8c28961b829a35ceb2fb0 (patch) | |
tree | 6691fda7c0985077aeb6ff3a93e829447dddd736 /externals/g3dlite/G3D.lib/source/PhysicsFrame.cpp | |
parent | ec244dbe366e84a93c8fa1ef294af4a2e4e3b0b1 (diff) | |
parent | dc510c9a143de1977daedea0aefb9589c01adde2 (diff) |
Merge
--HG--
branch : trunk
Diffstat (limited to 'externals/g3dlite/G3D.lib/source/PhysicsFrame.cpp')
-rw-r--r-- | externals/g3dlite/G3D.lib/source/PhysicsFrame.cpp | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/externals/g3dlite/G3D.lib/source/PhysicsFrame.cpp b/externals/g3dlite/G3D.lib/source/PhysicsFrame.cpp new file mode 100644 index 00000000000..034e585d01f --- /dev/null +++ b/externals/g3dlite/G3D.lib/source/PhysicsFrame.cpp @@ -0,0 +1,77 @@ +/** + @file PhysicsFrame.cpp + + @maintainer Morgan McGuire, matrix@graphics3d.com + + @created 2002-07-09 + @edited 2006-01-25 +*/ + +#include "G3D/platform.h" +#include "G3D/PhysicsFrame.h" +#include "G3D/BinaryInput.h" +#include "G3D/BinaryOutput.h" + +namespace G3D { + +PhysicsFrame::PhysicsFrame() { + translation = Vector3::zero(); + rotation = Quat(); +} + + +PhysicsFrame::PhysicsFrame( + const CoordinateFrame& coordinateFrame) { + + translation = coordinateFrame.translation; + rotation = Quat(coordinateFrame.rotation); +} + + +PhysicsFrame PhysicsFrame::operator*(const PhysicsFrame& other) const { + PhysicsFrame result; + + result.rotation = rotation * other.rotation; + result.translation = translation + rotation.toRotationMatrix() * other.translation; + + return result; +} + + +CoordinateFrame PhysicsFrame::toCoordinateFrame() const { + CoordinateFrame f; + + f.translation = translation; + f.rotation = rotation.toRotationMatrix(); + + return f; +} + + +PhysicsFrame PhysicsFrame::lerp( + const PhysicsFrame& other, + float alpha) const { + + PhysicsFrame result; + + result.translation = translation.lerp(other.translation, alpha); + result.rotation = rotation.slerp(other.rotation, alpha); + + return result; +} + + +void PhysicsFrame::deserialize(class BinaryInput& b) { + translation.deserialize(b); + rotation.deserialize(b); +} + + +void PhysicsFrame::serialize(class BinaryOutput& b) const { + translation.serialize(b); + rotation.serialize(b); +} + + +}; // namespace + |