21 OGRE_EXCEPT(Ogre::Exception::ERR_INVALIDPARAMS,
"Argument collision is NULL",
"CollisionSerializer::exportCollision");
24#if OGRE_VERSION < ((1 << 16) | (8 << 8) | 0)
25 mpfFile=fopen(filename.c_str(),
"wb");
28 OGRE_EXCEPT(Ogre::Exception::ERR_INVALIDPARAMS,
"Unable to open file " + filename +
" for writing",
"CollisionSerializer::exportCollision");
31 NewtonCollisionSerialize(collision->
getWorld()->
getNewtonWorld(), collision->
m_col, &CollisionSerializer::_newtonSerializeCallback,
this);
36 mStream = Ogre::Root::getSingleton().createFileStream(filename, Ogre::RGN_DEFAULT,
true);
37 NewtonCollisionSerialize(collision->
getWorld()->
getNewtonWorld(), collision->
m_col, &CollisionSerializer::_newtonSerializeCallback,
this);
39 catch (Ogre::Exception&)
41 OGRE_EXCEPT(Ogre::Exception::ERR_INVALIDPARAMS,
"Unable to open file " + filename +
" for writing",
"CollisionSerializer::exportCollision");
44 mStream.get()->close();
54 NewtonCollision* col = NewtonCreateCollisionFromSerialization(world->
getNewtonWorld(), &CollisionSerializer::_newtonDeserializeCallback, &stream);
101 void CollisionSerializer::_newtonSerializeCallback(
void* serializeHandle,
const void* buffer,
int size)
104 me->writeData(buffer, 1, size);
108 void CollisionSerializer::_newtonDeserializeCallback(
void* deserializeHandle,
void* buffer,
int size)
111 Ogre::DataStream& ptr = * (
static_cast<Ogre::DataStream*
>(deserializeHandle));
113 ptr.read(buffer, size);
represents a shape for collision detection
CollisionPrimitiveType getCollisionPrimitiveType() const
Returns the Collisiontype for this Collision.
const World * getWorld() const
standard primitive capsule.
filled-donut shape primitive.
create a compound from several collision pieces.
standard primitive cylinder.
standard primitive Ellipsoid.
null collision (results in no collision)
TreeCollision - complex polygonal collision.
OgreNewt::CollisionPtr importCollision(Ogre::DataStream &stream, OgreNewt::World *world)
CollisionSerializer()
constructor
virtual ~CollisionSerializer()
destructor
void exportCollision(const OgreNewt::CollisionPtr &collision, const Ogre::String &filename)
represents a physics world.
NewtonWorld * getNewtonWorld() const
retrieves a pointer to the NewtonWorld
@ CompoundCollisionPrimitiveType
@ HeighFieldPrimitiveType
@ ConvexHullPrimitiveType
@ ChamferCylinderPrimitiveType
@ TreeCollisionPrimitiveType