Mesh size

JBudOne

09-08-2008 18:36:20

Hey guys, first of all, incase any of the OgreNewt devs are looking here, I want to congradulate you on a very successful ...wrapper I guess they call it? I was able to download it, go through your tutorial and easily implement this right into my program =)

Now, I do have one problem. I'm adding objects in here using OgreMax, and I'm looping through each of the objects in the scene manager, giving them mass and inertia and such. My problem is that I can't get the size figured out. You see, OgreMax splits all of the items up into separate mesh files, and I load those in. How would I create the Collision object and Inertia (which both require the object size) ? What can I do to retrieve the actual Vector size of a mesh?

Thanks so much for the help, really appreciate it =)

dudeabot

09-08-2008 23:49:39

did you try to get the bounding box?

JBudOne

10-08-2008 06:19:52

Hey there, I just tried it out. It works, after messing around with it for a while.. In case anybody else tries this out, here's the solution I had for getting the, relatively, correct size:

Entity* entity = ______
Vector3 size;

size = entity->getBoundingBox().getSize();
size.y *= 2;


I have no idea why you need to multiply by 2, and why it's only for the y axis, but that seems to be the case.

Thanks so much for the tip =) But sadly it doesn't completely solve my solution, because now I need to somehow retrieve the entities from the OgreMax scene, and so far I can only get Nodes (plain nodes, not SceneNodes).

Anyone have any suggestion? If not, I'll post here when I find the solution.

JBudOne

10-08-2008 18:46:28

Found a solution to retrieving each of the entities (well, movableobjects at least) within the scene:

SceneManager::MovableObjectIterator itr = scene.GetSceneManager()->getMovableObjectIterator("Entity");

while (itr.hasMoreElements())
{
Vector3 size = itr.peekNextValue()->getBoundingBox().getSize();
size.y *= 2;

itr.moveNext();
}


Thanks for the help dudeabot =)

walaber

11-08-2008 18:48:56

please note that for the latest versions of OgreNewt (and Newton), you no longer need to use my "MomentOfInertia" namespace / helper functions.

for any Newton Collision shape (that is convex), you can now ask Newton to calculate the inertia directly, which should be more accurate than my functions.

the next version of OgreNewt will have the MomentOfInertia namespace removed completely. I believe the demos in my OgreNewt release have been updated to reflect this.. if they haven't, I can post some source code examples of the new "proper" way to do it.