Saturday, October 3, 2009

Frankenstein's Viewer

I'm going to try and "Frankenstein" together my own Viewer using FLTK, GLUT, and OpenGL. First of all, I already know how to build/use these libraries. Secondly, I have access to several existing programs that implement them (my "body parts" for the monster, if you will). Yay for 277, 460, and 462! I do feel bad about not using the viewer that Cat supplied me with (it is probably very well-written). If my Linux skills were stronger, I probably would. But, since the Viewer is not the focus of my project, I want to get it out of the way a.s.a.p., and if that means using what I know, then so be it. Yukari, who is also working with Cat to make realistic eye movements, contacted me regarding how to set up Qt on a Linux machine; I have no idea what to tell her. O__O

Alright then. Let's take a look at what ingredients I'll need in order to make the Viewer:
Face class:
- has a collection of vertices
- has a normal
- has a color
- has a Draw() function

ObjParser class:
- has a collection of vertices
- has a collection of Faces
- has a Clear() function for resetting the contents of its collections

Mesh class:
- has a collection of vertices
- has a collection of Faces
- has a "Visible" boolean
- has a Draw() function (calls each Face's Draw())

Head class:
- extends Mesh
- (has animations)

Collider class:
- extends Mesh
- has a PointInCollider() boolean function (that returns the shortest projection out of the collider)

HeadCollider class:
- extends Collider Mesh
- has a dictionary that maps its vertices to vertices in a Head
- has a PointInCollider() boolean function (that returns the shortest projection out of the collider)

Scalp class:
- extends HeadCollider

HairGroup class:
- has Strands, Clusters, and Strips
- has an Update() function
- has a Draw() function
- project focus

HairManagerEngine (HairRenderer) class:
- has a Scalp
- has a HairGroup
- has a GrowHair() (set_geometry()) function
- has an init() function (for GPU work)
- has an Update() (update_geometry()) function (calls its HairGroup's Update())
- has a Draw() function (calls its HairGroup's Draw())
- project focus

Camera class:
- has a position
- has an up vector
- has a focus point
- has rotate functions
- has zoom functions

TreeNode class:
- has a parent TreeNode
- has a collection of children TreeNodes


GeometryNode:
- extends TreeNode
- has a Mesh
- has a Draw() function (calls its Mesh's Draw())


TransformNode:
- extends TreeNode
- has a transformation matrix
- has functions for editing its transformation matrix


SceneTree class:
- has a collection of GeometryNodes
- has a collection of TransformNodes
- has TreeNode insertion and deletion functions


Window class:
- has a HairManagerEngine (gets it from Viewer)
- has a SceneTree (gets it from Viewer)
- has a collection of Meshes (gets it from Viewer)
- has a Draw() function (calls each GeometryNode's Mesh's Draw() and its HairManagerEngine's Draw())
- has callback functions

Viewer class:
- has a light (a vector position)
- has an ObjParser
- has a Scalp
- has a Head (should match up with its scalp)
- has a collection of Colliders
- has a HairManagerEngine
- has a Camera
- has a SceneTree
- has a Window
- has callback functions

Viewer class capabilities:
- import an .obj (or .mesh?) scalp into the scene (just one)
  • a corresponding Scalp object should be created and inserted into the SceneTree
  • ConvertObjToScalp() function to do this
  • uses Decimate() function
- import an .obj (or .mesh?) head into the scene (just one)
  • a corresponding Head object should be created and inserted into the SceneTree
  • ConvertObjToHead() function to do this
  • a Collision object should be generated from the Head's geometry
  • ConvertHeadToCollider() function to do this
  • uses Decimate() function
- import an .obj Collider into the scene (as many as desired)
  • a corresponding Collider object should be created and inserted into the SceneTree
  • ConvertObjToCollider() function to do this
- remove Scalp, Head, or Colliders from the scene (delete them from the SceneTree)
  • Node deletion functions to do this
- move around the scene with a Camera
  • Camera rotate and zoom functions to do this
- light the scene with a point light that can be rotated around the center of the scene
- rotate the Head around
  • TransformNode transform matrix manipulation functions to do this
- (trigger Head animations)
- move and rotate Colliders (not the head collider, though) around
  • Transform matrix manipulation functions to do this
- add a HairGroup to the Scalp
  • GrowHair() function to do this

Viewer class Q&A:
Q: For high-poly objects, is there a more efficient way to render them than by looping through each face and telling OpenGL to draw it?
A: For now, no.

Q: If the .obj head is going to be animated in some way, then perhaps importing the .obj should be eliminated in favor of importing some kind of .mesh object with associated keyframe data. This involves collaboration with Cat to see how this .mesh object might need to be drawn.
A: Since I have not heard back from Cat about this, I'm going to import an .obj head and give the user controls for rotating it. This should be good enough for approximating "yes" and "no" head animations.

Q: Should colliders be spheres, cubes, or meshes? Should collisions be determined by space partition instead?
A: For now, the plan is to make the head collider a decimated version of the original head.
Like a good mad scientist, I even sketched out how I want my monster to look:
(Click to enlarge)

No comments:

Post a Comment