[Solved] COSC363 Lab 5-Sweep Surfaces

$25

File Name: COSC363_Lab_5-Sweep_Surfaces.zip
File Size: 263.76 KB

SKU: [Solved] COSC363 Lab 5-Sweep Surfaces Category: Tag:
5/5 - (1 vote)

This lab is a continuation of Lab04 on object modelling. In this lab, we will consider another example of sweep surface obtained by successive transformations of a polygonal shape.

  1. Tower.cpp:

The Turning Torso (Fig. a), a twisted tower in Malmo, Sweden is an excellent architectural example of a sweep surface/structure (For more information on the tower, see: http://en.wikipedia.org/wiki/Turning_Torso ). We can generate a model of the tower using the shape shown in Fig (b) as the base polygon. The program Tower.cpp contains a representation of the polygonal shape using vertex coordinates stored in arrays vx[], vy[], vz[] inside the display() function. The polygon has 18 vertices as shown in Fig. (c). Since this is a closed polygon, the first vertex is appended to the end of the list again, to get a closed quad strip. The vertex list therefore contains 19 vertices.

Fig. (a) Fig. (b)
16 Fig. (c)

The tower consists of 9 blocks, each block having a height of approx. 20 meters, and turned clockwise about the vertical axis by 10 degrees relative to the lower block.

  1. The program displays only the base polygon (Fig. c) at the bottom part of the screen. The camera can be moved around the scene using the left and right arrow keys.
  2. Delete the code segment that draws the base polygon inside the display() function and implement the following algorithm:
  • Generate a new set of transformed coordinates wx[i], wy[i], wz[i], i = 0.. N1 (already declared in the program) by rotating the points (vx[i], vy[i], vz[i]) by -10 degs (clockwise) about the y-axis and translating along yaxis by 20 units. Since we require the transformed points, we cannot use the OpenGL function glRotatef() to perform the rotation. Instead, we use the following equations:

wx = vx cos + vz sin, = 10 Degs (Convert to radians!) wy = vy + 20 wz = vx sin + vz cos

  • Join the points Vi = (vx[i], vy[i], vz[i]) and the transformed points Wi = (wx[i], wy[i], wz[i]) using a quad strip to generate the surface of the extruded shape. Refer to the code given on Slide [5]-12.
  • After drawing the quad-strip, replace the values in (vx[], vy[], vz[]) with the transformed values in (wx[], wy[], wz[]).

The above three steps generate the surface of one block of the tower. Repeat the steps 8 more times.

The light and camera positions have already been defined in the program. Change the value of the global variable viewAngle to -160 degs. The program should generate an output similar to the one given in Fig. (d).

Fig. (d)

  1. The program includes the necessary functions for loading a bitmap texture TowerTexture.bmp. Please uncomment the three lines inside the initialise() function to enable texture mapping. The texture has 5 parts corresponding to 5 sides of the tower (Fig (e)).

t

Fig. (e)

  1. We need to assign texture coordinates to vertices of the quad strip. If a vertex Vi has texture coordinates (si, 0), then the corresponding vertex Wi will have texture coordinates (si, 1). The values si must be carefully chosen so that the image sections in the texture are properly mapped to the 5 sides of the polygon (see Fig. (c)). Fig(e) shows how this mapping must be done. The table below gives the texture s-coordinates for some of the vertices. Compute the remaining coordinates, assuming that the points are uniformly distributed within each of the 3 middle sections. Your program should then produce an output similar to the one given in Fig. (f).
Vertex index i 012:6:12:161718 Tex Coordsi 00.15 0.2:0.4:0.6:0.80.851 Fig. (f). Textured tower

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[Solved] COSC363 Lab 5-Sweep Surfaces
$25