Page 1 of 1

Translate

PostPosted: May 5, 2009 @ 8:57am
by Gar
Hi,

I am trying to fix the problem in my project when the object is moving. The Cube should locate in the center, but from the figures below are not.


Image

Image

I think it should be the translate problem. The part code is as following:

-----------------------------
//Before rotating, translating or scaling, reset the cube to its original position to prevent rounding errors
cube.Reset();
cube.Translate(patt_trans[0][3],-patt_trans[1][3],-patt_trans[2][3]);

cube.Rotate((4096/(2*3.14))*rot[0],(4096/(2*3.14))*rot[1],(4096/(2*3.14))*rot[2]);

//Set 3D perspective and move the camera backwards (scale for the Edge internal renderer)
display->Perspective3D(display->GetWidth(), display->GetHeight());

// #if !defined(EGL_USEGL)
display->WorldScale(65536 * 2, 65536 * 2, 65536 * 2);
// #endif

display->WorldScale(65536*patt_width/2, 65536*patt_width/2,65536*patt_width/2);
display->Render(&cube);
return(E_OK);
display->WorldReset();


------------------------------------
Thanks.

PostPosted: May 10, 2009 @ 5:41pm
by edge
Hi Gar,

It seems the translation is going fine, but your perspective isn't. Are you able to read the perspective matrix/properties from your camera? If you can retrieve the camera's perspective matrix, you can use the ClassEDisplay::SetPerspectiveMatrix function to fix your perpective.

Also, are you using OpenGL or the EDGELIB software 3D renderer?

PostPosted: May 11, 2009 @ 4:34am
by Gar
Hi Edge,

I read the perspective matrix from my camera, but this matrix is 4X4, and the ClassEDisplay::SetPerspectiveMatrix function is reading 20:12 fixed point. What should i do then?

>Also, are you using OpenGL or the EDGELIB software 3D renderer?

I am using EDGELIB software to render.

PostPosted: May 11, 2009 @ 8:38am
by edge