1 OGRE Programming Intermediate Tutorial: Volume Selection.

Slides:



Advertisements
Similar presentations
Introducing Macromedia FreeHand MX
Advertisements

Vertex Buffer Objects, Vertex Array Objects, Pixel Buffer Objects.
Coordinate System.
1 Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005 Building Models modified by Ray Wisman Ed Angel Professor of Computer Science,
1 Building Models. 2 Objectives Introduce simple data structures for building polygonal models ­Vertex lists ­Edge lists OpenGL vertex arrays.
Status – Week 257 Victor Moya. Summary GPU interface. GPU interface. GPU state. GPU state. API/Driver State. API/Driver State. Driver/CPU Proxy. Driver/CPU.
Computer Graphics Programming: Matrices and Transformations CSE 3451 Matt Boggus.
CAP4730: Computational Structures in Computer Graphics Visible Surface Determination.
Computer Graphics Visible Surface Determination. Goal of Visible Surface Determination To draw only the surfaces (triangles) that are visible, given a.
CS 4731: Computer Graphics Lecture 18: Hidden Surface Removal Emmanuel Agu.
CSC 461: Lecture 51 CSC461 Lecture 5: Simple OpenGL Program Objectives: Discuss a simple program Discuss a simple program Introduce the OpenGL program.
1 Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005 Programming with OpenGL Part 2: Complete Programs Ed Angel Professor of Computer Science,
3D Rendering with JOGL Introduction to Java OpenGL Graphic Library By Ricardo Veguilla
1 Computer Graphics Week13 –Shading Models. Shading Models Flat Shading Model: In this technique, each surface is assumed to have one normal vector (usually.
Basic Graphics Concepts Day One CSCI 440. Terminology object - the thing being modeled image - view of object(s) on the screen frame buffer - memory that.
CSE 381 – Advanced Game Programming Basic 3D Graphics
Geometric Objects and Transformations. Coordinate systems rial.html.
Rujchai Ung-arunyawee Department of Computer Engineering Khon Kaen University.
Computer Graphics World, View and Projection Matrices CO2409 Computer Graphics Week 8.
Buffers Textures and more Rendering Paul Taylor & Barry La Trobe University 2009.
CS 450: COMPUTER GRAPHICS REVIEW: INTRODUCTION TO COMPUTER GRAPHICS – PART 2 SPRING 2015 DR. MICHAEL J. REALE.
CSE 470: Computer Graphics. 10/15/ Defining a Vertex A 2D vertex: glVertex2f(GLfloat x, GLfloat y); 2D vertexfloating pointopenGL parameter type.
CSC 461: Lecture 3 1 CSC461 Lecture 3: Models and Architectures  Objectives –Learn the basic design of a graphics system –Introduce pipeline architecture.
Image Synthesis Rabie A. Ramadan, PhD 1. 2 About my self Rabie A. Ramadan My website and publications
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
Representation. Objectives Introduce concepts such as dimension and basis Introduce coordinate systems for representing vectors spaces and frames for.
Game Programming 06 The Rendering Engine
Transformations Objective: to develop an understanding of the four transformations. Starter – if 24 x 72 = 2016, find the value of: 1)2.8 x 72 = 2)2.8.
OpenGL The Viewing Pipeline: Definition: a series of operations that are applied to the OpenGL matrices, in order to create a 2D representation from 3D.
Image Synthesis Rabie A. Ramadan, PhD 4. 2 Review Questions Q1: What are the two principal tasks required to create an image of a three-dimensional scene?
RENDERING Introduction to Shading models – Flat and Smooth shading – Adding texture to faces – Adding shadows of objects – Building a camera in a program.
Bump Map 1. High Field Function: H(u, v) New Normal : N’
Lesson 5 Definition of Rotation and Basic Properties
1 E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012 Programming with OpenGL Part 2: Complete Programs Ed Angel Professor.
 Learn some important functions and process in OpenGL ES  Draw some triangles on the screen  Do some transformation on each triangle in each frame.
1 Programming with OpenGL Part 2: Complete Programs.
OpenGL API 2D Graphic Primitives Angel Angel: Interactive Computer Graphics5E © Addison-Wesley
1 Perception, Illusion and VR HNRS 299, Spring 2008 Lecture 15 Creating 3D Models.
Computer Graphics I, Fall 2010 Building Models.
By JerryDean Smith Chad Adams Karl Mullner.  The rectangle needs to be a ogre.ManualObject -this is done to create the rectangle and gives it special.
 The terms LMB, MMB, RMB, and mouse wheel (MW).
Transparency 9 Click the mouse button or press the Space Bar to display the answers.
Design Visualization Software Introduction / Review.
1 E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012 Models and Architectures 靜宜大學 資訊工程系 蔡奇偉 副教授 2012.
In the last several lessons, you have described translations using coordinates. You have also developed strategies for determining where an object started.
Computer Graphics I, Fall Programming with OpenGL Part 2: Complete Programs.
OpenGL CS418 Computer Graphics John C. Hart. OpenGL Based on GL (graphics library) by Silicon Graphics Inc. (SGI) Advantages: Runs on everything, including.
CS 480/680 Computer Graphics Programming with Open GL Part 2: Complete Programs Dr. Frederick C Harris, Jr. Fall 2011.
Angel: Interactive Computer Graphics 5E © Addison-Wesley 2009
Programming with OpenGL Part 2: Complete Programs
Programming with OpenGL Part 2: Complete Programs
Models and Architectures
Introduction to Computer Graphics with WebGL
Building Models Ed Angel
Graphics, Modeling, and Textures
Isaac Gang University of Mary Hardin-Baylor
Presented by 鄭游駿(Yu-Chun Cheng) 2009/11/27
Lecture 13 Clipping & Scan Conversion
Angel: Interactive Computer Graphics5E © Addison-Wesley 2009
Programming with OpenGL Part 2: Complete Programs
Programming with OpenGL Part 2: Complete Programs
Programming with OpenGL Part 2: Complete Programs
Programming with OpenGL Part 2: Complete Programs
Computer Graphics Introduction to Shaders
Game Programming Algorithms and Techniques
CS297 Graphics with Java and OpenGL
Programming with OpenGL Part 2: Complete Programs
Presentation transcript:

1 OGRE Programming Intermediate Tutorial: Volume Selection

2Contents 2 1.Perform volume selection. - Click and drag the mouse across the screen to define a rectangle - Release the mouse button to select all the objects within the selection area - Highlight the selected objects 2.Introduce to graphics hardware buffers 3.Use two objects: ManualObject (to create the rectangle) PlaneBoundedVolumeListSceneQuery

3 - Vertex buffers: define points in 3D space. - Index buffers: connect the points from the vertex buffer to form triangles. - Though all meshes have a vertex buffer, not all meshes will have an index buffer. - Vertex and index buffers: usually stored in the video card's own memory. Graphics Buffers

44 - Define points in 3D space. - Each element in the vertex buffer is defined by several attributes: - Position: The only attribute must be set. - Optional properties: color, texture coordinates and so on. Vertex Buffers

555 - Connect the points from the vertex buffer. - Every three indexes specified in the index buffer defines a single triangle to be drawn by the GPU. -The order of the vertices in the index buffer tells the graphics card which way the triangle faces. - A triangle drawn counter-clockwise is facing to the camera. - A triangle drawn clockwise is facing away from the camera. - Normally only the front of a triangle is rendered Index Buffers

6 -Define in 2D -Be rendered and on top of all other objects on the screen in the overlay layer. -In the SelectionRectangle's constructor: setRenderQueueGroup(RENDER_QUEUE_OVERLAY); setUseIdentityProjection(true); setUseIdentityView(true); setQueryFlags(0); The Selection Rectangle

77 The Selection Rectangle: Coordinate System - A new coordinate system with X and Y running from -1 to 1 inclusive - Have to transform the coordinate system (CEGUI) with [0, 1] x [0, 1] to [-1, 1] x [-1, 1].

88 Definition of the Selection Rectangle The line strip draws a line to each vertex from the previous vertex. -To create the rectangle, define 5 points (the first and the last point are the same to connect the entire rectangle): clear(); begin("", RenderOperation::OT_LINE_STRIP); position(left, top, -1); position(right, top, -1); position(right, bottom, -1); position(left, bottom, -1); position(left, top, -1); end();

9 class SelectionRectangle : public ManualObject { public: SelectionRectangle(const String &name) : ManualObject(name) { setUseIdentityProjection(true); setUseIdentityView(true); setRenderQueueGroup(RENDER_QUEUE_OVERLAY); setQueryFlags(0); } }; Definition of the Selection Rectangle

10 class SelectionRectangle : public ManualObject { void setCorners(float left, float top, float right, float bottom) { //mapping to ogre3D projection plane left = left * 2 - 1; right = right * 2 - 1; top = 1 - top * 2; bottom = 1 - bottom * 2; clear(); begin("", RenderOperation::OT_LINE_STRIP); position(left, top, -1); position(right, top, -1); position(right, bottom, -1); position(left, bottom, -1); position(left, top, -1); end(); AxisAlignedBox box; box.setInfinite(); setBoundingBox(box); } }; Definition of the Selection Rectangle

11 //Mapping to Ogre3D Projection Plane Space //BEGIN Using CEGUI //left = left * 2 - 1; //right = right * 2 - 1; //top = 1 - top * 2; //bottom = 1 - bottom * 2; //End USING CEGUI //BEGIN Using TrayMgr left = left * 2 - 1; right = right * 2 - 1; top = -1 - top * 2; bottom = -1 -bottom * 2; //End USING TrayMgr

12 Volume selection process  Define a volume selection query: PlaneBoundedVolumeListSceneQuery *mVolQuery;  Obtain the four rays at the four corners of the selection rectangle  Define the selection volume using the four rays - define the five planes which enclosing a selection volume; volList stores the list of the planes - set the selection volume: mVolQuery->setVolumes(volList);  execute the query; perform tasks on the results

13 Volume selection : code { … Ray topLeft = mCamera->getCameraToViewportRay(left, top); Ray topRight = mCamera->getCameraToViewportRay(right, top); Ray bottomLeft = mCamera->getCameraToViewportRay(left, bottom); Ray bottomRight = mCamera->getCameraToViewportRay(right, bottom); // The plane faces the counter clockwise position. PlaneBoundedVolume vol; int np = 100; vol.planes.push_back(Plane(topLeft.getPoint(3), topRight.getPoint(3), bottomRight.getPoint(3))); // front plane vol.planes.push_back(Plane(topLeft.getOrigin(), topLeft.getPoint(np), topRight.getPoint(np))); // top plane vol.planes.push_back(Plane(topLeft.getOrigin(), bottomLeft.getPoint(np), topLeft.getPoint(np))); // left plane vol.planes.push_back(Plane(bottomLeft.getOrigin(), bottomRight.getPoint(np), bottomLeft.getPoint(np))); // bottom plane vol.planes.push_back(Plane(bottomRight.getOrigin(), topRight.getPoint(np), bottomRight.getPoint(np))); // right plane PlaneBoundedVolumeList volList; volList.push_back(vol); mVolQuery->setVolumes(volList); SceneQueryResult result = mVolQuery->execute(); … }

14 PlaneBoundedVolumeList volList; mVolQuery = mSceneMgr ->createPlaneBoundedVolumeQuery(volList); How to define mVolQuery ?

15 Ray mRay =mTrayMgr->getCursorRay(mCamera); Vector2 scn = mTrayMgr ->sceneToScreen( mCamera, mRay.getOrigin()); Mapping to screen coordinates: mTrayMgr

16 References: Note: The selection volume is not correct in the original code. Last visit 1st April, 2008