I want some nxbodys to not have any effect on each other :/

Oceax

16-11-2008 14:48:48

I have a object system where the actual playble object in the game (for example a tank) is made up of different .mesh and nx files. the turret on the tank is one entity + nx file and the wheels an other entity + nx file. All these entitys are stuck together when they are created, but when NxOgre kicks in all the entitys for the object dissapear, my guess is that when they are stuck together like that physx consider it a brutal collision and the entitys fly away?.

Here is a screenshot that shows the tank when i have turned off physics for all its parts, but i have created the tanks main body as a separate entity with physics and that works perfectly, so there is nothing wrong with the .nxs files :/

http://www.oceax.eu/nx.jpg

For the tank, the wheels and turret are child nodes to the main body of the tank.

Is there a way to make certain bodys not have any effect on each other or any other idé how to solve this?

mcaden

16-11-2008 14:59:04

Best bet I'd say is to create the physics objects as being on top of eachother rather than inside eachother.

Why are you creating the entities separately? why not use bodies?

Oceax

16-11-2008 15:30:22

Why are you creating the entities separately? why not use bodies?

Hmm, im just doing as its done in the wiki tutorial.

First the entity and scene node.

Ogre::Entity *ent = mSceneMgr->createEntity( "box_entity", "cube.mesh" );
ent->setMaterialName("Examples/10PointBlock");
Ogre::SceneNode *boxNode= mSceneMgr->getRootSceneNode()->createChildSceneNode( "box_node" );
boxNode->attachObject( ent );


and then the NxOgre::Body

NxOgre::Body *body = mNxScene->createBody("box_body",new Cube(1),Vector3(0,10,0),nrp,"mass:10");

Oceax

16-11-2008 18:53:03

i tried to have the meshes separate now, it didnt help. and i tried to just make the main body of the tank have physics.

The result is that the tank flys away rotating up in the sky.

this is wierd ... is it simple not possible to have child nodes attached to a node that is used as a NxOgre::body?

mcaden

16-11-2008 23:26:56

sounds like you didn't turn on gravity

world creation code?

and what did you set renderable params to?

Oceax

17-11-2008 10:52:53

All other objects that dosnt have other childSceneNodes attached to it works perfectly so there is nothing wrong with gravity.


mNxWorld = new NxOgre::World("time-controller:ogre, use-log:yes");
mNxScene = mNxWorld->createScene("NxOgreScene", mSceneMgr, "gravity: yes, floor:yes, renderer:ogre");



NxOgre::NodeRenderableParams nrp;
nrp.setToDefault();
nrp.mIdentifierUsage = NxOgre::NodeRenderableParams::IU_Use;
nrp.mIdentifier = tmpComplexObjectNode.sceneNode->getName();


It looks like physx somehow thinks there has been a brutal collision. But now i have tried to only have one NxOgre::Body whose SceneNode has childSceneNodes that dosnt use NxOgre::Body. So i dont understand how there can be any collision.

mcaden

17-11-2008 12:16:01

Hmm...well that looks fine.

Full code? I can't think of why there'd be a crazy collision unless you're trying to place bodies inside eachother.

Oceax

17-11-2008 14:44:42

ok, i have created something simpler now, Just a box with a sphere.
http://www.oceax.eu/test1.jpg

the sphere is attached as a child node to the box node, and this is what happens.
http://se.youtube.com/watch?v=pYTpl2UMJKc

the box and sphere falls towards the terrain as they should, but when the box hits the ground the sphere goes crazy.


// Creating SceneNodes etc
Ogre::SceneNode *sn2 = mSceneMgr->getRootSceneNode()->createChildSceneNode();
Ogre::Entity *ent2 = mSceneMgr->createEntity("shit","Box01.mesh");
sn2->attachObject(ent2);
NxOgre::Resources::ResourceSystem::getSingleton()->addMeshAs("file://../../Data/Scenes/Box01.nxs", "Box01");

Ogre::SceneNode *sn3 = sn2->createChildSceneNode();
Ogre::Entity *ent3 = mSceneMgr->createEntity("shit2","Sphere01.mesh");
sn3->attachObject(ent3);
NxOgre::Resources::ResourceSystem::getSingleton()->addMeshAs("file://../../Data/Scenes/Sphere01.nxs", "Sphere01");

// PARAMS
NxOgre::ActorParams ap2;
ap2.setToDefault();
ap2.mMass = 10.0;
ap2.mDensity = 1.0;

NxOgre::ActorParams ap3;
ap3.setToDefault();
ap3.mMass = 10.0;
ap3.mDensity = 1.0;

NxOgre::NodeRenderableParams nrp2;
nrp2.setToDefault();

nrp2.mIdentifierUsage = NxOgre::NodeRenderableParams::IU_Use;
nrp2.mIdentifier = sn2->getName();

NxOgre::NodeRenderableParams nrp3;
nrp3.setToDefault();

nrp3.mIdentifierUsage = NxOgre::NodeRenderableParams::IU_Use;
nrp3.mIdentifier = sn3->getName();

Vector3 pos2(1800,1000,400);
Vector3 pos3(1800,1000,500);

// Creating the NxOgre::Bodys
NxOgre::Body *bd1 = (NxOgre::Body*)NxManager::getSingletonPtr()->getNxScene()->createBody<NxOgre::Body>( "Box01test", new NxOgre::Convex("Box01"),pos2, nrp2, ap2);
NxOgre::Body *bd2 = (NxOgre::Body*)NxManager::getSingletonPtr()->getNxScene()->createBody<NxOgre::Body>( "Sphere01test", new NxOgre::Convex("Sphere01"),pos3, nrp3, ap3);


This is a very simple experiment.... it seems that its not possible to have sceneNodes attached to each other when using NxOgre::Bodys? :(

mcaden

17-11-2008 23:54:53

Parenting is probably the issue.

Also unless I'm mistaken you want density set to 0 unless you're using a static mesh.