FMX Rendering and Animation

Overview

Freestyle motocross or FMX is a variation on the sport of motocross in which motorcycle riders attempt to impress judges with jumps and stunts. The aim of this assignment is to render and animate the rider and motorbike on the FMX track that you created in the previous assignment.

Preparation

  1. The assignment is to be maintained and submitted via classroom.github.com.
  2. Click on this assignment invitation link to begin.
  3. A repository will be created for your team.
  4. You have to use the same hierarchy for both the rider and motorbike models and the track model that you created in A2. You are free to refine your model geometry, but do not modify the hierarchy.
  5. There is no given basecode for the assignment. You are free to build on top of any of the tutorials or demo code given in the course, or to start from scratch.
  6. In your repository, all your source code must be in a folder called src, the report must be in a folder called doc and the executables must be made in a bin folder.
  7. You can put your include files in a separate include folder or you can put them in the src folder itself.
  8. Learn how to use a Makefile for compiling your code, like it was used in assignment 1.

Programming To Do :

Setting up cameras -

  1. Create a perspective camera and position it such it can see your entire scene. This is camera 1.
  2. Create a perspective camera that follows (always looks at and moves with) the rider as the rider moves (called a 3rd person camera). This is camera 2.
  3. Create a perspective camera that is attached to the helmet of the rider and sees from a first person point of view (like an action camera (e.g. GoPro) is used). This is camera 3.
  4. Add a key to toggle between these three cameras at runtime.

Setting up lighting -

  1. Create two (or more, at least two is mandatory) point lights and place them appropriately so that they light up your scene. Implement at least a Gouraud shader. You can change this to a per-pixel shader if you want.
  2. Add keys to switch these lights on/off.
  3. Add a headlight to the motorbike. Add a key to toggle this on/off. Make sure the headlight lights up the scene in front of the motorbike appropriately.
  4. Create a spotlight, that can follow the rider. Add a key to switch this light on/off. You must be able to see the effect of the spotlight, when all other lights are switched on or off.
  5. Make sure the textures on the models - the rider, the motorbike and the track are lit properly when lighting is turned on.

Setting up texturing -

  1. Create a skybox or bounding sphere with an environment map that should surround your entire scene. Make sure your lights and cameras are inside this bounding geometry.
  2. Apply an appropriate texture to the track, or parts of the track.
  3. Apply texture to at least one part of the rider and the motorbike.
  4. Make sure the textures on the models - the rider, the motorbike and the track are lit properly when lighting is turned on.

Animation -

Every parameter that you can modify in your scene - the state of various lights, positions of cameras, the overall translation and rotation of the rider and the bike, the pose of the rider and the bike - can be animated. Design a keyframe format. A line in your keyframes file will look like as follows:

…. …. .. …..

  1. Here are some guidelines for the keyframe file:

    1. This is a text file. Each item within <..> in a line represents a parameter value (your file will contain only the values - not the angular brackets).
    2. You can decide the number of fields you want, but it must be same throughout your keyframe file.
    3. Some parameters, like the light state, may only be 0/1 values indicating on/off and others may be real numbers. Decide according to usage.
    4. The time stamp should be in number of frames. It is a whole number.
  2. In order to generate the keyframes, and create the animation you have to implement the following:

    1. Create a program that implements everything asked above in terms of cameras, lighting and textures with the rider, bike and track. Make sure all your keyboard controls for moving and posing the rider and bike, for changing the cameras and lights work in this program. This program must compile to an executable called fmx-animate.
    2. Define a key S that saves the current state of your scene as a line in a keyframes file called keyframes.txt.
    3. You can enter the timestamp when S is pressed in the console or you can have a default value of the keyframe increment such that every time you save a keyframe, the timestamp increments by 10 frames. You can edit the keyframes.txt file later in a text editor to adjust the timestamps if needed.
    4. Now define a key L that reads the keyframes from the keyframes.txt file. Report on the console/terminal how many keyframes you read from the file.
    5. After the keyframes have been loaded, pressing the P key should playback the animation. For animating, interpolate between the keyframe, generating one frame for each time step. So if keyframe 1 has a timestamp 1 and keyframe 2 has a timestamp 15, the you will generate and render 15 frames between these keyframes using interpolation. Some values in the keyframe should not be interpolated, e.g., light state - you can decide this according to your keyframe format and design.
    6. You must use a GLFW timer callback to playback your animation at a particular frame rate - do not just put in a global loop with a sleep().
    7. After you are satisfied with your animation, pressing a key R should start a record mode for your animation. The same animation as before plays back, but now you capture the framebuffer at each time step to an image. Name your frames as frame-00000.xyz, frame-00001.xyz and so on, where the extension xyz will depend upon what image format you save to. You can refer to the code that is used to save the canvas to an image in A1 for doing this or figure out your own code to do this. Make sure you have enough disc space to save the frames before you enable this mode.
    8. While making the animation, it is a good idea to have a script so that your animation tell a small story. Explain this script in your report. Look at FMX motocross videos to get an idea of what happens in a FMX motocross competition. Try to animate the bike and the rider as convincingly as you can. The rider must usually be on the bike, but can do various stunts with it during the animation.
    9. Decide a frames per second rate (FPS) for your animation - actually you should do this early on. For eg. if you decide on a fps of 30fps, then 10 frames represent 1/3 seconds of animation. This will help you create timestamps for your keyframes. Do not choose a FPS less than 5.
    10. The entire duration of your animation must at least be 30 seconds. You can generate longer animations if your want.

Movie and Reporting To Do :

Making a movie -

  1. You movie should be at least 1 minute long
  2. Join the frames saved above into a movie file. You can do this using ffmpeg or avconv on linux,
  3. If you want, you can add music or sound effects to your movie file by either using ffmpeg/avconv or using editors like OpenShot.
  4. If you add a soundtrack, make sure you do not use copyrighted music.
  5. Upload your movie to youtube.
  6. Make sure you add it to your report and github README file.
  7. Take a frame of your movie. Save it as a jpg. Name this files as -.jpg. If you are working alone, use -nil.Upload this a single frame of your movie to the doc folder of your repository.
  8. Do NOT upload your movie or frames to your Github repository.

Report and Moodle Submission -

  1. Write a pdf report containing details of your lighting, texture and camera choices. Explain the script of your animation briefly.
  2. Add the youtube url of your movie to the report. Name this report file report.pdf. Make sure you include the names of both members of your group in the report. Put the report in the doc folder in the repository tree. There is no need to upload this to Moodle.

Do NOT do the following:

  1. Do not write untidy code or unorganized code. This will be penalized.
  2. Do not submit an untidy archive. Make sure that at submission time your archive contains only source files, shaders, final keyframes.txt file, texture images and the report. No temporary files, executables, object files or other files must be present.
  3. Do not have a .gitignore file that prevents you from uploading your texture images - otherwise we will not be able to run the code you submit.
  4. Do not name the submitted movie frame incorrectly.
  5. Do not forget to inlcude the youtube link for your movie.

Marking

  1. Camera 1, 2 and 3 with a key to toggle between them: 150 marks
  2. Point lights + key to switch on/off: 50 marks
  3. Headlight on motorbike + key to switch on/off: 50 marks
  4. Spotlight + key to switch on/off: 50 marks
  5. Bounding geometry environment map: 100 marks
  6. Texture on track: 50 marks
  7. Texture on rider and bike: 50 marks
  8. Texture and lighting working together: 50 marks
  9. Keyframe saving: 50 marks
  10. Keyframe loading: 30 marks
  11. Keyframe playback with interpolation in timer callback: 150 marks
  12. Saving frames and movie link: 50 marks
  13. PDF report with details of light, camera and texture, script of story and link to video: 50 marks
  14. Movie screenshot/frame in doc folder: 20 marks
  15. Total: 900 marks
  16. Deductions: Poorly structured code : 100 marks
  17. Deductions: Submitting an unclean archive : 50 marks.
  18. Deductions: Forgetting the declaration of originality: 50 marks
  19. Deductions: Any late submission: 100 marks

Important Note

  1. Please do not put your solution code and report anywhere public. Your assignment repositories are setup so that they are visible only to you and your project partner, and to the course instructor and TAs. It should not be available online.

To Submit

  1. Regularly check-in the code into your teams' github repository.
  2. The last checkin before the deadline will be considered for marking.
  3. Modify the README.md file in the repository root folder stating the names and roll numbers of your partner for the assignment, and a declaration in your own words that the assignment is your own work and that you have not copied it from anywhere.
  4. Also cite any sources that you may have used to complete it.
Previous