Search Home Members Contacts
About Us
Products
Downloads
Community
Support
Pages: [1]
  Print  
Author Topic: Obtaining Y rotation  (Read 1369 times)
jfberge
Customers
Community Member
*****
Posts: 225


« on: July 09, 2009, 02:54:35 PM »

So, I'm working on a wind animation for my grass minimesh. I'm pretty new to this, so I'm not entirely sure what I'm doing yet. I'd modified a shader I found which produces the desired sinusoidal sway, but because all of the grasses are rotated in random directions, they all sway in different directions.

I obviously need to factor in the rotation for the given minimesh, but I'm not sure where that is. I'm guessing it's available via a semantic of some type, embedded in a matrix. Make any sense? I'll figure this out eventually...
Logged

It works on my machine
Zaknafein
Customers
Community Member
*****
Posts: 2940


WWW
« Reply #1 on: July 09, 2009, 03:34:55 PM »

There is no semantic for the rotation matrix alone... you have the World matrix, which is a combination of translation, rotation and scaling. (see this page for all supported semantics in TV3D)

BUT, if your mesh isn't scaled, you can extract the rotation matrix from the world matrix.
By casting the world matrix to a 3x3, you get the combination of rotation and scaling. If scaling is an identity, you get rotation.

Then the sinusoidal offset would be a push in the X or Z direction, but transformed by this rotation matrix, which makes it relative to its current orientation.
Logged

jfberge
Customers
Community Member
*****
Posts: 225


« Reply #2 on: July 09, 2009, 03:50:59 PM »

BUT, if your mesh isn't scaled, you can extract the rotation matrix from the world matrix.
By casting the world matrix to a 3x3, you get the combination of rotation and scaling. If scaling is an identity, you get rotation.

Rats. My meshes are all different scales, too. Perhaps I'll just break up the groups into something like 7 minimeshes with each one having a discrete rotation (45 degree units). That'll still make things look somewhat random, and I can add a small variance to them all.

I really need to master my 3D maths. I feel like I'm close to it all finally clicking.

Thanks for the advice, Zaknafein!
Logged

It works on my machine
jfberge
Customers
Community Member
*****
Posts: 225


« Reply #3 on: July 13, 2009, 01:39:23 PM »

I found a compromise - stashing the rotation values in the Minimesh Color. It's dirty, but works nicely. I was only using the color for darkening the meshes, so there's still a float free to do that.

Now I just need to seed the plants with different time values so they aren't all in perfect unison.
Logged

It works on my machine
Pages: [1]
  Print  
 
Jump to:  

Powered by SMF 1.1.3 | SMF © 2006-2007, Simple Machines LLC
Seo4Smf v0.2 © Webmaster's Talks