camera perpendicular plane

Hi all,

I’m kinda stuck with a very simple problem and I’d like to ask for help…

I’m using the ofx3D lib to move the camera around, but sometimes I need to draw a fullscreen video as background. Problem is that I can’t position it properly (the camera is orbiting around an axis).

What I’m doing is:

-first undo all rotations

  
  
glPushMatrix();  
	  
	// get the current modelview matrix  
	glGetFloatv(GL_MODELVIEW_MATRIX , m);  
	  
	// undo all rotations  
	// beware all scaling is lost as well   
	for( i=0; i<3; i++ )   
	    for( j=0; j<3; j++ ) {  
			if ( i==j )  
				m[i*4+j] = 1.0;  
			else  
				m[i*4+j] = 0.0;  
	    }  
	  
	// set the modelview with no rotations  
	glLoadMatrixf(m);  
  

  • and secondly I try to position my camera at the correct place (i’ve been tweaking the values but my calculations ain’t rite).
  
  
ofxVec3f res = ofxVec3f();  
res[0] = camera.getPosition()[0] + m[0]*m[12] + m[1]*m[13] + m[2]*m[14];  
res[1] = camera.getPosition()[1] + m[4]*m[12] + m[5]*m[13] + m[6]*m[14];  
res[2] = camera.getPosition()[2] + m[8]*m[12] + m[9]*m[13] + m[9]*m[14];  
  
movie.draw(camera.getPosition()[0] - pos[0] - 800,  180, ofGetWidth(), -ofGetHeight());  
  

any help would be really appreciated :smiley:

all the best,
–k

Hi,
If you just want to draw a fullscreen quad with a texture over/behind a 3D scene, it’s simplest to use orthographic projection. Something like:

  
glMatrixMode(GL_PROJECTION);  
	glPushMatrix();  
		glLoadIdentity();  
		glOrtho(-1., 1., -1., 1., -100, 100);  
  
	glMatrixMode(GL_MODELVIEW);  
	glPushMatrix();  
		glLoadIdentity();  
  
// draw  
  
glMatrixMode(GL_PROJECTION);  
	glPopMatrix();  
  
	glMatrixMode(GL_MODELVIEW);  
	glPopMatrix();  

The above will make the coordinates system go from [-1, 1] x [-1,1].

there is a very simple solution to this but it might not be the fastest. call ofSetupScreen() just before you draw your background. this will reset the screen coordinates to the original values used in OF and you can draw normally like you would in 2d.

hi.

Thank you very much, guys.

Othersides’ solution worked like a charm :slight_smile:

thanks again,
–k