Unformatted text preview:

Picking and Curves Week 6ObjectivesPickingThree ApproachesUsing another buffer and colors for pickingUsing Regions of the ScreenRendering ModesHit RecordUsing Selection ModeSelection Mode FunctionsSelection Mode and PickinggluPickMatrix()Go to pick.cIntroduction to CurvesEscaping FlatlandModeling with CurvesWhat Makes a Good Representation?Explicit RepresentationImplicit RepresentationParametric CurvesSelecting FunctionsParametric LinesCurve SegmentsParametric Polynomial CurvesWhy PolynomialsCubic Parametric PolynomialsDesigning Parametric Cubic CurvesSlide 28Matrix-Vector FormInterpolating CurveInterpolating Multiple SegmentsInterpolation EquationsInterpolation MatrixBlending FunctionsSlide 35Other Types of Curves and SurfacesHermite FormEquationsMatrix FormBlending PolynomialsParametric and Geometric ContinuityExampleBezier and Spline CurvesSlide 44Bezier’s IdeaApproximating DerivativesSlide 47Bezier MatrixSlide 49Bernstein PolynomialsConvex Hull PropertyAnalysisB-SplinesCubic B-splineSlide 55Splines and BasisBasis FunctionsGeneralizing SplinesNURBSEvery Curve is a Bezier CurveMatricesSlide 62Drawing Bezier Curves in OpenGLBasic ProcedureSlide 651D Evaluator: glMap1f()Polynomial Order Has a LimitDefining partitions: glMapGrid1f()Evaluate Bezier at samples: glEvalMesh1()Slide 70Go to bezier.cPicking and CurvesWeek 6David BreenDepartment of Computer ScienceDrexel UniversityBased on material from Ed Angel, University of New MexicoCS 480/680INTERACTIVE COMPUTER GRAPHICSAngel: Interactive Computer Graphics 3E © Addison-Wesley 20022Objectives•Picking–Select objects from the display•Introduce types of curves and surfaces–Explicit–Implicit–Parametric–Strengths and weaknesses•Discuss Modeling and Approximations–Conditions–StabilityAngel: Interactive Computer Graphics 3E © Addison-Wesley 20023Picking•Identify a user-defined object on the display•In principle, it should be simple because the mouse gives the position and we should be able to determine to which object(s) a position corresponds•Practical difficulties–Pipeline architecture is feed forward, hard to go from screen back to world–Complicated by screen being 2D, world is 3D–How close do we have to come to object to say we selected it?Angel: Interactive Computer Graphics 3E © Addison-Wesley 20024Three Approaches•Hit list–Most general approach but most difficult to implement•Use back or some other buffer to store object ids as the objects are rendered•Rectangular maps –Easy to implement for many applications–Divide screen into rectangular regionsAngel: Interactive Computer Graphics 3E © Addison-Wesley 20025Using another buffer and colors for picking•For a small number of objects, we can assign a unique color (often in color index mode) to each object•We then render the scene to a color buffer other than the front buffer so the results of the rendering are not visible•We then get the mouse position and use glReadPixels() to read the color in the buffer we just wrote at the position of the mouse•The returned color gives the id of the objectAngel: Interactive Computer Graphics 3E © Addison-Wesley 20026Using Regions of the Screen•Many applications use a simple rectangular arrangement of the screen–Example: p aint/CAD p rogram•Easier to loo k at mouse position and determine which area of screen it is in that using selection mode pickingdrawing areatoolsmenusAngel: Interactive Computer Graphics 3E © Addison-Wesley 20027Rendering Modes•OpenGL can render in one of three modes selected by glRenderMode(mode)–GL_RENDER: normal rendering to the frame buffer (default)–GL_FEEDBACK: provides list of primitives rendered but no output to the frame buffer–GL_SELECTION: Each primitive in the view volume generates a hit record that is placed in a name stack which can be examined laterAngel: Interactive Computer Graphics 3E © Addison-Wesley 20028Hit RecordAngel: Interactive Computer Graphics 3E © Addison-Wesley 20029Using Selection Mode•Initialize name buffer•Enter selection mode (using mouse)•Render scene with user-defined names (id#)–Every object in view volume generates a hit–Name stack processing always done•Reenter normal render mode–This operation returns number of hits•Examine contents of name buffer (hit records)–Hit records include number of ids, depth information and ids on stack at moment of renderingAngel: Interactive Computer Graphics 3E © Addison-Wesley 200210Selection Mode Functions•glSelectBuffer(): specifies name buffer•glInitNames(): initializes name buffer•glPushName(id): push id on name buffer•glPopName(): pop top of name buffer•glLoadName(id): replace top name on buffer•id is set by application to identify objects•Can’t be called inside glBegin/glEndAngel: Interactive Computer Graphics 3E © Addison-Wesley 200211Selection Mode and Picking•In general, selection mode won’t work for picking because every primitive in the view volume will generate a hit•Change the viewing parameters so that only those primitives near the cursor are in the altered view volume–Use gluPickMatrixAngel: Interactive Computer Graphics 3E © Addison-Wesley 200212gluPickMatrix()•gluPickMatrix(Gldouble x, Gldouble y, Gldouble w, Gldouble h, Glint *vp) –k–Creates a projection matrix for picking that restricts drawing to a w x h area centered at (x,y) in the window coordinates within the viewport vpGo to pick.cIntroduction to CurvesAngel: Interactive Computer Graphics 3E © Addison-Wesley 200215Escaping Flatland•Until now we have worked with flat entities such as lines and flat polygons–Fit well with graphics hardware–Mathematically simple•But the world is not composed of flat entities–Need curves and curved surfaces–May only have need at the application level–Implementation can render them approximately with flat primitivesAngel: Interactive Computer Graphics 3E © Addison-Wesley 200216Modeling with Curvesdata pointsapproximating curveinterpolating data pointAngel: Interactive Computer Graphics 3E © Addison-Wesley 200217What Makes a Good Representation?•There are many ways to represent curves and surfaces•Want a representation that is–Stable–Smooth–Easy to evaluate–Must we interpolate or can we just come close to data?–Do we need derivatives?Angel: Interactive Computer Graphics 3E © Addison-Wesley 200218Explicit


View Full Document

DREXEL CS 480 - Lecture6

Documents in this Course
Load more
Download Lecture6
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 Lecture6 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 Lecture6 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?