Panda Class/Homework/Homework 5

From MCIS Wiki

Jump to: navigation, search

Due: February 10 (Tuesday):

Submit three programs. Place these all in one folder named 197 - HW5 - yourname and place in my dropoff.

Program #1: Use the pose editor to create a walking animation for sonic. Use 5 poses to get a smooth behavior and demonstrate an animation of sonic walking.

Program #2: Write a program that demonstrates some interesting aspect of Python by placing models in a static arrangement. Deal with one of the following:

  • Loops
  • Arrays
  • Functions


Program #3: Create a very simple game in which balls are lobbed at a target. Use the mouse to aim, setting the heading and pitch of the object being lobbed. Use a constant velocity. Fire on the left mouse button. When the objects being lobbed hit the ground they stay where they land. Place a static model in the scene as the target. Use a rectangle to draw a floor. Place the camera behind the place where the objects are being thrown from.

If you have questions about these programs you need to ask them in the wiki!

Discussion

How do I start the walking example?

You need to run the poser.py program to define your pose set. Once you have your poses saved in a csv file, you can play them back in a program that looks like this:

 poses = loadPoseFile("file.csv")
 sonic = ....
 sonic.control = interpolate(time, at(poses["pose1"] + to(.2, poses["pose2"]) + ...)

That is, a pose is a "control" - something that governs all of the joints in the sonic model. You can interpolate between controls.

I tried this:

 s.control = interpolate(time, at(poses["walk1"] + to(0,poses["walk2"]) + to(0,poses["walk3"]) + to(0,poses["walk4"]) + to(0,poses["walk5"])))

but I keep getting this error on the line:

 File "C:\Panda\lib\Control.py", line 12, in __add__
   for k, v in c2.dict.iteritems():
 AttributeError: To instance has no attribute 'dict'

what does this mean, and how do I fix it?

This is a downside to the current system: errors result in bizarre messages. You’re missing a paren after the at: at(poses[“walk1”]). Your “to” functions need a parameter that isn’t 0 – this is the elapsed time between the previous and current pose. If you use 0 then it will go straight to the last pose. --Professor Peterson 20:29, 10 February 2009 (UTC)

Personal tools