VTK. VTK Online Resources On-line Resources VTK –Manual: –Examples:

Slides:



Advertisements
Similar presentations
CS0004: Introduction to Programming Visual Studio 2010 and Controls.
Advertisements

Ray tracing. New Concepts The recursive ray tracing algorithm Generating eye rays Non Real-time rendering.
Graphics Pipeline.
Anders Hast Visualization Expert
Programming for Image Processing/Analysis and Visualization using The Visualization Toolkit Week 3: Simple Visualization Tasks Xenios Papademetris
Graphics Systems I-Chen Lin’s CG slides, Doug James’s CG slides Angel, Interactive Computer Graphics, Chap 1 Introduction to Graphics Pipeline.
Programming for Image Processing/Analysis and Visualization using The Visualization Toolkit Xenios Papademetris BML 325,
Visualization Knowledge (VisKo): Leveraging the Semantic Web to Support VisualizationVisKo University of Texas at El Paso Computer Science.
Visualization Knowledge (VisKo): Leveraging the Semantic Web to Support VisualizationVisKo Nicholas Del Rio CyberShARE Center University of Texas at El.
2. Introduction to the Visual Studio.NET IDE 2. Introduction to the Visual Studio.NET IDE Ch2 – Deitel’s Book.
3D Concepts Coordinate Systems Coordinates specify points in space 3D coords commonly use X, Y, & Z A vertex is a 'corner' of an object Different coordinate.
Scratch the Cat. Object Oriented Programing Writing computer programs Based on Objects Instead of Actions Based on Data Instead of Logic.
Modeling and Animation with 3DS MAX R 3.1 Graphics Lab. Korea Univ. Reference URL :
Chapter 3 Working with Symbols and Interactivity.
Introduction to 3D Computer Graphics and Virtual Reality McConnell text.
COMP 175: Computer Graphics March 24, 2015
CS324e - Elements of Graphics and Visualization Checkerboard World.
VTK: The Visualization Toolkit Part I: Overview and object models March 28, 2001.
Making a Boat Racing Game in Alice By Jenna Hayes Under the direction of Professor Susan Rodger Duke University, July 2010.
EEC-693/793 Applied Computer Vision with Depth Cameras Lecture 13 Wenbing Zhao
Written by: Itzik Ben Shabat Technion - Israel Institute of Technology Faculty of Mechanical Engineering Laboratory for CAD & Lifecycle Engineering Lab.
Week 2 - Wednesday CS361.
© 2011 Delmar, Cengage Learning Chapter 3 Working with Symbols and Interactivity.
Working with Symbols and Interactivity
1 k Jarek Rossignac,  2008 Processing  Install Processing  Learn how to edit, run, save, export, post programs  Understand.
Addison Wesley is an imprint of © 2010 Pearson Addison-Wesley. All rights reserved. Chapter 5 Working with Images Starting Out with Games & Graphics in.
V part C.  Different programs have different ways of displaying objects in real-time while the scenes are being created within the workspace. Some.
CS 450: COMPUTER GRAPHICS REVIEW: INTRODUCTION TO COMPUTER GRAPHICS – PART 2 SPRING 2015 DR. MICHAEL J. REALE.
Lecture 3 OpenGL.
© 2010 Delmar, Cengage Learning Chapter 3: Working with Symbols and Interactivity.
Graphics Systems and OpenGL. Business of Generating Images Images are made up of pixels.
MIT EECS 6.837, Durand and Teller 1 The Rendering Pipeline Local Illumination Models MIT EECS Lecture 4, September 17 th 2002.
Image Synthesis Rabie A. Ramadan, PhD 1. 2 About my self Rabie A. Ramadan My website and publications
Processing Lab 3 – Header issues and trace editing Bryce Hutchinson Objectives: Fixing elevation issues Define an LMO function Pick first breaks Kill traces.
1 Computer Graphics Week2 –Creating a Picture. Steps for creating a picture Creating a model Perform necessary transformation Lighting and rendering the.
12/03/10 ANIMASI TEKNOLOGI IF.UB. Eriq Muhammad Adams J. -
Visualization Knowledge (VisKo): Leveraging the Semantic Web to Support VisualizationVisKo Paulo Pinheiro da Silva and Nicholas Del Rio CyberShARE Center.
Learning Unity. Getting Unity
Computer Graphics Chapter 6 Andreas Savva. 2 Interactive Graphics Graphics provides one of the most natural means of communicating with a computer. Interactive.
Graphic Basics in C ATS 315. The Graphics Window Will look something like this.
NA-MIC, 2008 June Workshop, IHK Akademie Westerham VTK
VTK: The Visualization Toolkit Qaiser Chaudry Georgia Institute of Technology June 28, 2006.
PowerPoint Practice Exercise 1 1.Save this file in your AV-TECH Folder as PowerPoint Practice Exercise 1. 2.Open this file in PowerPoint. 3.Edit each slide.
CS324e - Elements of Graphics and Visualization Java 3D Intro.
Visualization Knowledge Query Language (VKQL) Workshop Nicholas Del Rio University of Texas at El Paso Computer Science.
Build-It-Yourself.com BLENDER 3D LESSON 3 BLENDER 3D LESSON 3.
CSE 381 – Advanced Game Programming GLSL. Rendering Revisited.
Subject Name: Computer Graphics Subject Code: Textbook: “Computer Graphics”, C Version By Hearn and Baker Credits: 6 1.
 Advancing from moving premade primitives to making our own models  Two different approaches: ◦ Direct mesh editing: A more traditional approach commonly.
 The terms LMB, MMB, RMB, and mouse wheel (MW).
1 CSC 221: Computer Programming I Fall 2009 Introduction to programming in Scratch  animation sprites  motion, control & sensing  costume changes 
CIS 205—Web Design & Development Flash Chapter 3 Working with Symbols and Interactivity.
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.
Graphics Programming. Graphics Functions We can think of the graphics system as a black box whose inputs are function calls from an application program;
1 CW11 Visualizing ACE3P Results in ParaView Greg Schussman Menlo Park, CA October 10, 2011.
CSCI 4972 Introduction to Visualization Fall 2010
July FLTK The Fast Light Toolkit • A C++ graphical user interface toolkit • Can be used under X, Windows, MacOS • Supports OpenGL • Provides: – Interactive.
Computer Graphics (Fall 2003) COMS 4160, Lecture 5: OpenGL 1 Ravi Ramamoorthi Many slides courtesy Greg Humphreys.
EEC-693/793 Applied Computer Vision with Depth Cameras
- Introduction - Graphics Pipeline
Photorealistic Rendering vs. Interactive 3D Graphics
EEC-693/793 Applied Computer Vision with Depth Cameras
CS451Real-time Rendering Pipeline
Introducing Blender.
EEC-693/793 Applied Computer Vision with Depth Cameras
Introducing Blender.
Assignment 1 Creating a Heart.
EEC-693/793 Applied Computer Vision with Depth Cameras
Assignment 1 Creating a Heart.
Presentation transcript:

VTK

VTK Online Resources On-line Resources VTK –Manual: –Examples: –More examples: –Everything else: TCL –Manual: –Online tutorial: –Everything else:

Recall, VTK Architecture “Object-oriented” –Instance, inheritance, subclass, … Instances of vtkRenderWindow Instances of vtkRenderer Instances of vtkActor vtkMapper defines actor geometry vtkProperty defines actor surface properties One or more vtLights illuminate the scence

Model.cxx – Overview #include - vtk stuff main () { // create rendering windows and three renderers // create an actor and give it cone geometry // create an actor and give it cube geometry // create an actor and give it sphere geometry // assign our actor to both renderers // set the size of our window // set the viewports and background of the renderers // draw the resulting scene // Clean up One vtkRenderer defines view for each renderer Instances of vtkRenderWindow Instances of vtkRenderer Instances of vtkActor vtkMapper defines actor geometry vtkProperty defines actor surface properties One or more vtLights illuminate the scence

Model.cxx – Overview – 1/5 #include - vtk stuff main () { // create rendering windows and three renderers // create an actor and give it cone geometry // create an actor and give it cube geometry // create an actor and give it sphere geometry // assign our actor to both renderers // set the size of our window // set the viewports and background of the renderers // draw the resulting scene // Clean up One vtkRenderer defines view for each renderer Instances of vtkRenderWindow Instances of vtkRenderer Instances of vtkActor vtkMapper defines actor geometry vtkProperty defines actor surface properties One or more vtLights illuminate the scence

Model.cxx – 2a/5 #include - vtk stuff main () { // create rendering windows and three renderers // create an actor and give it cone geometry // create an actor and give it cube geometry // create an actor and give it sphere geometry // assign our actor to both renderers // set the size of our window // set the viewports and background of the renderers // draw the resulting scene // Clean up #include "vtkRenderer.h" #include "vtkRenderWindow.h" #include "vtkRenderWindowInteractor.h" #include "vtkConeSource.h" #include "vtkPolyDataMapper.h" #include "vtkActor.h" #include "vtkCubeSource.h" #include "vtkSphereSource.h" #include "vtkProperty.h" main () { // create rendering windows and three renderers vtkRenderer *ren1 = vtkRenderer::New(); vtkRenderer *ren2 = vtkRenderer::New(); vtkRenderWindow *renWindow1 = vtkRenderWindow::New(); renWindow1->AddRenderer(ren1); renWindow1->AddRenderer(ren2); vtkRenderWindowInteractor *iren1 = vtkRenderWindowInteractor::New(); iren1->SetRenderWindow(renWindow1);. :

Model.cxx – 2b/5 #include - vtk stuff main () { // create rendering windows and three renderers (just 1 shown) // create an actor and give it cone geometry // create an actor and give it cube geometry // create an actor and give it sphere geometry // assign our actor to both renderers // set the size of our window // set the viewports and background of the renderers // draw the resulting scene // Clean up main () { // create rendering windows and three renderers vtkRenderer *ren1 = vtkRenderer::New(); vtkRenderer *ren2 = vtkRenderer::New(); vtkRenderWindow *renWindow1 = vtkRenderWindow::New(); renWindow1->AddRenderer(ren1); renWindow1->AddRenderer(ren2); vtkRenderWindowInteractor *iren1 = vtkRenderWindowInteractor::New(); iren1->SetRenderWindow(renWindow1);. :

Model.cxx – 3/5 #include - vtk stuff main () { // create rendering windows and three renderers // create an actor and give it cone geometry // create an actor and give it cube geometry // create an actor and give it sphere geometry // assign our actor to both renderers // set the size of our window // set the viewports and background of the renderers // draw the resulting scene // Clean up // create an actor and give it cone geometry vtkConeSource *cone = vtkConeSource::New(); cone->SetResolution(8); vtkPolyDataMapper *coneMaper = vtkPolyDataMapper::New(); coneMapper->SetInput(cone->GetOutput()); vtkActor *coneActor = vtkActor::New(); coneActor->SetMapper(coneMapper); coneActor->GetProperty()- >SetColor(0.2000,0.6300,0.7900); // create an actor and give it cube geometry vtkCubeSource *cube = vtkCubeSource::New(); vtkPolyDataMapper *cubeMapper = vtkPolyDataMapper::New(); cubeMapper->SetInput(cube->GetOutput()); vtkActor *cubeActor = vtkActor::New(); cubeActor->SetMapper(cubeMapper); cubeActor->GetProperty()- >SetColor(0.9804,0.5020,0.4471); // create an actor and give it sphere geometry vtkSphereSource *sphere = vtkSphereSource::New(); sphere->SetThetaResolution(16); sphere->SetPhiResolution(16); vtkPolyDataMapper *sphereMapper = vtkPolyDataMapper::New(); sphereMapper->SetInput(sphere->GetOutput()); vtkActor *sphereActor = vtkActor::New(); sphereActor->SetMapper(sphereMapper); sphereActor->GetProperty()- >SetColor(0.8900,0.6600,0.4100);

Model.cxx – 4/5 #include - vtk stuff main () { // create rendering windows and three renderers // create an actor and give it cone geometry // create an actor and give it cube geometry // create an actor and give it sphere geometry // assign our actor to both renderers // set the size of our window // set the viewports and background of the renderers // draw the resulting scene // Clean up // assign our actor to both renderers ren1->AddActor(coneActor); ren2->AddActor(sphereActor); ren3->AddActor(cubeActor); // set the size of our window renWindow1->SetSize(800,400); renWindow2->SetSize(400,400); // set the viewports and background of the renderers ren1->SetViewport(0,0,0.5,1); ren1->SetBackground(0.9,0.9,0.9); ren2->SetViewport(0.5,0,1,1); ren2->SetBackground(1,1,1); ren3->SetBackground(1,1,1); // draw the resulting scene renWindow1->Render(); renWindow2->Render(); iren1->Start();

Model.cxx – 5/5 #include - vtk stuff main () { // create rendering windows and three renderers // create an actor and give it cone geometry // create an actor and give it cube geometry // create an actor and give it sphere geometry // assign our actor to both renderers // set the size of our window // set the viewports and background of the renderers // draw the resulting scene // Clean up // Clean up ren1->Delete(); ren2->Delete(); renWindow1->Delete(); iren1->Delete(); ren3->Delete(); renWindow2->Delete(); iren2->Delete(); cone->Delete(); coneMapper->Delete(); coneActor->Delete(); cube->Delete(); cubeMapper->Delete(); cubeActor->Delete(); sphere->Delete(); sphereMapper->Delete(); sphereActor->Delete(); return 0; }

VTK Applications, 1 for this and sphere examplehttp://public.kitware.com/VTK/example-code.php 2 steps in creating graphics and visualization applications with VTK: –First, construct a data pipeline (i.e., visualization network) to process data –Second, – create the necessary graphics objects to display the data VTK architecture is based on a demand-driven, pipeline architecture (a visualization network) –Applications must first create a network, and then EXECUTE it –Typically requires: 1. Render() (sent to the rendering window) or an 2. Update() (sent to a filter in the pipeline) Just instantiating the objects and hooking them together won't do anything – YOU HAVE TO REQUEST DATA to get data

VTK Visualization Pipeline Pipeline has two phases: –Visualization phase Processes up to and including mapping of data to geometry –Graphics phase Creating the scene Or, visualization (VTK) transforms data into pictures

VTK Applications, 2 Constructing a pipeline means: –Connecting sources (ingest or create data), filters (process data), and mappers (map through lookup table and into graphics library) –Many different types available –Type checking (either at compile-time in C++ or run-time in Tcl) controls which filters can be connected together To create the graphics objects, typically –create a rendering window to render into –create a renderer –create an interactor (allows you to interact with the graphics) –create one or more actors (each of which is linked to a mapper) –render May also wish to: –transform objects; –set material properties; and/or –create lights, cameras, texture maps, and lookup tables, and various other graphics objects.

Sphere Example Will go through pipeline and render to window void main () { // geometry for sphere created vtkSphereSource *sphere = vtkSphereSource::New(); sphere->SetRadius(1.0); sphere->SetThetaResolution(18); sphere->SetPhiResolution(18); // map to graphics library vtkPolyDataMapper *map = vtkPolyDataMapper::New(); map->SetInput(sphere->GetOutput()); // actor coordinates geometry, properties, transformation vtkActor *aSphere = vtkActor::New(); aSphere->SetMapper(map); aSphere->GetProperty()->SetColor(0,0,1); // sphere color blue // renderer and render window vtkRenderer *ren1 = vtkRenderer::New(); // render window vtkRenderWindow *renWin = vtkRenderWindow::New(); renWin->AddRenderer(ren1); // interactor vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New(); iren->SetRenderWindow(renWin); ren1->AddActor(aSphere); // add the actor to the scene ren1->SetBackground(1,1,1); // Background color white renWin->Render(); // render an image (lights and cameras are created automatically) iren->Start(); } // begin mouse interaction (goes away, if not)

Sphere Example – Some Terms … geometry void main () { // geometry for sphere created vtkSphereSource *sphere = vtkSphereSource::New(); sphere->SetRadius(1.0); sphere->SetThetaResolution(18); sphere->SetPhiResolution(18); // map to graphics library vtkPolyDataMapper *map = vtkPolyDataMapper::New(); map->SetInput(sphere->GetOutput()); // actor coordinates geometry, properties, transformation vtkActor *aSphere = vtkActor::New(); aSphere->SetMapper(map); aSphere->GetProperty()->SetColor(0,0,1); // sphere color blue // renderer and render window vtkRenderer *ren1 = vtkRenderer::New(); // render window vtkRenderWindow *renWin = vtkRenderWindow::New(); renWin->AddRenderer(ren1); // interactor vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New(); iren->SetRenderWindow(renWin); ren1->AddActor(aSphere); // add the actor to the scene ren1->SetBackground(1,1,1); // Background color white renWin->Render(); // render an image (lights and cameras are created automatically) iren->Start(); } // begin mouse interaction (goes away, if not)

Sphere Example – Some Terms … map void main () { // geometry for sphere created vtkSphereSource *sphere = vtkSphereSource::New(); sphere->SetRadius(1.0); sphere->SetThetaResolution(18); sphere->SetPhiResolution(18); // map to graphics library vtkPolyDataMapper *map = vtkPolyDataMapper::New(); map->SetInput(sphere->GetOutput()); // actor coordinates geometry, properties, transformation vtkActor *aSphere = vtkActor::New(); aSphere->SetMapper(map); aSphere->GetProperty()->SetColor(0,0,1); // sphere color blue // renderer and render window vtkRenderer *ren1 = vtkRenderer::New(); // render window vtkRenderWindow *renWin = vtkRenderWindow::New(); renWin->AddRenderer(ren1); // interactor vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New(); iren->SetRenderWindow(renWin); ren1->AddActor(aSphere); // add the actor to the scene ren1->SetBackground(1,1,1); // Background color white renWin->Render(); // render an image (lights and cameras are created automatically) iren->Start(); } // begin mouse interaction (goes away, if not)

Sphere Example – Some Terms … actor void main () { // geometry for sphere created vtkSphereSource *sphere = vtkSphereSource::New(); sphere->SetRadius(1.0); sphere->SetThetaResolution(18); sphere->SetPhiResolution(18); // map to graphics library vtkPolyDataMapper *map = vtkPolyDataMapper::New(); map->SetInput(sphere->GetOutput()); // actor coordinates geometry, properties, transformation vtkActor *aSphere = vtkActor::New(); aSphere->SetMapper(map); aSphere->GetProperty()->SetColor(0,0,1); // sphere color blue // renderer and render window vtkRenderer *ren1 = vtkRenderer::New(); // render window vtkRenderWindow *renWin = vtkRenderWindow::New(); renWin->AddRenderer(ren1); // interactor vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New(); iren->SetRenderWindow(renWin); ren1->AddActor(aSphere); // add the actor to the scene ren1->SetBackground(1,1,1); // Background color white renWin->Render(); // render an image (lights and cameras are created automatically) iren->Start(); } // begin mouse interaction (goes away, if not)

Sphere Example – Some Terms … renderer, render window void main () { // geometry for sphere created vtkSphereSource *sphere = vtkSphereSource::New(); sphere->SetRadius(1.0); sphere->SetThetaResolution(18); sphere->SetPhiResolution(18); // map to graphics library vtkPolyDataMapper *map = vtkPolyDataMapper::New(); map->SetInput(sphere->GetOutput()); // actor coordinates geometry, properties, transformation vtkActor *aSphere = vtkActor::New(); aSphere->SetMapper(map); aSphere->GetProperty()->SetColor(0,0,1); // sphere color blue // renderer and render window vtkRenderer *ren1 = vtkRenderer::New(); // render window vtkRenderWindow *renWin = vtkRenderWindow::New(); renWin->AddRenderer(ren1); // interactor vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New(); iren->SetRenderWindow(renWin); ren1->AddActor(aSphere); // add the actor to the scene ren1->SetBackground(1,1,1); // Background color white renWin->Render(); // render an image (lights and cameras are created automatically) iren->Start(); } // begin mouse interaction (goes away, if not)

Sphere Example – Some Terms … interactor void main () { // geometry for sphere created vtkSphereSource *sphere = vtkSphereSource::New(); sphere->SetRadius(1.0); sphere->SetThetaResolution(18); sphere->SetPhiResolution(18); // map to graphics library vtkPolyDataMapper *map = vtkPolyDataMapper::New(); map->SetInput(sphere->GetOutput()); // actor coordinates geometry, properties, transformation vtkActor *aSphere = vtkActor::New(); aSphere->SetMapper(map); aSphere->GetProperty()->SetColor(0,0,1); // sphere color blue // renderer and render window vtkRenderer *ren1 = vtkRenderer::New(); // render window vtkRenderWindow *renWin = vtkRenderWindow::New(); renWin->AddRenderer(ren1); // interactor vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New(); iren->SetRenderWindow(renWin); ren1->AddActor(aSphere); // add the actor to the scene ren1->SetBackground(1,1,1); // Background color white renWin->Render(); // render an image (lights and cameras are created automatically) iren->Start(); } // begin mouse interaction (goes away, if not)

Sphere Example – Some Terms … render void main () { // geometry for sphere created vtkSphereSource *sphere = vtkSphereSource::New(); sphere->SetRadius(1.0); sphere->SetThetaResolution(18); sphere->SetPhiResolution(18); // map to graphics library vtkPolyDataMapper *map = vtkPolyDataMapper::New(); map->SetInput(sphere->GetOutput()); // actor coordinates geometry, properties, transformation vtkActor *aSphere = vtkActor::New(); aSphere->SetMapper(map); aSphere->GetProperty()->SetColor(0,0,1); // sphere color blue // renderer and render window vtkRenderer *ren1 = vtkRenderer::New(); // render window vtkRenderWindow *renWin = vtkRenderWindow::New(); renWin->AddRenderer(ren1); // interactor vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New(); iren->SetRenderWindow(renWin); ren1->AddActor(aSphere); // add the actor to the scene ren1->SetBackground(1,1,1); // Background color white renWin->Render(); // render an image (lights, cameras are created automatically) iren->Start(); } // begin mouse interaction (goes away, if not)

Cone – VTK Visualization Pipeline int main( int argc, char *argv[] ) { vtkConeSource *cone = vtkConeSource::New(); cone->SetHeight( 3.0 ); cone->SetRadius( 1.0 ); cone->SetResolution( 10 ); vtkPolyDataMapper *coneMapper = vtkPolyDataMapper::New(); coneMapper->SetInput( cone->GetOutput() ); vtkActor *coneActor = vtkActor::New(); coneActor->SetMapper( coneMapper ); // Create the Renderer and assign actors to it vtkRenderer *ren1= vtkRenderer::New(); ren1->AddActor( coneActor ); ren1->SetBackground( 0.1, 0.2, 0.4 ); vtkRenderWindow *renWin = vtkRenderWindow::New(); renWin->AddRenderer( ren1 ); renWin->SetSize( 300, 300 ); }

VTK Interaction Create a new vtkRenderWindowInteractor –controls user interaction with VTK visualisation –vtkRenderWindowInteractor iren Set the RenderWindow object that it will control –iren SetRenderWindow renWin Make the interactor active and start processing events –iren Initialize Functions available (vtkRenderWindowInteractor): –Rotate ( left mouse button ) –Zoom ( Right mouse button ) –Pan ( left mouse + shift key ) –‘w’ Draw as a wireframe mesh –‘s’ Draw as a surface mesh –‘r’ Reset camera view –‘u’ user defined command. Here, bring up window command box –iren SetUserMethod {wm deiconify.vtkInteract} –‘e’ exit –‘p’ pick actor underneath mouse pointer

Cone examples Book examples –(where vtk installed)…vtksrc/examples/tutorial

Cone – Visualization Pipeline // This example creates a polygonal model of a cone, and then renders it to // the screen. It will rotate the cone 360 degrees and then exit. The basic // setup of source -> mapper -> actor -> renderer -> renderwindow is // typical of most VTK programs. // First include the required header files for the VTK classes int main( int argc, char *argv[] ) { // Next we create an instance of vtkConeSource and set some of its // properties. The instance of vtkConeSource "cone" is part of a // visualization pipeline (it is a source process object); // it produces data (output type is vtkPolyData) //which other filters may process. // vtkConeSource *cone = vtkConeSource::New(); cone->SetHeight( 3.0 ); cone->SetRadius( 1.0 ); cone->SetResolution( 10 ); // In this example we terminate the pipeline with a mapper process object. // (Intermediate filters such as vtkShrinkPolyData could be inserted in // between the source and the mapper.) We create an instance of // vtkPolyDataMapper to map the polygonal data into graphics primitives. We // connect the output of the cone source to the input of this mapper. // vtkPolyDataMapper *coneMapper = vtkPolyDataMapper::New(); coneMapper->SetInput( cone->GetOutput() );

Cone – Visualization Pipeline // Create an actor to represent the cone. //The actor orchestrates rendering // of the mapper's graphics primitives. // We set this actor's mapper to be // coneMapper which we created/ above. vtkActor *coneActor = vtkActor::New(); coneActor->SetMapper( coneMapper ); // Create the Renderer and assign actors to it. A renderer is like a // viewport. It is part or all of a window on the screen and it is // responsible for drawing the actors it has. // We also set the background // color here. vtkRenderer *ren1= vtkRenderer::New(); ren1->AddActor( coneActor ); ren1->SetBackground( 0.1, 0.2, 0.4 );

Cone – Visualization Pipeline // Finally create render window which will show up on screen. // We put our renderer into render window using AddRenderer. // set the size to be 300 pixels by 300. // vtkRenderWindow *renWin = vtkRenderWindow::New(); renWin->AddRenderer( ren1 ); renWin->SetSize( 300, 300 ); // Now loop over 360 degrees and render the cone each time. // int i; for (i = 0; i < 360; ++i) { // render the image renWin->Render(); // rotate the active camera by one degree ren1->GetActiveCamera()->Azimuth( 1 ); // orange arrow } // Free up any objects we created using the Delete() method. // cone->Delete(); coneMapper->Delete(); coneActor->Delete(); ren1->Delete(); renWin->Delete(); return 0; }

(Several) Coordinate Systems Model/object … –local coordinate system World … –Where the models are placed View … –Logical Image Plane Display (image plane) –X,Y Pixel locations In cg and VTK several coordinate systems come into play:

VTK Camera Camera movements around focal point –camera.tcl –Pointing toward focal point, white –Elevation, green –Azimuth, orange –Roll, yellow –Direction of projection, purple arrow Camera movements centered at camera position –Pointing toward focal point, white –View up, blue –Pitch (vs. elevation), green –Yaw (vs. azimuth), orange –Roll, yellow –View plane normal (vs. direction of projection), purple arrow

Homework 2 Create a simple scene using the built-in VTK source objects, cf. Figure Use at least three different objects with different object types, placed in different positions, each with different color and surface properties. It would be great to get into it and do something interesting, e.g., a clock. Use the built-in window interactor to play around with viewing the scene. Turn in next week a screen capture and the code. Starting with a VTK supplied example is fine. As possible try to get TCL or Python to work, and consider using that for your work.

Real End.