Tree colli... --> 2D joint problem !!![SOLVED (?) ]

abecam

19-05-2006 16:15:53

Hello everyone!
I advance quite well doing my first game using Ogre and ONewt :) , then I have two questions :oops: . The first one because I did something wrong but I have no idea what... I use a ball & socket joint between a container and a handler, apply just gravity, the "handler" is stuck by a 2D joint:


----------------------Handler ellipsoid-------------------- 2D joint
|
| Ball& Socket joint
Container


Then it was working well, but now the handler turn like crazy. That's funny but not intented. And before I apply any translation force on it (only gravity). Any idea of my stupid mistake ? Here is my code:




OgreNewt::Body * container = makeSimpleBox(Ogre::Vector3(0.5,2,0.5), Ogre::Vector3(0,40,0), Ogre::Quaternion(Ogre::Quaternion::IDENTITY));
Ogre::Quaternion orientHandle ( Ogre::Vector3(0,0,0),Ogre::Vector3(0,1,0),Ogre::Vector3(0,0,0) );
handleBox = makeSimpleEll(Ogre::Vector3(0.5,1,0.5), Ogre::Vector3(0,42.5,0),orientHandle);

// Set the force to translate the handler to (0,0,0)
mesInteractions.setForceTrans(Ogre::Vector3(0,0,0));

handleBox->setUserData(&mesInteractions);

LogManager::getSingleton().logMessage(" Set the custom callback ");

handleBox->setCustomForceAndTorqueCallback(userForceCallback);
handleBox->setAutoFreeze(0);
container->setAutoFreeze(0);
container->setCustomForceAndTorqueCallback(userForceCallbackCont);

LogManager::getSingleton().logMessage(" To the joint ");


joint2= new OgreNewt::PrebuiltCustomJoints::Custom2DJoint(handleBox,Ogre::Vector3(0,2,0));

jointBS= new OgreNewt::BasicJoints::BallAndSocket( m_World, container, handleBox, Ogre::Vector3(0,40,0)+Ogre::Vector3(0,2,0) );

jointBS->setLimits (Ogre::Vector3(0,2,0), Ogre::Radian(0.8), Ogre::Radian(0.1));


UPDATE: I still have my crazy "handler", and I know it is a problem linked with the 2D joint (because it doesn't turn without the joint). The grey and white box is supposed to just "hang" quietly, and the ellipsoid is not supposed to turn at all...




Strangely it disappeared when I included the shadow information in my dotScene loader, and appeared again when I included my material infos (for the collision callbacks I use for my score, that works perfectly).
For the containing box problem (my rigid bodies didn't want to appear inside the box), it is fixed... :shock: I supposed I fixed it by trying to fix the crazy joint problem...

If someone knows, is this possible that my BallAndSocket joint is not at the right position compared to the 2D one??? A kind of conflict? (then I never changed this part of the code, and it worked before).
I tried also to give a constraint and to reset the angle, but it doesn't help that much... Anyway it is funny as it is :) , but not very usable for my game :roll:

abecam

21-05-2006 20:47:33

Ok, my first problem is resolved. Strangely, I wanted to have stencil shadows in my scenes, and there was a strange problem with my dotScene loader just after. It is resolved when I specify if one entity casts shadow or not :shock: :


if ( XMLUserData )
{
TiXmlElement *XMLProperty;
XMLProperty = XMLUserData->FirstChildElement("property");
while ( XMLProperty )
{
String first = NewNode->getName();
String second = XMLProperty->Attribute("name");
String third = XMLProperty->Attribute("data");
String type = XMLProperty->Attribute("type");
if (second.compare("SELFSHADOW") == 0 )
{
if (third.compare("false") == 0)
{
if ( XMLEntity )
NewEntity->setCastShadows(false);
else
NewEntity->setCastShadows(true);
}
}

nodeProperty newProp(first,second,third,type);
nodeProperties.push_back(newProp);
XMLProperty = XMLProperty->NextSiblingElement("property");
}
}


with an user data like that in the dotScene (maybe it is already included in the dotScene format :oops: ):


<userData>
<property type="BOOL" name="SELFSHADOW" data="false" />
</userData>


So if you have this kind of problem, it might help (though I do not understand where is the issue :roll: ).

Then for my second problem I need to do some experiments... Now I am adding collisionCallbacks, so I have added a LOT of bugs :twisted:

abecam

22-06-2006 07:56:15

A small update, for potential future use: it seems that this problem appeared and disappeared randomly. Finally I push some code to stabilize the "handler", and it works. So it was a kind of initialisation problem: sometime the couple ellipsoid-handler (with a ball and socket joint and a 2D joint) was starting on an "unbalanced state" (sorry for my english) and the instability was feed in a way by this situation, so it turned. After a while it could stop also.
So it was a kind of natural physics problem :lol: . And my two joints (the 2D joint is a strong constraint) was turning a small phenomena into a big issue.

Concerning the "inside" problem, it might be linked with the quality of the meshes only.