Tuesday, March 6, 2007

Leaf Green Cheats For Vba



Aide
Computer Graphics Laboratory

Questionnaire previous # 2
- Geometric Modeling -

1. What is a transformation geometric? What are the basic transformations and matrices?

transformations: a transformation T is a function to change a point or a vector v Q at another point P or another vector u: P = T (Q), u = T (v), any transformation should be applied point to point to all points of a scene.
transformations help us:
Manipulating objects in 3D space
Help to display and examine objects

affine Types:
- Translating
-
Rotation - Scaling
- Shearing
- Reflection

Translation: We move the origin and axes parallel. In two and three dimensions, where dx, dy, dz travel distances:





Rotation: In two dimensions, if we rotate the axes an angle (positive if it rotates counter-clockwise)

In three dimensions: we now have three different rotations on each of the coordinate axes (also considered positive if rotates anti-clockwise) rotation of Z is almost the same as before, but now we have to use a matrix (3x3)

For rotation about X, it is also practically the same as before, only the X axis was previously will now And, and that antesera Y, Z (also considered positive if rotates anti-clockwise)

If we rotate about Y, which in Rz was X will now be Z, and where we had And, now it to Z. So there queintercambiar also rows and columns in the matrix of rotation ...

rotation matrices are orthonormal. We can invert by transposition.
The rotation about any axis will need, in general, be performed as a composition of several transformations:
1. Spindle travel (and the objects to rotate) so that the axis passing through the origin
2. Decomposition of the rotation rotation simple compared to the three coordinate axes X, Y and Z
3. Reverse translation, making the reverse was done in (1)
uniform and nonuniform scaling: We vary the scale on the coordinate axes with the same or different scale factor for each axis (scale factors if the same or different)
Shearing
:
• Do not keep the corners, although the straight and parallel
• Less used in graphics
• In three dimensions is similar, although additional factors appear to us new

2. Type the commands that allow you to apply geometric transformations OpenGL, variants of these commands and describe its parameters.

Translation: void glTranslate (x, y, z) will allow us to move an object in space
Rotation: void glRotate (angle, x, y, z) will allow us to rotate an object
Scale: void glScale (x, y, z) will allow us to scale an object

Where: x, y, z are the coordinates of a point.

3. Describe what are the OpenGL GL_MODELVIEW and GL_PROJECTION matrices. What is the purpose? How can I switch between the two? What is the active matrix by default? What is the use the command glLoadIdentity ()?

GL_MODELVIEW: the array containing the transformations arising from the
modeling and position changes of the camera.
GL_PROJECTION: the array with the changes that made the projection of the scene
3 to 2 dimensions.

These two matrices are used to make a transformation operation. Is specified with the glMatrixMode (GLenum mode) that has as its subject one of the three constants listed. It behaves like a state, therefore, until you enter a new state all changes are made on the last matrix specified.
In resaphe function code () the previous chapter:
void reshape (int width, int height) {
glViewport (0, 0, width, height);
glMatrixMode (GL_PROJECTION);
glLoadIdentity ();
gluPerspective (60.0, (GLfloat) height / (GLfloat) width, 1.0, 128.0);
glMatrixMode (GL_MODELVIEW);
glLoadIdentity ();
gluLookAt (0.0, 1.0, 3.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0);}

used is noted glMatrixMode () twice, first with
GL_PROJECTION and the second with GL_MODELVIEW.
After the first call to glMatrixMode (), the matrix on which the transformations take place
is GL_PROJECTION, the first operation is to initialize the function matrix glLoadIdentity () to load the identity matrix and defines a perspective projection with gluPerspective function (). This function explained in the next chapter.
After the second call to glMatrixMode (), the matrix on which the transformations take place is GL_MODELVIEW
, also, the first operation is to initialize the function matrix glLoadIdentity () and then sets the camera position with gluLookAtAl OpenGL behave as a state machine, the following processing operations carried out in the code, which will be out resaphe function (), will be held on the last matrix specified, ie on GL_MODELVIEW.

4. What are the commands glPushMatrix () and glPopMatrix ()? Describe their use through an example in code.

glPushMatrix (); / / The function glPushMatrix () makes a copy of the upper die and puts it on the stack, so that the two above matrices are equal, the function call glPushMatrix () is doubled upper die. The following changes are made apply only to the upper die of the stack, leaving the former with the values \u200b\u200bit had at the time of the function call glPushMatrix ().
glPopMatrix (); The role glPopMatrix () removes the upper die, being in the top of the stack the matrix that was when the function call glPushMatrix ().

glColor4f (1.0,0.0,0.0,1.0);
dibujarCuadro (1.0);
glPushMatrix ();
glTranslatef (0.0, 2.0, 0.0);
dibujarCuadro (0.5);
glPopMatrix ();
glPushMatrix ();
glTranslatef (0.0, -2.0, 0.0);
dibujarCuadro (0.5);
glPopMatrix ();

5. What are the commands glBegin () and glEnd ()? Describe its use, its parameters and exemplify through a piece of code.

To create any geometric shape in OpenGL vertices must be defined between a pair of calls to glBegin () and glEnd (). A glBegin function can be passed an argument that determines what kind of geometric figure will be built. After the corners are defined by function calls glVertex. Here is an example which defines the polygon.
glBegin (GL_POLYGON)
glVertex2f (0.0, 0.0);
glVertex2f (0.0, 3.0);
glVertex2f (3.0, 3.0);
glVertex2f (4.0, 1.5);
glVertex2f (3.0, 0.0);
glEnd () ;
void glBegin (GLenum mode); marks the beginning of a list of vertices describing a geometric primitive. The mode parameter indicates the type of primitive (GL_POINTS individual points. GL_LINES Each pair of vertices form a single segment.
GL_POLYGON simple polygon vertices connected. GL_TRIANGLES Each triplet determines a triangle. GL_QUADS Each quadruple determines a square. GL_LINE_STRIP Series of connected line segments. GL_LINE_LOOP Series of connected line segments and closed. GL_TRIANGLE_STRIP chains connected triangles. GL_TRIANGLE_FAN polystrip chains (the center is the first
corner). Quadrilaterals GL_QUAD_STRIP chains.)
void glEnd (void); marks the end of a list of vertices.

6. What is geometric modeling? Describe the types of geometric modeling in the world.

Geometric Modeling: is a technique that can generate different types of objects.
models can be classified into Alambrito, surfaces (flat or curved) and solids. Curved surface models are divided into parametric (analytical and synthetic) and nonparametric (explicit and implicit). The most important solid models: semi-space, border, CSG, scanning, enumeration space, etc.
Among the unconventional models include: fractals, grammars, systems of particles, the blobs, and those based on physical properties.

7. Build code to draw a cube (check in the theory class), and from this hierarchical model of the humanoid figure and write the program that draws it. The measures are on your own.


#include
#include

void init(void)
{
glClearColor (0.0, 0.0, 1.0, 0.0);
glShadeModel (GL_FLAT);
}

void cube(void){
GLfloat vertices[][]={{0.55,0.5,0.5},
{-0.5,-0.5,0.5},
{0.5,-0.5,0.5},
{-0.5,0.5,0.5},
{-0.5,-0,5,-0.5},
{-0.5,0.5,-0.5},
{0.5,0.5,-0.5}};
glBegin(GL_QUADS);
glVertex3fv(vertices[0]);
glVertex3fv(vertices[1]);
glVertex3fv(vertices[2]);
glVertex3fv(vertices[3]);
glEnd();
glBegin(GL_QUADS);
glVertex3fv(vertices[4]);
glVertex3fv(vertices[5]);
glVertex3fv(vertices[6]);
glVertex3fv(vertices[7]);
glEnd();
glBegin(GL_QUADS);
glVertex3fv(vertices[1]);
glVertex3fv(vertices[6]);
glVertex3fv(vertices[5]);
glVertex3fv(vertices[2]);
glEnd();
glBegin(GL_QUADS);
glVertex3fv(vertices[0]);
glVertex3fv(vertices[3]);
glVertex3fv(vertices[4]);
glVertex3fv(vertices[7]);
glEnd();
glBegin(GL_QUADS);
glVertex3fv(vertices[0]);
glVertex3fv(vertices[7]);
glVertex3fv(vertices[6]);
glVertex3fv(vertices[1]);
glEnd();
glBegin(GL_QUADS);
glVertex3fv(vertices[2]);
glVertex3fv(vertices[5]);
glVertex3fv(vertices[4]);
glVertex3fv(vertices[3]);
glEnd();
}
void display(void)
{

glPushMatrix();
glTranslatef(0.0,1.25,0.0);
glPushMatrix();
glTranslatef(0.25,1.5,0.0);
glScalef(1.5,0.5,0.5);
cube();
glPopMatrix();

glPushMatrix();
glTranslatef(0.25,2.0,0.0);
glScalef(1.0,2.0,0.5);
cube();
glPopMatrix();

glPushMatrix();
glTranslatef(-4.75,1.75,0.0);
glScalef (0.5,2.0,0.5);
cube ();
glPopMatrix ();
glPushMatrix ();
glTranslatef (1.5,0.0,0.0);
glScalef (2.0,1.5,0.5);
cube ();
glPopMatrix ();

glPushMatrix ();
glTranslatef (2.0,0.0,0.0);
glScalef (2.0,0.5,0.5);
cube ();
glPopMatrix ();
glPushMatrix ();
glTranslatef (- 1.5,0.0,0.0);
cube ();
glPopMatrix ();

glPushMatrix ();
glTranslatef (-2.0,0.0,0.0);
glScalef (2.0,1.5,0.5);
cube ();
glPopMatrix (); glPushMatrix
();
glTranslatef (-2.0,0.75,0.0);
glScalef (2.0,0.5,0.5);
cube ();
glPopMatrix ();
glPushMatrix ();
glTranslatef (0.0, -2.0,0.0);
cube ();
glPopMatrix ();

glPushMatrix ( );
glTranslatef (0.75, -2.5,0.0);
glScalef (2.0,3.0,0.5);
cube ();
glPopMatrix ();
glPushMatrix ();
glScalef (0.5,2.0,0.5);
cube ();
glPopMatrix ();
glPushMatrix ();
glTranslatef (12:25, -2.0,0.0);
glScalef (1.0,2.0,1.0);
cube ();
glPopMatrix ();
glPushMatrix ();
glTranslatef (0.5, -1.5,0.0);
glScalef (1.5,0.5,0.5);
cube();
glPopMatrix();
glPopMatrix();

}
void reshape (int w, int h)
{
glViewport (0, 0, (GLsizei) w, (GLsizei) h);
glMatrixMode (GL_PROJECTION);
glLoadIdentity ();
glFrustum (-1.0, 1.0, -1.0, 1.0, 1.5, 20.0);
glMatrixMode (GL_MODELVIEW);
}
/* ARGSUSED1 */
/*void keyboard(unsigned char key, int x, int y)
{
switch (key) {
case 27:
exit(0);
break;
}
}*/
int main(int argc, char** argv)
{
glutInit(&argc, argv);
glutInitDisplayMode (GLUT_SINGLE GLUT_RGBA)
glutInitWindowSize (500, 300);
glutInitWindowPosition (300.230);
glutCreateWindow (argv [0]);
init ();
glutDisplayFunc (display);
glutReshapeFunc (reshape);
glutKeyboardFunc (keyboard);
glutMainLoop ();
return 0;}


8. What are the commands glClearColor () and glClear ()? Describe its operation, its parameters and exemplify through a piece of code. Void

glClearColor (GLclampf network GLclampf green, blue GLclampf, GLclampf alpha) Enables
current background color, the model RGB representation. Each argument represents the amount of color indicated that he has the background color, and takes values \u200b\u200bin the interval [0, 1 . The default color is BLACK which is represented by the value: (0, 0, 0, 0).
void display (void) {

glClearColor (0.0,0.0,0.0,0.0);
/ / Background color: black
glClear (GL_COLOR_BUFFER_BIT);
/ / Boramos
screen glMatrixMode (GL_PROJECTION);
/ / Mode
projection glLoadIdentity ();
/ / Load the identity matrix
glOrtho (-1.0,1.0, -1.0,1.0, -1.0,1.0);
/ / orthographic projection, said hub within
glMatrixMode (GL_MODELVIEW);
/ /
Modeling Mode glBegin (GL_TRIANGLES)
/ / Draw a triangle
glColor3f (1.0,0.0,0.0);
/ / first vertex color: red
glVertex3f (0.0,0.8,0.0);
/ / coordinates of first vertex glColor3f
( 0.0,1.0,0.0);
/ / second vertex color: green
glVertex3f (-0.6, -0.2,0.0);
/ / Coordinates of the second vertex
glColor3f (0.0,0.0,1.0);
/ / Color third point: blue
glVertex3f (0.6, -0.2,0.0);
/ / Coordinates of the third vertex
glEnd ();
/ / Finish drawing
glFlush ();
/ / We force the drawn
sleep (10);
/ / Wait 10 seconds
exit (0);
/ / Exit the program}


void glClear (GLbitfield mask);
Clear the buffer specified by the parameter, initialized to the value it had assigned the previous state variable. Possible values \u200b\u200bof argument, that is possible buffers we have are the following:
GL_COLOR_BUFFER_BIT
Color Depth Buffer Buffer Buffer Accumulate GL_DEPTH_BUFFER_BIT
GL_ACCUM_BUFFER_BIT
GL_STENCIL_BUFFER_BIT

Stencil Buffer void display (void) {
glClear (GL_COLOR_BUFFER_BIT GL_DEPTH_BUFFER_BIT) glPushMatrix
();
glMultMatrixd (mModel)
glColor3f (1.0,1.0,0.0);
drawTurtle ();
glPopMatrix ();
displayTrace ();
glutSwapBuffers ();}

9. Describe the commands glutInit (), glutInitDisplayMode (), glutInitWindowSize (), glutInitWindowPosition (), glutCreateWindow (), glutDisplayFunc (), glutReshapeFunc (), glutKeyboardFunc () and glutMainLoop (). Describe your operation, use and settings. Void

glutInit (& argc, argv); that initializes the GLUT, and negotiates with the system to open windows. The parameters should be the same argc and argv unmodified main (). Glut means a series of parameters that can be passed by command line. Void

glutDisplayFunc ( void (* func) (void)) The function func () is called each time you have to redraw the window. Initializes the buffer of the screen, esn this case is the mode and type of screen colors (RGB / RGBA)


glutReshapeFunc void (void (* func) (int width, int height)) The function func (width , height)
is called each time the window is resized, and receive as parameters the new width and height.

glutInitDisplayMode. Initialize mode. In this case, we are activating the depth buffer (GLUT_DEPTH), double buffering (GLUT_DOUBLE) and rendering RGB (GLUT_RGBA).

glutInitWindowSize (Width, height). Initialize the size of the window.

glutInitWindowPosition (x, y). Initialize the position of the window on the desktop.

glutCreateWindow (char * title). Create the window. This function displays a window of defined size and position and the title you have placed.

glutKeyboardFun Void (void (* func) (unsigned char key, int x, int y)): Responsible for the interaction of events on the keyboard. manages the control of the keyboard, making a transition between ASCII and GLUT

glutMainLoop Void (), is the main loop of the display, is responsible for interacting with events. This function initializes the framework running GLUT, and processes operating system messages

10. What is a Callback Function in GLUT?

The implementation of this function waits for events to occur. Every time I attend an event and executes the registered function, responsible for responding to the event (callback function).




0 comments:

Post a Comment