normal Tool with mirror

19 Mar 2016 10:01 #1

I would like to create a tool that has a mirror at its end.
Following the example 23-tooth I created a secondary camera and attached it to my mirror tool.
Then I created a frameBuffer but I don't want to use it in a cViewPanel like in the example.

    // attach mirror to tool

    // create secondary camera for side view
    cCamera* cameraTool = new cCamera(world);

    // attach camera to tool
    cameraTool->setLocalPos(0.0, 0.0, 0.1); 

    // create framebuffer for side view
    frameBuffer = cFrameBuffer::create();

I would like to apply the frameBuffer as a texture on my mirror tool (or maybe at one of its child objects), so it would appear as a real mirror that changes view in run-time. Is there a way to do something like that ?

This of course doesn't work because of the wrong casting, but it gives an idea of the goal:

Thank you very much in advance.

Please Log in or Create an account to join the conversation.

22 Mar 2016 00:17 #2

You can create a mirror by using a cMesh object and by assigning the texture to the framebuffer:

    // create mirror
    cMesh* mirror = new cMesh();

    // add mirror to world

    // create disc
    cCreateDisk(mirror, 0.2, 0.2);

    // assign framebuffer texture

    // enable texture rendering

    // disable material properties

To generate the mirror framebuffer image, you could try to attach a camera to the mirror by keeping in mind that you will probably have to adjust its position and orientation according the angle between the surface normal of the mirror and the location of the viewer.

You can check example 23-tooth to see how to create the camera and framebuffer. You will also need to render the framebuffer view before the camera view.
    // render framebuffer

    // render world
    camera->renderView(windowW, windowH);

Please Log in or Create an account to join the conversation.

25 Mar 2016 08:54 #3

That's what I needed :

// assign framebuffer 

Thank you. I'll check out the angle now.

Please Log in or Create an account to join the conversation.

25 Jan 2017 09:14 #4

I want to create an object with mirror at the end, too. But my device is custom device with non-actuated rotation.

When I add a camera to the tool image and render the frame buffer, I get a picture from another viewpoint which I don't know the logic of its place and for some small time I get frames from the real position of the camera. In other words I get some blinks from real position of camera.

Anybody knows what the problem is?

Please Log in or Create an account to join the conversation.

26 Jan 2017 18:47 #5

You will have update the orientation of the camera on the mirror according to the position of the camera rendering the full scene so that the reflection angle is consistent.

Regarding the device orientation, does your device support orientations? From you message its sounds like your device support 3-DOF in translation.

Please Log in or Create an account to join the conversation.