There are two more unit-sphere les given in

Assignment Help Computer Graphics
Reference no: EM13346582

There are two more unit-sphere ?les given in https://cis.poly.edu/cs653/assg3/, with 256 and 1024 triangles, respectively.

Draw the x-, y-, z-axes, the "ground" (the quadrilateral indicating the x-z plane), and roll the wire-frame sphere as in Assignment 2. Your task here is to add the corresponding shadow of the sphere on the ground given a ?xed light source located at position L = (-14.0, 12.0,-3.0, 1.0).

Draw the shadow with color (0.25, 0.25, 0.25, 0.65). Note that the shadow should be the wire- frame sphere projected onto the ground, projected from the light source. As the sphere rolls, the shadow should also "roll" accordingly.

As another option, draw the sphere as a solid sphere and roll it as before, by drawing the sphere triangles as ?lled triangles rather than just drawing the triangle edges. Produce the corresponding shadow effect for this rolling solid sphere as well, using the same shadow color and the same light source location L. (The options are put together by a menu; see Part (b).)

Programming Tips:

1. If you experienced a strange behavior of the z-buffer where some parts of the scene disappear randomly, check your gluPerspective() command; see Useful Tips Item 2 on page 4 for the details.

2. In OpenGL, although the perspective division is automatically done to convert (x, y, z,w) to (x/w, y/w, z/w, 1) for w = 0, the OpenGL implementation actually requires that w > 0. So if you tried q = ( f(x,y,z)/ h(x,y,z) , 0, g(x,y,z)/h(x,y,z) , 1) ≡ (f(x, y, z), 0, g(x, y, z), h(x, y, z)) and it did not work, try to use q = ( -f(x,y,z)/-h(x,y,z) , 0, -g(x,y,z)/-h(x,y,z) , 1) ≡ (-f(x, y, z), 0,-g(x, y, z),-h(x, y, z)).

(b) If you just draw the shadow as in Part (a), then you will see a broken shadow. The unde- sirable effect is especially obvious for the solid sphere. This is because the shadow and the ground are on the same plane, but the z-buffer only has a limited numerical precision. As a result, some portion of the shadow may appear in front of the ground and some portion may appear behind the ground and thus blocked by the ground; the result is unpredictable. Note that what you want here is to make the shadow always appear on top of the ground, i.e., to make the shadow a decal on top of the ground. Use the technique of making a decal, as discussed in class, to achieve the desired effect.

In addition, implement "Shading" as a submenu with 2 submenu entries: "?at shading" and "smooth shading". When lighting is disabled (by choosing "Enable Lighting" and then "No"), both options should just draw the sphere as a solid sphere (see Part (a)) and give the same result.

(c) Provide a global ambient white (with color (1.0, 1.0, 1.0, 1.0)) light, and also provide a directional light source with black ambient color (0.0, 0.0, 0.0, 1.0), white diffuse and specular color (1.0, 1.0, 1.0, 1.0), and position (0.0, 0.0, 1.0, 0.0) in the eye coordinate system. Note that (0.0, 0.0, 1.0, 0.0) is in fact a vector rather than a point, and thus this light source is a distant (directional) light. The colors and the position described above are actually the default values of GL_LIGHT0, so you can set it up by just enabling GL_LIGHT0 without specifying these values. If you do want to specify the values, notice that the position (vector) value is in the eye coordinate system (meaning that the vector is ?xed relative to the viewer), and you have to specify it in an appropriate place in your program; see Useful Tips Item 3 on page 4 for more details. Give your quadrilateral "ground" that indicates the x-z plane a green diffuse color (0.0, 1.0, 0.0) (with default ambient and specular colors), and give your sphere a golden yellow diffuse and specular color (1.0, 0.84, 0.0) (and a default ambient color) with a shininess coef?cient of 125.0. Consider the four unit-sphere ?les given. Actually, there is one more piece of information implicitly given in the ?le format: each triangle (given by the coordinates of its three vertices) has its three vertices ordered such that if the ?ngers of the right hand are curled along the direction of the vertex speci?cation, the thumb will point towards the triangle's outward normal (in this case this normal points towards the outside of the sphere). Augment your data structure from Assignment 2 so that associated with each triangle you also store its outward normal vector of length 1 (i.e., the unit-length outward normal vector).

Recall that the menu entry "Shading" has two submenu entries "?at shading" and "smooth shading". Implement these entries with the following shading effects when "Enable Lighting" is "Yes":

(1) "?at shading"- ?at shade the ?lled triangles of the unit sphere, where the unit-length normal vector associated with each triangle is the normal vector that you just computed and stored.

(2) "smooth shading" - smooth shade the ?lled triangles of the unit sphere. To assign the unit- length vertex normals, use the fact that if the unit sphere is centered at the origin o and v is a point on the surface of the unit sphere, then → ov is the unit-length normal vector at v.

 

Reference no: EM13346582

Questions Cloud

Steak sauce lawrys defense case to complete a formal : steak sauce lawrys defense case to complete a formal written case analysis.chuck smith senior brand manager on a.1.
1 define open and closed loop control systems explain : 1. define open and closed loop control systems. explain difference between time varying and time invariant control
1 a firm estimates its cubic production function of the : 1. a firm estimates its cubic production function of the following formq al3 bl2and obtains the following
Marketing research project project that required to plan : marketing research project project that required to plan and strategize effectively. if you use your time efficiently.
There are two more unit-sphere les given in : there are two more unit-sphere ?les given in httpcis.poly.educs653assg3 with 256 and 1024 triangles respectively.draw
1briefly describe venture debt capital and venture equity : 1.briefly describe venture debt capital and venture equity capital.2.describe how the costs of debt and equity differ
Sockets for this problem you will implement a client-server : sockets for this problem you will implement a client-server version of the rock-paper-scissors-lizard-spock game which
Question 1assume a manufacturer incurs 2000000 hours of : question 1assume a manufacturer incurs 2000000 hours of direct productive labor in a year at a total direct labor cost
1nbsp find the natural domain of the following functions : 1.nbsp find the natural domain of the following functions. explain your results.2. given the equation y x2 - 6x 8 find

Reviews

Write a Review

Computer Graphics Questions & Answers

  Create a simple warm-up program using your g3d

Create a simple warm-up program using your G3D programming and graphics environment.

  Shadow effect while rolling a sphere

Shadow effect while rolling a sphere as well as the options of shading and lighting.

  Relative positioning and interactive positioning

Relative Positioning and Interactive Positioning by Dragging and Clicking and some Simple Animation

  Draw a teapot at the global origin

Draw a teapot at the global origin

  Concepts of computer graphics

Concepts of Computer Graphics and develop a program using OpenGL

  The security policy document outline

Using the GDI Case Study below, complete the Security Policy Document Outline

  Develop the image manipulations

Develop the image manipulations

  What does resolution mean

What does resolution mean How is resolution connected to ppi and dpi units

  Differentiate between a bitmap image and a vector image

Differentiate between a bitmap image and a vector image Explain the following terms

  Essential elements of a design pattern

configuration of an Iterator pattern, patterns could be used in a Library System, Singleton, Template, Decorator, Façade,What does Alexander means by the following declaration "But it is impossible to form anything which has the temperament of natu..

  Framework of user interface design

design of user interfaces, natural mapping, GUI applications, web page design different to designing for printed media, risks exposed in this "phone as individual proxy" approach, interaction designers of ubicomp applications, Storyboards are usual..

  What are the factors affecting picture composition

Define picture composition What are the factors affecting picture composition. Elaborate on each factor Describe the basic lines present in a composition

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd