SLIDE Assignment 3: Dynamic Hierarchical Scenes and Bounding Boxes
Make sure you have read and understood the implementation
specifications in
http://www.cs.berkeley.edu/~ug/slide/pipeline/assignments/as3/implementation.shtml
Scene Traversal Functions
Most people might get confused with the functionality of these four
functions: Preprocess, PreprocessGraph, Update and UpdateGraph.
One
hint to understand them is by constructing parallels; i.e. Preprocess
does things similar to Update, and PreProcessGraph to UpdateGraph.
Preprocess
preprocess called on all elements, flat. This needs to mark dynamic
elements as dynamic - for your assignment, this would be only the
points and instances with dynamic transforms.
Hint: most of the work required in preprocess can be done by the
functions 'checkdynamic' and 'updatestate'
on POINT, FACE, TRANSFORM:
set assorted flags to mark something dynamic or not
(m_bDynamic etc)
on GROUP, OBJECT, INSTANCE (the NODES)
set m_BoundValid to false (so bounding box will be
computed)
on INSTANCE
updateState() -- 'compress' transforms into one
(matrix multiply)
PreprocessGraph
preprocess_graph called on root, which recursively calls pre_process
graph on children. This will mark elements as dynamic, hierarchically
(i.e. if the children are dynamic, the node is dynamic).
on GROUP, OBJECT, INSTANCE (the NODES)
set m_bDynamic, m_BoundDynamic and other bools in
CSLIDENode
(if child is dynamic OR one of the transforms are dynamic)
calculateBound()
(now, m_BoundValid should be set true somewhere
After computing PreProcessGraph(), CSLIDEWorld::Preprocess will create
a list of dynamic nodes (which are used in Update).
Update
update called on all dynamic elements flat
set m_BoundValid to false (so bounding box will be computed)
call updateState()
for POINT -- already written
for FACE, OBJECTS and GROUPS -- probably nothing
important
for INSTANCES -- multiply-transforms & inverses
UpdateGraph
called on root which then calls updateGraph on all children
on GROUP, OBJECT, INSTANCE (the NODES)
calculateBound
Computing Bounds
There are a variety of bounding box calculation methods, each with
different specifications.
Face::InsertIntoBound (CBound*)
adds all points (in the face) into the CBound passed
in
(called by CSlideObject::CalculateBound
called by CSlideObject::UpdateGraph /
PreProcessGraph)
CSlideObject::InsertIntoBound(const
Matrix&, CBound&)
inserts its own bound (m_bound), transformed by the
matrix, into the CBound passed in
CSlideGroup::InsertIntoBound(const
Matrix&, CBound&)
is just like CSlideObject::InsertIntoBound(const
Matrix&, CBound&),
CSLIDEInstance::InsertIntoBound(CBound
&bound)
(called by CSlideGroup::CalculateBound
called by CSlideGroup::UpdateGraph /
PreProcessGraph)
Rendering
To understand the matrices used in rendering, look at
CSLIDERender::Render(...)
i.e.
vp_proj - viewport mapping matrix (that you will
compute - see the linear algebra notes)
proj_vrc - camera projection - for 2D this (and
vrc_proj) is identity
RenderGeometry
See CSLIDEFace::RenderGeometry() to see which
arguments are important.
Hint: only the arguments with uncommented out
variable names are useful.