+1-415-670-9189
info@expertsmind.com
Shadow effect while rolling a sphere
Course:- Computer Graphics
Reference No.:- EM13474




Assignment Help
Expertsmind Rated 4.9 / 5 based on 47215 reviews.
Review Site
Assignment Help >> Computer Graphics

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.

 




Put your comment
 
Minimize


Ask Question & Get Answers from Experts
Browse some more (Computer Graphics) Materials
Using Java, Write a code that reads an integer n, followed by the coordinates of each of n points that are the vertices of a n-sided polygon. Plot the vertices and the lines
The rest is blank (i.e., no toner) The toner layer is 25 microns thick. The printer's toner cartridge measures 25 * 8 * 2 cm. How many pages is one toner cartridge good for?
Find an example of a document that misuses graphics. This can be a document that you have received (please blot out any sensitive information and names) or a document that y
Use turtle graphics to draw a simple slogan in all upper case letters. Turtle graphics is a simple model for graphics programming in which you have a "turtle" that can turn
Our goal for the campaign is to find a fun way to promote tap water as a healthier, cheaper and more environmentally friendly way to stay hydrated. We want tap water to beco
LAB- LET'S GET TWISTED, We will draw Bezier curves in this assignment, and some objects along them. You can add control points by left-clicking on the mouse. The points will
Write a socket based single side chat for graphical interface. The client will type message in a textbox and click "send" button and server will print it in a text area as s
Consider a cache consisting of 256 blocks of 16 words each, for a total of 4096(4k) words and assume that the main memory is addressable by a 16 bit address and it contains of