Bounding Box Problems

Irrlicht.Net is no longer developed or supported, Irrlicht.Net Cross Platform is a much more complete wrapper. Please ask your C# related questions on their forums first.
Locked
instruo

Bounding Box Problems

Post by instruo »

Hi there,

In the game I'm working on, I have a unit of troops (IAnimatedMesh's) that belong to Units (ISceneNode, created with both AddTest and AddEmpty)

What I need to do is be able to select the Unit's bounding box. The problem has been resizing the unit bounding box to include the bounding boxes of the troops. Here's my code:

this.unit_node.BoundingBox.Reset( 1, 1, 1 );

foreach ( TroopMesh t in this.troops )
{
this.unit_node.BoundingBox.AddInternalPoint(
t.MeshNode.BoundingBox );
}

However, when this is all done, the bounding box of unit_node hasn't changed any... I double checked that the bounding boxes of the troops where correct, and they are. Any ideas?
pfo
Posts: 370
Joined: Mon Aug 29, 2005 10:54 pm
Location: http://web.utk.edu/~pfox1

Post by pfo »

Try doing this: For the first troop, set the bounding box to that. For each additional troop, add internal box.

Code: Select all

int i = 0;
foreach (TroopMesh t in this.troops)
{
if (i == 0)   unit_node.BoundingBox == t.MeshNode.BoundingBox;
else           unit_node.BoundingBox.addInternalBox(t.MeshNode.BoundingBox);
i++;
}
[/code]
instruo

Post by instruo »

hmm... apparently the BoundingBox property is read only, so I can't do that :(
pfo
Posts: 370
Joined: Mon Aug 29, 2005 10:54 pm
Location: http://web.utk.edu/~pfox1

Post by pfo »

is there a getBoundingBox method? Should be...
instruo

Post by instruo »

Just noticed that the Reset method doesn't seem to be doing anything, either... When I set it to different values, it still doesn't change the box. Any other ideas why this might be a problem?
instruo

Post by instruo »

Nope, no getBoundingBox(). If I had to guess, the get{} for the BoundingBox object is giving me a new copy of the bounding box, instead of the box itself. Thus, when I use the this.unit_node.BoundingBox its not actually changing the object's box, but changing a copy of it...
Locked