mizio
18-07-2006 15:54:38
Hi
I have to control my physics simulation; in particular, at every start of the simulation loop I must to call a function that I have created ( for example myFunction() )...How I can to do this?
Thank you
betajaen
18-07-2006 16:20:16
The only way I can think of is modifying world to do it with.
Does it have to be called before NxOgre is called? because you can just create a frame listener for it
mizio
18-07-2006 16:27:55
In Ogre, with the frame listener I can create a frameStarted function. In Novodex (or with NxOgre) I can to do a similar things?
There is a simple tutorial or in which file of NxOgre you had to do this?
betajaen
18-07-2006 16:56:52
Well world *is* a frame listener too.
Like I said if your function doesn't need to be run before NxOgre is run then create a seperate frameListener for it, else you'll have to modify world.
mizio
18-07-2006 19:35:15
ok,
I have created a new world file with few functions useful for the my project; there is a problem, I'm following the docs of Novodex, I have created the scene and the actor; when I call the function mActor->getGlobalPosition() there is the crash of the system!
My code is:
NxActorDesc actorDesc;
NxBodyDesc bodyDesc;
mNode = mSceneMgr->getRootSceneNode()->createChildSceneNode(entityName + "Node");
mEntity = mSceneMgr->createEntity(entityName, meshName);
mNode->attachObject(mEntity);
NxBoxShapeDesc boxDesc;
boxDesc.setToDefault();
boxDesc.dimensions.set(NxVec3(1, 1, 1));
// Create a dynamic actor
actorDesc.setToDefault();//reset to default values.
actorDesc.shapes.pushBack(&shapeDesc);
actorDesc.body = &bodyDesc;
actorDesc.density = density;
actorDesc.globalPose.t = position;// set initial position.
mActor = mScene->createActor(actorDesc);
updateMesh();
where updateMesh() is:
NxVec3 newPos = mActor->getGlobalPosition();
NxQuat newOrien = mActor->getGlobalOrientationQuat();
mNode->setPosition( Ogre::Vector3(newPos.x, newPos.y, newPos.z) );
mNode->setOrientation( Ogre::Quaternion(newOrien.w, newOrien.x, newOrien.y, newOrien.z) );
Thank you
betajaen
18-07-2006 19:55:45
Erm....That code there is a body.
In NxOgre you can sum all of that code up in one line:
mScene->createBody("bodyName", "meshName", new cubeShape(1), density, newPos);
Seriously, read NxTutorial101.