Camera in .blend and in a .scene

Probably I did in the past a similar question, but I think with no replay, so I want to try to ask again givin more information.
Target is always my 2.5D engine with static fixed cameras.
In blender I’ve a scene with 1 (or more) camera/s. In JME I must have the same scene with the camera’s identical (so same position, same orientation
and same intrinsic properties such focal length etc…).
I can achieved it in 1 way, in pratical:

  1. I upload the scene in .blend format.

  2. With scene visitor whenever I find a CameraNode instance I save it.

  3. I change the CameraNode orientation (I don’t know why I must do it… but I must do :D)
    in this way (assuming q is original camera node orientation): -q.getZ(), q.getW(), q.getX(), -q.getY();

  4. I copy the camera inside the camera node to the scene camera (camera.copyFrom(camNode.getCamera()).

In this way It works, but I don’t like it for several reasons:

  1. Not good to import directly .blend scene
  2. As I understood It will be not supported for Android (in future I will try it).

So, it would be better to do it with a .scene file.

I tried to keep the same code of .blend case, but is not good the outcome. Even because with a .scene I’ve information about the camera node but not about the camera.

I’m a bit (a lot :D) confused, so I think that best stuff would be to understand relationship between .blend and .scene and how I can obtain the same result.

Does someone have some good advices for best strategy for do this?

@JESTERRRRRR - i think you also need it :smile:

Thanks very much

Uhm, just convert the blend to j3o as you’re supposed to?

So you mean to do this directly without passing from .scene file?
In this case intrinsic camera information are kept? Does I need to change something from original code (obviously except
the usage

I think I tried it in the past and maybe I got some troubles but I will try it again, mybe I did some mistakes.

anyway this is my old (and working) code:

/* Fields. */
CameraNode cameraNode = null;

/* State initialize code. */
BlenderKey roomKey = new BlenderKey(sceneFile);
Spatial sceneSpatial = assetManager.loadModel(roomKey);
Node sceneNode = new Node("SceneNode");

locationNode.depthFirstTraversal(new SceneGraphVisitor() {
    public void visit(Spatial s) {
		if (s instanceof CameraNode) {
			cameraNode = (CameraNode) s;

Quaternion rot = cameraNode.getLocalRotation();
cameraNode.setLocalRotation(new Quaternion(-rot.getZ(), rot.getW(), rot.getX(), -rot.getY()));

/* State update code. */
if (cameraNode != null) {

In this case so I need only to give to .j3o converted from .blend file?

I take this opportunity for another little question, you can see that I copy the camera from .blend to current camera every frame. Infact I saw that I need to do this
otherwise If I do only in the init the camera is not updated with new settings, do you know why? Because I think is not so good do in this way.

Thanks a lot again, is very nice too see a forum where user are supported so much :slight_smile:

You can use any way you prefer to create j3o files. They contain the complete scenegraph as you get it when you load a model file directly, no matter from which format.

As for your cam problem, you probably still have the FlyCam enabled. Just detach the FlyCamAppState or provide your own set of AppStates with the app constructor.

1 Like

Ok I solved it! Problem was that after the j3o import parallel projection was enabled and it needs to be disabled.
For the cam update even, was not a problem of FlyCam but the camera node must transfer its rotation to the camera itself, so was enough to call an updateLogicalState from the cam node and than copy the camera to the real camera!
Now only little problem is that if camera is tha. Orientation around x (or z axis i dont remember) is not taken well (this even from direct .blend import) but this is not so important, I can avoid it for now and maybe check it in the future.
Thanks very very much, now I have all that I need for re-create my 2.5D hybrid engine in a performin and flexible way.

Looks like you simply forgot to attach the node to the scene… No need to call updateLogical manually.