Texturing - texture coordinate, Computer Graphics

Assignment Help:

Background

Texturing is like wallpapering; you are pasting an image onto the OpenGL Quad primitive.  Recall that GL_QUAD is specified by four vertices.  An image, or a texture, also has four vertices.  However, they have different coordinate systems:

1224_Texturing - Texture Coordinate 1.png

Make sure you align your image/texture vertices with the correct GL_QUAD vertices!!!

When we read our TGA image files, we start at the top, left corner and read left to right (like we normally read books!).  So, for a texture, point (0,0) ALWAYS specifies the top, left corner.  Then, (1,0), specifies the top, right corner; (0,1) is the x, y coordinate to specify the bottom, left; and (1,1) specifies the bottom right.  When specifying texture vertices and GL_QUAD vertices, MAKE SURE YOU USE THE SAME WINDING ORDER (e.g., clockwise).

Can I specify a texture coordinate between 0 and 1? Yes!  If you let the x coordinates be 0 and 0.5, you would draw from the far left side (where x==0) to the middle of the image (where x=0.5).  Likewise for the y coordinate.

Can I specify a texture coordinate greater than 1?  Yes!  If the texture is set up to repeat, OpenGL will just repeat the texture that many times.  So, if x was 0 to 4 and y was 0 to 2, OpenG would repeat the texture 4 times in the X direction and 2 times in the Y direction, on the single quad you specified with GL_QUADS.  However,  in this lab, except for GROUND, the textures are NOT set up to repeat.

The code provided for this Workshop has a lot going on.  We read the image files, set up texturing within OpenGL, and we set up alpha (transparency).  Most of this work is done outside the main program file.  Check out Texture.cpp and Texture.h, if you are interested in all the dirty details.

If not, know that we have preloaded 15 textures for you to use today:

GROUND, LAKE , DUCK, FLOWER1, FLOWER2,  WELL, MOUNTAINS, STONE, TREE1, TREE2, TREE3, PINETREE1, PINETREE2, CLOUD1, and CLOUD2

Let's assume we want to draw a ground texture.  First, we need to tell OpenGL which texture we want to draw.  Next, we draw the GL_QUAD and at the same time, we tell OpenGL how to paste the image onto the quad.  Think of it like per-vertex coloring!  So, to draw a 2x2 ground square, centered at zero, and textured with the GROUND texture, we would say:

// Tell OpenGL which texture you want to draw

glBindTexture(GL_TEXTURE_2D, textureStruct[GROUND].texID);

glBegin(GL_QUADS);

                // Draw a ground square - 2x2

                glTexCoord2f(1.0f, 1.0f);   glVertex3f(-1.0f, 0.0f, -1.0f);

                glTexCoord2f(0.0f, 1.0f);   glVertex3f( 1.0f, 0.0f, -1.0f);

                glTexCoord2f(0.0f, 0.0f);   glVertex3f( 1.0f, 0.0f,  1.0f);

                glTexCoord2f(1.0f, 0.0f);   glVertex3f(-1.0f, 0.0f,  1.0f);

glEnd();

Interaction

This week the code base includes some keyboard interaction!  Use the "up" and "down" arrows to move on the z-axis.  The "PgUp" and "PgDn" buttons move along the y-axis.  The "a" and "s" buttons move along the x-axis.  Finally, the "left" and "right" arrows rotate left and right; that is, the left and right arrows rotate about the y-axis.

431_Texturing - Texture Coordinate 2.png

 


Deliverables - Exercise

1-Draw a tree with TREE1 texture(15 points)

Draw a tree using the preloaded TREE1 texture.  Note that this is still a square image file; it looks like a tree because we have transparency (alpha) set up!  Draw the tree facing the user so that your instructor can check your texturing orientations.  Your tree should be oriented like this:

2- Create a Virtual World (65 points)

In this exercise, you will create a simple worldwith the preloaded textures.  You must add at least five (5) different objects.  You must use at least three (3) different textures for your objects.   (These requirements are in addition to the ground, which was drawn for you, and the tree, which was drawn in the previous exercise).  Feel free to add more objects and/or more textures.  Have fun!!!
3- Revisit OpenGL transformation order (20 points)

Find the lines of code that allow the user to translate and rotate inside the world.  Hint: The lines are at the beginning of the display function.  Copy the lines of code here, and then reverse the order that the transformations happen.  Answer the following questions:

1. Copy Code here:

2. Please fully describe how the user was INITIALLY moving about the world.  In other words, describe what happened when you pressed the "up" arrow?  What happened when you pressed the left arrow? And so on.  Did you always move on a certain axis, or did that change after rotating?

3. Please fully describe how the user moves about the world AFTER you switched the order of the transformation.  What changed?  Why did it change?

Submit this document with your answers to Exercise #3 andyour code for your virtual world to Scholar(the whole folder in a zip file or the .cpp file you edited, whichever your instructor asks for). This is anINDIVIDUAL  assignment, though you can ask your teammates for assistance, you must submit individually.

Rename the project folder as LastName_FirstName_TextureLab before you zip.


Related Discussions:- Texturing - texture coordinate

Image capture formats, Image Capture Formats: Video cameras appear in...

Image Capture Formats: Video cameras appear in two various image capture formats: progressive and interlaced scan. Interlaced Scan It is a technique of enhancing the

What is the need of homogeneous coordinates, What is the need of homogeneou...

What is the need of homogeneous coordinates?  To perform more than one transformation at a time, use homogeneous coordinates or matrixes. They decrease unwanted calculations in

Different types of parallel and perspective projection, Q.   Describe diffe...

Q.   Describe different types of parallel and perspective projection used in computer graphics.

DDA, limitationsof dda

limitationsof dda

Definitions of hypermedia, Definitions of Hypermedia It is a term ...

Definitions of Hypermedia It is a term created through Ted Nelson in the year 1970. It utilized as a logical extension of the term hypertext, wherein graphics, video, audi

Raster scan display device - types of refresh monitors, Raster Scan Display...

Raster Scan Display Device - types of refresh monitors Now day screen display is also based on Cathode ray Tube technology, except that in place of displaying the picture tra

What is the use of control points, What is the use of control points?  ...

What is the use of control points?  Spline curve can be specified by giving a set of coordinate positions known as control points, which shows the general shape of the curve, c

Mathematical description of oblique projection onto xy-plane, Mathematical ...

Mathematical description of an Oblique projection onto xy-plane  In order to expand the transformation for the oblique projection, identify the Figure. This figure explains a

Important points about the frame buffers - graphics hardware, Important Poi...

Important Points about the Frame Buffers 1) Within a frame buffer, information storage starts from top left corner and goes until the bottom right corner. 2) By using this

Opengl, Write a program that allows interactive manipulation of the positio...

Write a program that allows interactive manipulation of the position and orientation of a camera. Draw a teapot at the global origin 0,0,0. You can find a shaded teapot model and

Write Your Message!

Captcha
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