chiess Posted June 14, 2013 Share Posted June 14, 2013 Hi, The topic sounds pretty simple and I am sure a few others have asked the same question before, but somehow I couldn't find a proper thread for it. Is it possible to use a loop in an expression? Hscript or Python, doesn't matter. It doesn't work for me at the moment. For example: I have a transform sop and I want a rotation on the z axis, from 0 to 90, starting at a certain frame. I don't want to handanimate it, since the starting frame can be random. for n in range(0, 90): ? How does the syntax look like or how can I even use any form of a loop in an expression? I can't figure it out right now Thank you! Quote Link to comment Share on other sites More sharing options...
WesleyE Posted June 14, 2013 Share Posted June 14, 2013 Doing a for loop in an expression would loop over some set of data, not so much over a couple of frames. What you could do is some linear interpolation between the frames. You could do this in a million ways, and this is one in HScript: 0 + (clamp($F - 10, 0, 10) / 10) * (90 - 0) In psuedo code, this will be: startRotation + (clamp($F - startFrame, 0, duration) / duration) * (endRotation - startRotation) Quote Link to comment Share on other sites More sharing options...
chiess Posted June 14, 2013 Author Share Posted June 14, 2013 Thanks a lot WesleyE! I am not sure how to figure such calculations out... would take me ages I guess. Thanks for the pseudo code, helped me a lot to understand it. Unfortunately I have another question now: How can I save the framenumber when a certain event happens. For example, a point gets the color red in frame 20. I want to save that value in an attrbiute or somewhere else now. Is that possible? $F or $FF don't work, since these would change the value every frame. Quote Link to comment Share on other sites More sharing options...
anim Posted June 15, 2013 Share Posted June 15, 2013 you would need to use Solver SOP or Sop Solver DOP for that or POPs or CHOPs since pure SOPs are not simulation environment therefore they cannot remember values for next frame you can find plenty of examples for any of methods I mentioned on the forums or in help Quote Link to comment Share on other sites More sharing options...
chiess Posted June 15, 2013 Author Share Posted June 15, 2013 Hi Tomas, Thanks for your the quick answer. Yeah I thought so, I just started reading through the help documentation of the solver sop. It seems once I get used to it and understand how to work with it, it will solve many of my current "problems". It's been a while back since I worked with Houdini, thats why it takes me some time to get back into it... besides that, Houdini is anyway different than the other 3D packages . I am slowly learning more and more everyday, but such expressions/calculations as WesleyE mentioned... I don't know how to "create/construct" such math-examples by myself. I probably would remember such calculations when using them many many times and of course start tweaking them for similar problems, but from scratch.... Anyway, thanks! Quote Link to comment Share on other sites More sharing options...
WesleyE Posted June 15, 2013 Share Posted June 15, 2013 Heh, to be honest, I always look up those kind of things myself. Linear interpolation is simply like having a 'slider' between two values where the frame number controls the slider, the clamp makes sure that it only starts 'sliding' between the start and end frames of the animation. The most important is to know what you want, the way you implement those things can be easily found on the net Quote Link to comment Share on other sites More sharing options...
anim Posted June 15, 2013 Share Posted June 15, 2013 (edited) and for many things you already have an expression so if you want just linear interpolation you can use fit() ressions/fit'>www.sidefx.com/docs/houdini12.5/expressions/fit for your case it would be fit(currentFrame, startFrame, endFrame, startRotation, endRotation)[/CODE]so like[CODE]fit($FF,10,20,0,90)[/CODE] Edited June 15, 2013 by anim Quote Link to comment Share on other sites More sharing options...
chiess Posted June 16, 2013 Author Share Posted June 16, 2013 Hey guys, Thanks for your input! I've tried to somehow store the framenumber now, but I am still struggling a lot with it. I don't know why I just can't get over it to fully understand that solver sop I attached a very simple scene again. I basically just want to save the framenumber, as soon as the sphere goes higher than 4 on the z-axis. I am using $F, but obviously it doesn't work with that variable. Any quick hint would be helpful, thanks! Chris storeFramenumber.hip Quote Link to comment Share on other sites More sharing options...
anim Posted June 16, 2013 Share Posted June 16, 2013 here is the example as soon as point z value is higher than 4 it remembers the frame, otherwise the startFrame attribute is -1 storeFramenumber_fix.hip Quote Link to comment Share on other sites More sharing options...
chiess Posted June 20, 2013 Author Share Posted June 20, 2013 Thanks Tomas! I'll need more time to go through your vopsop network. I don't understand all the steps you are doing yet, besides that, I don't seem to find the saved framenumber attrib Quote Link to comment Share on other sites More sharing options...
anim Posted June 20, 2013 Share Posted June 20, 2013 it's called startFrame and it stores the frame when each point first crossed 4 in Z (or whatever condition you want) if you didn't want it per point but for whole sphere, you need to make clear what you mean by "as soon as the sphere goes higher than 4 on the z-axis." center of the sphere? all points of the sphere? etc but principle is the same 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.