Jump to content

Camera rotation error during Blender Export


Recommended Posts

Maybe related to this first problem : http://www.html5gamedevs.com/topic/3159-quaternionrotationyawpitchroll-parameters-and-toeulerangles-result-should-be-the-same/

When i try some rotation-exportation from blender to babylon i found a problem. Here my scene in blender :


(download here : http://dfiles.eu/files/m1dcdze18)


As you can see the camera is not looking toward the object. but when i import the full scene on babylon js i can see this :



(download here : http://dfiles.eu/files/w4etjfuh6)



Looking deeper in the .babylon it seems that the exporter set a target on the camera (and not a rotation ?).

"cameras": [{    "name": "Camera",    "id": "Camera",    "position": [4.0000,    1.5000,    4.0000],    "target": [0.0000,    -1.0000,    0.0000],    "fov": 0.8576,    "minZ": 0.1000,    "maxZ": 100.0000,    "speed": 1.0000,    "inertia": 0.9000,    "checkCollisions": false,    "applyGravity": false,    "ellipsoid": [0.2000,    0.9000,    0.2000]}],

And it seems that this target is actually set in the camera during the parsing (in babylon.sceneLoader)

var parseCamera = function (parsedCamera, scene) {    var camera = new BABYLON.FreeCamera(parsedCamera.name, BABYLON.Vector3.FromArray(parsedCamera.position), scene);    camera.id = parsedCamera.id;     // Parent    if (parsedCamera.parentId) {        camera._waitingParentId = parsedCamera.parentId;    }    // Target    if (parsedCamera.target) {        camera.setTarget(BABYLON.Vector3.FromArray(parsedCamera.target));    } else {        camera.rotation = BABYLON.Vector3.FromArray(parsedCamera.rotation);    }

And ... strangely the target position is not rightly set according to the blender camera rotation matrix (but i dont look deeper inside the blender exporter).

Link to comment
Share on other sites

  • 2 weeks later...

According to this code, I would say that Deltakosh, you always set the target to be on the world Y axis (1 unit from the origin) and you express it in the camera space. That's why JulienGobin your camera will always first look at this point whatever the rotation of your camera in Blender.


Y in BabylonJS is Z in Blender.

Link to comment
Share on other sites

  • 2 weeks later...

Using rotation instead target working very well  :)

rotation = mathutils.Vector((-object.rotation_euler[0] + 1.570796326794897, object.rotation_euler[1], -object.rotation_euler[2])).........Export_babylon.write_vector(file_handler, "rotation", rotation)



Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...