Author Topic: Camera alignment error?  (Read 8929 times)

Offline mystara

  • int
  • **
  • Posts: 79
    • View Profile
Camera alignment error?
« 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):



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:



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.
« Last Edit: September 27, 2009, 10:12:35 am by mystara »

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12298
    • View Profile
    • http://www.jpct.net
Re: Camera alignment error?
« Reply #1 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

Offline mystara

  • int
  • **
  • Posts: 79
    • View Profile
Re: Camera alignment error?
« Reply #2 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 ?

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12298
    • View Profile
    • http://www.jpct.net
Re: Camera alignment error?
« Reply #3 on: September 27, 2009, 09:49:12 pm »
Yes.

Offline mystara

  • int
  • **
  • Posts: 79
    • View Profile
Re: Camera alignment error?
« Reply #4 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)

?

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12298
    • View Profile
    • http://www.jpct.net
Re: Camera alignment error?
« Reply #5 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.