Build a movie player and a movie script

Abstract

For this project you will write a program to read in a file containing a description of object and their movements. This program will then display this "movie". You will also develop a file to show off your work. This file will present a movie of a number of objects doing something interesting.

Outline

You need to write and test a movie generator. You also need to design a movie and show it with your system.

Goals

Some goals of this project are that you be able to understand and be able to deal with some of the complexity of modeling moving worlds of several objects. Another goal is that you understand the multi-dimension multi-mode behavior of objects in a model. In addition, a goal is to have you understand parametric representation and processing. It is also a goal that you be able to describe a movie in a formal notation.

Objectives

You will be able to address the world time line and the time lines of each individual object. You will be able to interpolate values in a parametric time line.

Prerequest Background

You need to be able to build a simple movie and write programs with complex interlocking data structures.

Content

Build a movie player and a movie script

This program extends the steps from the previous movie program to build truly complex environments. For this assignment you are to develop a 3D movie with a number of "actors". The actors are to be moving relative to each other. In addition the camera view point is to also be changing.

It is highly recommended that you "story board" this before you program it. This will allow you sketch out the relative motion and camera work without cutting any code. You may want to try several stories before you pick one to code.

One way to describe complex 3D worlds and movements is build a scripting file. This file describes what objects are to be where, and how they are to move. Your program will read this special file and then displays the objects and their motions. The file format is given in the following BNF:

Movie_File ::  File_Description CR Render_Steps CR Object_section


Object_Section :: Number_of_Objects CR (Object)*Number_of_Objects

Object :: Object_Name CR Object_Description CR Prototype_Name CR 
   Number_Of_Vertices CR (Vertex CR)*Number_Of_Vertices

Prototype_Name :: (camera, cube, sphere, cylinder, cone, UserFile_Name) 

 alternate version of Object
Object :: Object_Name CR Object_Description CR (Object_Name|Prototype_Name) CR
  Number_Of_Vertices CR (Vertex CR)*Number_Of_Vertices

Vertex :: Time R G B Alpha   X  Y  Z  R(x)  R(y)  R(z)

CD :: a carriage return or line feed
This section is an English narrative of the above grammar. The Movie_File has a line describing the file, a line specifying how many steps to render in the movie, and a section describing the objects and their motions. The first line, of the Object_Section specifies the number of objects that follow. For each object If the prototype name is one of the known names (camera, cube, sphere, cylinder, and cone) build the named item. If the prototype name is not known, the name is the name of a vtk file to be read. Following the descriptive information about the object is an 11 dimensional polyline. Let us look at just the time and position parts to start. This specifies a time that the object is to be at the specified location. The object is not to jump to the location specified at the time specified by the next vertex, but is to smoothly move to the next location over the specified time. The same is true for all of the 11 values specified.

There are some special values. The value of -1 for R G B and Alpha indicates, do not change the underlying object's color. You want this if you have already colored the object. This would probably be the case for objects you read in. Since it is hard to aim the camera, it is handled in a special way. Assume the camera will aim at the origin (0,0,0) no mater where the camera is located. If you want to look somewhere else, the rotation controls will be applied after the camera is pointed at the origin. Following is an example file:

Three object example
100
 4
cube1
bouncy cube at origin (gone after .75)
cube
 4
0.0  1 0 0 1   0 0 0   0  0   0
0.25 1 0 0 1   0 0 1   0  0  90
0.50 1 0 0 1   0 0 2   0  0 180
0.75 1 0 0 1   0 0 3   0  0 270
cube2
bouncy cube at  3 0 3 (starts at .5)
cube
4
0.5  0 0 1 1    3  0  3   0  0  0
0.6  0 0 1 1    4  0  4   0  0 90   
0.8  0 0 1 1    5  0  5   0  0 180
0.9  0 0 1 1    6  0  6   0  0 270
1.0  0 0 1 1    7  0  7   0  0 360 
truck
external object
myfile.vtk
5
0.0  -1 -1 -1 -1   10  0  0   90  0  0
0.25 -1 -1 -1 -1   10 10  0  180  0  0
0.50 -1 -1 -1 -1  -10  0  0  270  0  0
0.0  -1 -1 -1 -1    0 -10  0 360  0  0
0.0  -1 -1 -1 -1   10  0  0   90  0  0
camera1
camera planning around the origin
camera
5
0.0  -1 -1 -1 -1   20   0  10   0  0  0
0.25 -1 -1 -1 -1    0 -20  10   0  0  0
0.50 -1 -1 -1 -1  -20   0  10   0  0  0
0.75 -1 -1 -1 -1    0  20  10   0  0  0
1.00 -1 -1 -1 -1   20   0  10   0  0  0

We will want to display at more than times than just the time points specified in the polylines. We will display the number of images specified by Render_Steps. In the example file this value is 100. Our basic clock with be the time line for the camera. We are to have Render_steps of time along that time line. For each time, t, determine which object are to be displayed, and interpolate time t on that object's polyline. The interpolation will return a vertex which you will convert into a matrix and apply to the object. If an object's polyline time does not include the current time, it should not be displayed or should be displayed with alpha set to 0, transparent. If the time lies between two input specified values interpolate all of the values for each vertex. This includes the color, location and rotation values. A simple version of interpolation is to determine the per-cent of the distance covered on the time line from the previous time point, for that agent, to the next time point, for that agent. Then use the parametric form for a line to pro-rate the x from the previous time point to the next time point. Do this for the y, z, rotate x, rotate y, and rotate z for the four color parameters. If the current time is greater than any time specified, for that object, remove it.

If you want items to spin, you will need to do two things. Specify more than one time point on the curve. And use angles greater than 360 degrees. That is, you might want to specify successive turns of 0, 90, 180, 270, 360, 450 to get the effect of a turn.

You can directly use the built-in commands to position and rotate the agents. That is, anything built in that would help, is fair game. You need to write the program to handle the movements over time. And then you need to write the data set to cause the movie you want displayed.

Here is a drawing to show a small example. There are two objects. Both objects rotate, but at different rates. They also spring up, but at different rates.


NOT PART OF THIS ASSIGNMENT

If you were doing a lot of this, you might want to simplify the input and/or reduce the amount of calculation. You could do this by have the following either in the input, or calculated and storied in the program. Add two vectors to each time point: a movement vector and rotation vector. For example a vertex value of:
0.7 -1 -1 -1 -1 5 6 7 0 0 0 1 1 1 0 0 3
Would indicate that at time 0.7 the agent is to be at location (5,6,7) with rotations (0,0,0) from defined orientation. For each unit of time, move agent 2 by adding in movement vector (1,1,1) and rotations (0,0,3). That is, until something else is specified, move the object on the line of the vector (1,1,1) and rotate it around the z axis 3 degrees each unit of time.

One problem you may note in your movies is somewhat abrupt changes in direction. This is caused by drawing straight lines between points in space. You can fix this by making the lines smooth curves. You can get smooth curves using Bezier curves.

SOME ADDITIONAL THOUGHTS - starting points for modeling real systems

If you take the previous idea, you have added an description of inertia or translation and rotational inertial vectors. What do you do if you want to have the object, at a specified point in time, to have a predictable location and/or translation inertial and/or rotational inertial? Well, you will probably have to look at this in real world systems. Or you will have to study the real world system you are trying to model or display. This is similar to animators looking at films of elephant to determine how they want a image of a dinosaur to move. Or you could talk to the shuttle craft pilots and engineers to determine how they achieve a shuttle insertion into orbit.

You may want more complex objects. For instance, you may want an object, that when it moves to have a fixed speed or rotation without further specification. You may want objects that starting at a predetermined point in time start moving, they move slowly for 10 seconds and then move fast for 10 seconds. How can you build things such as these? The simple answer is to pre-specify a the path as we did in the first version of the problem statement. However, if we would like the object to do that without more detailed specification of its path, we will need to build a more complex object in our system and add new parameters to describe how it is to behave. This is basically how the complex computer modeling systems work. Games or real flight simulators have numerous sets of parameters specified to control the behavior of the displayed items. For a particular type of simulated airplane they have the range of speeds it can fly at, how fast it has go to take off, how fast it can turn and other parameters to describe how the object is to move. As you address more complex characterists, you will probably shift from presented or displayed information to model based parameters. For example, rather than specify the movement of the plane, you might describe the pilot's movement of the planes control yoke. This would then have to be translated into the plane's physical movements by a model of the way that plane responds to control inputs. This means, a model will have to be there to translate from one system to another.

How about if you want objects to change shape or other changes in the image. Such as percent of a texture map being displayed, whether the reflections should have highlights and so on. You would add new types of data and or commands to specify these needed behaviors and characteristics. The input data then starts taking on more of the characteristics of a programming language.

Posttest

After you finish this project, you should be able to solve problems such as:
Write a program to show the movement of the planets around the sun. Write the instructions to show a train with a number of cars going up and round a mountain.