ofCamera - panning, titling, and drawing

I can draw a scene using a camera fine, but if i change the tilt or pan of the camera then the box room I draw using planes gets destroyed, the angles of all the sides change and it looks like a scene from Labyrinth. I don’t understand what’s wrong.

_camera.begin()
_material.begin();

//Left
_material.end();
ofSetColor(0, 0, 255);
ofPushMatrix();
ofTranslate(-_roomWidth/2, _roomHeight/2);
ofRotateY(90);
_planes[eLeft].draw();
ofPopMatrix();
_material.begin();

//Front
//_material.end();
//ofSetColor(0, 0, 255);
ofPushMatrix();
ofTranslate(0.f, _roomHeight/2, -_roomDepth/2);
_planes[eFront].draw();
ofPopMatrix();
//_material.begin();

//Right
_material.end();
ofSetColor(0, 0, 255);
ofPushMatrix();
ofTranslate(_roomWidth/2, _roomHeight/2);
ofRotateY(-90.f);
_planes[eRight].draw();
ofPopMatrix();
_material.begin();

//Back
_material.end();
ofSetColor(0, 255, 0);
ofPushMatrix();
ofTranslate(0.f, _roomHeight/2, _roomDepth/2);
ofRotateY(180.f);
_planes[eBack].draw();
ofPopMatrix();
_material.begin();

//Top
_material.end();
ofSetColor(0, 255, 255);
ofPushMatrix();
ofTranslate(0.f, _roomHeight );
ofRotateX(90.f);
_planes[eTop].draw();
ofPopMatrix();
_material.begin();

//Bottom
_material.end();
ofSetColor(255, 0, 255);
ofPushMatrix();
ofTranslate(0.f,0.f);
ofRotateX(-90.f);
_planes[eBottom].draw();
ofPopMatrix();

_material.end();
_camera.end();

Hi, I see nothing strange happening.
Although, you might want to use ofEnableDepthTest(); which I guess will give you the result you are looking for.

Also you should remove the material as it is doing nothing.

cheers

maybe i should post up a screenshot to demonstrate the problem, first pictute is no pan or tilt, 2nd is some pan and tilt, so it should be looking a bit to the right and up (ignore the rectangle and square top left, thats just another camera looking behind). it feels like the rotation of the camera is affecting the rotation/translate of the planes.

are you placing the camera in a particular position? is it an ofCamera of ofEasyCam?
if ofCamera, it is placed in 0,0,0 looking towards 0,0,1
The second screenshot doesn´t look unreasonable to me.
You should call ofEnableDepthTest(); in the begining of draw();
Did you try with ofEasyCam instead of ofCamera? ofEasyCam inherits from ofCamera, so if anything is wrong with the ofCamera ofEasyCam will also have it, the difference is that ofEasyCam allows you to interact with it by dragging the mouse.

ofEnableDepthTeest() will only introduce obstruction of objects close to the camera and wont have anything to do with the incorrect positioning and angles of the planes shown in the 2nd image. consider the green is the roof and the blue is the floor.

can you post the code that you are using please. the complete code, not just the snippet already posted.
cheers

the only other relevant bits are

ofCamera _camera;
_camera.setFov(90.0f);
_camera.setPosition(0.f, 10.f, -20.f);

I think the problem is the renderer is applying the cameras rotation on the objects I draw in world space, which makes sense. I need to find a way to somehow turn it off.

Hi, what are class are the objects stored in the _plane array (or vector)? how are these setup?
you always draw stuff in world space, unless you have nested (parented) objects, which shouldn´t be the case.
The camera doesn’t transform the objects it renders, as it is unrelated to these.
did you try using ofEasyCam? what happens?

Same results with easycam, I’ve pasted the other code bits. One thing I recently noticed is I am translating then rotating, this should be creating an orbiting effect according to online sources, but the effect I get is a rotate and then translate. it still shouldnt be affected by the rotation of the camera though.

 ofPlanePrimitive _planes[6];

_roomHeight = 4000.f;
_roomDepth = 10000.f;
_roomWidth = 10000.f;
_cameraHeight = 100.f;

_planes[eLeft].set(_roomDepth, _roomHeight);
_planes[eLeft].setPosition(0.f,0.f,0.f);
_planes[eFront].set(_roomWidth, _roomHeight);
_planes[eFront].setPosition(0.f,0.f,0.f);
_planes[eRight].set(_roomDepth, _roomHeight);
_planes[eRight].setPosition(0.f,0.f,0.f);
_planes[eBack].set(_roomWidth, _roomHeight);
_planes[eBack].setPosition(0.f,0.f,0.f);
_planes[eTop].set(_roomWidth, _roomDepth);
_planes[eTop].setPosition(0.f,0.f,0.f);
_planes[eBottom].set(_roomWidth, _roomDepth);
_planes[eBottom].setPosition(0.f,0.f,0.f);

ok. so the problem is that you are having some massive clipping in the camera.
just set the far and near clip to be enough to cover your whole scene.

_camera.setNearClip(0);
_camera.setFarClip(100000);

And remember to call ofEnableDepthTes(); otherwise the wall will be drawn in the incorrect order.
Cheers!

it isnt clipping, the angles of the planes are changing. I’m now redrawing the planes by rotating before translating and it’s working. I’d still like to find out why the cameras rotation affects the rotation and translation of the planes when translating before rotating.