Microsoft Word - project4.docx CSCE4813–ComputerGraphics ProgrammingProject4–DueFriday03/13/2020 1.ProblemStatement:...

linked file but just need task 3 and 4 done.


Microsoft Word - project4.docx CSCE4813–ComputerGraphics ProgrammingProject4–DueFriday03/13/2020 1.ProblemStatement: ThegoalofthisprogrammingprojectistocreateanOpenGLprogramthatuses Phongshadingtodisplaygeometricmodelsofobjectsthathavebeenscannedwith anRGBDcamera.Colorinformation(RGB)willbestoredinoneJPEGimageand depthinformation(D)willbestoredinasecondJPEGimage.Wewillbestarting withtheRGBDimagesofapennybelow. Task1:ModelCreation Wewanttocreateapolygonmodeltorepresentthepenny.Theeasiestwaytodo thisistomodelthetopsurfaceofthepennywitha2DsurfaceD(x,y),wheretheDis thedepthand(x,y)arethesamplelocationsintheJPEGimage. YourfirsttaskistowriteanOpenGLprogramthatreadsinaJPEGdepthimageand storesthisinformationinapolygonmesh.Inthecaseofthepennyabove,theD valuesrangefrom[0..255]andthe(x,y)coordinatesgofrom[0..499,0..499].These valuesdonotcorrespondtotherealdimensionsofapenny(thethicknessofa pennyisnothalfthediameter)soyouwillhavetoscaletheDvaluesintoan appropriaterange. Thereareseveralwaystostorethe(x,y,z)locationsofpointsinyourpolygonmesh. Themostcommonchoicesare:(1)usingthree2Darraysoffloatvaluesx(u,v),y(u,v) andz(u,v),or(2)usingone2Darrayof3DpointvaluesP(u,v)whichstorex,y,z values.Youarewelcometochoosewhicheverrepresentationyouaremost comfortablewith. Task2:InteractiveModelDisplay Onceyouhavedefinedyoursurface,yournexttaskistoextendyourOpenGL programtodisplaythemodelsurface.Todothis,youshouldaddcodeinthedisplay callbacktoloopoverthepolygons,anddisplaythemusingGL_LINE_LOOP.Thefirst timeyourunthis,youwillprobablyseeablack/whitegridofparallellines.Thisis thetop-viewofthesurface,soyouwillnotseeanydepthinformation. Toviewthesurfacefromdifferentangles,youneedtoextendyourOpenGLprogram againtorotateitaroundthreeaxes.Toimplementthis,youneedtoaddcodetothe displaycallbacktocallglRotatef(x_angle,1,0,0),glRotatef(y_angle,0,1,0)and glRotatef(z_angle,0,0,1).Thenyouneedtoaddcodetothekeyboardcallbackto increase/decreasetheglobalvariablesstoringx_angle,y_angle,andz_anglewhen certainkeysarepressed.(Seeobject3.cppfordetails). Ifyourpennysurfacelookstoothickortoothin,youcanadjustyourscalefactors untilyougetsomethingthatlookssensible. Task3:SavingColorInformation ThecolorimageofthepennyprovidesuswiththeRGBvaluesateach(u,v)location onthepenny.YourthirdtaskistoextendyourOpenGLprogramtoreadthecolor image,andstorethisinformationinthreearraysR(u,v),G(u,v)B(u,v)orinthe3D pointdatastructure. IfyouprintouttheseRGBvaluesasyoureadthem,youwillseethatpixelsoutside thepennywillbealmostpurewhite(255,255,255)andthepixelsinsidethepenny willbeacoppercolor(reddishbrown).Inordertodisplaythepennyascolored polygons,youneedtoextendyourprogramtocalculateandsavetheaverageRGB colorofthepennypixels. Task4:DisplayingthePennywithStoredRGBValues NowthatweknowtheoriginalRGBcolorforeverypointonthepennysurface,we canusethisinformationtogenerateamorerealisticrenderingofthepenny.Create aseconddisplaycallbackcalled“color_display”thatdisplayspolygonsusing GL_POLYGONinsteadofGL_LINE_LOOP.ThenaddcodetospecifytheRGBcolor valuesofeachpolygonvertexusingtheglColor3f()function.Sincethisfunction expectscolorsinthe[0..1]range,youwillhavetoscaletheoriginalRGBvalues.As youinteractivelyrotateyournewpennyimage,itshouldlookmorerealisticbecause depthinformationisalsobeingdisplayed. Task5:DisplayingthePennyusingPhongShading Yournexttaskistocreateathirddisplaycallbackmethodcalled“phong_display” thatdisplaysyourpennysurfaceusingPhongshading.Beforeyoucandothis,you needtoaddcodetoyourprogramtocalculateandsavethesurfacenormalateach (u,v)locationonthesurface.Thiscanbedonerightafteryoureadandstorethe (x,y,z)surfaceinformationusingthecross-productapproachdiscussedinclass. TocalltheOpenGLfunctionsforPhongshading,youshould#include“shading.cpp” inyourprogram.Thenyouneedtomodifyinit()todefineyourlightpositionsand colors.TodisplaythepolygonsusingPhongshading,youneedtospecifymaterial propertiesusingtheaverageRGBcolorofthepennybeforethepolygondisplay loop.Finally,youneedtoremovecallstoglColor3f()andaddcallstoglNormal3f() tospecifythesurfacenormalateachpolygonpoint. WhenyoulookattheresultingPhongshadedsurface,itshouldlooklikeitisallone material,butthereshouldbecolorvariationsthatletyouseetheshapeofthepenny surface.YoumayneedtoplaywiththePhongshadingparametersKa,Kd,Ks,Kpto getsomethingthatlooksrealistic.Ifyousetyourlightsintherightlocations,you maygetaresultthatisclosetotheoriginalRGBimageofthepenny. Task6:CompletetheUserInterface Yourfinaltaskistoextendthe“keyboard”callbacktoallowuserstoswitchbetween thethreedisplaycallbackfunctionsyoucreated.Forexample,youcoulduse“1”for thewireframedisplay,“2”fortheRGBsurfacedisplay,and“3”forthePhongshaded display.Thiswilllettheuserlookatthepennyfromthesamepointofviewwith differentdisplaymethodstocompareresults. 2.Design: Thereareseveraldesigntasksyoumustcompleteforthisproject.Themost importantdecisionistoselectdatastructuresforthe(x,y,z)coordinates,the correspondingsurfacenormalvalues(Nx,Ny,Nz),andRGBthecolorsofeverypoint. TherearealsoanumberofscalefactorsandPhongshadingparametersthatyouwill needtoselecttogetrealisticlookingimages.Youmaywanttodothisbyextending theprogram’suserinterface,orbyaseriesofedit,compile,runexperiments. 3.Implementation: ThissemesterwewillbeusingC++andOpenGLtoimplementallofour programmingprojects.IfyouareusingaMacwithXcodeinstalled,thenyoucan downloadthesrc.tarfileandcompilethesamplegraphicscodeusingtheenclosed Makefile.IfyouareusingaPC,thenyourbestoptionwouldbetodownloadand installaLinuxVMfromthedepartment’swebsite.Theinstructionsfordoingthisare postedinREADMEfilethe“SourceCode”pageoftheclasswebsite.Onceyouhave LinuxandOpenGLinstalled,youcancompileyourgraphicsprogramusing“g++- Wallproject2.cpp-oproject2-lGL-lGLU-lglut”. Remembertouseincrementaldevelopmentandgoodprogrammingstylewhen creatingyourprogram.Choosegoodnamesforvariablesandconstants,useproper indentingforloopsandconditionals,andincludeclearcommentsinyourcode.Also, besuretosavebackupcopiesofyourprogramsomewheresafe.Otherwise,youmay endupretypingyourwholeprogramifsomethinggoeswrong. 4.Testing: Testyourprogramtocheckthatitoperatescorrectlyforalloftherequirements listedabove.Alsocheckfortheerrorhandlingcapabilitiesofthecode.Tryyour programwithseveralinputvalues,andsavescreenshotsofyouroutputinjpeg imagesforinclusioninyourprojectreport. 5.Documentation: WhenyouhavecompletedyourC++program,writeashortreportusingtheproject reporttemplatedescribingwhattheobjectiveswere,whatyoudid,andthestatusof theprogram.Doesitworkproperlyforalltestcases?Arethereanyknown problems?Savethisreporttobesubmittedelectronically. 6.ProjectSubmission: Inthisclass,wewillbeusingelectronicprojectsubmissiontomakesurethatall studentshandtheirprogrammingprojectsandlabsontime,andtoperform automaticplagiarismanalysisofallprogramsthataresubmitted. WhenyouhavecompletedthetasksabovegotoBlackboardtouploadyour documentation(asingledocxorpdffile),andallofyourC++programfiles.DoNOT uploadanexecutableversionofyourprogram. Thedatesonyourelectronicsubmissionwillbeusedtoverifythatyoumetthedue dateabove.Alllateprojectswillreceivereducedcredit: • 10%offiflessthan1daylate, • 20%offiflessthan2dayslate, • 30%offiflessthan3dayslate, • nocreditifmorethan3dayslate. Youwillreceivepartialcreditforallprogramsthatcompileeveniftheydonotmeet allprogramrequirements,sohandingprojectsinontimeishighlyrecommended. 7.AcademicHonestyStatement: Studentsareexpectedtosubmittheirownworkonallprogrammingprojects, unlessgroupprojectshavebeenexplicitlyassigned.StudentsareNOTallowedto distributecodetoeachother,orcopycodefromanotherindividualorwebsite. StudentsAREallowedtouseanymaterialsontheclasswebsite,orinthetextbook, orasktheinstructorand/orGTAsforassistance. Thiscoursewillbeusinghighlyeffectiveprogramcomparisonsoftwaretocalculate thesimilarityofallprogramstoeachother,andtohomeworkassignmentsfrom previoussemesters.Pleasedonotbetemptedtoplagiarizefromanotherstudent. ViolationsofthepoliciesabovewillbereportedtotheProvost'sofficeandmay resultinaZEROontheprogrammingproject,anFintheclass,orsuspensionfrom theuniversity,dependingontheseverityoftheviolationandanyhistoryofprior violations. Microsoft Word - project4.docx CSCE4813–ComputerGraphics ProgrammingProject4–DueFriday03/13/2020 1.ProblemStatement: ThegoalofthisprogrammingprojectistocreateanOpenGLprogramthatuses Phongshadingtodisplaygeometricmodelsofobjectsthathavebeenscannedwith anRGBDcamera.Colorinformation(RGB)willbestoredinoneJPEGimageand depthinformation(D)willbestoredinasecondJPEGimage.Wewillbestarting withtheRGBDimagesofapennybelow. Task1:ModelCreation Wewanttocreateapolygonmodeltorepresentthepenny.Theeasiestwaytodo thisistomodelthetopsurfaceofthepennywitha2DsurfaceD(x,y),wheretheDis thedepthand(x,y)arethesamplelocationsintheJPEGimage. YourfirsttaskistowriteanOpenGLprogramthatreadsinaJPEGdepthimageand storesthisinformationinapolygonmesh.Inthecaseofthepennyabove,theD valuesrangefrom[0..255]andthe(x,y)coordinatesgofrom[0..499,0..499].These valuesdonotcorrespondtotherealdimensionsofapenny(thethicknessofa pennyisnothalfthediameter)soyouwillhavetoscaletheDvaluesintoan appropriaterange. Thereareseveralwaystostorethe(x,y,z)locationsofpointsinyourpolygonmesh. Themostcommonchoicesare:(1)usingthree2Darraysoffloatvaluesx(u,v),y(u,v) andz(u,v),or(2)usingone2Darrayof3DpointvaluesP(u,v)whichstorex,y,z values.Youarewelcometochoosewhicheverrepresentationyouaremost comfortablewith. Task2:InteractiveModelDisplay Onceyouhavedefinedyoursurface,yournexttaskistoextendyourOpenGL programtodisplaythemodelsurface.Todothis,youshouldaddcodeinthedisplay callbacktoloopoverthepolygons,anddisplaythemusingGL_LINE_LOOP.Thefirst timeyourunthis,youwillprobablyseeablack/whitegridofparallellines.Thisis thetop-viewofthesurface,soyouwillnotseeanydepthinformation. Toviewthesurfacefromdifferentangles,youneedtoextendyourOpenGLprogram againtorotateitaroundthreeaxes.Toimplementthis,youneedtoaddcodetothe displaycallbacktocallglRotatef(x_angle,1,0,0),glRotatef(y_angle,0,1,0)and glRotatef(z_angle,0,0,1).Thenyouneedtoaddcodetothekeyboardcallbackto increase/decreasetheglobalvariablesstoringx_angle,y_angle,andz_anglewhen certainkeysarepressed.(Seeobject3.cppfordetails). Ifyourpennysurfacelookstoothickortoothin,youcanadjustyourscalefactors untilyougetsomethingthatlookssensible. Task3:SavingColorInformation ThecolorimageofthepennyprovidesuswiththeRGBvaluesateach(u,v)location onthepenny.YourthirdtaskistoextendyourOpenGLprogramtoreadthecolor image,andstorethisinformationinthreearraysR(u,v),G(u,v)B(u,v)orinthe3D pointdatastructure. IfyouprintouttheseRGBvaluesasyoureadthem,youwillseethatpixelsoutside thepennywillbealmostpurewhite(255,255,255)andthepixelsinsidethepenny willbeacoppercolor(reddishbrown).Inordertodisplaythepennyascolored polygons,youneedtoextendyourprogramtocalculateandsavetheaverageRGB colorofthepennypixels. Task4:DisplayingthePennywithStoredRGBValues NowthatweknowtheoriginalRGBcolorforeverypointonthepennysurface,we canusethisinformationtogenerateamorerealisticrenderingofthepenny.Create aseconddisplaycallbackcalled“color_display”thatdisplayspolygonsusing GL_POLYGONinsteadofGL_LINE_LOOP.ThenaddcodetospecifytheRGBcolor valuesofeachpolygonvertexusingtheglColor3f()function.Sincethisfunction expectscolorsinthe[0..1]range,youwillhavetoscaletheoriginalRGBvalues.As youinteractivelyrotateyournewpennyimage,itshouldlookmorerealisticbecause depthinformationisalsobeingdisplayed. Task5:DisplayingthePennyusingPhongShading Yournexttaskistocreateathirddisplaycallbackmethodcalled“phong_display” thatdisplaysyourpennysurfaceusingPhongshading.Beforeyoucandothis,you needtoaddcodetoyourprogramtocalculateandsavethesurfacenormalateach (u,v)locationonthesurface.Thiscanbedonerightafteryoureadandstorethe (x,y,z)surfaceinformationusingthecross-productapproachdiscussedinclass. TocalltheOpenGLfunctionsforPhongshading,youshould#include“shading.cpp” inyourprogram.Thenyouneedtomodifyinit()todefineyourlightpositionsand colors.TodisplaythepolygonsusingPhongshading,youneedtospecifymaterial propertiesusingtheaverageRGBcolorofthepennybeforethepolygondisplay loop.Finally,youneedtoremovecallstoglColor3f()andaddcallstoglNormal3f() tospecifythesurfacenormalateachpolygonpoint. WhenyoulookattheresultingPhongshadedsurface,itshouldlooklikeitisallone material,butthereshouldbecolorvariationsthatletyouseetheshapeofthepenny surface.YoumayneedtoplaywiththePhongshadingparametersKa,Kd,Ks,Kpto getsomethingthatlooksrealistic.Ifyousetyourlightsintherightlocations,you maygetaresultthatisclosetotheoriginalRGBimageofthepenny. Task6:CompletetheUserInterface Yourfinaltaskistoextendthe“keyboard”callbacktoallowuserstoswitchbetween thethreedisplaycallbackfunctionsyoucreated.Forexample,youcoulduse“1”for thewireframedisplay,“2”fortheRGBsurfacedisplay,and“3”forthePhongshaded display.Thiswilllettheuserlookatthepennyfromthesamepointofviewwith differentdisplaymethodstocompareresults. 2.Design: Thereareseveraldesigntasksyoumustcompleteforthisproject.Themost importantdecisionistoselectdatastructuresforthe(x,y,z)coordinates,the correspondingsurfacenormalvalues(Nx,Ny,Nz),andRGBthecolorsofeverypoint. TherearealsoanumberofscalefactorsandPhongshadingparametersthatyouwill needtoselecttogetrealisticlookingimages.Youmaywanttodothisbyextending theprogram’suserinterface,orbyaseriesofedit,compile,runexperiments. 3.Implementation: ThissemesterwewillbeusingC++andOpenGLtoimplementallofour programmingprojects.IfyouareusingaMacwithXcodeinstalled,thenyoucan downloadthesrc.tarfileandcompilethesamplegraphicscodeusingtheenclosed Makefile.IfyouareusingaPC,thenyourbestoptionwouldbetodownloadand installaLinuxVMfromthedepartment’swebsite.Theinstructionsfordoingthisare postedinREADMEfilethe“SourceCode”pageoftheclasswebsite.Onceyouhave LinuxandOpenGLinstalled,youcancompileyourgraphicsprogramusing“g++- Wallproject2.cpp-oproject2-lGL-lGLU-lglut”. Remembertouseincrementaldevelopmentandgoodprogrammingstylewhen creatingyourprogram.Choosegoodnamesforvariablesandconstants,useproper indentingforloopsandconditionals,andincludeclearcommentsinyourcode.Also, besuretosavebackupcopiesofyourprogramsomewheresafe.Otherwise,youmay endupretypingyourwholeprogramifsomethinggoeswrong. 4.Testing: Testyourprogramtocheckthatitoperatescorrectlyforalloftherequirements listedabove.Alsocheckfortheerrorhandlingcapabilitiesofthecode.Tryyour programwithseveralinputvalues,andsavescreenshotsofyouroutputinjpeg imagesforinclusioninyourprojectreport. 5.Documentation: WhenyouhavecompletedyourC++program,writeashortreportusingtheproject reporttemplatedescribingwhattheobjectiveswere,whatyoudid,andthestatusof theprogram.Doesitworkproperlyforalltestcases?Arethereanyknown problems?Savethisreporttobesubmittedelectronically. 6.ProjectSubmission: Inthisclass,wewillbeusingelectronicprojectsubmissiontomakesurethatall studentshandtheirprogrammingprojectsandlabsontime,andtoperform automaticplagiarismanalysisofallprogramsthataresubmitted. WhenyouhavecompletedthetasksabovegotoBlackboardtouploadyour documentation(asingledocxorpdffile),andallofyourC++programfiles.DoNOT uploadanexecutableversionofyourprogram. Thedatesonyourelectronicsubmissionwillbeusedtoverifythatyoumetthedue dateabove.Alllateprojectswillreceivereducedcredit: • 10%offiflessthan1daylate, • 20%offiflessthan2dayslate, • 30%offiflessthan3dayslate, • nocreditifmorethan3dayslate. Youwillreceivepartialcreditforallprogramsthatcompileeveniftheydonotmeet allprogramrequirements,sohandingprojectsinontimeishighlyrecommended. 7.AcademicHonestyStatement: Studentsareexpectedtosubmittheirownworkonallprogrammingprojects, unlessgroupprojectshavebeenexplicitlyassigned.StudentsareNOTallowedto distributecodetoeachother,orcopycodefromanotherindividualorwebsite. StudentsAREallowedtouseanymaterialsontheclasswebsite,orinthetextbook, orasktheinstructorand/orGTAsforassistance. Thiscoursewillbeusinghighlyeffectiveprogramcomparisonsoftwaretocalculate thesimilarityofallprogramstoeachother,andtohomeworkassignmentsfrom previoussemesters.Pleasedonotbetemptedtoplagiarizefromanotherstudent. ViolationsofthepoliciesabovewillbereportedtotheProvost'sofficeandmay resultinaZEROontheprogrammingproject,anFintheclass,orsuspensionfrom theuniversity,dependingontheseverityoftheviolationandanyhistoryofprior violations. 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
Mar 20, 2021
SOLUTION.PDF

Get Answer To This Question

Submit New Assignment

Copy and Paste Your Assignment Here