Just need project 3, i will attach project 2 and can change anything you want from it. I also just need the code, don't worry about the testing/ project report.
Microsoft Word - project2.docx CSCE4813–ComputerGraphics ProgrammingProject2–DueFriday02/14/2020 ProgrammingProject3–DueMonday02/24/2020 1.ProblemStatement: Thegoalofthistwo-partprogrammingprojectistodesignandimplementavideo gamecalled“angrybricks”modeledafterthewellknown“angrybirds”game.Inour game,theplayerwillgrabontoabrickthatisdisplayedonthelowerleftsideofthe screenwiththeirmouse,dragittotheleft,andwhentheyreleasethemouse,the brickwill“slingshot”towardsatargetontheright.Asthebrickmovesacrossthe screen,itwillrotateinthreedimensions,andfalltowardsthegroundduetheeffects ofgravity.Whenabrickhitstheleftorrightwallitwill“bounce”intheopposite direction.Thebrickwillfinallystopwhenithitstheground.Thegoalofthisgame istoselectatarget,andseeifyoucanslingshotthebricktothatlocation. Project2–Creatinganddisplayingthebrick YourfirsttaskistocreateanOpenGLprogramthatdisplaysacolorfulbrickata fixedlocationonthescreenusingthedisplaycallback.Todothis,youwillhaveto calculatethe(x,y,z)locationsofall8cornersofthebrick,anddefinethe6facesof thebrickusingpolygonswithdifferentcolors. Onceyouhavethisworking,youcancreateamousecallbackfunctionthatcaptures the(x,y)locationofthemouse,andredrawsthecolorfulbrickatthatlocation.As youmoveyourmousearoundandclickindifferentlocations,thebrickshouldbe erasedfromthescreenandredrawninthenewlocation.Thekeytothisprocess willbeconvertingfromthe(x,y)windowcoordinatesinto(x,y,z)objectcoordinates fordisplaypurposes. Finally,youneedtocreateamotioncallbackfunctionthatcapturesthe(x,y)window coordinatesofthemouseasyoudragitacrossthescreen.Asthemousemoves,you shouldredrawthebrickatthecorresponding(x,y,z)locationinobjectcoordinates. Fordebuggingpurposes,youmaywanttoprintoutthe(x,y)windowand(x,y,z) objectcoordinatesastheyarechanging. Project3–Simulatinganddisplayingbrickmotion Inordertosimulatebrickmotionyouneedtocalculatethevelocityvectorfrom your“slingshot”.Todothis,youcanrecordthe(x1,y1)locationwherethemouse wasclicked,andthe(x2,y2)locationwherethemousewasreleased,andsubtract thesetogetthedirectionandspeedofthebrickinobjectcoordinates. Yournexttaskistousetheidlecallbackorthetimercallbackto“simulatephysics” andupdatethe(x,y,z)locationofthebrickateachtimestepandredisplaythebrick. Thetrickyparthereistofindastepsizethatresultsin“natural”lookingmotion.If thestepsizeistoolarge,thebrickwillmovetooquickly.Ifthestepsizeistoosmall, thebrickwillmoveinslowmotion. Inordertosimulatethebrick“bounce”youwillhavetofigureoutwhenthebrick hitstheleftorrightwall,andupdatethebrickpositionandvelocityaccordingly.To keepthingssimple,youcanassumethatthebrickhitsthewallsquarelyand bouncesoffperfectlyintheoppositedirectionwithoutchangeinspeedandwithout introducinganystrangebrickrotations. Finally,itwouldbenicetoseethebrickrotateslowlyasitmovesacrossthescreen. Todothis,youshouldkeeptrackofthecurrentlocationandrotationanglesforthe brickateachtimestep.ThenyoucanusetheglLoadIdentity,glRotatef,and glTranslateffunctionstoupdatetheGL_MODELVIEWmatrixpriortodrawingthe brick.Thiswillmakeyourbrickrotateasitmoves.Again,youneedtoselectyour rotationstepsizesoitisnottoofastandnottooslow. 2.Design: Thereareseveraldesigntasksyoumustcompleteforthisproject.First,youmust designyourbrickmodel(acollectionof6polygonsshouldbeenough).Next,you needtodecidewheretopositionthebrick,andhowtodetectwhentheuserhas clickedonthebrick.Todothis,youwillneedtoconvertfrom“screencoordinates” to“objectcoordinates”. Yournexttaskistoworkouttheequationsneededto“simulatephysics”soyoucan calculatethe(x,y,z)locationsofthebrickasitisflyingacrossthescreen.Ifyou ignoretheeffectsofwindonthebrick,itshouldfollowaparabolicpath.Finally,you needtofigureouthowyouwilldetectwhenthebrickhitsthewallortheground, andadjustthepositionandvelocityaccordingly. 3.Implementation: ThissemesterwewillbeusingC++andOpenGLtoimplementallofour programmingprojects.IfyouareusingaMacwithXcodeinstalled,thenyoucan downloadthesrc.tarfileandcompilethesamplegraphicscodeusingtheenclosed Makefile.IfyouareusingaPC,thenyourbestoptionwouldbetodownloadand installaLinuxVMfromthedepartment’swebsite.Theinstructionsfordoingthis arepostedinREADMEfilethe“SourceCode”pageoftheclasswebsite.Onceyou haveLinuxandOpenGLinstalled,youcancompileyourgraphicsprogramusing “g++-Wallproject2.cpp-oproject2-lGL-lGLU-lglut”. Usingoneoftheprogramsinthesourcedirectoryasastartingpoint,youcanadd codetothe“display”functiontodisplayyourbrickonthescreen.Youwillneedto makeuseofthe“mouse”callbacktodetectwhentheuserhasselectedthebrick,and the“motion”callbacktotrackthemotionofthemouseastheuserdragsittothe left,andthe“idle”or“timer”functiontoupdatethelocationandorientationofthe brickafterithasbeenreleasedbytheslingshottowardsthetarget. 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.