DOC PREVIEW
UCSD CSE 167 - Hierarchical Transforms

This preview shows page 1-2-3-21-22-23-43-44-45 out of 45 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 45 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 45 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 45 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 45 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 45 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 45 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 45 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 45 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 45 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 45 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

#3: Hierarchical Transforms. Geometric CalculationsOutline for Today:Object and World CoordinatesObject CoordinatesWorld CoordinatesPlacing object in the worldPlacing object coordinates in the worldRelative TransformationsSample SceneSchematic Diagram (Top View)Top view with CoordinatesSlide 12Current coordinate systemDrawing with a CTMUsing a CTMTop view, just framesTable1 and Book1Draw Table1 and Book1Simplify the idiomDraw Table1 and Book, reduxTable2 and KeyboardDraw Table2 and KeyboardWhat about drawing entire scene?Keep a Stack for the CTMDraw whole scene, hierarchicallyHierachical grouping within a modelAccess something in the middle?CTM and matrix stack in OpenGLThinking top-down vs bottom-upAnother example:Slide 31Example: Normal of a TriangleSlide 33Example: Alignment to TargetSlide 35Example: Distance to PlaneSlide 37Example: Area of a TriangleSlide 39Scaling and volumeVolume Preserving ScaleTransforming normalsSlide 43Shear TransformationsNext class#3: Hierarchical Transforms. Geometric CalculationsCSE167: Computer GraphicsInstructor: Ronen BarzelUCSD, Winter 20062Outline for Today:Hierarchical TransformsGeometric Calculations3Object and World CoordinatesIn project1, constructed matrix to transform points of cubeCube defined using (-1,1,1), …Transformed each point to final positionQuickTime™ and aTIFF (LZW) decompressorare needed to see this picture.4Object CoordinatesEach object is defined using some convenient coordinatesOften “Axis-aligned”. (when there are natural axes for the object)Origin of coordinates is often in the middle of the objectOrigin of coordinates is often at the “base” or corner of the objectE.g. cube in project1 was -1,-1,1… could also use just 0,1 Axes could be lined up any way.•Model of a book: put the Z axis along the spine? Front-to-back?No “right” answer. Just what’s most convenient for whomever builds modelNotice: build, manipulate object in object coordinatesDon’t know (or care) where the object will end up in the scene.Also calledObject spaceLocal coordinates5World CoordinatesThe common coordinate system for the sceneAlso called World Space Also chosen for convenience, no “right” answer.Typically if there’s a ground plane, it’s XY horizontal and Z up•That’s most common for people thinking of models•I tend to use it a lotAside: Screen CoordinatesX to the right, Y up, Z towards you•That’s the convention when considering the screen (rendering)•Handy when drawing on the blackboard, slides•In project1, World Coordinates == Screen Coordinates6Placing object in the worldBundle together a single composite transform.Known as:Model MatrixModel TransformWorld MatrixWorld TransformModel-to-World TransformLocal-to-World MatrixIn OpenGL: included in MODELVIEW matrix (composed model & view matrix)Transforms each point7QuickTime™ and aTIFF (LZW) decompressorare needed to see this picture.Placing object coordinates in the worldPlace the coordinate frame for the object in the worldDon’t know or care about the shape of the objectWorld matrix columns = object’s frame in world coordinates8Relative TransformationsUntil now, used a separate world matrix to place each object into the world separately.But usually, objects are organized or grouped together in some wayFor example…A bunch of moons and planets orbiting around in a solar systemSeveral objects sitting on a tray that is being carried aroundA hotel with 1000 rooms, each room containing a bed, chairs, table, etc.A robot with torso and jointed arms & legsPlacement of objects is described more easily relative to each other rather than always in world space9Sample Scene10Schematic Diagram (Top View)QuickTime™ and aTIFF (LZW) decompressorare needed to see this picture.11Top view with CoordinatesQuickTime™ and aTIFF (LZW) decompressorare needed to see this picture.12Relative TransformationsPut the objects on the tablesEach table has a simple coordinate systemE.g. Book1 at (3.75,1,0) on Table1’s topE.g. Keyboard at (3,.5,0) on Table2’s topDon’t care where the tables are in order to do this partPut the tables in the roomBooks etc. should end up in the right placeHow do we do this…?13Current coordinate systemIn our code, we maintain a “current coordinate system”Everything we draw will be in those coordinatesI.e. we keep a variable with a matrix known as the “current transformation matrix” (CTM)Everything we draw we will transform using that matrixTransforms from current coordinates to world coordinates14Drawing with a CTMOld drawCube:drawCube(Matrix M) {p1 = M*Point3( 1,-1, 1);p2 = M*Point3( 1,-1,-1);p3 = M*Point3( 1, 1,-1);p4 = M*Point3( 1, 1, 1);p5 = M*Point3(-1,-1, 1);p6 = M*Point3(-1,-1,-1);p7 = M*Point3(-1, 1,-1);p8 = M*Point3(-1, 1, 1); . . .}New drawCube:// global CTMdrawCube() {p1 = CTM*Point3( 1,-1, 1);p2 = CTM*Point3( 1,-1,-1);p3 = CTM*Point3( 1, 1,-1);p4 = CTM*Point3( 1, 1, 1);p5 = CTM*Point3(-1,-1, 1);p6 = CTM*Point3(-1,-1,-1);p7 = CTM*Point3(-1, 1,-1);p8 = CTM*Point3(-1, 1, 1); . . .}15Using a CTMAs we go through the program, we incrementally update the CTMStart with the current coordinates=world coordinatesCTM = IBefore we draw an object, we update the CTMfrom the current location to the object’s locationWe perform a relative transformation.The CTM accumulates the full current-to-world transformation.Draw from the outside in.Draw containers before the things they contain.16Top view, just framesQuickTime™ and aTIFF (LZW) decompressorare needed to see this picture.17Table1 and Book1QuickTime™ and aTIFF (LZW) decompressorare needed to see this picture.18Draw Table1 and Book1 // Start in World coords, on floor of roomCTM = Matrix::IDENTITY;// Move to Table1 position, draw tableCTM = CTM*Matrix.MakeTranslate(2,8,0);drawTable();// Move up to tabletop heightCTM = CTM*Matrix.MakeTranslate(0,0,3);// Move to Book1 position & orientation, draw CTM = CTM*Matrix.MakeTranslate(3.75,1,0);CTM = CTM*Matrix.MakeRotateZ(90);drawBook();19Simplify the idiomRoutines that affect the CTM:LoadIdentity () { CTM = Matrix::IDENTITY }Translate(V) { CTM = CTM*Matrix::MakeTranslate(V) }RotateZ(angle) { CTM = CTM*Matrix::MakeRotateZ(angle) }Etc…Transform(M) { CTM = CTM*M }20Draw Table1 and Book, redux // Start in


View Full Document

UCSD CSE 167 - Hierarchical Transforms

Documents in this Course
Lighting

Lighting

38 pages

Review

Review

59 pages

Surfaces

Surfaces

22 pages

Review

Review

110 pages

Midterm

Midterm

4 pages

Lighting

Lighting

38 pages

Lighting

Lighting

71 pages

Review

Review

110 pages

Lighting

Lighting

71 pages

Load more
Download Hierarchical Transforms
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Hierarchical Transforms and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Hierarchical Transforms 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?