jufranz
04-08-2011 20:14:03
betajaen
04-08-2011 21:00:20
This is quite odd.
Can we see your setup code, and the code that moves the ball around?
jufranz
11-08-2011 04:11:34
This is quite odd.
Can we see your setup code, and the code that moves the ball around?
Soooo sory, forgot to set the topic tracking =/
Really odd isnt it?
Sure you can, what is the best way to show it, copy and paste with the Code tag?
Tks
jufranz
15-08-2011 16:54:45
This is quite odd.
Can we see your setup code, and the code that moves the ball around?
Betajaen,
here is the code. To move the ball around I use a 6DOF device called Phantom Omni from Sansable.
The comments are in portuguese, sory for that.
Ogre, NxOgre and Phantom initialization
//INICIALIZA NXOGRE:
mWorld = NxOgre::World::createWorld();
NxOgre::SceneDescription sceneDesc;
sceneDesc.mGravity = NxOgre::Vec3(0, -40.0f, 0);
sceneDesc.mName = "BloodyMessTutorial2";
mScene = mWorld->createScene(sceneDesc);
printf("1.75 \n");
mScene->getMaterial(0)->setStaticFriction(0.5);
mScene->getMaterial(0)->setDynamicFriction(0.5);
mScene->getMaterial(0)->setRestitution(0.1);
mRenderSystem = new OGRE3DRenderSystem(mScene);
printf("2 \n");
//debugger
mVisualDebugger = mWorld->getVisualDebugger();
mVisualDebuggerRenderable = new OGRE3DRenderable(NxOgre::Enums::RenderableType_VisualDebugger);
mVisualDebugger->setRenderable(mVisualDebuggerRenderable);
mVisualDebuggerNode = mSceneMgr->getRootSceneNode()->createChildSceneNode();
mVisualDebuggerNode->attachObject(mVisualDebuggerRenderable);
mVisualDebugger->setVisualisationMode(NxOgre::Enums::VisualDebugger_ShowAll);
//DEfine novos callbacks para colisão
mContactModify =new ContactModify();
mScene->getScene()->setUserContactModify(mContactModify);//setUserContactReport( mContactReport );
mContactReport =new ContactReport();
mScene->getScene()->setUserContactReport(mContactReport);//setUserContactReport( mContactReport );
//Inicializa o phantom com as variáceis da ogre e NxOgre:
mPhantomManager->initialize(mScene,mWorld, mRenderSystem, mSceneMgr,mContactReport,mContactModify);
Pieces creation
bool PieceArray::createPieces(){
bool rotaciona = false;
int pecas = 0;
float altura = 0;
// itera por todaas as peças registradas
//for(int rosalia = 0; rosalia<2; ++rosalia)
{
for (int i=0 ; i<pieces.size() ; i++){
// cria OGRE3Dbody e colliders para cada peça
OGRE3DBody* pieceSN;
NxOgre::Shapes colliders;
// cria um collider na forma de cubo para cada cubo da peça
for (int j=0; j < pieces.allCubeInfo.size(); j++){
NxOgre::Shape * collider = new NxOgre::Box(1, 0.6, 1);
// cria colider transladado pelo offset:
int offset = pieces.offset;
collider = new NxOgre::Box(1, 0.6, 1); //franz
collider->setLocalPose(NxOgre::Matrix44(1,0,0,offset*pieces.allCubeInfo[j].x,
0,1,0,offset*pieces.allCubeInfo[j].y,
0,0,1,offset*pieces.allCubeInfo[j].z,
0,0,0,1));
// insere cada cllider em colliders
collider->setMass(1);
//pMaterial->setDynamicFriction(10);
//pMaterial->setRestitution(.0);
//pMaterial->setStaticFriction(30);
//collider->setMaterial(pMaterial->getIdentifier());
colliders.insert(collider);
}
// cria OGRE3Dbody com informação em colliders - será que tem como definir um nome para a peça?
//mPieceRenderSys->createKinematicBody(new NxOgre::Box(1,0.6,1), NxOgre::Vec3(0,0,0),"cube.1m.mesh" );
pieceSN = mPieceRenderSys->createBody(colliders, NxOgre::Vec3(0,0,0), "cube2.mesh");
// pieceSN->setMa
pieceSN->getEntity()->setVisible(false);
//pieceSN->setLinearVelocity(NxOgre::Vec3(0,0,0)); //Franz
// set da massa do objeto
//pieceSN->setMass(0.2);
pieceSN->setMass(1.0);
// cria forma física dos cubos
for (int j=0; j < pieces.allCubeInfo.size(); j++){
int offset = pieces.offset;
Ogre::Entity* cubo = mPieceSceneMgr->createEntity("mesh"+Ogre::StringConverter::toString(pieces.allCubeInfo[j].cubeID), "cube2.mesh");
//Ogre::Entity* cubo = mPieceSceneMgr->createEntity("mesh"+Ogre::StringConverter::toString(pieces.allCubeInfo[j].cubeID), "cube.1m.mesh");
//atribui o material (teste por enquanto)...
if (pieces.allCubeInfo[j].textureID==0)
cubo->setMaterialName("wood2/Wood");
else
cubo->setMaterialName("wood1/Wood");
NxOgre::Material *pMaterial;
//cubo->setCastShadows(false);
Ogre::SceneNode* coliderNode = pieceSN->getEntity()->getParentSceneNode()->createChildSceneNode("cube"+Ogre::StringConverter::toString(pieces.allCubeInfo[j].cubeID));
coliderNode->attachObject(cubo);
coliderNode->setScale(1.0,0.6,1.0);//franz
coliderNode->setPosition(Ogre::Vector3(Ogre::Real(pieces.allCubeInfo[j].x*offset),Ogre::Real(pieces.allCubeInfo[j].y*offset),Ogre::Real(pieces.allCubeInfo[j].z*offset)));
I think thats all the important code related to the problem.
Tks in avance =D
betajaen
15-08-2011 18:09:15
Which NxOgre version is this?
And this seems to be the code that is out of place;
//DEfine novos callbacks para colisão
mContactModify =new ContactModify();
mScene->getScene()->setUserContactModify(mContactModify);//setUserContactReport( mContactReport );
mContactReport =new ContactReport();
mScene->getScene()->setUserContactReport(mContactReport);//setUserContactReport( mContactReport );
Try commenting it out, and see what happens.
jufranz
15-08-2011 21:24:35
Which NxOgre version is this?
And this seems to be the code that is out of place;
//DEfine novos callbacks para colisão
mContactModify =new ContactModify();
mScene->getScene()->setUserContactModify(mContactModify);//setUserContactReport( mContactReport );
mContactReport =new ContactReport();
mScene->getScene()->setUserContactReport(mContactReport);//setUserContactReport( mContactReport );
Try commenting it out, and see what happens.
It´s the BloodyMess. I´ve recorded a new video:
http://www.youtube.com/watch?v=jEeFdHoCEv4
The ContactReport is used to manage the Phantom, do you think thats where the problem is?
void ContactReport::onContactNotify(NxContactPair &pair,NxU32 events){
//verifica se eh o proxy que tá colidindo:
/*std::cout<<pair.actors[0]->getName() <<std::endl;
std::cout<<pair.actors[1]->getName() <<std::endl;*/
if (/*this->pecaProxy != NULL &&*/ (
( strcmp( pair.actors[0]->getName(),"Teste")==0)||
( strcmp( pair.actors[1]->getName(),"Teste")==0)
)
){
//usado pelo phantomManager
//std::cout << "evento com proxy"<<eventId++ <<std::endl;
if (events == NX_NOTIFY_ON_START_TOUCH){
if (collisionCount < 0){
collisionCount = 0;
}
collisionCount++;
//std::cout << "Collisio Start"<<std::endl;
}else if(events == NX_NOTIFY_ON_END_TOUCH) {
collisionCount --;
//std::cout << "Collisio End" <<std::endl;
}
}
}
The createBody call using Shapes its correct right?
I´ve found something interesting today, the pieces seems to move when the have some angle with the floor. Actually that force generated by the piece its very strong sometimes.
Since this is a old project that i´m using again the Ogre version is not the newest also.
I can upload the whole project to the dropbox and post the link.