Jump to content

Dynamically rotate geometry via VEX


art3mis

Recommended Posts

So as a starting point am using VEX code from this thread but so far not working.

 

I need to dynamically rotate geometry in VEX (the geometry is constantly rotating)  and change the speed of rotation via a float parameter.

I also tried this fairly simple code from cgwiki which gives me a constant rotation but am unable to dynamically alter the rate of rotation

matrix3 mat = ident();
float angle = atan(@P.x, @P.y);
float r = length(set(@P.x, @P.y));//*chf('amount');
 
@P.x = sin(@Time+angle)*r ;
@P.y = cos(@Time+angle)*r;

 

 

 

Edited by art3mis
Link to comment
Share on other sites

So managed to get this working but one curious glitch however is that the in the viewport it appears the lighting is 'baked'. When my geometry is rotating it appears as if the light is rotating with it.  If I try and manually alter the rotation in the Transform this doesn't happen.

matrix3 mat = ident();
float angle = atan(@P.x, @P.y);
float r = length(set(@P.x, @P.y));//*chf('amount');
 
@P.x = sin((@Time*chf('amount'))+angle)*r ;
@P.y = cos((@Time*chf('amount'))+angle)*r;

 

Edited by art3mis
Link to comment
Share on other sites

Thanks!! I figured something to do with normals. But in my case would it simply be adding?

@N=@P;

Another thing I was wondering is if it is possible to determine the current RPM value using my above VEX code?

Edited by art3mis
Link to comment
Share on other sites

Setting N to P would only be a good idea if you're rotating a unit sphere. Otherwise your normals aren't going to be normalized, and may possibly make no sense when rendering or displaying.

Thomas is correct in that you should update the normals as well as P... multiplying by the same matrix (and possibly normalizing afterwards to be safe) is a good choice. The Deformation Wrangle SOP will update normals and other vector attributes automatically, if you want to give that node a shot... it requires slightly different syntax.

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...