Skip to main content
GameDev.net gamedev.net
🔒 Locked 🎮 Unity

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

Started by programci_84 Oct 16, 2010 at 7:27 PM 0 replies 550+ views
Original Post
programci_84
programci_84
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]
There's no "hard", and "the impossible" takes just a little time.
programci_84
programci_84
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
There's no "hard", and "the impossible" takes just a little time.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.