jerome Posted May 6, 2015 Share Posted May 6, 2015 Hello, AFAIK, many users (and sometimes I) face the same rotation complex problem :they've a got a mesh, just created in its local space, and they want it somewhere else (quite easy with .position attributes) with another orientation. Another orientation is the problem. What does BJS do so far ?It provides many methods to rotate a mesh, it is to say, under the hood to set up the mesh world transformation matrix (translation, rotation, scale) and they apply it to get the result. But, usually, the user doesn't really know how much he has to rotate his mesh and relatively to what (translation and scaling are quite obvious, not rotations).He only knows that he wants his mesh at this final position with, say, its length aligned on the box-sphere axis, its width in the plane x0z and its depth facing this other mesh, etc.In other terms, the user usually knows the final result he wants and not how to get it. We can assume he knows then the new translated/rotated local system coordinates in the world : he knows the position of his mesh (the wanted new origin) and its orientation : 3 orthogonal vectors in the world describing the new mesh orientation (remember : the length aligned with box-sphere axis could be the new local X axis , etc ) So, since BJS is simple and powerful, maybe do we need some locate() function (any better name welcome) to set up the underlying rotation layers given a target orientation (axisX, axisY, axisZ) ? ex : I want a plane set at (5, 5, -2) with its width aligned with the (1, 2, 0) axis, let's call it a, and its length in the plane yOa.I definetly don't know how to rotate my plane to get this... so I'd like to do :var plane = BABYLON.CreatePlane("plane", 10.0, scene);// creates a plane as usualvar origin = new BABYLON.Vector3(5, 5, -2); // sets the target positionvar axisX = new BABYLON.Vector3(1, 2, 0); // sets 3 orthogonal axis to define the target orientation var axisY = BABYLON.Vector3.Cross(axisX, BABYLON.Axis.Z);var axisZ = BABYLON.Vector3.Cross(axisX, axisY);plane.locate(origin, axisX, axisY, axisZ); // locates the mesh at this position with this orientationI guess I could code this if someone would tell me please what is the BJS order for rotation matrices application under the hood :Rx * Ry * Rz ?Rz * Ry * Rx ?something else ? Not sure I'm very clear Wingnut 1 Quote Link to comment Share on other sites More sharing options...
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.