art3mis Posted October 17, 2019 Share Posted October 17, 2019 (edited) 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 October 18, 2019 by art3mis Quote Link to comment Share on other sites More sharing options...
art3mis Posted October 18, 2019 Author Share Posted October 18, 2019 (edited) 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 October 18, 2019 by art3mis Quote Link to comment Share on other sites More sharing options...
ThomasPara Posted October 18, 2019 Share Posted October 18, 2019 matrix3 m = ident(); vector axis = set(0,1,0); float angle = radians(chf("angle")*360); rotate(m,angle,axis); @P *= m; @N *= m; When you rotate the @P you also need to rotate the @N, or else it will look like the light is baked. Quote Link to comment Share on other sites More sharing options...
art3mis Posted October 18, 2019 Author Share Posted October 18, 2019 (edited) 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 October 18, 2019 by art3mis Quote Link to comment Share on other sites More sharing options...
toadstorm Posted October 18, 2019 Share Posted October 18, 2019 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. Quote Link to comment Share on other sites More sharing options...
art3mis Posted October 18, 2019 Author Share Posted October 18, 2019 Thanks Henry. So a little more complicated than expected. So will try to integrate @Time into Thomas example to make dynamic. 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.