Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Computer Graphics Expert

There are two more unit-sphere ?les given in http://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.

 

Computer Graphics, Computer Science

  • Category:- Computer Graphics
  • Reference No.:- M9130937
  • Price:- $25

Priced at Now at $25, Verified Solution

Have any Question?


Related Questions in Computer Graphics

The saffir-simpson hurricane scale classifies hurricanes

The Saffir-Simpson Hurricane Scale classifies hurricanes into five categories numbered 1 through 5. Write an application named Hurricane that outputs a hurricane's category based on the user's input of the wind speed. CA ...

The problemyou are to search a bitmap in rgb format and

The problem: You are to search a bitmap in RGB format and count the number of pixels which match a set of colors. The bitmap will be 1024 by 1024 pixels for the purposes of explaining this problem. The set of colors will ...

Please read my question if you post copy and pasted code

Please read my question if you post copy and pasted code you will get a negative review. This is java In this graphical program, you are going to simulate arcade car racing game. You need a single player that is movable ...

You have a program draw a rectangle on the screen and allow

You have a program draw a rectangle on the screen and allow the user to change the color/size of the rectangle. The program will store in the browser the settings of the color/size so that upon revisiting the page, the v ...

The problemsit is strongly recommended that you tackle the

The problems: It is strongly recommended that you tackle the following tasks in a modular way -- a separate standalone function for each task. Draw a rectangle as a Rectangle and as a Polygon. Make the lines of the Polyg ...

Question a describe the architecture of simple raster

Question : a) Describe the architecture of simple raster graphics system? b) Explain raster scan display processor?

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As