Object disappears when moved up in parallel projection

Problems building or running Ardor3D, questions about how to use features, etc.

Object disappears when moved up in parallel projection

Postby neothemachine » Mon Apr 30, 2012 1:50 am

Hi folks,
I try to render a scene in parallel orthographic projection with only one object of which I later take a screenshot. So far, so good. I got the parallel projection working with:

Code: Select all
Camera cam = canvas.getCanvasRenderer().getCamera();
cam.setProjectionMode(ProjectionMode.Parallel);
cam.setFrustum(-4242, 4242, 0, 920, 1380, 0);
cam.setLocation(-cam.getFrustumRight()/2, -cam.getFrustumTop()/2, cam.getFrustumRight()*2);


If I understand it correctly, I could theoretically use -infinity and +infinity for near and far frustum, right? I tried that, but got a corrupted image so I chose an arbitrarily big value.

The camera location is such that the object is centered vertically and horizontally. Again, the z-value is an arbitrary value because +/-infinity didn't work (object disappeared).

But now I'm facing a strange problem I can't solve. When I try to position the object into the middle with the above code it just disappears. I made some debug controls to control the cam location and as soon as I hit a certain y-value the object completely disappears and reappears when I move it down again. So e.g. When y is at -400, all is fine. When I go to -427 and beyond it is disappeared. I wouldn't mind if it's some extreme corner case thing but the location I try to set is actually the canvas center which I try to set with the above formulas (-cam.getFrustumTop()/2 ...).

I don't know what to look for, so any help is greatly appreciated :)

Cheers
neo
neothemachine
regular
 
Posts: 86
Joined: Tue Mar 13, 2012 9:58 am

Re: Object disappears when moved up in parallel projection

Postby neothemachine » Fri May 11, 2012 5:58 am

Should I create a sample eclipse project so you can see it? I really need to get this working.
neothemachine
regular
 
Posts: 86
Joined: Tue Mar 13, 2012 9:58 am

Re: Object disappears when moved up in parallel projection

Postby neothemachine » Mon May 21, 2012 2:33 am

Getting on that problem again I came to frustum culling, and actually, that's the problem.

As I need to display everything anyway, I hacked the camera like that:

Code: Select all
class CamHack extends Camera {
   public CamHack(Camera old) {
      super(old);
   }
   @Override
   public FrustumIntersect contains(BoundingVolume bound) {
      return FrustumIntersect.Inside;
   }
}


And it worked! So there definitely is a bug somewhere in frustum culling, OR it's my own fault because I forgot to set the bounding stuff, but I would assume that such a box is calculated automatically when I load a model. Is it?

Cheers
neo
neothemachine
regular
 
Posts: 86
Joined: Tue Mar 13, 2012 9:58 am


Return to HELP!

Who is online

Users browsing this forum: No registered users and 0 guests

cron