text
stringlengths
0
2.2M
// camera->world
//
// Our box is in camera space, if we
// want to draw that into world space
// we have to apply the camera->world
// transformation.
//
ofPushMatrix();
ofMultMatrix(inverseCameraMatrix);
ofSetColor(255, 100, 100);
//////////////////////
// DRAW WIREFRAME BOX
//
// xy plane at z=-1 in camera sapce
// (small rectangle at camera position)
//
GLfloat vertices1[] = {
-1.0f, -1.0f, -1.0f,
-1.0f, 1.0f, -1.0f,
1.0f, 1.0f, -1.0f,
1.0f, -1.0f, -1.0f
};
glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(3, GL_FLOAT, 0, vertices1);
glDrawArrays(GL_LINE_LOOP, 0, 4);
glDisableClientState(GL_VERTEX_ARRAY);
// xy plane at z=1 in camera space
// (generally invisible because so far away)
//
GLfloat vertices2[] = {
-1.0f, -1.0f, 1.0f,
-1.0f, 1.0f, 1.0f,
1.0f, 1.0f, 1.0f,
1.0f, -1.0f, 1.0f};
glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(3, GL_FLOAT, 0, vertices2);
glDrawArrays(GL_LINE_LOOP, 0, 4);
glDisableClientState(GL_VERTEX_ARRAY);
// connecting lines between above 2 planes
// (these are the long lines)
//
GLfloat vertices3[] = {
-1.0f, 1.0f, -1.0f,
-1.0f, 1.0f, 1.0f,
1.0f, 1.0f, -1.0f,
1.0f, 1.0f, 1.0f,
-1.0f, -1.0f, -1.0f,
-1.0f, -1.0f, 1.0f,
1.0f, -1.0f, -1.0f,
1.0f, -1.0f, 1.0f
};
glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(3, GL_FLOAT, 0, vertices3);
glDrawArrays(GL_LINE_LOOP, 0, 8);
glDisableClientState(GL_VERTEX_ARRAY);
//
//////////////////////
ofPopStyle();
ofPopMatrix();
}
//
//////////////////////////////////
//////////////////////////////////
// DRAW RAY
//////////////////////////////////
//
//draw if we've got camEasyCam selected
//and we're not looking through it
if (iMainCamera == 0 && iCameraDraw != 0)
{
ofPushStyle();
ofSetColor(100, 100, 255);
ofDrawLine(ray[0], ray[1]);
ofPopStyle();
}
//
//////////////////////////////////
}
//--------------------------------------------------------------
void ofApp::updateMouseRay()
{