Weird Problem Loading In Mobile Mesh's

Discuss any questions about BEPUphysics or problems encountered.
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: Weird Problem Loading In Mobile Mesh's

Post by Norbo »

Using an Unmodified version of BEPU physics and the GraphicMatchingDemo, Loading in only one of my models, the shapes do not align
If you'd like to send me a model file which fails in the GraphicMatchingDemo, I can take a look.
theneonirvana
Posts: 24
Joined: Wed Aug 17, 2011 9:20 pm

Re: Weird Problem Loading In Mobile Mesh's

Post by theneonirvana »

sorry to waste your time norbo... upon running through the source more ive found my models do align, however i didnt notice that a third entity was being drawn, and thus i thought the third bepuentity being drawn was the non aligned physics.

The offset can be computed by comparing the bounds (AABB or sphere) of the graphic, making some other measurement, or just by eyeballing it. Once the offset is found, the remaining logic for aligning the graphic to the shape is the same.}
I just dont quite unjderstand comparing bounds can u explain this a little more indepth for me?

I feel bad this thread has gone on so long.... thank you again for your insight
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: Weird Problem Loading In Mobile Mesh's

Post by Norbo »

When creating a ConvexHull or MobileMesh from model vertex data, it computes an offset to move the shape onto the local origin. The BoxShape and other simple primitive shapes are not created from model data and just start at the local origin. Because it isn't based on the model data and doesn't compute an offset, the offset to align the graphic with the collision shape must be calculated manually.

One way to manually compute this alignment offset is to compute the axis-aligned bounding box of the model data. Then, create a BoxShape with the width, height, and length of that bounding box. Recall that the BoxShape is centered on the origin. To find the offset to align the model to the shape, compute the center of the model bounding box. The offset that needs to be applied to the graphic in local space to bring it into alignment with the box is -center.
Post Reply