mObjBox, flying trees, and just lots of problems
by Max Robinson · in Torque Game Engine · 10/11/2002 (9:14 pm) · 3 replies
I'm trying to get a stupid object box to scale to the size of my tracer object, otherwise I need to cull based on the tip which is really stupid.
I'm getting a LOT of problems. What happens right now, is, if I shoot a lot, objects will start flying around the screen and scaling themselves and particles will appear as giant planes cutting into the terrain, layered ontop of eachother. It's like some sort of apocalypse scenario, as viewed by a person on a lot of stuff. And I dont like it either. I have a sort of debug box being drawn, along with a trajector path, and they fly around too. You'd think it'd just attach to the object and be scaled incorectly, but no, it flies.
here is how my scaling works:
It should work, in theory. I've moved those last 3 things around (basically setting transform and resetWorldBox) and commented and etc, but it doesnt fix anything.
When I force the box to be -1,-1,-1 and 1,1,1 there is no problems what so ever, other than that it is an awful way to cull the tracer.
Some questions I have regarding this mObjBox feature are:
1. The box position is relative to the render transform, correct?
2. What could cause the box to fly around (and I mean FAST)?
3. What happens if the render transform is outside of the box?
4. Is the box moved to be centered on the transform, or are the max and mins preserved, and 0,0,0 used for the render transform?
And of course, if someone could tell me exactly what I'm doing wrong, that would be excellent.
I'm getting a LOT of problems. What happens right now, is, if I shoot a lot, objects will start flying around the screen and scaling themselves and particles will appear as giant planes cutting into the terrain, layered ontop of eachother. It's like some sort of apocalypse scenario, as viewed by a person on a lot of stuff. And I dont like it either. I have a sort of debug box being drawn, along with a trajector path, and they fly around too. You'd think it'd just attach to the object and be scaled incorectly, but no, it flies.
here is how my scaling works:
void Shocktracer::updateWBox( )
{
if(ringList.first() == NULL)
return;
mObjBox.min.set( 1e10, 1e10, 1e10);
mObjBox.max.set(-1e10, -1e10, -1e10);
ShocktracerRing* ring = ringList.last(); // from back
Point3F relRingPosition;
while (ring != NULL)
{
relRingPosition = ring->position - mCurrentPosition; // ring->points[0].position
mObjBox.min.setMin( relRingPosition );
mObjBox.max.setMax( relRingPosition );
ring = ringList.prev(ring);
}
mObjBox.min.setMin( Point3F( -1.0f, -1.0f, -1.0f ) );
mObjBox.max.setMax( Point3F( 1.0f, 1.0f, 1.0f ) ); // to front
MatrixF xform = getTransform();
setTransform(xform);
resetWorldBox();
}It should work, in theory. I've moved those last 3 things around (basically setting transform and resetWorldBox) and commented and etc, but it doesnt fix anything.
When I force the box to be -1,-1,-1 and 1,1,1 there is no problems what so ever, other than that it is an awful way to cull the tracer.
Some questions I have regarding this mObjBox feature are:
1. The box position is relative to the render transform, correct?
2. What could cause the box to fly around (and I mean FAST)?
3. What happens if the render transform is outside of the box?
4. Is the box moved to be centered on the transform, or are the max and mins preserved, and 0,0,0 used for the render transform?
And of course, if someone could tell me exactly what I'm doing wrong, that would be excellent.
#2
10/14/2002 (12:38 pm)
Would be cool if you could share your solutions in case anybody else needs to know that... :)
#3
There is a possibility that the set transform isn't necessary...
10/14/2002 (6:50 pm)
Well the deal is, I'm not 100% sure what fixed it. It might have been the method I was rendering the debug box, which would make me really mad. But I did change it to a simpler, more brute force method (basically I just gave it the faces, takes about 50 lines too). Also, I moved lines around like crazy. If you want to know how to make a box that fits x objects in a link list that each have positions, I can show you that (just in case someone wants to know how to do this and searches for object box, what the hell):void Shocktracer::updateWBox( )
{
if(ringList.first() == NULL)
{
return;
}
mObjBox.min.set( 1e10, 1e10, 1e10);
mObjBox.max.set(-1e10, -1e10, -1e10);
ShocktracerRing* ring = ringList.last(); // from back
Point3F relRingPosition;
while (ring != NULL)
{
relRingPosition = ring->points[0].position - mCurrentPosition;
mObjBox.min.setMin( relRingPosition );
mObjBox.max.setMax( relRingPosition );
ring = ringList.prev(ring);
}
mObjBox.min.setMin( Point3F( -1.0f, -1.0f, -1.0f ) );
mObjBox.max.setMax( Point3F( 1.0f, 1.0f, 1.0f ) ); // to front
MatrixF xform = getTransform();
setTransform(xform);
resetWorldBox();
}There is a possibility that the set transform isn't necessary...
Torque Owner Max Robinson