Docsity

Project Report 3: Mobile - Computer Graphics | CS 6491, Study Guides, Projects, Research of Computer Graphics

Partial preview of the text

Download Project Report 3: Mobile - Computer Graphics | CS 6491 and more Study Guides, Projects, Research Computer Graphics in PDF only on Docsity!

Revathi Balakrishnan Ramkumar Krishnan Radu Daniel Cazan

PROJECT 3: Mobile

ovember 22, 2007

Revathi Balakrishnan

Ramkumar Krishnan

Radu Daniel Cazan

Revathi Balakrishnan Ramkumar Krishnan Radu Daniel Cazan

Revathi Balakrishnan Ramkumar Krishnan Radu Daniel Cazan

PROJECT SPECIFICATIONS

Contact Information

Revathi Balakrishnan [email protected] http://www-static.cc.gatech.edu/grads/r/revavare Ramkumar Krishnan [email protected] http://www-static.cc.gatech.edu/grads/r/ramkumar/cs6491/ Radu Daniel Cazan [email protected] ([email protected]) http://www.danielcazan.com

Website

http://www-static.cc.gatech.edu/grads/r/revavare/MyHomepage/CompGraph/CS6491.html

Software

Coding and Visualization Processing 0133 (Beta) http://processing.org Report Graphics Photoshop CS

Original Problem Statement:

  • Program a mobile animation: Use the code provided or your own code to implement an applet that will display a hierarchical mobile. Not just the one I have made with 4 branches, but a hierarchical structure with mobiles hanging from branches of mobiles, some having 2, some 3, some 4 branches. Each mobile should be rotating around the vertical axis at a different speed, and some should be rotating in the opposite direction. From the branches of the leaf mobiles, should be hanging shapes, each represented by a triangle mesh, and rotating around the wire from which it hangs.
  • Realistic hanging – Compute the center of mass of each solid and ensure that it is exactly below the point at which the wire is attached that connects the solid to the mobile branch from which it is hanging.
  • Graph representation – Design a data structure and file format for representing the mobile structure and its animation. Design the read/write functions. Provide a user interface for editing the graph (add/delete nodes, change number and length of branches) or its animations (speed, direction of rotation).
  • Animation of solids – Make each solid change its shape over time (as it is spinning in the mobile) in an interesting way. You can pick one of the three suggested methods or implement a method that would have commensurate

Revathi Balakrishnan Ramkumar Krishnan Radu Daniel Cazan

difficulty and animation effect (just scaling the shape as an animation will not suffice. (1) Morphing between two shapes using the Minkowsky morph. (2) deforming itself using a free form deformation, such as Twister, (3) behaving as an articulated body to simulate a puppet running in place, a bird moving its wings and tail in a realistic simulation of flight.

  • Integration – Integrate all these functionality into a mobile design studio, where the operator can edit the structure of the mobile, create the solid animation, hang the animated solids on the mobile, control the speed functions, and save the animation on file.

Implemented Features:

  • (REQ) Mobile Structure with multiple levels and unique leaf nodes o (REQ) Joints do rotate at varying speeds and directions o (REQ) Leaf Nodes do rotate at varying speeds and directions with appropriate pivots o As new child-joints are added, the existing siblings adjust themselves to be at equal angles to the new joint and each other
  • (REQ) Graph (Tree) Approach to problem, complete with user-interface o Ability to select nodes through mouse- driven interface o Hotkey-driven (with side-bar button support) interface o (REQ) User is able to add / delete nodes o (REQ) Mobile is scalable and contains variable rotation speeds
  • (REQ) Animated solids o Implementation of Minkowsky morph between various simple shapes o Implemented animated birds (code derived from online references)

Revathi Balakrishnan Ramkumar Krishnan Radu Daniel Cazan

Problem Solving Approach (Summary)

The project was divided into several steps, to be tackled in this order:

  1. Create a stand-alone Joint that could be part of a tree-structure

  2. Create a mobile (tree) structure of multiple joints

  3. Implement an intuitive user-interface for interacting with the tree structure

  4. Implement a stand-alone shape that could be added to a leaf node

  5. Implement a simple Minkowsky morph (face->vertex)

  6. Implement a complex Minkowsky morph (edge->edge)

For the purpose of this project we chose to create all forms from primitives or from scratch rather then extending previous individual projects. We made this choice in order to minimize integration of the overall team, and due to time constraints (getting stuck on troubleshooting or explaining a previous feature may be more expensive then moving forward with a more limited but cleaner toolset)

Revathi Balakrishnan Ramkumar Krishnan Radu Daniel Cazan

Interface

Hotkeys

(s) Select: (Toggle) Pauses the structure, Enables click-selection on the bottom sphere of any joint. Head joint cannot be selected (q) Add Joint: Add a joint to a selected joint (provided it has no leaf-nodes (f) Add Form: Adds a form to a selected joint (replaces present children) OR Switch Form: Switch between different form types by continuing to press (f) (x) Remove Joint Removes a selected joint and all of its children from the scene (r,e,v,a) AddDown Pressed in order, add a joint to (r) Snake, (e) 1st^ child at level 1, (v) 1 st^ child of 1st^ child, (a), 1st^ chid of 1st^ child of 1st^ child (p) Pause (Toggle) Switch between static and animated joint rotations (l) Load Load (switches between previous saved mobiles) (v) Save Save the current mobile (w) Clear Clears the screen, reseting it to just the head joint

Graphical User Interface

‘Select Joint’ (Toggle) Pauses the structure, Enables click-selection on bottom-sphere ‘Add Child Form’ Adds a form to selected joint or switch between different form types ‘Add Child Joint’ Adds a joint to the selected joint (if no leaf-nodes present) ‘Add To Snake’ Adds joints to the head joint (head joint can only be modified using this functionality ‘Save Mobile’ Saves the current animation to a file ‘Load Mobile’ Loads a set of exported animations (one by one) ‘Clear’ Erases the mobile, exposing only the top head joint

(Mouse drag) Rotates the tree structure, with the head joint as the pivot. If joints are hard to see in complex structure, this is useful for rotating to a better angle of selection.

Revathi Balakrishnan Ramkumar Krishnan Radu Daniel Cazan

Shadow Projection Calculation

Step 1) For each joint, check the positions of the first and middle ’balls’.

Step 2) Calculate distance between the points and the plane in relation to y-axis. To do this we check the position of the points in relation to world space, the position of the ground plane in relation to world space, and the difference between the two.

Step 3) Draw a cone between the two locations with a width relative to the initial width of the joints.

Textured Objects

Step 1) Specify the input image to use by adding it to a ‘texture’ object pre-defined in Processing.

Step 2) When we begin a new shape in processing, before completing the shape, specify the texture object to be applied to the shape being created: ‘texture ( textureVariable )’

Minkowsky Morph

Calculating Corner Normals

Step 1) Calculate face normals for all faces

  • For a triangle in the face, take the cross product of its three points. The result is the Face Normal
  • We used the ‘triNormalFromPts’ function from the Vector.pde file
  • Since all faces should be planar, the result will be the face normal for the entire face. This normal will be normalized so that all faces carry the same weight

Step 2) Take the average of the normals as the corner normal

Revathi Balakrishnan Ramkumar Krishnan Radu Daniel Cazan

Calculate Face -> Vertex Transformation

Step 1) For each face in a shape check its normal versus the normal of all corner vertices of the shape we are deforming towards.

Step 2) For all corners that have a normal similar (within 90 degrees) to the current face make an instance of the face.

Step 3) For each corner of instance face calculate a vector to the corner it was created for.

Step 4) At each frame of animation, move the vertices of an instanced face a set distance along the calculated vector.

Step 5) Repeat the above process for both shapes.

Step 6) To evaluate the forms at any given point in time, send the distance to move along a vector according to a percent of the vector (in this implementation that is treated as a float number from 0->1 where 1 is 100%). One form should move by that percent, and the other by its inverse (1-InputPercent).

Edge->Edge Transformation

In a Minkowsky Transformation, moving only the face instances will leave holes between the two shapes.

To handle this we have to also go through and connect all the edges of the faces that that are separating.

This could be handled by checking the normals of the edges themselves. Instead we chose to track all the edges of instances faces as they leave. By checking what faces they shared edges with in the original form, as well as what edges were shared, we create edge pairs of what should be joined.

Since these edges are effectively temporary (only used for the purpose of the morph) we do not try to triangulate them. Instead we create quads in 3D space (using the ‘Shape’ feature of Processing) between every edge that is separating.

Revathi Balakrishnan Ramkumar Krishnan Radu Daniel Cazan

Angle Speed (angleOfRotation) How quickly children will be spinning

Functionality

Add ( add ) The function attempts to add a new joint. In the case of another joint being added, all other joints are adjusted such that all joints are evenly-spaced.

Pick Ball ( pickBall ) Code developed by Dr. Jarek Rossignac – Code is utilized in selection interfae

Show Children ( showChildren ) Animates and Displays Children of the snake class

TREE:: JOINT STRUCTURE

Description

The Joint structure is the most basic element (object) of our tree structure.

‘Head’ Joint – a joint may be tagged as ‘head’ meaning that it will only have one direction (down), and it has no parent

‘Child’ Joint – all joints other then the ‘head’ have a parent joint they belong to, two directions (extending outwards, then downwards at 90 degrees)

All joints may have either more ‘child joints’ or a ‘leaf’ (some stand-alone object) but no both. If a joint has child joints it may have between 0->10 children.

Pre-reqs

Form.pde Necessary for addition of forms as leaf-nodes (no additional direct impact)

MatrixTransform.pde Used for basic mathematical functionality, primarily transformation of points

Properties

Number of Children (numChildren) How many children it Currently has

Revathi Balakrishnan Ramkumar Krishnan Radu Daniel Cazan

Child Type (childType) – A joint may either be the parent to other Joints (->10) or a Form (->1)

Start / Mid / End Position (start,mid,end) Position in local space of the start, hinge, and final vertices of the joint, ‘Start’ is (0,0,0)

Start / Mid / End Show Positions (startShow, midShow, endShow) Positions of start, hinge, and final vertices in world-space / in relation to the world (0,0,0)

Length 1, 2 (len1, len2) The length of the vectors from start->hinge (len1) and hinge to end positions

Angle Speed (angleOfRotation) How quickly children will be spinning

Functionality

Select Closest Joint ( selectClosestJoint ) Attempts to derive the user-selection based on mouse-clicks in screen-space

Add ( add ) Depending on the current children of the joint and the requested add type, the function attempts to add a new joint or form. In the case of another joint being added, all other joints are adjusted such that all joints are evenly-spaced.

Show( show ) The joint is displayed on the screen

TREE:: FORM STRUCTURE

Description

The Form structure handles a variety of leaf joints, including their selection and display properties.

Pre-reqs

FormMorph.pde A Minkowsky style morphing construct discussed later in this document, used only if ‘Form’ is asked to display morphing objects

DanForm.pde Used to populate the FormMorph class, this is discussed in further detail later

Properties

Form Type ( formType )

Revathi Balakrishnan Ramkumar Krishnan Radu Daniel Cazan

Calculates the Vector Path for all vertices to converge on a set point and stores the data.

Set / Constructors In addition to storing the location of the three vertices, these functions also calculate and update the Vector Path.

Share Any Edge (ShareAnyEdge) Checks of the current triangle has any edges in common with a queried triangle.

Share Edge ( ShareEdge ) Checks if a particular edge is shared between triangles.

Display Paths ( DisplayPaths ) Shows the current Vector Paths being followed by the triangles.

Show ( Show ) Displays the triangle with whatever fill has already been set.

Show with Normal ( ShowN ) Displays the triangle, as well as its face normal.

MORPH:: FACE

Description

The ‘Face’ is a more complex basic elements of a form consisting of 1 or more triangles. It shares a lot of functions with the Triangle (and in many places it pushes function calls to the individual triangles), but it is more concerned with border vertices then inner vertices. A Face is only meant to contain planar triangles that all have edges in common. Faces do have a default color they display with and that can be individually changed.

Pre-reqs

Triangle.pde Class is described in this document and is essential for ‘Face’ to work

Properties

Number of Border Vertices ( numBorderVertex ) / Border Vertices ( V ) How many vertices are on the outer form of the face and a list of the border vertices (deep copies of the triangle vertices)

Number of Triangles ( numTriangles ) / Triangles ( T )

Revathi Balakrishnan Ramkumar Krishnan Radu Daniel Cazan

How many triangles compose the face and a list of all the triangles that compose the face (all should share the same face normal and touch each other.

Vector Normal ( vN ) The normalized vector normal of the face (should be shared by all triangles)

Functionality

Move ( Move ) Sends out a Move command to all triangles in order for their vertices to plan out paths and converge on a set location in space.

Find Point ( FindPt ) Checks if a given point is among the border vertices.

Face To Point ( FaceToPoint ) Passes on a call to the triangles to calculate their vector paths

Add Triangle ( AddTriangle ) Attempts to add a triangle to the face (deep copy) but only if it has the same face normal as existing triangles and it shares an edge. In the process it updates the face to eliminate any vertices that are no longer on the border.

Display Paths ( DisplayPaths ) Shows the Vector Paths from each triangle vertex to a calculated position in space.

Show ( Show ) Displays all the triangles in the face using the current default color or an input color

MORPH:: DANFORM

Description

DanForm is a specific leaf type optimized for morphing. It tracks all the faces / triangles / points in the form and it also tracks all the ‘Corners’ – positions where three or more faces meet. In a non-manifold object with no holes all corners will have at least three faces converging on them. Danforms do have a default color they display with and that can be individually changed.

Pre-reqs

Triangle.pde Described in other portions of this document

Face.pde

Revathi Balakrishnan Ramkumar Krishnan Radu Daniel Cazan

MORPH:: FORM MORPH

Description

The Form Morph class stores two shapes (potentially more in the future), computers a Minkowsky morph between them, and displays the resulting animation.

Pre-reqs

Triangle.pde Described in other portions of this document

Face.pde Described in other portions of this document

DanForm.pde Described in other portions of this document

Properties

Show Edge to Edge ( ShowEdgeToEdge ) Boolean toggle. When set to true a normal Minkowsky morph is displayed, but toggled off the morph displays with only the face to vertex portion of the morph.

Number of Faces ( numfA ) / Faces ( fA ) Number of Faces ( numfB ) / Faces ( fB ) The faces stored by this class are not the individual faces of the contained forms, but rather the maximum number of faces created by the face-to-vertex animation. The faces coming from form A and form B are stored separately.

Number of Edges ( numEdgesA ) / Max EdgesA ( maxEdgesA ) / Edges ( edgesA ) Number of Edges ( numEdgesB ) / Max EdgesB ( maxEdgesB ) / Edges ( edgesB ) Used for edge-to-edge face calculation. Because of the calculation time for preparing the edges, edge mappings are pre-calculated during the morph set-up. The size of the edges array expands as needed but does not contract again.

Functionality

Set ( Set ) / Constructor Takes in the shapes and calls functionality for calculating the paths of all the edges / faces traveling.

Calculate Paths ( CalculatePaths ) Looks at every shape in each shape and maps out the paths from each face to every corner vertex with a normal within 90 degrees of the face normal. Also calls out the edge calculation functions.

Revathi Balakrishnan Ramkumar Krishnan Radu Daniel Cazan

Calculate Edge to Edge ( CalculateEdgeToEdge ) At the moment the edge to edge mapping is implemented without the use of edge normals. Instead every edge checks the edge it was initially connected to for the calculation and applies that to the copied faces moving away.

Show Morph ( ShowMorph ) Displays the morphing faces / edge faces at a specific point in the animation. That point is based on the input which should be somewhere between 0 (form A) to 1 (form B).

Display Paths ( DisplayPaths ) Shows the planned paths for all the face-to-vertex face animations.