Center of mass for box does not appear correct.

14 views
Skip to first unread message

David Cofer

unread,
Nov 15, 2013, 8:25:42 AM11/15/13
to osgbull...@googlegroups.com
I am trying to use OsgBullet to create a simple box that has its center of mass at a point other than the geometric center. I looked through the center of mass example that was included and I modified it to try and do what I need. However, it is not behaving the same as the example. I have attached my sample file I copied the createObject method and refactored it to just create an osg box instead of loading the com node from a file. The rest of the code is the same. I have it create two boxes in main. The first is with the standard com at the center, and in the second one I am trying to shift the com down so it will be closer to the ground when it hits. Both boxes are rotated slightly. From a physics perspective I would expect that the box with the normal com would fall over, while the one with the com down low to the ground would stabilize and remain upright. However, when I run the simulation and look at the debug drawing the bullet location of the box no longer matches the osg location. This discrepancy means that the osg box appears to hit the ground while it is still in the air. I believe that there is some difference in the way OsgBullet is setting up the motion state for some reason, or I am just messing up the configuration in some way I do not understand. Hopefully, it is that easy and someone can point me to what I am doing wrong.
centerofmass.cpp

Paul Martz

unread,
Nov 15, 2013, 11:14:04 AM11/15/13
to osgbull...@googlegroups.com
Not sure when I would have time to debug this.

My suspicion is that the visitor ran by osgbDynamics::createRigidBody to create the collision shape is doing something wrong in the presence of the ShapeDrawable. I wonder if the problem goes away when you use osgwTools::makeBox() instead, which uses plain osg::Geometry instead of a osg::ShapeDrawable.


On Fri, Nov 15, 2013 at 6:25 AM, David Cofer <davidc...@gmail.com> wrote:
I am trying to use OsgBullet to create a simple box that has its center of mass at a point other than the geometric center. I looked through the center of mass example that was included and I modified it to try and do what I need. However, it is not behaving the same as the example. I have attached my sample file I copied the createObject method and refactored it to just create an osg box instead of loading the com node from a file. The rest of the code is the same. I have it create two boxes in main. The first is with the standard com at the center, and in the second one I am trying to shift the com down so it will be closer to the ground when it hits. Both boxes are rotated slightly. From a physics perspective I would expect that the box with the normal com would fall over, while the one with the com down low to the ground would stabilize and remain upright. However, when I run the simulation and look at the debug drawing the bullet location of the box no longer matches the osg location. This discrepancy means that the osg box appears to hit the ground while it is still in the air. I believe that there is some difference in the way OsgBullet is setting up the motion state for some reason, or I am just messing up the configuration in some way I do not understand. Hopefully, it is that easy and someone can point me to what I am doing wrong.

--
You received this message because you are subscribed to the Google Groups "osgbullet-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to osgbullet-use...@googlegroups.com.
To post to this group, send email to osgbull...@googlegroups.com.
Visit this group at http://groups.google.com/group/osgbullet-users.
For more options, visit https://groups.google.com/groups/opt_out.



--
Paul Martz
Skew Matrix Software LLC

David Cofer

unread,
Nov 15, 2013, 11:47:07 AM11/15/13
to osgbull...@googlegroups.com
I will try that and let you know, but I doubt it is that simple. This is actually a test version I was building to try and troubleshoot the same problem I was having with my real application. I do not use shapedrawable in that app and it does the same thing.

David Cofer

unread,
Nov 17, 2013, 8:56:25 AM11/17/13
to osgbull...@googlegroups.com
Looks like you were right and it was that simple. When I switched it to use the osg works so it did not use shape drawable then it worked correctly. This should give me a base to start debugging and figure out what I am doing wrong in my real code. Thanks for your suggestion.

Paul Martz

unread,
Nov 17, 2013, 2:35:45 PM11/17/13
to osgbull...@googlegroups.com
No problem. I do seem to recall seeing some osgBullet code for handling ShapeDrawable in a special way. Perhaps that code needs to be re-examined, corrected, or possibly removed.

The nice thing about the osgWorks shapes code is, since they use Geometry, they will export to any file format (.flt, .3ds, etc.), whereas ShapeDrawable might or might not depending on whether the OSG export plugin supports it or not.


--
You received this message because you are subscribed to the Google Groups "osgbullet-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to osgbullet-use...@googlegroups.com.
To post to this group, send email to osgbull...@googlegroups.com.
Visit this group at http://groups.google.com/group/osgbullet-users.
For more options, visit https://groups.google.com/groups/opt_out.
Reply all
Reply to author
Forward
0 new messages