Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

native animations #180

Open
jeff-dh opened this issue Jun 1, 2021 · 2 comments
Open

native animations #180

jeff-dh opened this issue Jun 1, 2021 · 2 comments

Comments

@jeff-dh
Copy link
Contributor

jeff-dh commented Jun 1, 2021

from solid import *

view_port_magic = """
                       $vpt = [4, 3, 15];
                       $vpr = [60, 0, 360 * $t];
                       $vpd = 100;
                   """

c = cube(scad_inline("$t*10"))

scad_render_to_file(c, file_header=view_port_magic)

yeah!

Works with expsolid should work with master too.

(you need scad_inline from #178)

@etjones
Copy link
Contributor

etjones commented Jun 1, 2021

Oh shit, this could make animation so much better than the hack I have in place now! Dude, you're improving all of this way faster than I can keep up. Nice work.

@jeff-dh
Copy link
Contributor Author

jeff-dh commented Jun 1, 2021

physics:

import numpy as np

from solid import *

ball_radius = 100

def get_bouncing_ball_data(pos=np.array([0.0, 0.0, 0.0]), vel=np.array([5.0, 5.0, 200.0])):
    data = []
    gravity = np.array([0.0, 0.0, -8.0])
    for t in range(1000):
        vel = (vel + gravity) * 0.995
        pos += vel
        if pos[2] < ball_radius:
            vel[2] = vel[2] * -1
            pos[2] = ball_radius

        data.append(pos.tolist())

    return data

ball_data = f'bouncing_ball_data = {get_bouncing_ball_data()};'

ball_pos_over_time = scad_inline("bouncing_ball_data[$t * 1000]")

ball = translate(ball_pos_over_time)(sphere(ball_radius))
floor = background(cube([2000, 2000, 0.01]))

scad_render_to_file(ball + floor, file_header=ball_data)

No clue what this could be good for, but....... I guess it might be possible to plug a -- more complex :-p -- physics engine into it and render animated movies....

All of this is implemented and working with exp_solid and these snippets are in the examples, check it out...

(but this should also work with master with little effort -> scad_inline from #178)

PS: anybody an idea where to get the vitamins for a 4d printer? 😛

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants