[Closed] Storing position/rotation
Hello again,
Part of my ongoing project involves a circular saw that will be turned on/off, on several occasions throughout the short. What I’ve done is set up a custom slider in the scene that works on a expression where “if the value of the slider is beyond 50%, then the saw will rotate in a continuous loop using an expression involving MOD”. The reason for this is so that I can control the speed of the rotation through the mod value and force it to rotate continuously in real time which is working perfectly. Now I’m taking it a step further and creating a separate window interface that will control the two dozen functions of this robot that I have so far, thus saving the trouble of constantly moving the viewport, zooming in/out and taking up valuable space, every time i need to get to the controllers.
What I've done now is set up a checkbutton on the interface that allows me to turn the slider to 100% and back to 0% and this works great, but now here is where the problem comes in: I need to know how to store the blade's end rotation degree value, the reason for this is because when I stop the saw, the slider jumps back to 0% and the blade jumps back to its 0% rotation value, so when motionblur is applied you get a very heavy blur for the last few frames. The reason is because this blade will continue rotating towards infinity, so when i decide to stop it after a while; say after it gets to about -60000 X value rotation and all of a sudden jumps back down to it's default 150 X value rotation, it causes the heavy blur.
So I basically need to know how to store it's last X rotation degree, so that it stops rotation at the point I made it stop instead of reverting back to default, and when i run it again, it continues from its end position.
Here's what I have for the expression controlling the looping rotation of the blade.
if(SpinLoop>.5,mod(NT*-400,6.25),0)
[i]Simplified[/i]
"SpinLoop" is the variable for the slider that enables/disables the reloading loop i mentioned above
-400=Rotation Speed
6.25=Rotation Limit (full 360 rotation according to my calculations)
And this is the maxscript I am working on(simplified with just the current issue)
Note: Arc08 is a dummy that controls the X rotation of the blade.
C.Saw Controller-spin loop is the full path for the slider that I used the variable for above. I chose to go with its local position to turn it on/off rather than percent.value.
macroScript CanBot Controller Interface category:"My Tools"
(
rollout window "CanBot" width:250 height:100
(
groupBox grp1 "On/Off" pos:[5,5] width:240 height:90 enabled:true
checkButton ckb1 "Saw Rotation Toggle" pos:[57,26] width:136 height:48 highlightColor:(color 0 255 0)
on ckb1 changed state do
if state== on then
move $'C.SAW Controller-Spin Loop' [123.843,0,0]
else
move $'C.SAW Controller-Spin Loop' [-101.886,0,0]
rotate $Arc08 (angleaxis 181 [0,0,1])
)
createDialog window width:250 height:100
)
If I did not explain this clearly, please let me know and I'll try my best to rephrase it.
I would have to see what you are doing but I can tell you it isn’t the right way. What you need to do is use the slider as a rate of rotation so that it is keyed to the rate of change in the frames. Each frame the amount of rotation needs to be added to the saw. So what you have is something like this.
theSawRotation+=(frame-lastFrame)*slider
What I’ve tracked it down to is the expression I’m using that’s wrong as well. Basically I’m using the expression as a motor (like the one in reactor that continuously rotates) that drives the blade to rotate in real time.
So customslider1 is doing precisely what you mentioned and controls the rotation of the blade a full 360 Degrees as it reaches 100%. Now the expression controller is applied to customslider1 and the expression looks to see if customslider2(power on/off type switch, 0-50%=off and 50-100%=on) has its value above 50% and if it does, it will perform the mod expression, which causes the blade to rotate to 6.25 (or 625% of customslider1, which results in a full rotation) and then the mod value resets it back to 0% and does it all over again, resulting in a looping sequence. This loop still runs even without any keyframing at all.
The problem is that I used NT to automate the rotation so it follows the world NT scale and tends to jump from one location to another rather than counting from when it’s activated. For example, if i activate it at frame 0, it does a smooth rotation till i stop it but if i activate it at frame 10, it suddenly jumps 45 degrees(because NT started at frame 0) and continues running smoothly after that.
I have attached a simplified file for the blade if it makes it easier to understand. Thanks again for the help.
So this is where you need to do my suggestion and have it rotate a given angle each frame, this would be additive and not absolute so it would keep rotating. Problem with this method is when it comes to rendering you either have to render it on one machine or bake the animation on it. I usually go with the baking option and build that into the script. We used the same method for the Heli on Roary the Racing Car.
Thanks Paul, I tried to the best of my knowledge to understand but unfortunately, I really don’t know how and where to use what you have suggested.
I found a temporary fix to the issue with vray by dragging down motion blur to .1 frames which works really well; but hiding the problem isn’t helping me in any way.
I would love to understand how to do this properly so I can use it elsewhere.
loocas created a rig to do additive rotation in this thread here. It may help with what you are trying to do.
-Eric
Thanks a lot Eric, I am looking at his script piece by piece trying to understand what he’s done. Although the setup he’s used is really nice, I will try to implement his method in my interface, so I can at least learn something from it.
So I decided to go a different path while trying not to over think this problem and discovered a much easier solution.
This method involves integration into a UI Dialog that I’m already using on my secondary monitor, to make view port navigation a less frustrating experience.
This method also uses interval key framing which prevents the problem Paul mentioned earlier about rendering over a farm; which in my case is true because I plan to own some nodes by the time I’m done this project, so might as well prepare for it now.
Thanks again for the help guys and hopefully someone in the same situation as myself will find this useful.
macroScript TEST
macroScript TEST
category:"My Tools"
(
rollout window1 "TEST1" width:200 height:100
(
[b]timer[/b] tmrspeed "" interval:10 active:false
[b]checkbutton [/b]chkpower "Power" pos:[20,5] width:50 height:44
[b]spinner [/b]spnspeed "Speed" pos:[100, 25] width:70 height:70 range:[0,40,(tmrspeed.interval)]
--Control Blade Rotation Speed
[b]on [/b]spnspeed changed state [b]do[/b]
tmrspeed.interval=spnspeed.value
--Enable Timer Upon Button Press
[b]on [/b]chkpower changed state [b]do[/b]
[b]if [/b]state==true [b]then[/b]
tmrspeed.active=true
[b]else[/b]
tmrspeed.active=false
--Rotate Blade on Timer Interval
[b]on [/b] tmrspeed tick [b]do[/b]
rotate $Blade (angleaxis 10 [0,0,1])
)
createDialog window1 width:200 height:100
)