《计算机图形学》Chapters 10 图形对象和场景图-(英文)教学课件(非AI生成).ppt
GraphicalObjectsandSceneGraphs1
ObjectivesIntroducegraphicalobjectsGeneralizethenotionofobjectstoincludelights,cameras,attributesIntroducescenegraphs2
LimitationsofImmediateModeGraphicsWhenwedefineageometricobjectinanapplication,uponexecutionofthecodetheobjectispassedthroughthepipelineItthendisappearsfromthegraphicalsystemToredrawtheobject,eitherchangedorthesame,wemustreexecutethecodeDisplaylistsprovideonlyapartialsolutiontothisproblem3
OpenGLandObjectsOpenGLlacksanobjectorientationConsider,forexample,agreensphereWecanmodelthespherewithpolygonsoruseOpenGLquadricsItscolorisdeterminedbytheOpenGLstateandisnotapropertyoftheobjectDefiesournotionofaphysicalobjectWecantrytobuildbetterobjectsincodeusingobject-orientedlanguages/techniques4
ImperativeProgrammingModelExample:rotateacubeTherotationfunctionmustknowhowthecubeisrepresentedVertexlistEdgelistApplicationglRotatecubedataresults5
Object-OrientedProgrammingModelApplicationCubeObjectInthismodel,therepresentationisstoredwiththeobjectTheapplicationsendsamessagetotheobjectTheobjectcontainsfunctions(methods)whichallowittotransformitselfmessage6
C/C++CantrytouseCstructstobuildobjectsC++providesbettersupportUseclassconstructCanhideimplementationusingpublic,private,andprotectedmembersinaclassCanalsousefrienddesignationtoallowclassestoaccesseachother7
CubeObjectSupposethatwewanttocreateasimplecubeobjectthatwecanscale,orient,positionandsetitscolordirectlythroughcodesuchascubemycube;mycube.color[0]=1.0;mycube.color[1]=mycube.color[2]=0.0;mycube.matrix[0][0]=………8
CubeObjectFunctionsWewouldalsoliketohavefunctionsthatactonthecubesuchasmycube.translate(1.0,0.0,0.0);mycube.rotate(theta,1.0,0.0,0.0);setcolor(mycube,1.0,0.0,0.0);Wealsoneedawayofdisplayingthecubemycube.render()