MS_4 Invisible wheels
by Akiraa · in Torque Game Engine Advanced · 09/10/2006 (8:54 am) · 12 replies
I have just finished porting Starter_Racing demo to MS 4 and the wheels on my vehicle are not showing up. The rest of the vehicle is rendering properly.
Anyone experiencing similar problem ?
Anyone experiencing similar problem ?
#2
09/10/2006 (10:31 am)
The wheel rendering code still hasn't been updated to match the characteristics of the batching system.
#3
Robert, my name isn't Akiraa, loved the Anime movie...
09/10/2006 (10:41 am)
Thank you for the info, Chris.Robert, my name isn't Akiraa, loved the Anime movie...
#4
09/10/2006 (3:44 pm)
Nice!!My Daughter Is named Akira...I named her after the Movie!!
#5
I presume we need to add some code to WheeledVehicle.cpp to call the batch code before and after the wheels are dealt with.
10/06/2006 (5:17 am)
Anyone able to shed light on add the wheels into the new batching approach?I presume we need to add some code to WheeledVehicle.cpp to call the batch code before and after the wheels are dealt with.
#6
And add this right after it:
Now in wheeledVehicle.cpp, somewhere after the WheeledVehicle::renderImage() function add this:
That'll make the wheels render. They'll not cast shadows, however, that requires some extra changes I haven't made yet.
10/09/2006 (6:33 am)
On wheeledVehicle.h, find this:void setWheelSpring(S32 wheel,WheeledVehicleSpring*);
And add this right after it:
void prepBatchRender( SceneState *state, S32 mountedImageIndex );
Now in wheeledVehicle.cpp, somewhere after the WheeledVehicle::renderImage() function add this:
void WheeledVehicle::prepBatchRender(SceneState* state, S32 mountedImageIndex )
{
Parent::prepBatchRender(state, mountedImageIndex);
// Shape transform
GFX->pushWorldMatrix();
MatrixF mat = getRenderTransform();
mat.scale( mObjScale );
GFX->setWorldMatrix( mat );
Wheel* wend = &mWheel[mDataBlock->wheelCount];
for (Wheel* wheel = mWheel; wheel < wend; wheel++)
{
if (wheel->shapeInstance)
{
GFX->pushWorldMatrix();
// Steering & spring extension
MatrixF hub(EulerF(0,0,mSteering.x * wheel->steering));
Point3F pos = wheel->data->pos;
pos.z -= wheel->spring->length * wheel->extension;
hub.setColumn(3,pos);
GFX->multWorld(hub);
// Wheel rotation
MatrixF rot(EulerF(wheel->apos * M_2PI,0,0));
GFX->multWorld(rot);
// Rotation the tire to face the right direction
// (could pre-calculate this)
MatrixF wrot(EulerF(0,0,(wheel->data->pos.x > 0)? M_PI/2: -M_PI/2));
GFX->multWorld(wrot);
// Render!
wheel->shapeInstance->animate();
wheel->shapeInstance->render();
GFX->popWorldMatrix();
}
}
GFX->popWorldMatrix();
}That'll make the wheels render. They'll not cast shadows, however, that requires some extra changes I haven't made yet.
#7
10/11/2006 (12:52 am)
Thank you Manoel, I will give it a try.
#8
10/12/2006 (11:12 am)
I added this but wheels are not rending still in TSE. Do you have to call that function anywhere?
#9
In game/shapeBase.h, find this line:
And change it to this:
Since WheeledVehicles inherit from shapeBase, you need to virtualize shapeBase's prepBatchRender so the WheeledVehicle can override it with it's own.
10/16/2006 (6:24 am)
Oops, I forgot one change! Sorry!In game/shapeBase.h, find this line:
void prepBatchRender( SceneState *state, S32 mountedImageIndex );
And change it to this:
virtual void prepBatchRender( SceneState *state, S32 mountedImageIndex );
Since WheeledVehicles inherit from shapeBase, you need to virtualize shapeBase's prepBatchRender so the WheeledVehicle can override it with it's own.
#11
I'm working on the shadow issue for wheels now... anyone look at it yet?
11/02/2006 (5:43 pm)
@Manoel - There is a bug in your code there... prepBatchRender will also be called per-mounted object... that's what the 'mountedImageIndex' is. So if you have something mounted to the vehicle you'll get the wheels rendered twice. The fix is to add this...void WheeledVehicle::prepBatchRender(SceneState* state, S32 mountedImageIndex )
{
Parent::prepBatchRender(state, mountedImageIndex);
if ( mountedImageIndex != -1 )
return;I'm working on the shadow issue for wheels now... anyone look at it yet?
#12
11/09/2006 (11:32 am)
Added that. wheels work now woot! =)
Torque Owner Bobby Leighton
Imagn' Games