00001
00008 #include "SO3ShapeCylinder.h"
00009 #include "../SO3SceneGraph/SO3NodeScol.h"
00010 #include "../SO3SceneGraph/SO3Entity.h"
00011 #include "../SO3SceneGraph/SO3Scene.h"
00012
00013 namespace SO3
00014 {
00015
00016 SShapeCylinder::SShapeCylinder() : SShape("", SShape::SO3_NULL_COLLISION)
00017 {
00018
00019 }
00020
00021 SShapeCylinder::SShapeCylinder(std::string shapeName, SNode* node, Ogre::Real radius, Ogre::Real height) : SShape(shapeName, SShape::SO3_CYLINDER_COLLISION)
00022 {
00023 Ogre::Vector3 poffset = Ogre::Vector3::ZERO;
00024 if (node->GetNodeType() == SNode::ENTITY_TYPE_ID)
00025 {
00026 SEntity* entity = static_cast<SEntity*> (node);
00027 poffset = entity->GetBoundingBoxCenter();
00028 }
00029
00030 mCollisionPtr = OgreNewt::CollisionPtr(new OgreNewt::CollisionPrimitives::Cylinder(node->GetParentScene()->GetPhysicsWorld()->GetPhysicWorld(), radius, height, 0, Ogre::Quaternion::IDENTITY, poffset));
00031 mRadius = radius;
00032 mHeight = height;
00033 }
00034
00035 SShapeCylinder::~SShapeCylinder()
00036 {
00037 }
00038
00039 Ogre::Real SShapeCylinder::GetRadius()
00040 {
00041 return mRadius;
00042 }
00043
00044 Ogre::Real SShapeCylinder::GetHeight()
00045 {
00046 return mHeight;
00047 }
00048
00049 Ogre::Vector3 SShapeCylinder::CalculateInertialMatrix()
00050 {
00051 Ogre::Vector3 iner, off;
00052 (static_cast<OgreNewt::CollisionPrimitives::Cylinder*>(mCollisionPtr.get()))->calculateInertialMatrix(iner, off);
00053 return iner;
00054 }
00055
00056 Ogre::Vector3 SShapeCylinder::CalculateOffset()
00057 {
00058 Ogre::Vector3 iner, off;
00059 (static_cast<OgreNewt::CollisionPrimitives::Cylinder*>(mCollisionPtr.get()))->calculateInertialMatrix(iner, off);
00060 return off;
00061 }
00062
00063 }