JulienGobin Posted January 23, 2014 Share Posted January 23, 2014 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). Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted January 23, 2014 Share Posted January 23, 2014 Hum here how I compute the target position according to camera rotation in blender: invWorld = object.matrix_world.copy() invWorld.invert() target = mathutils.Vector((0, 1, 0)) * invWorld Quote Link to comment Share on other sites More sharing options...
gwenael Posted February 5, 2014 Share Posted February 5, 2014 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. Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted February 5, 2014 Share Posted February 5, 2014 We can change this behavior guys Just let me know your ideas gwenael 1 Quote Link to comment Share on other sites More sharing options...
khmm12 Posted February 19, 2014 Share Posted February 19, 2014 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) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.