Animation in SketchUp
-
@morisdov said:
I think its best to stay with the native API timer with its limitation of firing every one second,
Huh? I'm using
UI.start_timer( 1.0/fps, true )
(fps usually 25) and getting nice, smooth animations. -
@martinrinehart said:
@morisdov said:
I think its best to stay with the native API timer with its limitation of firing every one second,
Huh? I'm using
UI.start_timer( 1.0/fps, true )
(fps usually 25) and getting nice, smooth animations.Did a quick test:
t=Time.now; i=0;id = UI.start_timer(1.0, true) { puts Time.now - t; i+=1; UI.stop_timer(id) if i > 9 }; 826 1.015 2.027 3.041 4.056 5.07 6.085 7.097 8.111 9.125 10.14
t=Time.now; i=0;id = UI.start_timer(1.0 / 2, true) { puts Time.now - t; i+=1; UI.stop_timer(id) if i > 9 }; 783 0.045 0.072 0.093 0.113 0.132 0.151 0.171 0.19 0.211 0.23
Note that the timer set to less than one second doesn't trigger every half second as you'd expect it to. The results are the same if it's
1.0 / 2
or1.0 / 10
... -
Seems that when the timer is less than a second it's the same as a normal loop, the timer code block will trigger as fast as I can.
-
You may be getting smooth animations, but they are not 25 fps. When you use a timer, the animations play as fast as your computer can play them because the timer rounds the fractional second down to near zero.
It's not terribly important, in my opinion because you can still generate the correct frame-rate when exporting images to compile into an animation; and also renderers can do the same. It is only the in-sketchup animation that will be incorrect.
-
ThomThom and Jim:
Thank you!
-
@jim said:
It's not terribly important, in my opinion because you can still generate the correct frame-rate when exporting images to compile into an animation; and also renderers can do the same. It is only the in-sketchup animation that will be incorrect.
+1
I agree completely. I don't think that main desire for animations is to make something move inside of SU, but to make something move that can be output inside a video. It should also be viewable in SU, but the final output only needs to be accurate in the video for my needs.
Chris
-
Does help if SU can display an approximate - so you get a feel of the animation before you render.
-
I'm going to try to make stuff move in SketchUp. And move at the rate I specify. Chapter 16 has now been re-purposed to Animation. Will I get an accurate (or at least more-or-less accurate) frame rate using Animation?
What we are saying here is that Lininger's article on timers was dead wrong. Are you comfortable with that?
When I use a timer, I get smooth animation. For example, a clock hand rotates from 3 to 6. When I use a loop, the clock hand just jumps 90 degrees. SU somehow sees that invalidate() is a waste of time in the latter case? Or the timer wastes so many clocks that SU has time to redraw, or ... I'm not comfortable. Forging ahead, but not comfortable.
-
@martinrinehart said:
When I use a timer, I get smooth animation. For example, a clock hand rotates from 3 to 6. When I use a loop, the clock hand just jumps 90 degrees. SU somehow sees that invalidate() is a waste of time in the latter case? Or the timer wastes so many clocks that SU has time to redraw, or ... I'm not comfortable. Forging ahead, but not comfortable.
Not sure what it actually do, but it's clear that plain loops locks up the processing completely preventing UI to redraw. I'm guessing that timers will allow other things to process after each execution of the block, while loops keep it's control.
-
I think animation in SU, however it is achieved, is susceptible to skipping if the model is large, or vast amounts of data are being animated. Try it in a DC. DC's animate objects and you can put them on a timer. The more complex the object being animated is, the bumpier the live animation is.
But if it could be exported to a video, then it wouldn't matter so much.
Advertisement