www.jpct.net

jPCT - a 3d engine for Java => Bugs => Topic started by: mystara on September 27, 2009, 10:07:47 am

Title: Camera alignment error?
Post by: mystara on September 27, 2009, 10:07:47 am
Howdy,

I've been experiencing a weird effect when I do:
Code: [Select]
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):

(http://alan.alwebwiz.net/darkshot.png)

If I manually reset and rotate the camera in this way:
Code: [Select]
camera.getBack().setIdentity();
camera.rotateCameraY(someObject3D.yRotationAngle);
camera.rotateCameraX(someObject3D.xRotationAngle);

The shot appears (correctly) like this:

(http://alan.alwebwiz.net/correctshot.png)

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.
Title: Re: Camera alignment error?
Post by: EgonOlsen on September 27, 2009, 12:58:20 pm
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 (http://www.jpct.net/download/beta/jpctapi_119pre2_5.zip)
Title: Re: Camera alignment error?
Post by: mystara on September 27, 2009, 08:26:39 pm
Does this version also incorporate the fix from:
http://www.jpct.net/forum2/index.php/topic,1427.0.html ?
Title: Re: Camera alignment error?
Post by: EgonOlsen on September 27, 2009, 09:49:12 pm
Yes.
Title: Re: Camera alignment error?
Post by: mystara on September 28, 2009, 09:54:27 am
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)

?
Title: Re: Camera alignment error?
Post by: EgonOlsen on September 28, 2009, 09:55:42 am
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.