#88304 - dexter0 - Sun Jun 18, 2006 5:52 pm
I have been using 3d programs for a while now and decided to try programming 3D on the DS. I am using a combination of PA_LIB and libnds in my code. All the objects seem to position correctly but when I set my camera/perspective to 1.0,0.0,1.5,0.0,0.0,0.0 the camera does not seem to be moving ONLY on the x-axis. It appears to be orbiting around the center. Changing the Y position does the same except it orbits vertically. The Z position behaves correctly except that when Z hits a negative value the camera rotates 180. Is this standard 3D behavior or am I not doing something right?
Code: |
#include <PA9.h>
int main() { float x=1.0; float y=0.0; float z=1.5; float rx=0.0; PA_Init(); PA_InitVBL(); PA_InitText(1,0); PA_SetTextCol(1,31,31,31); PA_Init3D();//init the 3d PA_Init3DDrawing(1.0,0.0,1.5,0.0,0.0,0.0);//eyex, eyey, eyez while(1) { PA_OutputText(1,0,0,"PosX: %f", x); PA_OutputText(1,0,1,"PosY: %f", y); PA_OutputText(1,0,2,"PosZ: %f", z); PA_OutputText(1,0,3,"RotX: %f", rx); if(Pad.Held.Left) { x=x-0.05; } if(Pad.Held.Right) { x=x+0.05; } if(Pad.Held.Up) { y=y-0.05; } if(Pad.Held.Down) { y=y+0.05; } if(Pad.Held.X) { z=z-0.05; } if(Pad.Held.Y) { z=z+0.05; } if(Pad.Held.L) { rx=rx-0.05; } if(Pad.Held.R) { rx=rx+0.05; } if(Pad.Held.A) { x=0.0; y=0.0; z=1.0; rx=0.0; } gluLookAt(x,y,z,rx,0.0,0.0,0.0,0.1,0.0); glPushMatrix(); PA_3DBox(0.0,0.0,0.0,0.5,0.5,0.5,0.0,0.0,0.0,255,255,255);//color PA_3DBox(0.0,0.0,0.0,2.0,0.1,0.1,0.0,0.0,0.0,0,255,0);//color PA_3DBox(0.0,0.0,0.0,0.1,2.0,0.1,0.0,0.0,0.0,0,0,255);//color PA_3DBox(0.0,0.0,0.0,0.1,0.1,2.0,0.0,0.0,0.0,255,0,0);//color glPopMatrix(1); glFlush();//show } return 0; } |