The way I've tried to do it so far is to get the y axis from the analog stick , multiply it by 0.01f and add it to the z value for the top two vertices then subtract it from the z values of the bottom two verticies (making sure the z value starts in a middle position).
This doesn't get the desired effect though. What am I doing wrong?
Code: Select all
float z1 =2.56001f; //Z depth of each vertex //1.28*2 + a little?
float zy =0.0f; //The amount of y tilt.
float zx =0.0f; //The amount of x tilt.
...
void tilty(signed short int tilt) //Takes a number between -128 -16 and 16 128
{
zy = tilt*0.01f; //between -1.28f and 1.28f
}
...
void blit(void) {
pvr_poly_hdr_t hdr;
pvr_vertex_t vert;
pvr_poly_cxt_t cxt;
#ifdef PALETTE
pvr_txr_load_ex(vidram_buf, vidram_tex, 256,256, PVR_TXRLOAD_8BPP); //Send buffer to texture and swiz it up.
#else
pvr_txr_load(vidram_buf, vidram_tex, sizeofbuf); //Send buffer to texture
#endif
pvr_wait_ready();
pvr_scene_begin();
pvr_list_begin(PVR_LIST_OP_POLY);
#ifdef PALETTE
pvr_poly_cxt_txr(&cxt, PVR_LIST_OP_POLY, PVR_TXRFMT_PAL8BPP, 256,256, vidram_tex, 0);
#else
pvr_poly_cxt_txr(&cxt, PVR_LIST_OP_POLY, PVR_TXRFMT_RGB565|PVR_TXRFMT_NONTWIDDLED, 256,256, vidram_tex, 0);
#endif
pvr_poly_compile(&hdr, &cxt);
pvr_prim(&hdr, sizeof(hdr));
vert.argb = PVR_PACK_COLOR(1.0f, 1.0f, 1.0f, 1.0f);
vert.oargb = 0;
vert.flags = PVR_CMD_VERTEX;
/* Top left */
vert.x = X1;
vert.y = Y1;
vert.z = z1+zy;
vert.u = u1;
vert.v = v1;
pvr_prim(&vert, sizeof(vert));
/* Top right */
vert.x = X1+w;
vert.y = Y1;
vert.z = z1+zy;
vert.u = u2;
vert.v = v1;
pvr_prim(&vert, sizeof(vert));
/* Bottom left */
vert.x = X1;
vert.y = Y1+h;
vert.z = z1-zy;
vert.u = u1;
vert.v = v2;
pvr_prim(&vert, sizeof(vert));
/* Bottom right */
vert.x = X1+w;
vert.y = Y1+h;
vert.z = z1-zy;
vert.u = u2;
vert.v = v2;
vert.flags = PVR_CMD_VERTEX_EOL;
pvr_prim(&vert, sizeof(vert));
pvr_list_finish();
pvr_scene_finish();
}