jjstanley Posted August 11, 2006 Share Posted August 11, 2006 I am working on a flame with sprites and was wondering how to rotate sprites. I want the flame to flow around an object. I used the scale attribute to have the sprite long and narrow and then go to square as it gets older which looks very good! The only problem is that as it moves around the object they still stay vertical. Is there a way to have them rotate with the direction of their flow? It seems like I saw this somewere but can't find out how now Quote Link to comment Share on other sites More sharing options...
hoknamahn Posted August 11, 2006 Share Posted August 11, 2006 You need to change a Rotate parameter of a Sprite POP or to generate spriterot attribute in a way you want. Try something like atan($VX / $VY) I haven't tried but maybe this will make the trick. But as sprites are 'working' in the 2d space it can be necessary to calculate 2d velocity vectors in NDC and then to calculate right rotation. Quote Link to comment Share on other sites More sharing options...
doc Posted August 11, 2006 Share Posted August 11, 2006 I am working on a flame with sprites and was wondering how to rotate sprites. I want the flame to flow around an object. I used the scale attribute to have the sprite long and narrow and then go to square as it gets older which looks very good! The only problem is that as it moves around the object they still stay vertical. Is there a way to have them rotate with the direction of their flow?It seems like I saw this somewere but can't find out how now Just talking out my ass here, but you start by combing normals on the collision object to point in the direction you want the flames to go. Then you could use attribute transfer to transfer these normals to your points. Then you could use dihedra()l or lookat() to get the rotation required rotate the sprite accordingly. hope that helps Luca Quote Link to comment Share on other sites More sharing options...
hoknamahn Posted August 11, 2006 Share Posted August 11, 2006 Hey Doc! It's a good idea about normals of collision object and angel between them and ... what do you propose to use as second vector? Can you post an example? And how to get an angel in properly space (screen space)? Quote Link to comment Share on other sites More sharing options...
doc Posted August 11, 2006 Share Posted August 11, 2006 Hey Doc!It's a good idea about normals of collision object and angel between them and ... what do you propose to use as second vector? Can you post an example? And how to get an angel in properly space (screen space)? I usually use (0,0,1) as my second vector. I've attached an example of the dihedral expression, I'm sure you can do the same thing in vops, just multiply the matrix from the dihedral expression with P. I seem to remember that there are certain circumstances where the dihedral expression breaks down( can't remember what they are exactly) so you may want to use mlookat instead. hope that helps Luca dihedral.hip Quote Link to comment Share on other sites More sharing options...
hoknamahn Posted August 11, 2006 Share Posted August 11, 2006 That's great... but we still have a 3d rotation and sprites requires 2d. So I guess we need to transform rotation somehow from object space to screen space and use then Z component of rotation. So sleepy now. Better I'll go to bed Quote Link to comment Share on other sites More sharing options...
doc Posted August 11, 2006 Share Posted August 11, 2006 That's great... but we still have a 3d rotation and sprites requires 2d. So I guess we need to transform rotation somehow from object space to screen space and use then Z component of rotation. So sleepy now. Better I'll go to bed Hmmm... if you do N-dot(directionFromCamera,N)*normalize(directionFromCamera) I think that will give you a vector that is in the plane of the camera. Not 100% sure though, my math's al ittle rusty. Hope that helps Luca 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.