Capturing an additional camera perspective in ofEasyCam environment as a texture


#1

I’m currently working an a simulated 3D environment, in which an ofEasyCam is being used for the main viewport. I would like to add an additional camera from a static perspective that i can output via ofxSyphon as an ofTexture and i’m wondering what the best way to go about this is. I’ve looked into FBO’s and various version of ofCamera and i’m having trouble finding something with the functionality i need. Any help is appreciated!


#2

Hi, you need to "render"the scene for each camera, something like
assuming that this is in ofApp.

void ofApp::drawScene(){
/// whatever code needed to draw the scene.
}
void ofApp::draw(){
easyCam.begin();
drawScene();
easyCam.end();

fbo.begin();
otherCam.begin();
drawScene();
otherCam.end();
fbo.end();
syphonServer.publishTexture(&fbo.getTexture());//syphonServer is an instance of ofxSyphonServer
}

#3

Thanks! I’ll give it a shot!


#4

That did work for me, thanks! I’m getting the camera feed through Syphon but now there are two more issues.

First, is that the syphon output is basically an aggregate of every frame, superimposed into the same image (ghosting sort of). I’m guessing i just need to clear something but i’ve tried a few methods with no luck.

Second, one of the objects in my environment is a syphon texture from another program, but the syphon camera is seeing as a solid white quad, rather than the texture which is showing properly on my primary ofEasyCam. I’m attempting to create a virtual feedback loop, essentially.

//--------------------------------------------------------------
void ofApp::drawScene(){
/// whatever code needed to draw the scene.

ofEnableDepthTest();
ofEnableAlphaBlending();

sim.draw();

//Draw the Syphon feed as the back of the cube
mClient.draw(ofPoint(-1200,-1200,-1200),ofPoint(1200,-1200,-1200),ofPoint(1200,1200,-1200),ofPoint(-1200,1200,-1200));
}

//--------------------------------------------------------------
void ofApp::draw(){
ofxLaserSim::Mirror * m = sim.getMirror(0);
ofxLaserSim::Beam * b = sim.getBeam(0);

ofVec3f targetPos = cam.getTarget().getPosition();

fbFbo.begin();
feedBackCam.begin();
drawScene();
feedBackCam.end();
fbFbo.end();
ofClear(0, 0, 0);

cam.begin();
cam.lookAt(targetPos);
drawScene();
cam.end();

syphonServer.publishTexture(&fbFbo.getTexture());

#5

Hi, no idea about the syphon texture youre not getting back.
as from the code you posted, ofClear(0,0,0,0); needs to go in between fbo.begin() and fbo.end(). It usually goes right after fbo.begin();
Have you tried making a feedback loop but without the FBOs?


#6

That fixed the ghosting/refresh, thanks! Looks like something related to a bitmap string at the end of the draw function was causing the white layer, when i hide the info string i see the texture properly