DezOnlyOne Posted October 30, 2015 Share Posted October 30, 2015 Right now I am trying to figure out how to make my character's eyes rotate and orient towards a camera. I am attaching my babylon file to this, but what I am hoping to do is create a lookAt function for the eyes. Is there an easy way that I can set the local rotation for the eyes so that they follow the camera, or any object in 3d space? The pivot point of the eyes is in the center of the eyes so they should rotate without a problem. I realize that the idea of the forum is to contribute to the solution as well, but I am a little lost as to where to start. Is there some information on the web that can help as well? Thanks. I attached the babylon file in case anyone wanted it. content.zip Quote Link to comment Share on other sites More sharing options...
RaananW Posted October 30, 2015 Share Posted October 30, 2015 Billboard mode will keep a mesh always pointing at the (free) camera. For example - http://www.babylonjs-playground.com/#OKRRCPlay around and see what it means. Can be useful for your eyes-meshes as well, I guess. Quote Link to comment Share on other sites More sharing options...
iiceman Posted October 30, 2015 Share Posted October 30, 2015 The .lookAt() method could be an alternative to Billboard mode. Quote Link to comment Share on other sites More sharing options...
DezOnlyOne Posted October 30, 2015 Author Share Posted October 30, 2015 The lookAt function seems to work for keeping the eyes rotated. Is there aw way to apply lookAt to its local rotation? They look directly at the camera, but they fly around outside of my characters. skull. Fitting for Halloween I suppose. This is the function I am usingfunction look(mesh, pos) { mesh.lookAt(new BABYLON.Vector3(pos.x, pos.y, pos.z), 0, -Math.PI / 2, 0);};Billboard had similar results, but the eyes were facing to the right. Quote Link to comment Share on other sites More sharing options...
jerome Posted October 31, 2015 Share Posted October 31, 2015 You can also get the wanted rotation with RotationFromAxis(). This allows you to compute the needed rotation to apply to something to rotate it up to the target system orientation. This target system can be 3 the axis : eye-cam / Y / 3rd orthogonal vector http://doc.babylonjs.com/overviews/How_Rotations_and_Translations_Work => "generating a rotation from a target system" part demo : http://www.babylonjs-playground.com/#VYM1E#5 Quote Link to comment Share on other sites More sharing options...
iiceman Posted October 31, 2015 Share Posted October 31, 2015 Maybe try to bake the current transformation before using look at. http://doc.babylonjs.com/classes/2.2/Mesh#baketransformintovertices-transform-rarr-void Or maybe setting a pivot matrix to avoid the offset around the pivot point: http://doc.babylonjs.com/classes/2.2/AbstractMesh#setpivotmatrix-matrix-rarr-void 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.