Updated SDK....Big problems involving 3D math

Discuss the development of new homebrew software, tools and libraries.

Moderators: cheriff, TyRaNiD

Post Reply
AnonymousTipster
Posts: 197
Joined: Fri Jul 01, 2005 2:50 am

Updated SDK....Big problems involving 3D math

Post by AnonymousTipster »

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: Select all

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.
chp
Posts: 313
Joined: Wed Jun 23, 2004 7:16 am

Post by chp »

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
AnonymousTipster
Posts: 197
Joined: Fri Jul 01, 2005 2:50 am

Post by AnonymousTipster »

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: Select all

sceGumMatrixMode(GU_PROJECTION);
		sceGumLoadIdentity();
sceGumPerspective(fovAmount,16.0f/9.0f,3.5f,500.0f);
and

Code: Select all

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?
chp
Posts: 313
Joined: Wed Jun 23, 2004 7:16 am

Post by chp »

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
AnonymousTipster
Posts: 197
Joined: Fri Jul 01, 2005 2:50 am

Post by AnonymousTipster »

Ok, thanks for fixing LookAt, it works as expected now.
Post Reply