# 05-07.11 jReality scene graph, Assignment2, …

Projects: It’s still early in the process for choosing a project.  You may be interested in these guidelines from last year.

Teamwork:  You are expected to work in teams.  It’s more fun and the results are of higher quality (IMHO). We can discuss any technical problems with team building today.

05.11 Lecture: Dr. Gunn took the opportunity to present an introduction to the jReality scene graph.   Look also here for a more sober introduction to the same topic. As Assignment2 (below) is easy, you are encouraged to spend some time in the next week familiarizing yourself with the jReality developer tutorial, particularly the sections devoted to transformations, geometry, and appearances. You can do this using your browser and webstart, but if you want to play with the code for particular examples (strongly recommended), these reside in the jReality project under the src-tutorial folder.

07.11 Lecture: We looked in more detail at the SceneGraphComponent javadoc. We also looked at the base class SceneGraphNode and its subclasses. Then, departing from his original plan to discuss the  Appearance class,  Dr. Gunn turned the discussion to the tool system, and showed how to add a tool to the leaf child of Assignment2 in such a way that the resulting transformation was applied before the animation transformation (coming from setValueAtTime()), with interesting results. This discussion also hopefully established the importance of the SceneGraphPath class in determining the exact position of a node in the scene graph.

Assignment1 is completed and the results are, from my point of view, very satisfactory.  To begin with, most of the technical difficulties have been overcome and I have “harvested” git repositories for the majority of the students who have signed up for the class.  And secondly, the quality and variety of the turned-in assignments is impressive.  I only wish it were easier to collect all the different assignments into a “composite” application to be shared and enjoyed by all.  If anyone has any ideas how this can be technically achieved please get in touch with me.  Otherwise I will continue to show a few samples during the tutorial sessions as time permits.

Assignment2 is already there, due this Friday at midnight. It’s basically Assignment1 the way it should have been.  Includes storing and saving properties,  on-line documentation file, and a more modular structure.  Just take what you did for Assignment1 and convert it to the improved format.  Of course if you want to improve it (for example with the extra credit idea), please do so.  In particular, here are the directions:

• Follow the directions here to update the course repository.  You should find a new package template.assignment2.  To prepare your own version of assignment2, do the following, assuming your package name is student007:
• Create a package student007.assignment and copy into it the files assignment2.xml, assg2-anim.xml, Assignment2.html, and assg2-01.png.
• In this package create a new Java class named Assignment2.  It should inherit from the class template.assignment2.Assignment2.
• Edit the newly created class.  You should see stubs for the following methods, which are declared abstract in the superclass:
• protected Matrix getSetupMatrix(int i, int j)
• protected Matrix setArrayValueAtTime(double time, int i, int j)
• protected String getPropertiesFile()
• protected String getDocumentationFile()
• If you look into template.Assignment2 or template.Assignment you can see how these methods should be used.
• Copy code from your original Assignment1 into these method stubs to create a running application that does the same thing your original assignment1 did.  getPropertiesFile() should return “src/student007/assignment2/assignment2.xml” and getDocumentationFile() should return “Assignment2.html”.
• If you’ve added a slider to the inspector (which was part of the assignment), you’ll also need to override the getInspector() method.  To add your GUI elements, you can call super.getInspector(), cast the return value to an instance of Box, and add your GUI elements to this box.  Or don’t call super.getInspector(), and construct the complete inspector in your method.
• On a related note, if you’ve added parameters which you want to store and restore as properties, you’ll need to overwrite storeState() and restoreState() (look into the parent class to see how this is done).
• Run the program.
• Verify that the on-line documentation works by typing the ‘h’ key — your browser should open a window and display the provided html file.  Edit it to reflect what your group did. You can use a normal text editor to do this if you don’t have access to an html editor — just ignore all the html formatting and replace the text sections with text that describes your application.
• Also verify that the properties file and animation file are working by changing some parameters and saving them (save the property file by choosing File->Quit, save the animation file by choosing “File->Save As…” and saving it in student007/assignment2/assg2-anim.xml.)
• Notice that the parameters in the left inspection panel are now saved in the properties file.  If you have other parameters or have removed some of these, please overwrite the methods storeStates() and restoreStates() (see template.assignment2.Assignment2 for details).
• Note that the inspector panel of the Assignment2 superclass contains the 5 parameters provided by the template assignment.  If you still use these but have added more of your own, you can implement the method getInspector(), and add your new GUI elements to the component which super.getInspector() returns.  (You may have to cast this to class Box to be able to add components to it.)
• Extra credit assignment. There is now a method Pn.projectivity(double[] dst, double[][] from, double[][] to) which provides the projective matrix mapping the $n+2$ points from onto the $n+2$ points to.  Of course to get it you’ll need to update your jreality repository which we’ll do in the tutorial this week, or see the post describing the steps.