Remove object from camera

I have built up a custom shape object that in my application mostly stays inside an EasyCam.
However, sometimes, the shape object requires transformations to be done which makes it very difficult to do inside the cam with the changed coordinates (that the ofEasyCam does)

I wanted to ask if there’s a way I could temporarily remove my object from inside the cam and then put it back later when I am finished with my operation. This would make the life much easier here.

When you say “the changed coordinates” I think you mean the screen coordinates? In that case couldn’t you do something like:

ofVec3f unAlteredVertex = ofCamera.screenToWorld(shape.getVertex(i));  

and do your transformation there? You can also always get the matrix that your ofCamera is using, find its inverse, and then multiply all your points by that to get the original points.


I did try to use the screenToWorld to just get the shape drawn at the same place where it would have been drawn if there was no cam. I am not getting the results and here’s a short part of the code from what I am trying.

Consider this shape
(very crude code here, just wrote it down in the text box without IDE)

MyCustomShape class

class MyCustomShape : ofNode {  
MyCustomShape(camRef* camParam = NULL)  
videoPlayer.width = 200;  
videoPlayer.height = 100;  
animationPlaying = false;  
camRef = camParam;  
//Load and play in video player  
finalPosition.set(100,50,0); //final position when the shape (i.e. video player here) should be drawn as a full screen without any transformations (similar to what it would have done without ofEasyCam  
void customDraw()  
//A changed orientation of video player in 3D  
else if (animtionPlaying){  
//Remove the orientation of the video player. It should be displayed like a simple rectangle drawn on the screen without camera  
ofVec3f playerPos = camRef.screenToWorld(finalPosition);  
//No look At, No rotations, No transformation required. Just plain display of video over the screen with the starting coordinate at finalPostion.x and finalPosition.y  
videoPlayer.draw(playerPos.x, playerPos.y, 800, 600);  
bool animationPlaying;  
ofVec3f origin;  
ofVideoPlayer videoPlayer;  
ofVec3f finalPosition;  
ofEasyCam* camRef;  


MyCustomShape* myShape;  
ofEasyCam myCam;  


void testApp::setup(){  
myShape = new MyCustomShape(&myCam);  
void testApp::draw(){  
void testApp::keyPressed(){  
if(key==' '){  
myShape->animationPlaying =  true;  

If I do the above, I was expecting the video to just come directly in the face of the user at the finalPosition (not rotated or transformed etc.). However, what I get is this:

animationPlaying flag = false;

animationPlaying flag = true;

Currently, MyCustomShape only has a boolean flag of playing/not playing. I am later going to change this to an enumeration of stopped, hover, playing, not playing, done etc. with different positions of MyCustomShape to be set then.

  1. The above finalPosition looks like still looking at the origin although in the (animationPlaying) if condition, I didn’t ask it to lookAt.
  2. The video position should have come somewhere top left + 100, top Left + 50 but the video is coming in the centre somewhere which I wasn’t expecting after screenToWorld
  3. If you notice, after applying the cam, all the drawn objects look inverted (the circle that you on the above video rectangle if actually topLeft, but after inverting appearing bottomLeft). Is there any way I correct this?

Without the EasyCam here, the video would have appeared at vertex (100, 50, 0) and not inverted, and that is the same thing I am trying to get when it’s inside the cam.

if you want to perform a translate in screen space (e.g. translate right by 10% the width of the screen):

//gets the position in normalised space  
ofVec3f positionInScreenNormalised = myNode.getPosition() * myCamera.getViewProjectionMatrix();  
//the width of the screen in normalised coordinates is 2.0f  
positionInScreenNormalised.x += 0.1f * 2.0f;   
//update the node's world position  
myNode.setPosition(positionInScreenNormalised * myCamera.getViewProjectionMatrix().getInversed());  

I haven’t checked these functions are spelt correctly, so might need some minor modifications.

From here it’s possible to consider moving x and y in screen space by pixel amounts (e.g. divide the amount by the width of the screen and multiply by 2. you might notice you need to multiply the displacement in y by -1.

I am using"">ofxTweenable addon, which I use to extend one of my classes (such as rectangle, circle) and subsequently animate them in their draw functions.

Using the addon is helpful in this case, since the animations are a bit complex to do by manual translation/rotations in the code each time, and also give me a reusable animatable object that I can use. Negating the values such as y to -y and then taking further similar things into account for rotation, etc. looks like making the things complex here.

Also, for a certain section of the above question that I asked in which I have a VideoPlayer inside a camera, I tried to do the following to make it look straight on screen (instead as it looks inverted currently when inside ofEasyCam):

class CustomVideoPlayer : public ofNode  
virtual void customDraw()  
ofVec3f videoPos(365,50,0)  
setPosition(videoPos * cam->getProjectionMatrix().getInverse()); //cam is a pointer passed to this class. Also cam->getModelViewProjectionMatrix()  

The final shape that I get still keeps on looking at the origin point (also inverted inside EasyCam and at the wrong place as well.

I was really hoping for screenToWorld to work for me which would have abstracted a lot of complexities, but probably I am not using it correctly to translate my animation coordinates by calculations into ofEasyCam world coordinates so that it looks similar (cam or no cam)