Ogre3D export of Blender camera?

Hi,



When you export a scene in Blender using the Ogre3D exporter, there is an option ‘Force Camera’, which should export the active Blender camera.



If you check the .scene file that was generated (XML), you find :

node name=“cam1” uuid="…"

… some Node stuff …

… some Game stuff …

camera … … /camera

/node



Problem : I can only access the ‘node’ information…

Node cam1_n= (Node) scene.getChild(“cam1”);

I don’t know how to access the ‘camera’ info; that is : how do I read this XML info into the JME3 Camera object ?



Thanks !

Nobody ???



Maybe my question wasn’t very clear then…

I meant to ask : can you make use of the Blender camera in JME3 (after export with the Ogre3D exporter) ? Or do you have to use the JME3 built-in camera object ?



Thanks !

Not much help but I setup camera from .scene with this code:



[java]



scene = new Scene(app.getAssetManager().loadModel(“Models/city/city.scene”));

scene.SetSceneCamera(app.getCamera(), “Camera01”);





public void SetSceneCamera(Camera cam, String cameraName)

{

Node n = (Node) (((Node) scene).getChild(cameraName));

if (n != null)

{

cam.setLocation(n.getWorldTranslation());

cam.setRotation(new Quaternion(-n.getWorldRotation().getZ(), n.getWorldRotation().getW(), n.getWorldRotation().getX(), -n.getWorldRotation().getY())); // hack?

}

}

[/java]



This works when exporting scene with ogremax, but now tested with blender’s .scene exporter and cam.SetRotation is wrong, camera

looks at the wrong direction (but at least camera’s position is right).

1 Like

But if want to hack some more, use SpotLight and setup its position and direction to the camera, it works.

Thanks for your replies, Larda !



If I understand your code correctly, then you basically take all information of the Blender camera from the export file, and manually adjust the JME3 camera to reflect the Blender settings.

I guess I may have to do it that way as well, but I usually have a whole bunch of Blender camera settings, such as : lens perspective/ortho, focal lenght, depth of field, distance, etc. So I was hoping for some JME3 ‘magic’. :slight_smile:

If you just need to play some 3d visuals do it in blender, else what you say makes not much sense as for a game just having a different monitor aspect ratio will force you to adapt the camera settings.

Hello normen,



Thanks for your reply !

It is for a game… (I hope <he, he>). I was planning to use a fixed ratio + black borders.

My question was really a general question : is it useful to export the blender cam to jme3 ?

I guess my question has been answered by larda : you can export the blender cam, read its settings from the Ogre3D XML-file, and use these to set the jme3 cam…

And I added that it doesn’t make sense cause you only can use the location and rotation data anyway, which you can set with an empty node or something as well.

Oh. I didn’t realize that was the only information that’s exported… Thanks for pointing that out !