Technion - Israel Institute of Technology Faculty of Mechanical Engineering Laboratory for CAD & Lifecycle Engineering Lab 10: 3D & Projections Advanced.

Slides:



Advertisements
Similar presentations
Computer Graphics - Viewing -
Advertisements

COS 429 PS2: Reconstructing a Simpler World
Three Dimensional Viewing
Shared Graphics Skills Cameras and Clipping Planes
Exploded CAD Assembly Models © 2012 Project Lead The Way, Inc.
1 Computer Graphics Week6 –Basic Transformations- Translation & Scaling.
1 3D modelling with OpenGL Brian Farrimond Robina Hetherington.
CSC 461: Lecture 51 CSC461 Lecture 5: Simple OpenGL Program Objectives: Discuss a simple program Discuss a simple program Introduce the OpenGL program.
Technion - Israel Institute of Technology Faculty of Mechanical Engineering Laboratory for CAD & Lifecycle Engineering Lab 9: 3D & Projections Basics.
Written by: Itzik Ben Shabat Technion - Israel Institute of Technology Faculty of Mechanical Engineering Laboratory for CAD & Lifecycle Engineering Lab.
Chapter 10 Creating 3D Objects. Objectives Extrude objects Revolve objects Manipulate surface shading and lighting Map artwork to 3D objects Work with.
3D Concepts UNIT 3. 3-D Coordinate Spaces Remember what we mean by a 3-D coordinate space x axis y axis z axis P y z x Right-Hand Reference System.
1 Chapter 5 Viewing. 2 Perspective Projection 3 Parallel Projection.
3D Rendering with JOGL Introduction to Java OpenGL Graphic Library By Ricardo Veguilla
 1999 BG Mobasseri1 8/29/2015 MATLAB GRAPHICS - PART II ADVANCED PLOTTING June 4, ‘99.
Modeling and Animation with 3DS MAX R 3.1 Graphics Lab. Korea Univ. Reference URL :
Programming a GUI Hanan sedaghat pisheh. For calling GUI, we need a function with no inputs or outputs First We create a m.file m file has the same name.
Basic graphics. ReviewReview Viewing Process, Window and viewport, World, normalized and device coordinates Input and output primitives and their attributes.
1 iSee Player Tutorial Using the Forest Biomass Accumulation Model as an Example ( Tutorial Developed by: (
Computer Graphics (fall 2009)
Chapter 10 Creating 3D Objects. Extruding Objects The Extrude & Bevel effect makes two- dimensional objects three-dimensional. A two-dimensional object.
Written by: Itzik Ben Shabat Technion - Israel Institute of Technology Faculty of Mechanical Engineering Laboratory for CAD & Lifecycle Engineering Lab.
Week 2 - Wednesday CS361.
GUI development with Matlab: GUI Front Panel Components 1 GUI front panel components In this section, we will look at -GUI front panel components -Programming.
Computer Graphics Bing-Yu Chen National Taiwan University.
Lecture 6: 3D graphics Concepts 1  Principles of Interactive Graphics  CMSCD2012  Dr David England, Room 718,  ex 2271 
1Computer Graphics Lecture 4 - Models and Architectures John Shearer Culture Lab – space 2
Written by: Itzik Ben Shabat Technion - Israel Institute of Technology Faculty of Mechanical Engineering Laboratory for CAD & Lifecycle Engineering Lab.
Modeling with OpenGL Practice with OpenGL transformations.
Game Maker Terminology
Introduction to MATLAB Session 5 Simopekka Vänskä, THL 2010.
Unit 6 3D Modeling Concepts
2D Routines in 3D. Outline Announcements –HW II--due Friday. 5PM HW1 & Cookie Grids & Meshes Representing f(x,y) Lines & Surfaces in 3D Survey.
Basic 3D Concepts. Overview 1.Coordinate systems 2.Transformations 3.Projection 4.Rasterization.
Written by: Itzik Ben Shabat Technion - Israel Institute of Technology Faculty of Mechanical Engineering Laboratory for CAD & Lifecycle Engineering Lab.
Review on Graphics Basics. Outline Polygon rendering pipeline Affine transformations Projective transformations Lighting and shading From vertices to.
12/24/2015 A.Aruna/Assistant professor/IT/SNSCE 1.
Graphics CSCI 343, Fall 2015 Lecture 16 Viewing I
CS COMPUTER GRAPHICS LABORATORY. LIST OF EXPERIMENTS 1.Implementation of Bresenhams Algorithm – Line, Circle, Ellipse. 2.Implementation of Line,
Written by: Itzik Ben Shabat Technion - Israel Institute of Technology Faculty of Mechanical Engineering Laboratory for CAD & Lifecycle Engineering Lab.
1 Angel: Interactive Computer Graphics5E © Addison- Wesley 2009 Image Formation Fundamental imaging notions Fundamental imaging notions Physical basis.
Improving the appearance of 3D OpenGL scenes
5 Event Handling Interactive Programming Suggested Reading Interaction: Events and Event Handling, Supplemental Text for CPSC 203 Distributed this term.
Written by: Itzik Ben Shabat Technion - Israel Institute of Technology Faculty of Mechanical Engineering Laboratory for CAD & Lifecycle Engineering Lab.
Written by: Itzik Ben Shabat Technion - Israel Institute of Technology Faculty of Mechanical Engineering Laboratory for CAD & Lifecycle Engineering Lab.
1 Programming with OpenGL Part 2: Complete Programs.
 Advancing from moving premade primitives to making our own models  Two different approaches: ◦ Direct mesh editing: A more traditional approach commonly.
Technion - Israel Institute of Technology Faculty of Mechanical Engineering Laboratory for CAD & Lifecycle Engineering Lab 9: 3D & Projections Basics.
 The terms LMB, MMB, RMB, and mouse wheel (MW).
Exploded CAD Assembly Models Also called… Pictorial Assembly Exploded View Exploded Assembly Exploded Pictorial Exploded Assembly Presentation.
More Matlab Graphics and GUI Graphics subplots some useful commands 3D graphics GUI GUI controls The callback property Other essential properties.
Chapter 1 Graphics Systems and Models Models and Architectures.
Computer Graphics Imaging Lecture 13 and 14 UV Mapping.
UNIT 11: 3D AutoCAD Objectives: How to print or plot a drawing How to setup a layout using title blocks and viewports Create and manage new layouts Be.
EEE 242 Computer Tools for Electrical Engineering
Viewing. Classical Viewing Viewing requires three basic elements - One or more objects - A viewer with a projection surface - Projectors that go from.
3D Ojbects: Transformations and Modeling. Matrix Operations Matrices have dimensions: Vectors can be thought of as matrices: v=[2,3,4,1] is a 1x4 matrix.
Written by: Itzik Ben Shabat Technion - Israel Institute of Technology Faculty of Mechanical Engineering Laboratory for CAD & Lifecycle Engineering Lab.
© University of Wisconsin, CS559 Spring 2004
Projection Our 3-D scenes are all specified in 3-D world coordinates
Under the direction of Susan Rodger
Modeling 101 For the moment assume that all geometry consists of points, lines and faces Line: A segment between two endpoints Face: A planar area bounded.
2D Routines in 3D.
Exploded CAD Assembly Models
Forging new generations of engineers
Computer Animation UV Mapping.
Forging new generations of engineers
Computer Animation Texture Mapping.
Viewing (Projections)
Viewing (Projections)
Presentation transcript:

Technion - Israel Institute of Technology Faculty of Mechanical Engineering Laboratory for CAD & Lifecycle Engineering Lab 10: 3D & Projections Advanced

Technion - Israel Institute of Technology Faculty of Mechanical Engineering Laboratory for CAD & Lifecycle Engineering Tutorial contents 3D primitives Plotting a cube View Transformations basic Projections Orthographic Perspective Isometric View Transformation Advanced

Technion - Israel Institute of Technology Faculty of Mechanical Engineering Laboratory for CAD & Lifecycle Engineering 3D Primitives surf(X,Y,Z) surf(...,'PropertyName',PropertyValue) Uses Z for the color data and surface height. X and Y are vectors or matrices defining the x and y components of a surface For a full property list use linklink

Technion - Israel Institute of Technology Faculty of Mechanical Engineering Laboratory for CAD & Lifecycle Engineering 3D Primitives patch(X,Y,Z,C) patch('PropertyName',propertyvalue,...) Adds a filled 3-D patch object to the current axes. A patch object is one or more polygons defined by the coordinates of its vertices. The elements of X, Y and Z specify the vertices of a polygon. If X, Y and Z are m-by-n matrices, MATLAB draws n polygons with m vertices. C determines the color of the patch. For a full property list visit linklink

Technion - Israel Institute of Technology Faculty of Mechanical Engineering Laboratory for CAD & Lifecycle Engineering 3D Primitives sphere The sphere function generates the x-, y-, and z-coordinates of a unit sphere for use with surf sphere generates a sphere consisting of 20-by-20 faces

Technion - Israel Institute of Technology Faculty of Mechanical Engineering Laboratory for CAD & Lifecycle Engineering Plotting a cube Create a new.m file and call it “yourname_3D_projection” Create 5 functions (code is given in following slides) Main9() DrawingCB() drawCube ( size ) KeyboardCB(hObject, event) ReshapeCB(ax) In main9 open a new figure with the following properties Black background Position and size - as you wish Name – Yourname 3D projection Number title – off Set keyboard button press callback to be KeyboardCB Call drawingCB();

Technion - Israel Institute of Technology Faculty of Mechanical Engineering Laboratory for CAD & Lifecycle Engineering Plotting a cube Your code for main9 should look something like this function main9() %main9 demonstarits 3D primitives and Projections Tutorial %initialize clear all; close all; clc; Figureh=figure('NumberTitle','off','Name','3D Projection Example',... 'Position',[ ],'color','k'); DrawingCB(); end

Technion - Israel Institute of Technology Faculty of Mechanical Engineering Laboratory for CAD & Lifecycle Engineering Plotting a cube In DrawingCB Clear the current figure (use clf) Creat axes with limits [-1 1] in all directions Set background to black Initialize cube size variable to be [1 1 1] Draw the cube Call Reshape function

Technion - Israel Institute of Technology Faculty of Mechanical Engineering Laboratory for CAD & Lifecycle Engineering Plotting a cube Your code for DrawingCB should look something like this function []=DrawingCB() %initialize variables clf; cubesize=[1,1,1]; %draw Axesh=axes('XLim',[-1 1],'YLim',[-1,1],'ZLim',[-1,1],'Color','k'); cubehandle=drawCube ( cubesize); ReshapeCB(Axesh); end

Technion - Israel Institute of Technology Faculty of Mechanical Engineering Laboratory for CAD & Lifecycle Engineering Plotting a cube In draw cube function – Input is cube size Initialize vertices around 0 Draw using patch Set different color to each face Set edge color to be white

Technion - Israel Institute of Technology Faculty of Mechanical Engineering Laboratory for CAD & Lifecycle Engineering Plotting a cube Your code should look something like this function cube=drawCube ( size ) %drawcube draws a cube around (0,0,0) in input size and return the cubes %handle %INPUT: size - 3 element vector [sizex, sizey,sizez) %OUTPUT: cube - a handle of the patches drawn %Initialize cube parameters x=([ ; ; ; ]-0.5)*size(1); y=([ ; ; ; ]-0.5)*size(2); z=([ ; ; ; ]-0.5)*size(3); %Define patches color cdata(:,:,1) = [ ]; cdata(:,:,2) = [ ]; cdata(:,:,3) = [ ]; cube=patch(x,y,z,cdata); set(cube,'edgecolor','w'); end

Technion - Israel Institute of Technology Faculty of Mechanical Engineering Laboratory for CAD & Lifecycle Engineering Plotting a cube Copy the following code to KeyboardCB – What does it do? function []=KeyboardCB(hObject, event) global ProjType Phi Teta switch event.Key case 'p' if ProjType==1 ProjType=2; else ProjType=1; end case 'leftarrow' Phi=Phi+5; case 'rightarrow' Phi=Phi-5; case 'uparrow' Teta=Teta+5; case 'downarrow' Teta=Teta-5; end DrawingCB(); end

Technion - Israel Institute of Technology Faculty of Mechanical Engineering Laboratory for CAD & Lifecycle Engineering Plotting a cube Copy the following code to reshape function []=ReshapeCB(ax) global ProjType daspect([1,1,1]); if ProjType==1 else end

Technion - Israel Institute of Technology Faculty of Mechanical Engineering Laboratory for CAD & Lifecycle Engineering Plotting a cube In main9 define global variables and set their initial value global ProjType Phi Teta ProjType=1; Phi=0; Teta=0;

Technion - Israel Institute of Technology Faculty of Mechanical Engineering Laboratory for CAD & Lifecycle Engineering Plotting a cube Your output should look like this Question Where is the cube ?

Technion - Israel Institute of Technology Faculty of Mechanical Engineering Laboratory for CAD & Lifecycle Engineering View Transformation Basic In order to see the cube in 3D space we need to set the viewpoint Currently we are viewing the cube in perpendicular direction to one of its faces view([az,el]) view([x,y,z]) view(2|3) The position of the viewer (the viewpoint) determines the orientation of the axes. You specify the viewpoint in terms of azimuth and elevation, or by a point in three-dimensional space. view(2) sets the default two-dimensional view, az = 0, el = 90. view(3) sets the default three-dimensional view, az = –37.5, el = 30 – isometric.

View Transformations Basic Lets set the initial view to be isometric Add view(3); in the end of DrawingCB Your Output should look like this Technion - Israel Institute of Technology Faculty of Mechanical Engineering Laboratory for CAD & Lifecycle Engineering

Projections In order to see the effects of changing projection type first make the following alterations to your code: Set face color to none after plotting the patches- set(cube,'facecolor','none'); Technion - Israel Institute of Technology Faculty of Mechanical Engineering Laboratory for CAD & Lifecycle Engineering

Projections The output depends on several parameters Projection type (Orthographic \ Perspective) Projection Parameters (camera position, view angle etc.) The object location in space In order to see the effects of changing projection type we must first set the projection type and then set all of these parameters Technion - Israel Institute of Technology Faculty of Mechanical Engineering Laboratory for CAD & Lifecycle Engineering

Projections Set The projection Type set(ax,'Projection','Orthographic'); OR set(ax,'Projection','Perspective'); Question: We wish to toggle between these two modes by pressing ‘p’ – where should you put this code? Technion - Israel Institute of Technology Faculty of Mechanical Engineering Laboratory for CAD & Lifecycle Engineering

Projections Run the code and press p – do you see the change in projection? In order to see the change better we should look perpendicular to a face Technion - Israel Institute of Technology Faculty of Mechanical Engineering Laboratory for CAD & Lifecycle Engineering

Projections Comment view(3); - %view(3) Run the code again Technion - Israel Institute of Technology Faculty of Mechanical Engineering Laboratory for CAD & Lifecycle Engineering

View Transformations Advanced Now we wish to change the view angle manually by pressing the arrows (up, down, left and right). We can move the camera/eye as we wish Lets move it along a spherical shell Technion - Israel Institute of Technology Faculty of Mechanical Engineering Laboratory for CAD & Lifecycle Engineering

View Transformations Advanced Changing the view manually 24

View Transformations Advanced Lets place the eye on a sphere of radius r: Spherical coordinates: From wikipedia However – our coordinate system is rotated so we replace z with y, x with z, and y with x. 25 z y x

View Transformations Advanced To initialize the view in the –z direction Now all we have left is to find the vector up 26 z y x t

View Transformations Advanced Axes camera properties 'CameraPosition‘ – A 3 element vector containing the x,y,z coordinates of the camera. 'CameraTarget‘ – A 3 element vector containing the x,y,z coordineates of the target (what is the camera looking at) 'CameraUpVector‘ – Camera orientation definition in respects to the vector from the camera to the target. 'CameraViewAngle‘ – The scene range of visibility Technion - Israel Institute of Technology Faculty of Mechanical Engineering Laboratory for CAD & Lifecycle Engineering

View Transformations Advanced Set camera parameters in DrawingCB r=5; CamX=r*sind(Teta)*sind(Phi); CamY=r*cosd(Teta); CamZ=r*sind(Teta)*cosd(Phi); UpX=-cosd(Teta)*sind(Phi);UpY=sind(Teta);UpZ=- cosd(Teta)*cosd(Phi); set(Axesh,'CameraPosition',[CamX,CamY,CamZ],'CameraTarget',[0 0 0],... 'CameraUpVector',[UpX,UpY,UpZ],'CameraViewAngle',40); Dont forget to define the global parameters global Phi Teta Technion - Israel Institute of Technology Faculty of Mechanical Engineering Laboratory for CAD & Lifecycle Engineering

View Transformations Advanced Change some of the parameters and see what happens Change r Change ViewAngle Change CameraTarget Set face color back on and play around Technion - Israel Institute of Technology Faculty of Mechanical Engineering Laboratory for CAD & Lifecycle Engineering

View Transformations Advanced ViewAngle property Defines the range of visibility of the scene (not the distortion) Technion - Israel Institute of Technology Faculty of Mechanical Engineering Laboratory for CAD & Lifecycle Engineering

Technion - Israel Institute of Technology Faculty of Mechanical Engineering Laboratory for CAD & Lifecycle Engineering Sources and References Mathworks Documentation Center Further read is highly recommended projections.html projections.html camera-graphics.html camera-graphics.html camera-toolbar.html camera-toolbar.html