Slion.net>Dev>OpenGLLookAtGoBlack

9:18:45 PM) StephaneLenclud?: Question: why is is it that when I set my cam to position to 0,x,0 my model is not shown?

(9:19:00 PM) StephaneLenclud?: I have a simple model viewer application

(9:19:11 PM) StephaneLenclud?: I look at 0,0,0

(9:19:34 PM) StephaneLenclud?: when my cam position is 0,82,1 I can see my nice model

(9:19:53 PM) StephaneLenclud?: when I move it to 0,82,0 my model just vanish?

(9:20:02 PM) StephaneLenclud?: Am I missing something?

(9:20:48 PM) chriswright: sounds like a near/far clip plane problem

(9:21:08 PM) chriswright: er.. no, wait.

(9:21:50 PM) StephaneLenclud?: Mmmh funny that, that's not happening in a simple game of mine

(9:22:17 PM) StephaneLenclud?: I still see all my models when I set the cam pos to 0,40,0

(9:23:22 PM) StephaneLenclud?: BTW no matter the Y I get an empty screen in my model viewer if X=0 and Z=0

(9:24:02 PM) StephaneLenclud?: If I change either of the X and Z I can see my model again

(9:24:42 PM) chriswright: try playing with fractional x/z coords, and try to find something interesting (0,40,0.1, etc)

(9:24:50 PM) chriswright: [mind you, without code this is just a bunch of handwaving]

(9:26:07 PM) StephaneLenclud?: I get the same behavior displaying another model

(9:26:37 PM) StephaneLenclud?: let me see

(9:30:01 PM) StephaneLenclud?: With Z=0.1 it's just fine

(9:30:20 PM) StephaneLenclud?: it's only when X=0 and Z=0

(9:30:44 PM) StephaneLenclud?: So strange

(9:32:09 PM) Xmas|: StephaneLenclud?, how do you set your camera position?

(9:32:28 PM) StephaneLenclud?: let me see

(9:36:38 PM) StephaneLenclud?: Well I have a function called LookAt? wich is basically doing what the glu lookat function does but with fixed math since it's openGL ES

(9:37:22 PM) StephaneLenclud?: But maybe something goes wrong in the math

(9:37:59 PM) Xmas|: I suspect your "forward" and "up" vectors are parallel when you're setting a position with X=0 and Z=0

(9:38:35 PM) Xmas|: what are the parameters you're passing to that function?

(9:41:00 PM) StephaneLenclud?: So my lookat does a glMultMatrixx and glTranslatex

(9:41:56 PM) StephaneLenclud?: Camera::LookAt(iPosition.iX,iPosition.iY,iPosition.iZ,iEye.iX,iEye.iY,iEye.iZ,0,ONE,0);

(9:42:11 PM) StephaneLenclud?: so upx == upz (9:42:51 PM) StephaneLenclud?: upx==upz==0

(9:43:28 PM) Xmas|: iPosition is the position of your camera, and iEye the point you're looking at?

(9:43:40 PM) StephaneLenclud?: that's right

(9:44:01 PM) Xmas|: so if iEye is 0 and iPosition.iX and iPosition.iZ are 0, you get parallel forward and up vectors

(9:44:32 PM) StephaneLenclud?: mmmh

(9:44:47 PM) Xmas|: which means you'll get a 0 right/left vector by taking the cross product between forward and up

(9:45:01 PM) Xmas|: and you won't see anything on screen

(9:46:26 PM) StephaneLenclud?: I have to admit my Math are bit rusty but I'm glad there is a logical explanation to my problem smile

(9:46:39 PM) StephaneLenclud?: I'll write it down

(9:47:55 PM) Xmas|: It's a problem inherent to LookAt? if you have a static up vector

(9:48:14 PM) StephaneLenclud?: which I have

(9:48:17 PM) Xmas|: if you rotate the camera so you look along that up vector, things go black

(9:49:44 PM) StephaneLenclud?: good to know

(9:49:58 PM) StephaneLenclud?: thanks a lot for the explanations

(9:58:59 PM) StephaneLenclud?: So want's the best solution to that problem?

(9:59:56 PM) StephaneLenclud?: I guess if I always make sure the eye is like 0,0,0.0001 that would do right?

(10:01:18 PM) Xmas|: no

(10:01:56 PM) Xmas|: because then you get the same problem when your camera is at 0, y, 0.0001

(10:03:53 PM) StephaneLenclud?: ok right but then I typically use non decimal value for my cam position