--
You received this message because you are subscribed to the Google Groups "ode-users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/ode-users/-/pdSeWXsUSWIJ.
To post to this group, send email to ode-...@googlegroups.com.
To unsubscribe from this group, send email to ode-users+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/ode-users?hl=en.
This transform API keeps getting brought up, but it only seems to be
used in that demo for composite objects not for trimeshes so, as far as
I can tell, is unrelated to what I am asking about.
One thing you might need to double-check is how you set the offset. If you translate the body mass by a vector T in order to get it to line up with the body's center of gravity then to make up for this by using a *geom* offset I think you'd need to offset the geom by -T with respect with the body to correctly reflect the initial configuration of the body. Of course I've never actually encountered this situation or used geom offsets and its way past 1 AM over here so I might be talking nonsense.
This transform API keeps getting brought up, but it only seems to be
used in that demo for composite objects not for trimeshes so, as far as
I can tell, is unrelated to what I am asking about.
Correct me if my cursory glance at the demo source leads me to false conclusions but in the demo a trimesh is only used as the static environment geom which has no body and therefore nothing to do with centers of gravity and the like. So either geom offsets or transform geoms are irrelevant in this context as you correctly point out. Everybody keeps mentioning transform geoms because they're the predecessor to what you (allegedly) need to use.
One thing you might need to double-check is how you set the offset. If you translate the body mass by a vector T in order to get it to line up with the body's center of gravity then to make up for this by using a *geom* offset I think you'd need to offset the geom by -T with respect with the body to correctly reflect the initial configuration of the body. Of course I've never actually encountered this situation or used geom offsets and its way past 1 AM over here so I might be talking nonsense.
They are not just used as static geoms. You can also drop dynamic trimeshes by pressing 'm'. In my tests I have stripped out everything except for this dynamic trimesh and have removed the randomization on its position and rotation.
In the code the mass is translated by -m.c as follows
dMassTranslate(&m, -m.c[0], -m.c[1], -m.c[2]);
If I don't do that, or call dMassTranslate with some other value then it will crash with "ODE INTERNAL ERROR 2: The centre of mass must be at the origin. in dBodySetMass()"
You are saying I should use a geom offset of m.c and not -m.c?
What the code in the demo does is translate the geom itself:
dGeomSetPosition(obj[i].geom, -m.c[0], -m.c[1], -m.c[2]);
but, as I said in my previous email I believe this line does not do anything since later on the geom is attached to a body and takes its position.
The problem still is that what defines the behavior in my first test is
the assumption that the center of mass of the trimesh is at it's origin
(which isn't quite right with the bunny), but if I don't know where the
center of mass is (my original issue) I have to do something a little
different. Call the vector we translate the mass by to get it to play
nice -T. I believe what I want to do is place the body at -M + T, and
set the geom offset to be -T. In this way the center of mass is being
determined by the mass object, I am offsetting the geom to line up with
this and then moving the body to be where I want it to be. I just need
to remember that if I want to get the position of a vertex in world
coordinates at a later time, I first have to translate it by the offset
before calling dBodyGetRelPointPos.
Does this all make sense?
So I think we are in agreement for the most part, but your statement
about drawing the bunny at the geom's offset position made me unsure if
I had this correct. I was just using the position from dGeomGetPosition
for my dsDrawTriangle calls, and this appears to be correct i.e. if I
drop a sphere it appears to interact with the bunny where I have it placed.
I am unsure of why this is the case though. As I said previously, in
order to get the correct position of a vertex in global coordinates
(using dBodyGetRelPointPos) I need to first apply the offset. So why do
I not need to apply the offset when drawing the triangles? What is the
difference between these two?
So I think we are in agreement for the most part, but your statement
about drawing the bunny at the geom's offset position made me unsure if
I had this correct. I was just using the position from dGeomGetPosition
for my dsDrawTriangle calls, and this appears to be correct i.e. if I
drop a sphere it appears to interact with the bunny where I have it placed.
I am unsure of why this is the case though. As I said previously, in
order to get the correct position of a vertex in global coordinates
(using dBodyGetRelPointPos) I need to first apply the offset. So why do
I not need to apply the offset when drawing the triangles? What is the
difference between these two?
I haven't used offsets so you better double-check but I would guess that if geom offsets are in effect then dGeomGetPosition returns the (correctly offset) geom position and dBodyGetPosition would return the (non-offset as offset apply to the geom only) body's position which should differ by the precvious exactly by the offset. On the other hand dBodyGetRelPointPos, being related to the body calculates the point relative to the body's (non-offset) reference frame so you have to add the offset manually. Again, I would consider this behavior a reasonable explanation of what you observe and the "obvious thing to do" but check with your actual code to make sure.
Dimitris