I am trying to display a 3d Object (CAR) and want to move it forward. During this forward move, I want to rotate it's wheels around their own pivot point!
Everything works fine as long as the car does not move but once I start moving the car along it's Y axis, the wheels remain in place!
This is what I draw each frame:
Code: Select all
static void draw_frame(float frame)
{
ScePspFVector3 eye, center, up;
sceGuStart(GU_DIRECT,list);
sceGuClear(GU_COLOR_BUFFER_BIT|GU_DEPTH_BUFFER_BIT);
sceGumPushMatrix();
sceGumLoadIdentity();
DrawCube(1.0f, frame);
sceGumPopMatrix();
sceGuFinish();
sceGuSync(0,0);
}
Code: Select all
void DrawCube(float scale, float frame)
{
ScePspFVector3 vec;
float angle;
ScePspFMatrix4 wheel;
ScePspFMatrix4 temp;
vec.x=scale, vec.y=scale, vec.z=scale;
sceGumScale(&vec);
sceGumDrawArray(GU_TRIANGLES,
GU_TEXTURE_32BITF|GU_NORMAL_32BITF|GU_VERTEX_32BITF|GU_INDEX_16BIT,
alight_NUMFACES*3, (void *)alight_idx, (void *)alight_vtx);
more faces are drawn here
........
and here I try my wheel thing (this displays one wheel and the RIM) and rotates it:
Code: Select all
sceGumStoreMatrix(&temp);
sceGumLoadMatrix(&wheel);
sceGumLoadIdentity();
pos.trans.x = -lftire_pivot.px;
pos.trans.y = -lftire_pivot.py;
pos.trans.z = -lftire_pivot.pz;
sceGumTranslate(&pos.trans);
angle = frame*50 * (M_PI/180.0f);
sceGumRotateX(angle);
pos.trans.x = lftire_pivot.px;
pos.trans.y = lftire_pivot.py;
pos.trans.z = lftire_pivot.pz;
sceGumTranslate(&pos.trans);
sceGumDrawArray(GU_TRIANGLES,
GU_TEXTURE_32BITF|GU_NORMAL_32BITF|GU_VERTEX_32BITF|GU_INDEX_16BIT,
lftire_NUMFACES*3, (void *)lftire_idx, (void *)lftire_vtx);
sceGumDrawArray(GU_TRIANGLES,
GU_TEXTURE_32BITF|GU_NORMAL_32BITF|GU_VERTEX_32BITF|GU_INDEX_16BIT,
lfrim_NUMFACES*3, (void *)lfrim_idx, (void *)lfrim_vtx);
sceGumMultMatrix(&temp);
}
My problem is, that I am fairly new to 3d and I dont really get the whole things with the matrices..
Thank you very much for your help. It's greatly appreciated!
Roland