[ODE] Using dGeomSetPosition()
Michael Bailey
mike-ba at cox.net
Tue Feb 4 14:26:01 2003
This is a multi-part message in MIME format.
------=_NextPart_000_0222_01C2CC50.ED2D63A0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
I'm having a bit of trouble with dGeomSetPosition(). I'm trying to deal
with the common issue of fast moving objects passing through non-movable
geometry. Here's my method, from my main animation loop:
// Get the current Body location
pCurrentPos=dBodyGetPosition(pMyObj->m_ODEBody);
// Check to see if the body is moving farther than the radius of its
geometry
if(Distance(pCurrentPos,pLastPos) > pMyObj->m_fBoundsRadius) {
// Calc a new Pos with less movement, a point in the direction vector
// somewhat less than the Geom radius.
pCurrentPos= blah, blah
// Tell ODE where *I* want the Geom to be.
// Don't call dBodySetPosition() since dGeomSetPosition() seems to call
both.
dGeomSetPosition(pMyObj->m_ODEGeom,pCurrentPos[0],pCurrentPos[1],pCurrentPos
[2]);
}
// Save the current Pos for the next loop
pLastPos=pCurrentPos; //phsudo code here :-)
Now for the problem: When dSpaceCollide() is called the Geom's center point
used for the collision detection seems to be the original point ODE
calculated for the bodies position (before my dGeomSetPosition()). The code
above works fine, I can even call dGeomGetPosition() right after
dGeomSetPosition() and it returns the point I set.
Even in my own TriCollider when I call dGeomGetPosition() the point seems to
be something other than the one I set.
I've modified the code above to always set the Geom pos to the same point
each time, say 0,0,0. But the Collider still seems to use some other value
for its calculations. As if my dGeomSetPosition() was ignored.
Any help in the right direction would be greatly appreciated.
Regards,
Mike
Radish Works
------=_NextPart_000_0222_01C2CC50.ED2D63A0
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.2800.1126" name=3DGENERATOR></HEAD>
<BODY>
<DIV><SPAN class=3D936385619-04022003><FONT face=3DArial size=3D2>I'm =
having a bit of=20
trouble with dGeomSetPosition(). I'm trying to deal with the =
common=20
issue of fast moving objects passing through non-movable geometry. =
Here's=20
my method, from my main animation loop:</FONT></SPAN></DIV>
<DIV><SPAN class=3D936385619-04022003><FONT face=3DArial=20
size=3D2></FONT></SPAN> </DIV>
<DIV><SPAN class=3D936385619-04022003><FONT face=3D"Courier New" =
size=3D2>// Get the=20
current Body location</FONT></SPAN></DIV>
<DIV><SPAN class=3D936385619-04022003><FONT face=3D"Courier New"=20
size=3D2>pCurrentPos=3DdBodyGetPosition(pMyObj->m_ODEBody);</FONT></SP=
AN></DIV>
<DIV><SPAN class=3D936385619-04022003><FONT face=3D"Courier New"=20
size=3D2></FONT></SPAN> </DIV>
<DIV><SPAN class=3D936385619-04022003><FONT face=3D"Courier New" =
size=3D2>// Check to=20
see if the body is moving farther than the radius of its=20
geometry</FONT></SPAN></DIV>
<DIV><SPAN class=3D936385619-04022003><FONT face=3D"Courier New"=20
size=3D2>if(Distance(pCurrentPos,pLastPos) > =
pMyObj->m_fBoundsRadius)=20
{</FONT></SPAN></DIV>
<DIV><SPAN class=3D936385619-04022003><FONT face=3D"Courier New"=20
size=3D2> </FONT></SPAN></DIV>
<DIV><SPAN class=3D936385619-04022003><FONT face=3D"Courier New"=20
size=3D2> // Calc a new Pos with less movement, a =
point in the=20
direction vector</FONT></SPAN></DIV>
<DIV><SPAN class=3D936385619-04022003><FONT face=3D"Courier New"=20
size=3D2> // somewhat less than the Geom=20
radius.</FONT></SPAN></DIV>
<DIV><SPAN class=3D936385619-04022003><FONT face=3D"Courier New"=20
size=3D2> pCurrentPos=3D blah, =
blah</FONT></SPAN></DIV>
<DIV><SPAN class=3D936385619-04022003><FONT face=3D"Courier New"=20
size=3D2> </FONT></SPAN></DIV>
<DIV><SPAN class=3D936385619-04022003><FONT face=3D"Courier New"=20
size=3D2> // Tell ODE where *I* want the Geom to be.=20
</FONT></SPAN></DIV>
<DIV><SPAN class=3D936385619-04022003><FONT face=3D"Courier New"=20
size=3D2> // Don't call dBodySetPosition() since=20
dGeomSetPosition() seems to call both.</FONT></SPAN></DIV>
<DIV><SPAN class=3D936385619-04022003><FONT face=3D"Courier New"=20
size=3D2> dGeomSetPosition(pMyObj->m_ODEGeom,pC=
urrentPos[0],pCurrentPos[1],pCurrentPos[2]);</DIV></FONT></SPAN>
<DIV><SPAN class=3D936385619-04022003><FONT face=3D"Courier New"=20
size=3D2>}</FONT></SPAN></DIV>
<DIV><SPAN class=3D936385619-04022003><FONT face=3D"Courier New"=20
size=3D2></FONT></SPAN> </DIV>
<DIV><SPAN class=3D936385619-04022003><FONT face=3D"Courier New" =
size=3D2>// Save the=20
current Pos for the next loop</FONT></SPAN></DIV>
<DIV><SPAN class=3D936385619-04022003><FONT face=3D"Courier New"=20
size=3D2>pLastPos=3DpCurrentPos; //phsudo code here =
:-)</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><SPAN class=3D936385619-04022003><FONT face=3DArial=20
size=3D2></FONT></SPAN> </DIV>
<DIV><SPAN class=3D936385619-04022003><FONT face=3DArial size=3D2>Now =
for the=20
problem: When dSpaceCollide() is called the Geom's center =
point used=20
for the collision detection seems to be the original point ODE =
calculated=20
for the bodies position (before my dGeomSetPosition()). The code =
above=20
works fine, I can even call dGeomGetPosition() right after =
dGeomSetPosition()=20
and it returns the point I set. </FONT></SPAN></DIV>
<DIV><SPAN class=3D936385619-04022003><FONT face=3DArial=20
size=3D2></FONT></SPAN> </DIV>
<DIV><SPAN class=3D936385619-04022003><FONT face=3DArial size=3D2>Even =
in my own=20
TriCollider when I call dGeomGetPosition() the point seems to be =
something other=20
than the one I set. </FONT></SPAN></DIV>
<DIV><SPAN class=3D936385619-04022003><FONT face=3DArial=20
size=3D2></FONT></SPAN> </DIV>
<DIV><SPAN class=3D936385619-04022003><FONT face=3DArial size=3D2>I've =
modified the=20
code above to always set the Geom pos to the same point each time, say=20
0,0,0. But the Collider still seems to use some other value for =
its=20
calculations. As if my dGeomSetPosition() was =
ignored.</FONT></SPAN></DIV>
<DIV><SPAN class=3D936385619-04022003><FONT face=3DArial=20
size=3D2></FONT></SPAN> </DIV>
<DIV><SPAN class=3D936385619-04022003><FONT face=3DArial size=3D2>Any =
help in the=20
right direction would be greatly appreciated.</FONT></SPAN></DIV>
<DIV><SPAN class=3D936385619-04022003><FONT face=3DArial=20
size=3D2></FONT></SPAN> </DIV>
<DIV><SPAN class=3D936385619-04022003><FONT face=3DArial=20
size=3D2>Regards,</FONT></SPAN></DIV>
<DIV><SPAN class=3D936385619-04022003><FONT face=3DArial=20
size=3D2>Mike</FONT></SPAN></DIV>
<DIV><SPAN class=3D936385619-04022003><FONT face=3DArial size=3D2>Radish =
Works</FONT></SPAN></DIV>
<DIV><FONT face=3DArial><BR><FONT size=3D2></FONT></FONT></DIV></SPAN>
<DIV><SPAN class=3D936385619-04022003><FONT face=3DArial=20
size=3D2></FONT></SPAN> </DIV>
<DIV><SPAN class=3D936385619-04022003><FONT face=3DArial=20
size=3D2></FONT></SPAN> </DIV>
<DIV><SPAN class=3D936385619-04022003><FONT face=3DArial =
size=3D2></FONT><FONT=20
face=3DArial size=3D2></FONT></SPAN> </DIV></BODY></HTML>
------=_NextPart_000_0222_01C2CC50.ED2D63A0--