CSE 682: MEL tasks
Assignment: Complete the following MEL programming tasks
Half credit will be given for tasks submitted up to 2 days late (zero after that).
You will demo your work to me on Monday, February 7.
- bouncing ball
- use MEL commands to:
- create a sphere
- add attributes of vx and vy and initialize to reasonable values
- create an expression that
- if it's frame 1, reset the ball to the origin and reinitialize velocity
- otherwise update position by adding the velocity to it and add a constant (negative) acceleration to the ball's y velocity
- if the ball's y value is less than zero, set it to zero, set velocity to original velocity times scale factor, scale down scale factor
- Spring connected balls - you will interactively move one and the other will move as if attached as a spring
- use MEL commands
- create 2 balls, b1 and b2
- to b2, add attributes of velocity in x, y, z
- create an expression
- if it's frame 1, reset b2 to the origin and reinitialize velocity to zero
- else
- compute the vector between the two balls, d = p1-p2
- compute the distance between the two balls, call it 'dist'
- get the velocity of b2 into a vector, v
- compute the spring force using spring and damper constants, ks and kd
f = ks*dist*d - kd*v
This will pull b2 right on top of b1.
If you want to maintain a separation of 'L', the use
f = ks*(dist-L)*d - kd*v
- using the mass of b2, compute the acceleration for b2
a = f/m
- add the acceleration to the velocity of b2
v = v + a
- add the velocity to the position of b2
p = p + v
- after setting the current frame to something other than 1, interactively grab b1 and move it around.
b2 should follow as if connected by a spring.
- During your debugging phase, you can re-center b2 by setting the frame to 1.