0
$\begingroup$

I'm trying to create a program that allows you to input an amount of time (e.g. 50 years, 100 years, 10 years) and the script runs for that scalable amount of time but shortened (so scale 50 years to 5 seconds, 100 years to 10 seconds, 10 years to 1 second).

Currently my main program looks like so

clear_screen()
clear_heirarchy()
scene = bpy.context.scene
# change this to see 3 or 2 tuple demo
tuples = 3
cultures = 4
lamp, cam, kernel, culture_list = graphics_factory.create(tuples,cultures)

positions = []

# random points for modeling purposes, this will change to data later
for i in range(200):
    if(tuples==2):
        y = uniform(-2.0,2.0)
        positions.append((0,y,0))
    elif(tuples==4):
        x = uniform(-2.0,2.0)
        y = uniform(-2.0,2.0)
        positions.append((x,y,0))
    else:
        positions.append(get_triangle_constraints(
            [(0,0,0),(5,0,0),(2.5,5,0)]))

number_of_frame = 0  
t_end = time.time()+10
# makes cultures move around
while time.time() < t_end:

    scene.frame_set(number_of_frame)

    for culture in culture_list:
        culture.location = positions[randint(0,100)]
        culture.keyframe_insert(data_path="location")

    # move next 10 frames forward - Blender will figure out what to do between this time
    number_of_frame += 25

as of right now I am not simulating time. I have found the "my_handler" method of working with frames in a scene but this doesn't seem to allow me to change the a.) number of frames or b.) amount of time it takes to run through the program. I'd like to move away from running through the loop for 10 seconds like I do but i'm not sure of any other way to simulate movement. Does anyone know of a good way that allows me to simulate movement and time?

$\endgroup$
0
$\begingroup$

I've found there's no built in way in blender (other than physics simulation engines) to do this. Instead I mapped 'time' to frames linearly and customized the number of frames in the animation with scene.frame_end with the while conditional being

   while number_of_frame < scene.frame_end:
|improve this answer|||||
$\endgroup$

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.