Bleeding vs 0.9, General Before-After code questions answers

toglia

17-05-2008 07:36:25

I thought it was a good idea to group all before and after code questions and answers in one thread for the people changing to bleeding, like me.

[with Bleeding 1.0.20]

First up. I have noticed that sometimes my string params don't work like on 0.9:

mWorld->createScene("myScene", "gravity: 0 -100 0, floor: yes, renderer: ogre");
That gravity parameter doesn't seem to work, (bodies fall very slowly).

I solved it this way:
NxOgre::SceneParams sceneParams;
sceneParams.setToDefault();

sceneParams.mGravity = NxVec3(0,-100,0);
sceneParams.mFloor = true;
sceneParams.mRenderer = NxOgre::SceneParams::RN_OGRE;

mScene = mWorld->createScene("myScene",sceneParams);

Second, I used to assign my Nx-material in the shape parameter this way (Bleeding way now):
NxOgre::Material * mMat = mScene->createMaterial("myMat");
mMat->setRestitution(1);

mScene->createBody("myBody",new NxOgre::Sphere(1,"material:myMat"), Vector3(0,10,0),"model:sphere.mesh","mass: 1");

But that sphere doesn't bounce...

Solved this way:
NxOgre::ShapeParams matParam;
matParam.setToDefault();
matParam.mMass = 1;
matParam.mMaterial = mMat->getMaterialIndex();

... new NxOgre::Sphere(1,mParam) ...

or

myBody->getCollisionModel().Get(0)->getNxShape()->setMaterial(mMat->getMaterialIndex());


That's what I have found so far, but I would like to know how to use the string parameters again to assign materials and gravity.

I will probably be adding more stuff to this topic while I learn, others could join too. :idea:

toglia

17-05-2008 10:06:58

I'm struggling to change the Ogre::Material of a Body on runtime...
I used to do it:
myBody->getEntity()->setMaterialName("Blah");
now I think its:
static_cast<OgreNodeRenderable*>(cuerpo->getRenderable())->setMaterial("Blah");

Haven't tried it though, I damaged my resource initiation code and all my materials all black... :roll:

Can anybody point me on how to create a body using an entity that has already been created. That could make my material change much cleaner.

betajaen

17-05-2008 11:04:13

You should use the class version of the params if anything more than 3-4 in them it's faster. I use the string params in public because it's easier to read, in my own code I use the class versions.

Anyway, NodeRenderableParams are really easy once you get the hang of it.

With the OgreSceneRenderer and the OgreNodeRenderable.


"model: test.mesh, model-type: resource"
create a scene node. Load the mesh "test.mesh" using the resource system, create an entity of it, and place it into the scene node.

"model: myEntity, model-type: reference"
Take on the entity "myEntity" (unattaching it safely to anything it is attached to), and place it into a new scene node.

"identifier: mySceneNode, usage: use"
Take on the scene node named "mySceneNode".

toglia

18-05-2008 22:48:04

Cool! Very manoeuvrable. :P