 |
forums.ps2dev.org Homebrew PS2, PSP & PS3 Development Discussions
|
| View previous topic :: View next topic |
| Author |
Message |
Heimdall
Joined: 10 Nov 2005 Posts: 259 Location: Netherlands
|
Posted: Sun Nov 30, 2008 5:14 am Post subject: need help with some guTranslate problem |
|
|
I've a simple piece of code:
| Code: | fbp0 = 0;
// Init GU
sceGuInit();
sceGuStart(GU_DIRECT, display_list);
// Set Buffers
sceGuDrawBuffer(GU_PSM_8888, fbp0, BUF_WIDTH);
sceGuDispBuffer(SCR_WIDTH, SCR_HEIGHT, (void*)0x88000, BUF_WIDTH);
sceGuDepthBuffer((void*)0x110000, BUF_WIDTH);
sceGuOffset(2048 - (SCR_WIDTH/2), 2048 - (SCR_HEIGHT/2));
sceGuViewport(2048, 2048, SCR_WIDTH, SCR_HEIGHT);
sceGuDepthRange(65535, 0);
// Set Render States
// Enable scissor test, depth test, smooth shading and culling
sceGuScissor(0, 0, SCR_WIDTH, SCR_HEIGHT);
sceGuEnable(GU_SCISSOR_TEST);
sceGuDepthFunc(GU_GEQUAL);
sceGuEnable(GU_DEPTH_TEST);
sceGuShadeModel(GU_SMOOTH);
sceGuFrontFace(GU_CCW);
sceGuEnable(GU_CULL_FACE);
sceGuEnable(GU_CLIP_PLANES);
// set clear color/depth
sceGuClearColor( GU_COLOR( 0.0f, 0.0f, 0.0f, 1.0f ) );
sceGuClearDepth(0);
// setup texture
sceGuEnable(GU_TEXTURE_2D); //Enable Texture2D
sceGuTexFunc(GU_TFX_MODULATE, GU_TCC_RGB);
sceGuTexFilter(GU_LINEAR, GU_LINEAR); // Linear filtering
sceGuTexScale(1.0f, 1.0f); // No scaling
sceGuTexOffset(0.0f, 0.0f);
sceGuFinish();
sceGuSync(0,0);
sceDisplayWaitVblankStart();
sceGuDisplay(GU_TRUE);
// finish
// setup projection matrix
sceGumMatrixMode(GU_PROJECTION);
sceGumLoadIdentity();
sceGumPerspective(fov, aspect, znear, zfar);
// look at
sceGumMatrixMode(GU_VIEW);
sceGumLoadIdentity();
sceGumLookAt(eye, center, up);
// io
sceCtrlSetSamplingMode(PSP_CTRL_MODE_ANALOG);
Model* model = loadModel();
while(1) {
// begin
sceGuStart(GU_DIRECT, display_list);
sceGuClear(GU_COLOR_BUFFER_BIT|GU_DEPTH_BUFFER_BIT);
// peek
sceCtrlPeekBufferPositive(&pad, 1);
// update x and y
model->position->x = (float) (pad.Lx - 128);
model->position->y = (float) (pad.Ly - 128);
// texture bind
sceGuColor(GU_COLOR(1.0f,1.0f,1.0f,0.0f));
sceGuTexMode(model->texture->mode, 0, 0, 1);
sceGuTexImage(0,
model->texture->width,
model->texture->height,
model->texture->width,
model->texture->pixels);
sceGumMatrixMode(GU_MODEL);
// i should see the model to go left and right, top down, right? why doesn't it work?
sceGumTranslate(model->position));
sceGumLoadMatrix(model->initialTransform));
// draw mesh
sceGumDrawArray(
GU_TRIANGLES,
model->mesh->vtype | GU_TRANSFORM_3D,
model->mesh->nFaces * 3,
model->mesh->indices,
model->mesh->vertices);
// end
sceGuFinish();
sceGuSync(0, 0);
// swap buffers
fbp0 = sceGuSwapBuffers();
} |
And I was trying to use the analog stick to translate my mesh on the x, y axys but i cannot see anything happening.
The model is rendered and the texture also but the translation doesn't seem to work, I'm doing something wrong for sure, can anyone show me what?
Thanks! |
|
| Back to top |
|
 |
jsharrad
Joined: 20 Oct 2005 Posts: 102
|
Posted: Sun Nov 30, 2008 6:13 am Post subject: |
|
|
| Looks like you're overwriting the current translated matrix with model->initialTransform before you draw the model. |
|
| Back to top |
|
 |
Insert_witty_name
Joined: 10 May 2006 Posts: 376
|
Posted: Sun Nov 30, 2008 10:00 am Post subject: |
|
|
Something like this may help:
| Code: | sceGumMatrixMode(GU_MODEL);
sceGumLoadMatrix(model->initialTransform);
sceGumPushMatrix();
sceGumTranslate(model->position);
// draw mesh
sceGumDrawArray(
GU_TRIANGLES,
model->mesh->vtype | GU_TRANSFORM_3D,
model->mesh->nFaces * 3,
model->mesh->indices,
model->mesh->vertices);
sceGumPopMatrix(); |
|
|
| Back to top |
|
 |
Heimdall
Joined: 10 Nov 2005 Posts: 259 Location: Netherlands
|
Posted: Mon Dec 01, 2008 4:12 am Post subject: |
|
|
| yeap that was it, thanks! |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|