Blender CameraNodes control direction [PATCH]

@Kaelthas Now that the blender loader creates CameraNodes, the default control direction is CameraToSpatial which is the wrong direction. This patch fixes it.



[patch]Index: src/blender/com/jme3/scene/plugins/blender/cameras/CameraHelper.java

===================================================================

— src/blender/com/jme3/scene/plugins/blender/cameras/CameraHelper.java (revision 9717)

+++ src/blender/com/jme3/scene/plugins/blender/cameras/CameraHelper.java (working copy)

@@ -3,6 +3,7 @@

import com.jme3.asset.BlenderKey.FeaturesToLoad;

import com.jme3.renderer.Camera;

import com.jme3.scene.CameraNode;

+import com.jme3.scene.control.CameraControl;

import com.jme3.scene.plugins.blender.AbstractBlenderHelper;

import com.jme3.scene.plugins.blender.BlenderContext;

import com.jme3.scene.plugins.blender.exceptions.BlenderFileException;

@@ -78,7 +79,7 @@

aspect = ((Number) structure.getFieldValue(“ortho_scale”)).floatValue();

}

camera.setFrustumPerspective(45, aspect, clipsta, clipend);

  •    return new CameraNode(null, camera);<br />
    
  •    return new CameraNode(null, new CameraControl(camera, CameraControl.ControlDirection.SpatialToCamera));<br />
    

}



/**

@@ -109,7 +110,7 @@

aspect = ((Number) structure.getFieldValue("ortho_scale")).floatValue();

}

camera.setFrustumPerspective(aspect, camera.getWidth() / camera.getHeight(), clipsta, clipend);

  •    return new CameraNode(null, camera);<br />
    
  •    return new CameraNode(null, new CameraControl(camera, CameraControl.ControlDirection.SpatialToCamera));<br />
    

}



@Override

[/patch]

4 Likes

You’re right again :slight_smile:

Wow man thanks for controlling such stuff.



I didn’t check it and assumed that by default camera will use spatial’s transform and not the other way.

This is done this way with LightNode so I thought that it will be done here the same way.



But maybe it would be better to change the CameraControl and give it a different default value.

Could someone explain why CameraControl has control direction from camera to spatial used as default value instead spatial->camera ???

It’s has been contributed like this from the beginning, and changing it now would mean breaking user code.

I agree it’s more intuitive the other way around.

When I made the LightNode on the same model, I must have overlooked this and just set it to the intuitive default. Both should be consistent in their behavior though…

I think it is OK to change that even if it breaks user’s code.

JME is still being developed and all people who use it should be aware that such changes might occur :slight_smile:



Of course it is only a suggestion. If you decide not to change it then I’ll make a fix in my piece of code.

1 Like

No you’re right…this thing bothers me each time I use it.



Can you change it and commit?

OK, I’ve made a commit.

2 Likes

Thanks :wink:

@Kaelthas said:
OK, I've made a commit.


I think you should also change the default values in CameraControl.read() and write() methods to match the new default.

But these were already OK.

They are set to ControlDirection.SpatialToCamera.

Only the default value in the CameraControl class was different and I changed it.

@Kaelthas said:
But these were already OK.


Oh, you're right - sorry. So that itself was an existing bug :) (that the read/write defaults did not match the real default)