Feature Request: Collision Export

pixl

28-03-2006 15:33:27

I think it would be nice if oFusion could export an extra xml file containing vertex data (only positions) for each object contained in the osm file. This can then be used by server side application to create collision geometry from. Something even better would be a physics plugin which would include a property rollout so that you can directly modify physics properties of a given object, but maybe that is too much to ask :D

BergBoy

29-03-2006 14:57:35

When I load an Ofusion scene I use a callback that checks the name of the object. This means it picks out if the object is meant to be visible etc as well as whether a trimesh needs to be generated (I use Newton) or if its just a position to be used to place down an entity (like a guard etc). Thats the best way I can think up to use Ofusion quickly to create a physics world (or scripted elements: like trigger blocks)

Lioric

29-03-2006 17:22:02

Physics is a very user dependant process, you need support for the method you posted, but other user will need a very different method

That is why in the Pro version you have an new object properties editor in max, where you can create specific properties (i.e. "physics collision type" list property, for "objects" type with a enum of "Trimesh, AABB, Sphere")
This new property will be visible to all objects, and its value can be defined for each object, or the selection (i.e. object1 and object20 uses "Trimesh", object2 uses "AABB", object3 "Sphere Collision")

The oscene loader lib will present you with the new object loaded and its properties, where you can parse them and use its values

Mass, Center of Gravity, spring, bounce factor, friction coef, joints, are some example of the properties that you will define for your objects

For the CE version, the method used by BergBoy is very good

Evak

29-03-2006 17:24:35

a quick nametag like a mesh with _col in the name is a good way to set up invisible low poly collision scenery meshes for your physics engine to collide with. Often you only need about one collision poly for every 30 visible ones. Which is why I recommend the lower poly proxy collision for static meshes. Sometimes you can use them for your AI too.

Which collision and physics libs are you guys using, I've previously used ODE and Tokomak with other game engines. Ogre has quite a few more options so I've been wondering which gives the best compromise between accuracy and performance.

Lioric: That sounds excellent :)

praetor

29-03-2006 22:46:22

I really like the feel of newton. It's easy to use, and has some really nice features. It isn't open source, but it is free.

I can't wait for oFusion pro. That is definitely worth a purchase.

pixl

03-04-2006 10:45:00

Yeah it would be cool with a property editor =)

In my original post though I was thinking about a separate scene export that would only export the physical world. Yeah sure you can load all the mesh data from .mesh into ogre and then extract the physics stuff, but it would be alot cleaner to have a separate file for collision and for graphics data. Thats how many games do it. That way you wouldn't need much of the ogre stuff on the server side where it doesn't belong anyway.

Lioric

03-04-2006 18:22:22

What you need is very user/project dependant

You can easily use the Scene Loader lib to make a collision geom creator to produce the data you need, and you can call it inside max after exporting your scene automatically

Rambo

11-05-2006 13:05:42

Can somebody write sample code for create phisics world (OgreNewt) using oFusion?

celic

11-05-2006 13:28:10

Can somebody write sample code for create phisics world (OgreNewt) using oFusion?

Could you be more specific about your requirement? :)
As I understand you want oFusion to export the collision info for OgreNewt, but it's not a physical tool, it just cope with geometry, which isn't all the time the same as collision model.

Rambo

11-05-2006 14:03:01

Hmmm... :) No,you don't understand.

I have world in OSM file and I try convert enitity(node) from this world to physics entity(node).

I try this :

oScene.initialise(OSMfile.c_str());
oScene.createScene();

OSMScene::EntityList::iterator it;
OSMScene::EntityList eList = oScene.getEntityList();
SceneNode* scn;

for(it = eList.begin();it != eList.end() ; ++it)
{
scn=mWorldSceneMgr->getSceneNode((*it)->getName());
Collision* col = new OgreNewt::CollisionPrimitives::TreeCollision(mWorld,scn,true);
Body* elements = new OgreNewt::Body( mWorld, col );
elements->attachToNode(scn);
delete col;
delete elements;
delete scn;
}


but that method don't work (I don't know why).

Maybe you can explain how I can to do this ?

Lioric

12-05-2006 17:27:44

I have not used Newton system, but it should work

Provide more details on what "don't work" in your post exactly means, for example is any error message present? has Newton any debug feature where lines or primitives can be drawn? what is the display result of enabling this debug?

Can you see in your application the loaded meshes?

chan

05-06-2006 14:51:58

You must assign mass and inertia to the body object, something like this:
Ogre::Real mass=55.0;
Ogre::Vector3 inertia=OgreNewt::MomentOfInertia::CalcEllipsoidSolid (mass,Vector3(10.0,25.0,8.0));

bod2->setMassMatrix(mass,inertia);

Then you should apply any force to the rigid body, i.e:bod2->setStandardForceCallback();
Then you should update the newton world in the main loop (inside your frameListener or whatever you use) using mWorld->update(elapsedTime);

With all that stuff you should be able to see phisycs working.

ocrim74

12-12-2006 16:03:16

Hi,

I am working with NxOgre and OFusion. I tried to import entries from a self customized OSM-File. On the top level I added new lists. Like lights and entities I added "staticbodies" and "dynamicbodies". We have bought the OFusion pro version and my idea is that I can define objects like "staticbodies" and "dynamicbodies" instead of entities. I did an overwrite of the createScene-method and it works with my self customized OSM-File.

Is there a possibility to create custom objects-types with the OFusion-Plugin for 3DS or will I only be able to add additional properties to an "Entity"?

Thanks in advance,

ocrim74

Lioric

12-12-2006 20:52:41

In oFusion Pro you can create a new and totally custom file format if you want to, via a scene plugin, see the "Custom Scene File Formats" chapter of the User's Guide

But probably for your project, you can use the Custom Object Properties support, and when loading an entity, test a "type" property (i.e. staticbody, dynamicbody) and other relevant properties and treat the entity as a physics body or whatever its needed by your application

Most projects uses the user property support to define the type of an object

guk_guk41

14-12-2006 00:29:17

Hi Rambo,

I've just started using OgreNewt when I found a problem just like you. And after i read the OgreNewt doc, I found that TreeCollision has an infinite mass, so you can't use it for dynamic rigid body. It is used for applying collision detection for level mesh e.g. city block. If you want to use a dynamic rigid body for your mesh, try to use ConvexHull instead. Maybe that can help :D