Jump to content

Camera rotation error during Blender Export


JulienGobin
 Share

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 :

14012306103778327.png
 

(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 :

140123061104639066.png

 

(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)

post-6992-0-27067600-1392833828_thumb.pn

post-6992-0-97142700-1392833835_thumb.jp

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.

Guest
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.

Loading...
 Share

  • Recently Browsing   0 members

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