Camera alignment error?

Started by mystara, September 27, 2009, 10:07:47 AM

Previous topic - Next topic

mystara

Howdy,

I've been experiencing a weird effect when I do:

camera.align(someObject3D);


In one particular case, it seems to cause the light level of my world to dramatically fall. Objects don't appear unless the camera is pointed directly at them and is close up. For example, the following screenshot occurs by carrying out the camera alignment (above):



If I manually reset and rotate the camera in this way:

camera.getBack().setIdentity();
camera.rotateCameraY(someObject3D.yRotationAngle);
camera.rotateCameraX(someObject3D.xRotationAngle);


The shot appears (correctly) like this:



Obviously I've resolved my problem by finding another way to do what I wanted to achieve, so it's not urgent.
But I thought someone here might like to know on the off chance that it's a bug in jpct. I cannot understand how aligning the camera would affect the light levels. But since that's the only line of code I'm changing, I can't see what else it would be.

EgonOlsen

It's a bug. It's caused by the fact that jPCT codes scaling directly into the rotation matrix. The align-method took this matrix, inverted it and used it as the new rotation matrix for the camera. This has to take scaling into account which it didn't. This build may fix it (untested): http://www.jpct.net/download/beta/jpctapi_119pre2_5.zip


EgonOlsen


mystara

That seemed to fix the problem.

Out of curiosity, is there any significant difference in efficiency between:

camera.getBack().setIdentity();
camera.rotateCameraY(someObject3D.yRotationAngle);
camera.rotateCameraX(someObject3D.xRotationAngle);

or

camera.alignTo(someObject3D)

?

EgonOlsen

I don't think so. Maybe if you do it a million times per frame, but even then i wouldn't be sure which one is faster. Don't worry about it.