《计算机图形学》Chapter 12 OpenGL 中的曲线与曲面-(英文)教学课件(非AI生成).ppt
CurvesandSurfacesinOpenGL1
ObjectivesIntroduceOpenGLevaluatorsLearntorenderpolynomialcurvesandsurfacesDiscussquadricsinOpenGLGLUTQuadricsGLUQuadrics2
WhatDoesOpenGLSupport?Evaluators:ageneralmechanismforworkingwiththeBernsteinpolynomialsCanuseanydegreepolynomialsCanusein1-4dimensionsAutomaticgenerationofnormalsandtexturecoordinatesNURBSsupportedinGLUQuadricsGLUandGLUTcontainpolynomialapproximationsofquadrics3
One-DimensionalEvaluatorsEvaluateaBernsteinpolynomialofanydegreeatasetofspecifiedvaluesCanevaluateavarietyofvariablesPointsalonga2,3or4dimensionalcurveColorsNormalsTextureCoordinatesWecansetupmultipleevaluatorsthatareallevaluatedforthesamevalue4
SettingUpanEvaluatorglMap1f(type,u_min,u_max,stride,order,pointer_to_array)whatwewanttoevaluatemaxandminofu1+degreeofpolynomialpointertocontroldataseparationbetweendatapointsEachtypemustbeenabledbyglEnable(type)5
ExampleConsideranevaluatorforacubicBeziercurveover(0,1)pointdata[]={…………..};*/3ddata/*glMap1f(GL_MAP_VERTEX_3,0.0,1.0,3,4,data);dataare3Dverticescubicdataarearrangedasx,y,z,x,y,z……threefloatsbetweendatapointsinarrayglEnable(GL_MAP_VERTEX_3);6
EvaluatingThefunctionglEvalCoord1f(u)causesallenabledevaluatorstobeevaluatedforthespecifieduCanreplaceglVertex,glNormal,glTexCoordThevaluesofuneednotbeequallyspaced7
ExampleConsiderthepreviousevaluatorthatwassetupforacubicBezierover(0,1)Supposethatwewanttoapproximatethecurvewitha100pointpolylineglBegin(GL_LINE_STRIP)for(i=0;i100;i++)glEvalCoord1f((float)i/100.0);glEnd();8
EquallySpacedPointsRatherthanusealoop,wecansetupanequallyspacedmesh(grid)andthenevaluateitwithonefunctioncallglMapGrid(100,0.0,1.0);setsup100equally-spacedpointson(0,1)glEvalMesh1(GL_LINE,0,99);renderslinesbetweenadjacentevaluatedpointsfrompoint0to