讲解:CMPT 361、system、Java,c++、PythonSQL|C/C++

Computing Science CMPT 361 Fall 2019Assignment #3Due date: November 27th at 11:59 pm.Ray TracingYou will write a basic ray tracer. The entire assignment can be completed in Euclideanspace; there is no need for homogeneous coordinates. There are 25 points available.(a) [1 point] Window setupUse OpenGL to set up a window with a 400 x 400 pixel drawing window. Use a symbolicconstant rather than 400 so that you can change resolution by changing the constant.(b) [2 points] ViewingThe eyepoint is the origin, and the view is down the negative z-axis with the y-axis pointingup. The coordinate system is right-handed.Have a constant or a procedure call that defines the Field of View in the Y-direction (fovy), indegrees. The field of view is the angle between the top of the view volume and the bottomof the view volume. It is illustrated in the following image, but note that we will have nonear or far clipping planes. Note that since we have a square window (400 x 400) the field ofview in the x-direction (fovx) is equal to fovy.(image from learnwebgl.brown37.net)Assume that the virtual screen is on the plane at z = -1.Design an object called Ray to hold a ray, which consists of a start point p0 and a vector vand represents the ray p(t) = p0 + tv for t ≥ 0.Computing Science CMPT 361 Fall 2019In a routine named render, write a loop nest that will generate the initial rays for each of thepixels. These initial rays start at the origin and have a vector v = (vx, vy, -1). Your job here isto figure out the correct vx’s and vy’s given fovy. At this point, the body of the loop nestshould just create a ray object.(c) [2 points] PrimitivesYou will have two types of objects that you will be making images of: spheres and planes.Define an object for each of these primitives, e.g. a Sphere and a Plane. Design ways ofcreating these objects so that they are put on a globally-accessible list (array, vector, etc.) ofobjects. You may either keep one such list or two (which would be one for Spheres and onefor Planes).When creating an object, specify its geometry and its material/surface properties. Forexample, you might have:new Sphere(1.0, 2.0, -3.0, 1.25, 0.1, 0.8, 0.8, 0.9, 0.9, 0.9, 32, 0.5, 0.0, 1.5)which is quite hard to figure out. It’s better if you have objects that group the parameters,such as a Point and a Color:new Sphere(Point(1.0, 2.0, -3.0), 1.25, Color(0.1, 0.8, 0.8), Color(0.9, 0.9, 0.9), 32, 0.5, 0.0, 1.5)This is still a long parameter list, but it is meant to represent:Center of sphere: (1.0, 2.0, -3.0)radius of sphere: 1.25kd: Color(0.1, 0.8, 0.8)ks: Color(0.9, 0.9, 0.9)q: 32kr: 0.5kt: 0.0 (no refraction)index of refraction: 1.5One can perhaps simplify the parameters farther by defining an object Material consisting ofall the material properties. Material* aqua = new Material(Color(0.1, 0.8,0.8), Color(0.9, 0.9, 0.9), 32, 0.5, 0.0, 1.5) … new Sphere(Point(1.0, 2.0, -3.0), 1.25, aqua);Computing Science CMPT 361 Fall 2019Instructor: Tom Shermer Simon Fraser UniversityThe object Plane should be similar, with the first four parameters denoting A, B, C, and D ofthe plane equation Ax + By + Cz + D = 0:new Plane(0.0, 1.0, 0.0, 1.0 , aqua);This is the plane y = -1 given the ‘aqua’ material properties.(d) [1 point] LightsThe lights you will be using are simple local point light sources with no falloff.Define an object Light and a way of creating them so that they are put on a globallyaccessiblelist (array, vector, etc.) of lights. Each light should have a location and a colorintensity:new Light(Point(-100.0, -100.0, -20.0), Color(2.5, 2.5, 2.0))Note that the “Color” here is color intensity and can contain values greater than 1.0; normalcolors (kd and ks) have channels that range between 0.0 and 1.0.(e) [1 point] Scene setup and command-line argumentYour program must be capable of displaying one of four different scenes depending on acommand-line argument (which will be a number, 1 to 4). Each scene should set up lights,primitives, camera (fovy), and also set a depth limit for the ray tree, an ambient lightintensity, and a background light intensity. You should have one subroutine for each sceneto display. Here’s roughly what a scene subroutine should look like, if you use the Materialobject:void scene2() {Material* aqua = new Material( … );Material* greenGlass = new Material(…);Material* chrome = new Material(…);fovy(40);rayTreeDepth(4);ambient(new Color(…);bacCMPT 361代写、代做system、Java,c++编程kground(new Color(…);new Light(…);new Light(…);new Sphere(…);new Sphere(…);new Plane(…);render();}Don’t slavishly copy that; you may have other syntax for creating your objects, or differentlynamedsubroutines, etc.Computing Science CMPT 361 Fall 2019Instructor: Tom Shermer Simon Fraser University(f) [3 points] Ray-primitive intersectionsAs member functions of the primitive objects (Plane and Sphere), implement a routine whichwill intersect a ray with the object. It should take the ray as a parameter and return thesmallest positive t value at which the ray intersects the primitive. If there is no such t value,it returns a negative number. (This is an overloading of the return value but in this casespeed is important so we’ll forgive ourselves.) These computations have been covered inlecture.(g) [7 points] Ray tracingImplement a function trace that takes a ray and a depth of tracing as parameters, andreturns a color intensity.If the depth of tracing is 0, then trace should return the background color intensity.If the depth of tracing is greater than 0, then trace should intersect the ray with all primitivesin the scene and determine which one has the smallest positive t where it intersects. This isthe object the ray hits. If the ray hits no object, then trace should return the backgroundcolor intensity.If the ray hits an object, then let p(t) be the point where it hits. At this point, apply thelighting formula𝐼 = 𝐼𝑎𝑘𝑑 + 𝐼𝑟𝑘𝑟 + 𝐼𝑡𝑘𝑡 +∑𝑆𝑖𝐼𝑖(𝑘𝑑𝑁 ∙ 𝐿𝑖 + 𝑘𝑠(𝑅𝑖∙ 𝑉)𝑞)𝑚𝑖=1Ir and It are obtained by recursively tracing the reflected and refracted rays, respectively. Besure to decrement the depth-of-tracing parameter by 1 when you make the recursive call.SI should be 0 or 1 and is obtained by a ray cast from p(t) in the direction of light source i.The view vector V is the reverse direction of the incoming ray that hit the surface at p(t).You will need to find the normal vector to your primitive at p(t), and also Li and Ri. You’ll alsohave to find the directions of the reflected and refracted rays; the refracted one is moredifficult but that is a problem I leave for you to solve. Do not generate reflected or refractedrays if kr or kt is zero.Modify your render subroutine so that it traces the rays that it generates. When it gets acolor intensity back from trace, it should first convert that color so that all channels liebetween 0.0 and 1.0 ( because the intensity you get may be out of range). You choose howto do this. Then it should write that color to the appropriate pixel on the OpenGL display.See the programs in section 23-1 of your text if you are unsure how to do this…it’s done withcode like:glColor3f(r, ,g, b);glBegin(GL_POINTS); glVertex2f(x, y);glEnd();Computing Science CMPT 361 Fall 2019Instructor: Tom Shermer Simon Fraser University(h) [8 points; 2 points each] Four scenesEach scene should contain at least three spheres and one plane.Scene 1 should convincingly demonstrate that you have basic Phong lighting controlsimplemented. I want to see diffuse and specular effects. Be sure to include surfaces withdifferent values of q, the specular exponent. Be sure the image clearly shows an effect fromthe changing q.Scene 2 should convincingly demonstrate that you have reflection and shadowing working.Scene 3 should convincingly demonstrate that you have refraction working.Scene 4 is your choice. Design a nice scene and impress us with what your ray-tracer will do.ExtrasNo extra credit is available, but you can implement extra functionality if you would like. Forinstance, have a function to call from a scene function that will set the resolution of therender (rather than 400 x 400). Or you could implement extra primitives, like polygons,quadrics, or CSG. Or you could implement light attenuation. Or texture-map the plane likea checkerboard. On the structural side, you could implement bounding volume hierarchies.These are just some ideas in case you’d like to expand this project.Note that you can include these extras in your scenes, particularly in scene 4.Submission:• All source code,• a Makefile to make the executable called rayT (the make command should besimply “make”),• four images called S1.jpg, S2.jpg, S3.jpg, S4.jpg that show the images that resultfrom running your program with arguments 1, 2, 3, and 4, respectively,• and a README file that documents any steps not completed, additional features,and any extra instructions for your TA.转自:http://www.6daixie.com/contents/9/4428.html

©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 218,607评论 6 507
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 93,239评论 3 395
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 164,960评论 0 355
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 58,750评论 1 294
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 67,764评论 6 392
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 51,604评论 1 305
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 40,347评论 3 418
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 39,253评论 0 276
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 45,702评论 1 315
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 37,893评论 3 336
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 40,015评论 1 348
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 35,734评论 5 346
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 41,352评论 3 330
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 31,934评论 0 22
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 33,052评论 1 270
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 48,216评论 3 371
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 44,969评论 2 355

推荐阅读更多精彩内容