manga
13-06-2009 13:31:32
I'm trying to create a double pendulum. I have created a fixed cube that is connected to another cube that can moves freely and is connected to another cube that can moves freely. The connections are spherical joints.
However, NxOgre creates another joint (or it's what it looks like on Debug Renderer) between the fixed cube and the last cube and I don't want this!
I have already tried a lot of things and nothing solve this. Strange that I have already created a double pendulum the same way and it worked...
I have posted my code below if you want to see what I done.
Thanks for the help.
However, NxOgre creates another joint (or it's what it looks like on Debug Renderer) between the fixed cube and the last cube and I don't want this!
I have already tried a lot of things and nothing solve this. Strange that I have already created a double pendulum the same way and it worked...
I have posted my code below if you want to see what I done.
Thanks for the help.
double massa[2];
double comprimentoFio[2];
double angulo[2];
Ogre::Entity* entidade[3];
Ogre::SceneNode* nodo[3];
NxOgre::Body* corpo[3];
NxOgre::SphericalJoint* junta[2];
massa[0] = 10;
massa[1] = 10;
comprimentoFio[0] = 200;
comprimentoFio[1] = 200;
angulo[0] = pi/4;
angulo[1] = pi/6;
Ogre::Vector3 posicaoTopo = Ogre::Vector3 (0, 700, 0);
entidade[0] = sys::mSceneMgr->createEntity ("Pendulo1", "Cube3.mesh");
nodo[0] = sys::mSceneMgr->getRootSceneNode()->createChildSceneNode("Nodo do Pendulo1", posicaoTopo);
nodo[0]->attachObject(entidade[0]);
nodo[0]->scale (0.5, 0.5, 0.5);
NxOgre::NodeRenderableParams parametros;
parametros.setToDefault();
parametros.mIdentifierUsage = NxOgre::NodeRenderableParams::IU_Use;
parametros.mIdentifier = nodo[0]->getName();
corpo[0] = sys::mNxScene->createBody("Corpo do Pendulo1", new NxOgre::Cube(Ogre::Vector3(50,50,50)),posicaoTopo,parametros,"mass: 10");
corpo[0]->raiseBodyFlag(NX_BF_DISABLE_GRAVITY);
corpo[0]->raiseBodyFlag(NX_BF_KINEMATIC);
entidade[1] = sys::mSceneMgr->createEntity ("pendulo2", "Cube3.mesh");
nodo[1] = sys::mSceneMgr->getRootSceneNode()->createChildSceneNode("Nodo do Pendulo2", posicaoTopo+Ogre::Vector3(comprimentoFio[0]*sin(angulo[0]),-comprimentoFio[0]*cos(angulo[0]),0));
nodo[1]->attachObject(entidade[1]);
nodo[1]->scale (0.5, 0.5, 0.5);
NxOgre::NodeRenderableParams parametros2;
parametros2.setToDefault();
parametros2.mIdentifierUsage = NxOgre::NodeRenderableParams::IU_Use;
parametros2.mIdentifier = nodo[1]->getName();
corpo[1] = sys::mNxScene->createBody("Corpo do Pendulo2", new NxOgre::Cube(Ogre::Vector3(50,50,50)),posicaoTopo+Ogre::Vector3(comprimentoFio[0]*sin(angulo[0]),-comprimentoFio[0]*cos(angulo[0]),0),parametros2,"mass: 10");
corpo[1]->setMass(massa[0]);
entidade[2] = sys::mSceneMgr->createEntity ("Pendulo3", "Cube3.mesh");
nodo[2] = sys::mSceneMgr->getRootSceneNode()->createChildSceneNode("Nodo do Pendulo3", posicaoTopo+Ogre::Vector3(comprimentoFio[0]*sin(angulo[0])+comprimentoFio[1]*sin(angulo[1]),-comprimentoFio[0]*cos(angulo[0])-comprimentoFio[1]*cos(angulo[1]),0));
nodo[2]->attachObject(entidade[2]);
nodo[2]->scale (0.5, 0.5, 0.5);
NxOgre::NodeRenderableParams parametros3;
parametros3.setToDefault();
parametros3.mIdentifierUsage = NxOgre::NodeRenderableParams::IU_Use;
parametros3.mIdentifier = nodo[2]->getName();
corpo[2] = sys::mNxScene->createBody("Corpo do Pendulo3", new NxOgre::Cube(Ogre::Vector3(50,50,50)),posicaoTopo+Ogre::Vector3(comprimentoFio[0]*sin(angulo[0])+comprimentoFio[1]*sin(angulo[1]),-comprimentoFio[0]*cos(angulo[0])-comprimentoFio[1]*cos(angulo[1]),0),parametros3,"mass: 10");
corpo[2]->setMass(massa[1]);
NxOgre::JointParams pJuntas;
pJuntas.setToDefault();
pJuntas.mActorsCollidable=true;
pJuntas.mVisualiseJoint=true;
NxOgre::JointParams pJuntas2;
pJuntas2.setToDefault();
pJuntas2.mActorsCollidable=true;
pJuntas2.mVisualiseJoint=true;
junta[0] = sys::mNxScene->createSphericalJoint(corpo[0],corpo[1],posicaoTopo+Ogre::Vector3(comprimentoFio[0]*sin(angulo[0])/2,-comprimentoFio[0]*cos(angulo[0])/2,0),pJuntas);
junta[1] = sys::mNxScene->createSphericalJoint(corpo[1],corpo[2],posicaoTopo+Ogre::Vector3((comprimentoFio[0]*sin(angulo[0])+comprimentoFio[1]*sin(angulo[1]))/2,-(comprimentoFio[0]*cos(angulo[0])-comprimentoFio[1]*cos(angulo[1])),0)/2,pJuntas2);