 |
forums.ps2dev.org Homebrew PS2, PSP & PS3 Development Discussions
|
| View previous topic :: View next topic |
| Author |
Message |
AnonymousTipster
Joined: 01 Jul 2005 Posts: 197
|
Posted: Wed Nov 09, 2005 7:11 am Post subject: Updated SDK....Big problems involving 3D math |
|
|
I hadn't updated my toolchain for a month or so, so I downloaded a new one and updated the SDK. To my horror, after compiling the program, something in the GU or gum libraries had changed, which meant that some of the objects were out of place, and the cameras position (which depended on extracting vectors from a matrix) was completely off.
I need to know what has changed in the gum/gu libraries in the past month, and how to rectify my code.
The code for positioning the camera is as follows:
| Code: | const dReal* carRot;
carRot = dBodyGetRotation(carBody);
ScePspFVector3 cameraPos = { 0, 4, -10};
ScePspFVector3 lookAtPos = { 0, 0, 0};
ScePspFVector3 upVec = { 0, 1, 0};
upVec.y = 1;
float awayFrom;//distance from center to camera
awayFrom = (circleCamY/50)*20.0f;
float pointX;
float pointY;
float angle;
pointX = (dBodyGetPosition(carBody)[0]-(carRot[9]*camDistance));
pointY = (dBodyGetPosition(carBody)[2]+(carRot[1]*camDistance));
cameraPos.x = pointX;
cameraPos.y = dBodyGetPosition(carBody)[1]+5.0f;
cameraPos.z = pointY;
lookAtPos.x = dBodyGetPosition(carBody)[0];
lookAtPos.y = dBodyGetPosition(carBody)[1];
lookAtPos.z = dBodyGetPosition(carBody)[2];
sceGumLookAt(&cameraPos, &lookAtPos, &upVec); | This code put the camera directly behind the object, and when the object turned, the camera followed. Now, the camera spirals downward as the object turns. lookAtPos.y doesn't seem to constrain the camera to 5 above the object any more.
I hope you can help. |
|
| Back to top |
|
 |
chp
Joined: 23 Jun 2004 Posts: 313
|
Posted: Wed Nov 09, 2005 7:23 am Post subject: |
|
|
The order of operations in GUM was faulty previously, and I fixed this. Reverse the order you apply your sceGum*-operations and it should clean up. _________________ GE Dominator |
|
| Back to top |
|
 |
AnonymousTipster
Joined: 01 Jul 2005 Posts: 197
|
Posted: Wed Nov 09, 2005 7:51 am Post subject: |
|
|
Well, that fixes the problems with some of the objects being positioned incorrectly, but doesn't explain the problems with the camera.
Apart from | Code: | sceGumMatrixMode(GU_PROJECTION);
sceGumLoadIdentity();
sceGumPerspective(fovAmount,16.0f/9.0f,3.5f,500.0f); | and | Code: | | sceGumLookAt(&cameraPos, &lookAtPos, &upVec); | I don't use any Gum functions, so i'm not rotating before translating when using the LookAt function.
Has anything changed involving the LookAt function? |
|
| Back to top |
|
 |
chp
Joined: 23 Jun 2004 Posts: 313
|
Posted: Wed Nov 09, 2005 4:10 pm Post subject: |
|
|
I took a look at gumLookAt(), and it seems it used the old order of operations (which would be broken with the new matrix-multiply). Try grabbing the latest. _________________ GE Dominator |
|
| Back to top |
|
 |
AnonymousTipster
Joined: 01 Jul 2005 Posts: 197
|
Posted: Thu Nov 10, 2005 4:55 am Post subject: |
|
|
| Ok, thanks for fixing LookAt, it works as expected now. |
|
| 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
|