Model Construction, Interaction and Viewing - PowerPoint PPT Presentation

1 / 39
About This Presentation
Title:

Model Construction, Interaction and Viewing

Description:

gluLookAt(ex,ey,ez,lx,ly,lz,ux,uy,uz) postmultiplies current matrix, so to be safe: ... create a unit square parallel to camera at z = -10. translate in z by 3 ... – PowerPoint PPT presentation

Number of Views:69
Avg rating:3.0/5.0
Slides: 40
Provided by: rgh1
Category:

less

Transcript and Presenter's Notes

Title: Model Construction, Interaction and Viewing


1
Model Construction, Interaction and Viewing
  • Week 5
  • Further Programming for 3D Applications

2
Using Modelling Software
  • Maya
  • 3d Studio Max
  • VRML generators

3
Features
  • Primitives
  • Groups
  • Complex , irregular shapes
  • Lines, Points, Facets
  • Curved surfaces
  • Texture mapped surfaces
  • Lighting and Shading
  • Interactions and Behaviours

4
Primitives
  • Facets constructed from known geometric
    relationships
  • Uses polygons to map to standard mesh structure
  • Scaling , shearing, rotation and translation used
    to modify vertex information, vertex ordering
    remains same

5
Complex or Irregular objects
  • Manual construction
  • Lines and vertices positioned by hand/ eye
  • Modification of primitives
  • Extrusions
  • Curved surfaces
  • B-splines
  • Bezier curves
  • Parametric meshes
  • etc

6
Scene view
  • Scene hierarchy required
  • Must have mechanism to store results
  • Output file structure must link to internal
    structure
  • Hierarchy
  • Relationship between hierarchical nodes
  • Vertex list
  • Vertex ordering list
  • Lighting information
  • Texture mapping
  • May also hold recent viewing parameters

7
3DS File structure
  • May be ASCII output
  • Tags outline structures
  • Must read between Tags
  • Comma delimitation usually to separate vertex
    list and ordering information

8
The 3ds File Structure
  • Sometimes more efficient to read binary output
  • Consists of chunks of binary data

9
Chunks
  • A chunk is composed of 4 fields 
  • Identifier
  • a hexadecimal number of two byte of length that
    identify the chunk..
  • extrapolate the contained information in it and,
    if necessary, in its children,
  • if instead the chunk is useless we jump it using
    the following information... 
  • Length of the chunk
  • 4 bytes, that is the sum of the chunk length and
    all the lengths of every contained sub-chunks.
  • Chunk data this field has a variable length. The
    real data of the chunk are contained in this
    field.
  • Sub-Chunks

10
Typical structure
11
Example
  • MAIN CHUNK 0x4D4D 3D EDITOR CHUNK 0x3D3D
    OBJECT BLOCK 0x4000 TRIANGULAR MESH
    0x4100 VERTICES LIST
    0x4110             FACES DESCRIPTION
    0x4120                FACES MATERIAL 0x4130
    MAPPING COORDINATES LIST 0x4140
    SMOOTHING GROUP LIST 0x4150
    LOCAL COORDINATES SYSTEM 0x4160 LIGHT
    0x4600 SPOTLIGHT 0x4610
    CAMERA 0x4700 MATERIAL BLOCK 0xAFFF

12
Traversal
  • If we for example want to reach the chunk
    VERTICES LIST
  • we have to read the MAIN CHUNK,
  • the 3D EDITOR CHUNK,
  • the OBJECT BLOCK
  • and finally the TRIANGULAR MESH.

13
Chunk Identification
14
(No Transcript)
15
(No Transcript)
16
Load a 3DS object
  • Implement a "while" loop that continues its
    execution until the end of file is reached. 
  • For each cycle read the chunk_id and the
    chunk_length. 
  • Through a switch statement analyse the content of
    the chunk_id
  • If the chunk is a section of the tree not needed
    to pass then jump the whole length of the chunk
    moving the file pointer to the position
    calculated using the length of the chunk added to
    the current position. In this way jump the chunk
    and all the contained sub-chunks.  
  • Or if the chunk enables reach of another needed
    chunk, or maybe it contains data that is needed,
    then read its data, then read the next chunk. 

17
Computing Normals
  • normal
  • direction specifying orientation of polygon
  • w0 means direction with homogeneous coords
  • vs. w1 for points/vectors of object vertices
  • used for lighting
  • must be normalized to unit length
  • can compute if not supplied with object

18
Transforming Normals
  • cannot transform normals using same matrix as
    points
  • nonuniform scaling would cause to be not
    perpendicular to desired plane!

given M, what should Q be?
inverse transpose of the modelling transformation
19
Using Transformations
  • three ways
  • modelling transforms
  • place objects within scene (shared world)
  • affine transformations
  • viewing transforms
  • place camera
  • rigid body transformations rotate, translate
  • projection transforms
  • change type of camera
  • projective transformation

20
Viewing and Projection
  • need to get from 3D world to 2D image
  • projection geometric abstraction
  • what eyes or cameras do
  • two pieces
  • viewing transform
  • where is the camera, what is it pointing at?
  • perspective transform 3D to 2D
  • flatten to image

21
Rendering Pipeline
22
Rendering Pipeline
23
OpenGL Transformation Storage
  • modeling and viewing stored together
  • possible because no intervening operations
  • perspective stored in separate matrix
  • specify which matrix is target of operations
  • common practice return to default modelview mode
    after doing projection operations
  • glMatrixMode(GL_MODELVIEW)
  • glMatrixMode(GL_PROJECTION)

24
Coordinate Systems
  • result of a transformation
  • names
  • convenience
  • mouse leg, head, tail
  • standard conventions in graphics pipeline
  • object/modelling
  • world
  • camera/viewing/eye
  • screen/window
  • raster/device

25
Projective Rendering Pipeline
object
world
viewing
O2W
W2V
V2C
VCS
OCS
WCS
clipping
C2N
CCS
  • OCS - object/model coordinate system
  • WCS - world coordinate system
  • VCS - viewing/camera/eye coordinate system
  • CCS - clipping coordinate system
  • NDCS - normalized device coordinate system
  • DCS - device/display/screen coordinate system

perspectivedivide
normalized device
N2D
NDCS
device
DCS
26
Viewing Transformation
y
image plane
VCS
z
OCS
z
y
Peye
y
x
x
WCS
object
world
viewing
OCS
VCS
WCS
Mmod
Mcam
OpenGL ModelView matrix
27
Basic Viewing
  • starting spot - OpenGL
  • camera at world origin
  • probably inside an object
  • y axis is up
  • looking down negative z axis
  • why? RHS with x horizontal, y vertical, z out of
    screen
  • translate backward so scene is visible
  • move distance d focal length
  • where is camera in P1 template code?
  • 5 units back, looking down -z axis

28
Convenient Camera Motion
  • rotate/translate/scale versus
  • eye point, gaze/lookat direction, up vector

29
OpenGL Viewing Transformation
  • gluLookAt(ex,ey,ez,lx,ly,lz,ux,uy,uz)
  • postmultiplies current matrix, so to be
    safeglMatrixMode(GL_MODELVIEW)glLoadIdentity(
    )gluLookAt(ex,ey,ez,lx,ly,lz,ux,uy,uz)// now
    ok to do model transformations
  • demo Nate Robins tutorial projection

30
Convenient Camera Motion
  • rotate/translate/scale versus
  • eye point, gaze/lookat direction, up vector

y
lookat
Pref
x
WCS
view
up
z
eye
Peye
31
From World to View Coordinates W2V
  • translate eye to origin
  • rotate view vector (lookat eye) to w axis
  • rotate around w to bring up into vw-plane

32
Deriving W2V Transformation
  • translate eye to origin

33
Deriving W2V Transformation
  • rotate view vector (lookat eye) to w axis
  • w normalized opposite of view/gaze vector g

34
Deriving W2V Transformation
  • rotate around w to bring up into vw-plane
  • u should be perpendicular to vw-plane, thus
    perpendicular to w and up vector t
  • v should be perpendicular to u and w

35
Deriving W2V Transformation
  • rotate from WCS xyz into uvw coordinate system
    with matrix that has columns u, v, w
  • reminder rotate from uvw to xyz coord sys with
    matrix M that has columns u,v,w

MW2VTR
36
W2V vs. V2W
  • MW2VTR
  • we derived position of camera in world
  • invert for world with respect to camera
  • MV2W(MW2V)-1R-1T-1
  • inverse is transpose for orthonormal matrices
  • inverse is negative for translations

37
W2V vs. V2W
  • MW2VTR
  • we derived position of camera in world
  • invert for world with respect to camera
  • MV2W(MW2V)-1R-1T-1

38
Moving the Camera or the World?
  • two equivalent operations
  • move camera one way vs. move world other way
  • example
  • initial OpenGL camera at origin, looking along
    -z axis
  • create a unit square parallel to camera at z
    -10
  • translate in z by 3 possible in two ways
  • camera moves to z -3
  • Note OpenGL models viewing in left-hand
    coordinates
  • camera stays put, but world moves to -7
  • resulting image same either way
  • possible difference are lights specified in
    world or view coordinates?

39
World vs. Camera Coordinates Example
a (1,1)W
C2
b (1,1)C1 (5,3)W
c
c (1,1)C2 (1,3)C1 (5,5)W
b
a
C1
W
Write a Comment
User Comments (0)
About PowerShow.com