sadboy Posted November 16, 2020 Share Posted November 16, 2020 Does anyone know how to rotate an object around its velocity vector while it is still pointing into the direction of its velocity in vex? Maybe it is easier in vops, but it would help me understand better the underlying math behind it with vex. Quote Link to comment Share on other sites More sharing options...
dandeentremont Posted November 17, 2020 Share Posted November 17, 2020 Are you using "@v" and "@up" to orient your object, or "@orient"? Quote Link to comment Share on other sites More sharing options...
Ultraman Posted November 17, 2020 Share Posted November 17, 2020 10 hours ago, dandeentremont said: Are you using "@v" and "@up" to orient your object, or "@orient"? https://www.tokeru.com/cgwiki/index.php?title=JoyOfVex17 1 Quote Link to comment Share on other sites More sharing options...
dandeentremont Posted November 17, 2020 Share Posted November 17, 2020 (edited) Well, if you have just the @v and @up, it's not the most ideal to create a spinning around v axis, because the orientation tends to get wonky when the v vector gets near the up vector. Either way, here's a poor man's setup I use: //This method may result in fast flipping if the particles do loop-de-loops //v@up = {0,1,0};//set this if you don't already have an up attribute vector forward = normalize(v@v); //create a quaternion rotating about the forward axis over time vector4 rotQuat = quaternion(@Time*10, forward); //use qrotate to rotate a vector by the quaternion v@up = qrotate(rotQuat, v@up); Using @orient is better because you don't have to worry about zero velocity situations or up vectors, but it requires some extra setup during the sim process (Assuming it's POPs) Edited November 17, 2020 by dandeentremont simplified code 1 Quote Link to comment Share on other sites More sharing options...
sadboy Posted November 17, 2020 Author Share Posted November 17, 2020 thank you dan and ultraman. I am using @orient. I ended up using a matrix rotate (in vops) along the velocity vector with a random rotation per id, then converting it to a quaternion. The vex approach you posted makes a little bit more sense. Im going to give it a try! I need to brush up on my linear algebra lol. thank you so much again! 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.