SpiderPig Posted March 24, 2019 Share Posted March 24, 2019 How would I transform the following (or any other) vector to a 3D rotation without using a pivot as a buffer? Can the Transform functions be used here or have I already found the easiest way? Calling on any math guys out there... upDirection = Vec3(0.0f, 1.0f, 0.0f); pivotAlignment->AlignToVector(upDirection, 1); Vec3 _rot = pivotAlignment->GetRotation(); //_rot = Vec3(0.0f, 0.0f, 0.0f); physicsParent->PhysicsSetRotation(_rot, 1.0f); I don't want to use a pivot because, well, it just seems ugly. Quote Link to comment Share on other sites More sharing options...
Solution Josh Posted March 24, 2019 Solution Share Posted March 24, 2019 The difficulty here is that a vector does not describe a 3D rotation. You need another term for roll, and your vector you used above demonstrates the exact problem, since it points straight up. Mat4 mat; mat.MakeDir(x,y,z) Quat rotation = mat.GetQuaternion() Note this will still have problems when pointing straight up. 1 Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
SpiderPig Posted March 24, 2019 Author Share Posted March 24, 2019 Thanks. So those problems wouldn't exist with AlignToVector() or Point()? ? Quote Link to comment Share on other sites More sharing options...
Josh Posted March 24, 2019 Share Posted March 24, 2019 Those use the same code internally as this. I'm not sure. The routine might just consider 90,0,0 to be "up" rotation. It will probably work okay. But just know that the engine is making a decision for you because the problem does not have one solution. Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
SpiderPig Posted March 24, 2019 Author Share Posted March 24, 2019 Okay thanks, I'll see how it goes. If it doesn't work well I'll try making a predefined list of rotations for each of the gravity directions. 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.