0
$\begingroup$

I want to create an operator to preview a physic animation in real time. I have this set of object and I wanted to move them for example using a basic equation like this:

locx = locx - 0.1

a certain number of times a frame. (The number depends on a subframes Variable.). and then using bpy.context.scene.frame_set() move to the next frame and subframe, and while I execute operations the viewport should update (so 10 times per frame, in this case). The problem is that to keep a velocity that's pertinent to scene fps, the time elapsing from x*y operation should be 1 second, or in case blender couldn't keep up, more. (Where x is subframes and y is scene fps.)

(I wanted to state that moving objects isn't the only thing I'd like to do, I should also create objects and delete them, which isn't exactly a fast operation as moving objects can be.)

So, in other words I would like the operator to behave a bit like the 3d view animation when set to No-Sync as scene sync setting, infact, if the scene fps are 60 it will not proceed for more than 60 frames in a time of a second.

I know not so much about real-time operators, I know you could use modal but I've never found anything useful on how tu use them.

$\endgroup$
  • $\begingroup$ I don't get it, why moving the objects in between frames? Notice that you can pass subframes to frame_set(frame=3, subframe=0.01), that should force the scene to update automatically. $\endgroup$ – brockmann May 12 '18 at 15:26
  • $\begingroup$ My fault, I made some errors, now should be ok. $\endgroup$ – Fabrizio May 12 '18 at 15:50
  • $\begingroup$ And... the values of your physics animation coming in from a text file or something? $\endgroup$ – brockmann May 12 '18 at 16:05
  • $\begingroup$ no, real time. It's like particles, I ceate a particle each frame and then animate it's location on x axis using this equation: "locx = locx-(0.5*g*(t^2))", where locx is the current location, g is 9.81 and t is (1/fps) $\endgroup$ – Fabrizio May 12 '18 at 16:07
  • $\begingroup$ calculated in real-time* $\endgroup$ – Fabrizio May 12 '18 at 16:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.