Rear view mirrors

Hello everyone,



I am developing a truck simulator with JME. I recently took over the project, so forgive me if I ask simple questions ;).



I try to create rear view mirrors for the truck. Since we have a cockpit already my first idea was to make separate ViewPorts for each mirror with a camera pointing backwards. However, the mirrors are not mirrored then. I tried to implement something similar to the SimpleWaterProcessor but failed.



My current approach is to create the mirrors as objects in the world that would then move with the camera. I have created a box with mirroring surface like this:

[java]// Try to use a box as mirror

Box box = new Box(new Vector3f(0f, 5f, 0f), 5f, 5f, 5f);

Geometry mirrorBox = new Geometry(“Mirrorbox”, box);



// ViewPort view3 = renderManager.createMainView(“Right Mirror”, cam3);

SimpleWaterProcessor waterProcessor = new SimpleWaterProcessor(assetManager);

waterProcessor.setReflectionScene(rootNode);

waterProcessor.setDistortionScale(0.0f);

waterProcessor.setWaveSpeed(0.0f);

waterProcessor.setWaterDepth(0f);

// waterProcessor.setWaterTransparency(10f);

waterProcessor.setPlane(new Vector3f(0f, 5f, -5f), new Vector3f(0f, 0f, 1f));



viewPort.addProcessor(waterProcessor);





Material mat = waterProcessor.getMaterial();

mirrorBox.setMaterial(mat);

rootNode.attachChild(mirrorBox);[/java]



This works fine, except the reflection is rotated by 90 degrees to the left. I tried tweaking the Plane of the WaterProcessor without success.



Any suggestions what I’m doing wrong? Or do you think my first approach was the better one? In that case, how would I go about mirroring the camera view?



Thanks for any suggestions,

Thomas