next up previous
Next: Hierarchical Data Structures Up: Hierarchical Models and Previous: Hierarchical Models and

Hierarchical Transformations

How do we model complex objects and scenes?
Start with basic set of 3D primitives:
Cubes, spheres, prisms ...

Suppose we want two houses.

\

Pictorially we have a DAG
--a directed acyclic graph.

We can model this procedurally:

    Procedure Scene()
        House(B);
        House(D);
    end

    Procedure House(E)
        Prism(E o M);
        Cube(E o N);
    end

    Procedure Cube(F)
        . . .
    end

    Procedure Prism(F)
        . . .
    end

Implementation:

\

Code now looks like

    Procedure Scene()
        MultMatrix(P);
        MultMatrix(V);
        PushMatrix(); 
            MultMatrix(B); 
            House(); 
        PopMatrix();
        PushMatrix(); 
            MultMatrix(D); 
            House(); 
        PopMatrix();
    end


    Procedure House()
        PushMatrix(); 
            MultMatrix(M); 
            Prism(); 
        Popmatrix();
        PushMatrix(); 
            MultMatrix(N); 
            Cube(); 
        Popmatrix();
    end

    Procedure Cube()
        . . .
    end

    Procedure Prism()
        . . .
    end

Readings: Hearn and Baker, Chapter 7; IRIS GL programing guide, Chapter 7; OpenGL Programming Guide, Chapter 3, Manipulating Matrix Stacks; Red book, Chapter 7; White book, Chapter 7.


next up previous
Next: Hierarchical Data Structures Up: Hierarchical Models and Previous: Hierarchical Models and

CS488/688: Introduction to Interactive Computer Graphics
University of Waterloo
Computer Graphics Lab

cs488@cgl.uwaterloo.ca