Model-Entity scale issues

Discuss any questions about BEPUphysics or problems encountered.
Post Reply
ThatsAMorais
Posts: 18
Joined: Mon Oct 05, 2009 5:24 am

Model-Entity scale issues

Post by ThatsAMorais »

I'm trying to understand how best to match my convex hull entity to the model (or vice versa). I've managed to get the vertices using the method in an XNA post ( http://forums.xna.com/forums/p/35948/207471.aspx ), and I can tell that the physical body encompassing my 6-sided die is cube-like with rounded edges, but the size of the model and the entity don't match.
Here, the dice are kinda stacked up in this box and jiggling a little as they rub together.  Sounds really sexy..., but it isn't.  They aren't free-falling, either.
Here, the dice are kinda stacked up in this box and jiggling a little as they rub together. Sounds really sexy..., but it isn't. They aren't free-falling, either.
dice_entity_too_large.png (12.33 KiB) Viewed 4571 times
Any help? I can give you some code if that's required, as well.
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: Model-Entity scale issues

Post by Norbo »

Be sure to bake any scaling that you do into the vertex positions that you pass the convex hulls. If you give the ConvexHull a list of points and then later draw the model from which you got the points with a different scaling, the entity and graphics will not match.

If you are having issues with the model being 'offset' from the center of the entity, you can either re-center it in the modeling program or pre-multiply a translation when you render the model to put it in the proper location.
ThatsAMorais
Posts: 18
Joined: Mon Oct 05, 2009 5:24 am

Re: Model-Entity scale issues

Post by ThatsAMorais »

Is there a way to determine the relative size difference between my ConvexHull and Model? I'm not manually applying any scaling to the dice. That may actually be the problem, of course, but I don't want to be guessing on this.
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: Model-Entity scale issues

Post by Norbo »

A relative size difference depends on how you want to measure it. To compare it, you would need to check the graphics' vertex positions against the convex hull point positions and measure the extremes along the desired axes. However, to be meaningful, you would need the transformed version of the graphics' vertex positions. If you had that, you could avoid the problem in the first place by applying that scaling to the convex hull points. You should be able to check for this transformation in the model if you're using XNA's Model class (in the bone transformations and such).

If there are any scaling transformations in the model that aren't baked into the vertex positions, they may not be reflected in the data you extract and give to the convex hulls. These may be 'left over' within the model, since you can export transformations. To simplify things, try to freeze all the transformations in the model editor prior to exporting it if you can.
ThatsAMorais
Posts: 18
Joined: Mon Oct 05, 2009 5:24 am

Re: Model-Entity scale issues

Post by ThatsAMorais »

Interesting idea on freezing the transforms. I'll have to see how that's done in Blender.

The thing is, I finally broke down and bought some dice models because my homemade one in blender wasn't ever going to be very accurate. Mine was relatively stable, though, compared to what I imported from a 3ds file to blender and then out to FBX. I can pretty much verify that I had a decent hull. I had to center the models I purchased in blender myself and orient them with the side I wanted on top. I also noticed an error in one of the d6 models that looked kinda sloppy. In short, I won't be surprised to have to tidy up these models further. Thanks!
Post Reply