文档详情

《计算机图形学》Chapters 10 图形对象和场景图-(英文)教学课件(非AI生成).ppt

发布:2025-04-28约4.53千字共21页下载文档
文本预览下载声明

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()

显示全部
相似文档