deadvirus
19-06-2009 16:32:10
Hello,
What is the best way to obtain a nice collision body for an aeroplane? I need it to be close to the plane shape, because it will be for an shooter...
Any suggestions? I can't use some 3D models tool if needed...
Thanks.
melven
19-06-2009 21:07:28
You could use compound collisions: This way you can use several convex shapes (e.g. one for each wing, one for the fuselage...) to compose your whole aeroplane.
deadvirus
20-06-2009 13:33:16
You could use compound collisions: This way you can use several convex shapes (e.g. one for each wing, one for the fuselage...) to compose your whole aeroplane.
Thanks. I had tough about that, but didn't want to recreate it each time the app runs, because it would be different from plane to plane, and would be hard to do it in a way that it creates a nice collision for every plane. But I've seen in the other thread that newton can save the collisions to a file... so that's great.
I can't create it one time (one for each plane), than export to file, then each plane mesh will be "associated" with a collision file, so when I need to load some plain, I will get it's collision... Right?
Can you give me a little light on how to export/import collisions? I didn't saw this feature in OgreNewt, I think...
Thank you.
melven
20-06-2009 14:19:09
You need the newton 2.0 beta and the OgreNewt version from here:
viewtopic.php?f=4&t=980&start=75#p54612
In order to load a collision you can do something like this:
OgreNewt::CollisionPtr loadFromFile(const Ogre::String& filename)
{
OgreNewt::CollisionPtr rval;
FILE* pFile = fopen(filename.c_str(), "r" );
if( pFile )
{
Ogre::DataStreamPtr streamPtr( new Ogre::FileHandleDataStream( pFile ) );
OgreNewt::CollisionSerializer collisionSerializer;
rval = collisionSerializer.importCollision( streamPtr, ogreNewtWorldPointer );
}
return rval;
}
Saving a collision is even more simple:
OgreNewt::CollisionSerializer collisionSerializer;
collisionSerializer.exportCollision( col, filename );
You can create one instance of OgreNewt::CollisionSerializer and reuse it, of course.
deadvirus
20-06-2009 19:55:54
You need the newton 2.0 beta and the OgreNewt version from here: viewtopic.php?f=4&t=980&start=75#p54612
Only works with 2.0? Not in 1.53?
I need it for a school project, so I need it to be kind of stable... 2.0 is unstable for now, isn't it?
kallaspriit
23-06-2009 11:29:02
Not really, it is indeed in beta status but on the most part, stable and very much usable
Zero23
23-06-2009 18:15:43
Yes, when you not want to use any multicore features from Newton:D
deadvirus
24-06-2009 23:05:06
You need the newton 2.0 beta and the OgreNewt version from here: viewtopic.php?f=4&t=980&start=75#p54612
In order to load a collision you can do something like this:
OgreNewt::CollisionPtr loadFromFile(const Ogre::String& filename)
{
OgreNewt::CollisionPtr rval;
FILE* pFile = fopen(filename.c_str(), "r" );
if( pFile )
{
Ogre::DataStreamPtr streamPtr( new Ogre::FileHandleDataStream( pFile ) );
OgreNewt::CollisionSerializer collisionSerializer;
rval = collisionSerializer.importCollision( streamPtr, ogreNewtWorldPointer );
}
return rval;
}
Saving a collision is even more simple:
OgreNewt::CollisionSerializer collisionSerializer;
collisionSerializer.exportCollision( col, filename );
You can create one instance of OgreNewt::CollisionSerializer and reuse it, of course.
Another way to import the collision is using the Ogre::ResourceGroupManager.
Ogre::DataStreamPtr dsptr = Ogre::ResourceGroupManager::getSingletonPtr()->openResource("collision.col");
OgreNewt::CollisionSerializer colSer;
OgreNewt::CollisionPtr col = colSer.importCollision(dsptr, mWorld);
Now I have a problem. the importCollision returns a CollisionPtr. But how can I find the inertia then? Since I'm loading a ConvexCollision, I've done this, but it doesn't feel right because it goes "over" the wrapper:
NewtonConvexCollisionCalculateInertialMatrix(col->getNewtonCollision(), &inertia.x, ¢mass.x);
Any sugestion?
melven
29-06-2009 17:55:23
You can use
OgreNewt::ConvexCollisionPtr convexCollPtr = boost::dynamic_pointer_cast<OgreNewt::ConvexCollision>(collPtr);
and then call the convexCollPtr->calculateInertialMatrix(...) ...
deadvirus
29-06-2009 20:38:12
You can use
OgreNewt::ConvexCollisionPtr convexCollPtr = boost::dynamic_pointer_cast<OgreNewt::ConvexCollision>(collPtr);
and then call the convexCollPtr->calculateInertialMatrix(...) ...
It's not working... convexColPtr is NULL after that...