Sign in to follow this  
programci_84

[SOLVED] [DX9] Bounding Volumes per subset - Transformations problem

Recommended Posts

programci_84    336
Hi all,

Currently I'm working on phyics part of my renderer. I'm using nVidia PhysX.

I want to render bounding boxes of models as a physics debugging. Now I can create seperate bounding boxes for all subsets of the mesh. But when I transform'em and render, they're all positioning at the center of the model (i.e. center of the model's bounding sphere).

For example, I've a car and it has wheels and body as different subsets. I create bounding boxes for'em (with correct vMax and vMin values), then render. But I see wheels' bounding volumes are positioned at the center of model.

How can I solve this problem?

Thanks in advance.

[Edited by - programci_84 on October 16, 2010 8:02:07 PM]

Share this post


Link to post
Share on other sites
programci_84    336
Forget it guys, I've solved it :D

Here's the trick:
* Take model's world matrix:

matrix mWorld = model.worldMatrix;

* multiply the center point of bounding box with that matrix:

vec3 center = (BBox.vMax + BBox.vMin) * .5f;
vec3 centerW = TransformCoord (center, mWorld);

* manually position that matrix at that centerW thing:

mWorld.m41 = centerW.x; mWorld.m42 = centerW.y; mWorld.m43 = centerW.z;

* Then use that matrix while rendering.

Thanks anyway.
-R

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this