private static void Init() { float[] ambient = { 0.0f, 0.0f, 0.0f, 1.0f }; float[] diffuse = { 1.0f, 1.0f, 1.0f, 1.0f }; float[] specular = { 1.0f, 1.0f, 1.0f, 1.0f }; float[] position = { 0.0f, 3.0f, 3.0f, 0.0f }; float[] modelAmbient = { 0.2f, 0.2f, 0.2f, 1.0f }; float[] localView = { 0.0f }; Gl.glLightfv(Gl.GL_LIGHT0, Gl.GL_AMBIENT, ambient); Gl.glLightfv(Gl.GL_LIGHT0, Gl.GL_DIFFUSE, diffuse); Gl.glLightfv(Gl.GL_LIGHT0, Gl.GL_POSITION, position); Gl.glLightModelfv(Gl.GL_LIGHT_MODEL_AMBIENT, modelAmbient); Gl.glLightModelfv(Gl.GL_LIGHT_MODEL_LOCAL_VIEWER, localView); Gl.glFrontFace(Gl.GL_CW); Gl.glEnable(Gl.GL_LIGHTING); Gl.glEnable(Gl.GL_LIGHT0); Gl.glEnable(Gl.GL_AUTO_NORMAL); Gl.glEnable(Gl.GL_NORMALIZE); Gl.glEnable(Gl.GL_DEPTH_TEST); Gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f); Gl.glClearAccum(0.0f, 0.0f, 0.0f, 0.0f); // make teapot display list teapotList = Gl.glGenLists(1); Gl.glNewList(teapotList, Gl.GL_COMPILE); Glut.glutSolidTeapot(0.5); Gl.glEndList(); }
private static void RenderRedTeapot(float x, float y, float z) { float[] mat; Gl.glPushMatrix(); Gl.glTranslatef(x, y, z); mat = new float[4]; mat[0] = 0.1745f; mat[1] = 0.01175f; mat[2] = 0.01175f; mat[3] = 1.0f; Gl.glMaterialfv(Gl.GL_FRONT, Gl.GL_AMBIENT, mat); mat = new float[3]; mat[0] = 0.61424f; mat[1] = 0.04136f; mat[2] = 0.04136f; Gl.glMaterialfv(Gl.GL_FRONT, Gl.GL_DIFFUSE, mat); mat[0] = 0.727811f; mat[1] = 0.626959f; mat[2] = 0.626959f; Gl.glMaterialfv(Gl.GL_FRONT, Gl.GL_SPECULAR, mat); Gl.glMaterialf(Gl.GL_FRONT, Gl.GL_SHININESS, 0.6f * 128.0f); Glut.glutSolidTeapot(1.0); Gl.glPopMatrix(); }
// --- Callbacks --- #region Display() private static void Display() { float[] lowAmbient = { 0.1f, 0.1f, 0.1f, 1.0f }; float[] moreAmbient = { 0.4f, 0.4f, 0.4f, 1.0f }; float[] mostAmbient = { 1.0f, 1.0f, 1.0f, 1.0f }; Gl.glClear(Gl.GL_COLOR_BUFFER_BIT | Gl.GL_DEPTH_BUFFER_BIT); // material has small ambient reflection Gl.glMaterialfv(Gl.GL_FRONT, Gl.GL_AMBIENT, lowAmbient); Gl.glMaterialf(Gl.GL_FRONT, Gl.GL_SHININESS, 40.0f); Gl.glPushMatrix(); Gl.glTranslatef(0.0f, 2.0f, 0.0f); Glut.glutSolidTeapot(1.0); Gl.glPopMatrix(); // material has moderate ambient reflection Gl.glMaterialfv(Gl.GL_FRONT, Gl.GL_AMBIENT, moreAmbient); Gl.glPushMatrix(); Gl.glTranslatef(0.0f, 0.0f, 0.0f); Glut.glutSolidTeapot(1.0); Gl.glPopMatrix(); // material has large ambient reflection Gl.glMaterialfv(Gl.GL_FRONT, Gl.GL_AMBIENT, mostAmbient); Gl.glPushMatrix(); Gl.glTranslatef(0.0f, -2.0f, 0.0f); Glut.glutSolidTeapot(1.0); Gl.glPopMatrix(); Gl.glFlush(); }
static void Desenha() { Gl.glClear(Gl.GL_COLOR_BUFFER_BIT | Gl.GL_DEPTH_BUFFER_BIT); Gl.glColor3f(0.0f, 0.0f, 1.0f); Glut.glutSolidTeapot(50.0f); Glut.glutSwapBuffers(); }
static void on_display() { Gl.glClear(Gl.GL_COLOR_BUFFER_BIT | Gl.GL_DEPTH_BUFFER_BIT); Gl.glLoadIdentity(); Glu.gluLookAt(0, 0, 5, 0, 0, 1, 0, 1, 0); Glut.glutSolidTeapot(1); Glut.glutSwapBuffers(); }
// --- Callbacks --- #region Display() private static void Display() { Gl.glClear(Gl.GL_COLOR_BUFFER_BIT | Gl.GL_DEPTH_BUFFER_BIT); Gl.glPushMatrix(); Gl.glRotatef(45.0f, 0.0f, 0.0f, 1.0f); Gl.glBindTexture(Gl.GL_TEXTURE_1D, texture[0]); Glut.glutSolidTeapot(2.0); Gl.glPopMatrix(); Gl.glFlush(); }
protected override void Particular() { Gl.glColor3d(1, 1, 1); Gl.glBindTexture(Gl.GL_TEXTURE_2D, GlUtils.Texture("old3")); Gl.glPushMatrix(); double tph = 10; Gl.glTranslated(largo * 100 / 4, Height + tph * .8, -ancho * 100 / 2); Gl.glRotated(30, 0, 1, 0); Glut.glutSolidTeapot(10); Gl.glPopMatrix(); }
private void timer1_Tick(object sender, EventArgs e) { //t+=3; Gl.glClear(Gl.GL_COLOR_BUFFER_BIT | Gl.GL_DEPTH_BUFFER_BIT); Gl.glLoadIdentity(); Gl.glColor3b(255, 0, 0); Gl.glPushMatrix(); Gl.glTranslated(0, 0, -double.Parse(textBox8.Text)); //Gl.glRotated(double.Parse(textBox1.Text), 1, 0, 0); Gl.glRotated(t, 1, 0, 0); Gl.glRotated(t1, 0, 1, 0); Gl.glBegin(Gl.GL_TRIANGLE_STRIP); Gl.glVertex3f(float.Parse(textBox2.Text), float.Parse(textBox3.Text), 0); Gl.glVertex3f(float.Parse(textBox4.Text), float.Parse(textBox5.Text), 0f); Gl.glVertex3f(float.Parse(textBox6.Text), float.Parse(textBox7.Text), 0); Gl.glEnd(); Gl.glBegin(Gl.GL_QUAD_STRIP); Gl.glVertex3f(-0.9f, 0, 0); Gl.glVertex3f(0.9f, 0, 0f); Gl.glVertex3f(-0.9f, -1, 0); Gl.glVertex3f(0.9f, -1, 0); Gl.glEnd(); Gl.glBegin(Gl.GL_TRIANGLE_STRIP); Gl.glVertex3f(float.Parse(textBox2.Text) + 3, float.Parse(textBox3.Text), 0); Gl.glVertex3f(float.Parse(textBox4.Text) + 3, float.Parse(textBox5.Text), 0f); Gl.glVertex3f(float.Parse(textBox6.Text) + 3, float.Parse(textBox7.Text), 0); Gl.glEnd(); Gl.glBegin(Gl.GL_QUAD_STRIP); Gl.glVertex3f(2.1f, 0, 0); Gl.glVertex3f(3.9f, 0, 0f); Gl.glVertex3f(2.1f, -1, 0); Gl.glVertex3f(3.9f, -1, 0); Gl.glEnd(); Glut.glutSolidTeapot(2); Gl.glPopMatrix(); Gl.glFlush(); simpleOpenGlControl1.Invalidate(); }
void render() { Gl.glClear(Gl.GL_COLOR_BUFFER_BIT | Gl.GL_DEPTH_BUFFER_BIT); Gl.glPushMatrix(); //push матрицы перед выховом glRotatef и glTranslatef Gl.glRotatef(Xrot, 1.0f, 0.0f, 0.0f); //Повернуть на х Gl.glRotatef(Yrot, 0.0f, 1.0f, 0.0f); //Повернуть на y Gl.glRotatef(Zrot, 0.0f, 0.0f, 1.0f); //Повернуть на z Gl.glTranslatef(X, Y, Z); //Переводит экран влево, вправо, вверх, вниз и масштабирование Glu.gluLookAt(0, 0, 0, 0, 0, 1, 0, 1, 0); Random rnd = new Random(); float r = (float)(rnd.Next(0, 255) / 255f); float g = (float)(rnd.Next(0, 255) / 255f); float b = (float)(rnd.Next(0, 255) / 255f); Gl.glColor3d(r, g, b);// устанавливаем параметр цвета, основанный на параметрах a b c Glut.glutSolidTeapot(1); Glut.glutPostRedisplay(); //перерисовка Gl.glPopMatrix(); //pop the Matrix Glut.glutSwapBuffers(); }
private void timer2_Tick(object sender, EventArgs e) { if (isLoaded) { Gl.glClear(Gl.GL_COLOR_BUFFER_BIT | Gl.GL_DEPTH_BUFFER_BIT); Gl.glClearColor(0, 0, 0, 1); Gl.glLoadIdentity(); Gl.glEnable(Gl.GL_TEXTURE_2D); Gl.glBindTexture(Gl.GL_TEXTURE_2D, indexObject); Gl.glPushMatrix(); Gl.glTranslated(0, -1, -15); Gl.glRotated(t, 1, 0, 0); Gl.glRotated(t1, 0, 1, 0); Glu.GLUquadric quadro = Glu.gluNewQuadric(); Glu.gluQuadricTexture(quadro, Gl.GL_TRUE); Gl.glEnable(Gl.GL_TEXTURE_2D); //Glu.gluSphere(quadro, 0.3, 50, 50); Glut.glutSolidTeapot(2); Gl.glDisable(Gl.GL_TEXTURE_2D); Gl.glPopMatrix(); Gl.glDisable(Gl.GL_TEXTURE_2D); simpleOpenGlControl1.Invalidate(); } }
private void DrawTeapot() { Gl.glDisable(Gl.GL_BLEND); Gl.glColor3f(0, 1, 1); Gl.glPushMatrix(); GlutRotation(); // рисуем чайник с помощью библиотеки FreeGLUT if (checkBoxType.Checked) { Glut.glutWireTeapot(1); } else { Glut.glutSolidTeapot(1); } Gl.glPopMatrix(); Gl.glDisable(Gl.GL_LIGHTING); // Будем рассчитывать освещенность Gl.glFlush(); }
private void DrawTeapot() { //рисование чайника с помощью библиотеки FreeGlut Gl.glDisable(Gl.GL_BLEND); Gl.glColor3f(Convert.ToSingle(_figureColor.R) / 255, Convert.ToSingle(_figureColor.G) / 255, Convert.ToSingle(_figureColor.B) / 255); //цвет фигуры без освещения Gl.glPushMatrix(); // сохраняет текущие координаты Gl.glTranslated(0, 0, -5f); // перенос по Z RotationGlut(); // поворот // рисуем чайник с помощью библиотеки FreeGLUT if (Wire.Checked) { Glut.glutWireTeapot(1);// сеточный режим } else { Glut.glutSolidTeapot(1);//режим с заливкой } Gl.glPopMatrix(); Gl.glDisable(Gl.GL_LIGHTING); // пересчитываем освещение Gl.glFlush(); // довыполнение предыдущих команд }
// функция отрисовки private void Draw() { // очистка буфера цвета и буфера глубины Gl.glClear(Gl.GL_COLOR_BUFFER_BIT | Gl.GL_DEPTH_BUFFER_BIT); Gl.glClearColor(255, 255, 255, 1); // очищение текущей матрицы Gl.glLoadIdentity(); // помещаем состояние матрицы в стек матриц, дальнейшие трансформации затронут только визуализацию объекта Gl.glPushMatrix(); // производим перемещение в зависимости от значений, полученных при перемещении ползунков Gl.glTranslated(Inter.Camera.X, Inter.Camera.Y, Inter.Camera.Z); // поворот по установленной оси //Gl.glRotated(Inter.Angle, Inter.Rotation.X, Inter.Rotation.Y, Inter.Rotation.Z); //Gl.glRotated() Rotating(); AutoRotating(); // и масштабирование объекта Gl.glScaled(Inter.Camera.Zoom, Inter.Camera.Zoom, Inter.Camera.Zoom); // в зависимости от установленного типа объекта switch (ObjectComboBox.SelectedIndex) { // рисуем нужный объект, используя функции библиотеки GLUT case 0: { if (Inter.Wire) // если установлен сеточный режим визуализации { Glut.glutWireSphere(2, 16, 16); // сеточная сфера } else { Glut.glutSolidSphere(2, 16, 16); // полигональная сфера } break; } case 1: { if (Inter.Wire) // если установлен сеточный режим визуализации { Glut.glutWireCylinder(1, 2, 32, 32); // цилиндр } else { Glut.glutSolidCylinder(1, 2, 32, 32); } break; } case 2: { if (Inter.Wire) // если установлен сеточный режим визуализации { Glut.glutWireCube(2); // куб } else { Glut.glutSolidCube(2); } break; } case 3: { if (Inter.Wire) // если установлен сеточный режим визуализации { Glut.glutWireCone(2, 3, 32, 32); // конус } else { Glut.glutSolidCone(2, 3, 32, 32); } break; } case 4: { if (Inter.Wire) // если установлен сеточный режим визуализации { Glut.glutWireTorus(0.5, 1.5, 32, 32); // тор } else { Glut.glutSolidTorus(0.5, 1.5, 32, 32); } break; } case 5: { if (Inter.Wire) // если установлен сеточный режим визуализации { Glut.glutWireDodecahedron(); // Додекайдер } else { Glut.glutSolidDodecahedron(); } break; } case 6: { if (Inter.Wire) // если установлен сеточный режим визуализации { Glut.glutWireIcosahedron(); // исосахедрон } else { Glut.glutSolidIcosahedron(); } break; } case 7: { if (Inter.Wire) // если установлен сеточный режим визуализации { Glut.glutWireOctahedron(); } else { Glut.glutSolidOctahedron(); } break; } case 8: { if (Inter.Wire) // если установлен сеточный режим визуализации { Glut.glutWireRhombicDodecahedron(); } else { Glut.glutSolidRhombicDodecahedron(); } break; } case 9: { if (Inter.Wire) // если установлен сеточный режим визуализации { Glut.glutWireSierpinskiSponge(3, new double[] { 0.0, 0.2, 0.5 }, 2); } else { Glut.glutSolidSierpinskiSponge(3, new double[] { 0.0, 0.2, 0.5 }, 2); } break; } case 10: { if (Inter.Wire) // если установлен сеточный режим визуализации { Glut.glutWireTeapot(2); // чайник } else { Glut.glutSolidTeapot(2); } break; } case 11: { if (Inter.Wire) // если установлен сеточный режим визуализации { Glut.glutWireTetrahedron(); // херня } else { Glut.glutSolidTetrahedron(); } break; } case 12: { if (Inter.Wire) // если установлен сеточный режим визуализации { Glut.glutWireSierpinskiSponge(1, new double[] { 0.0, 0.3, 0.5 }, 2); } else { Glut.glutSolidSierpinskiSponge(1, new double[] { 0.0, 0.3, 0.5 }, 2); } break; } case 13: { if (Inter.Wire) // если установлен сеточный режим визуализации { Glut.glutWireSierpinskiSponge(7, new double[] { 0.0, 0.3, 0.5, 0.7, 0.9 }, 2); } else { Glut.glutSolidSierpinskiSponge(7, new double[] { 0.0, 0.3, 0.5, 0.7, 0.9 }, 2); } break; } /* * case 100: * { * if (Inter.Wire) // если установлен сеточный режим визуализации * Glut.glutWire; // херня * else * Glut.glutSolid; * break; * } */ } if (AutoRotateCheckBox.Checked) { //Inter.Angle = Inter.Angle == 360 ? -360 : Inter.Angle + 1; //ValueAngle.Text = Inter.Angle.ToString(); //TrackBarAngle.Value = (int)Inter.Angle; } // возвращаем состояние матрицы Gl.glPopMatrix(); // завершаем рисование Gl.glFlush(); // обновляем элемент AnT AnT.Invalidate(); }
/**********************************************************************/ /* */ /* Function Name: TeaPotDisplay */ /* */ /* Description: OpenGL display Tea Pot */ /* */ /* Parameters: */ /* */ /* Returns: */ /* */ /**********************************************************************/ private void TeaPotDisplay() { float flt; //the light position at (0, 0, 5) float[] lightpos = new float[] { 0.0F, 0.0F, 5.0F, 0.0F }; //a diffuse light source with white light float[] light_diffuse = new float[4] { 1.0F, 1.0F, 1.0F, 1.0F }; //keep the qData.quat into ResetQuat //ResetQuat can help adjust the direction of teapot if (flg_ResetRotate == 1) // if aligment button was pressed, the direction reset { flg_ResetRotate = 0; for (int i = 0; i < 4; i++) { ResetQuat[i] = qData.Quat[i]; } } Gl.glDepthMask(1); Gl.glEnable(Gl.GL_COLOR_MATERIAL); Gl.glEnable(Gl.GL_LIGHTING); //give a diffuse light source with white light and at (0, 0, 5) Gl.glLightfv(Gl.GL_LIGHT0, Gl.GL_DIFFUSE, light_diffuse); Gl.glLightfv(Gl.GL_LIGHT0, Gl.GL_POSITION, lightpos); Gl.glEnable(Gl.GL_LIGHT0); Gl.glShadeModel(Gl.GL_SMOOTH); Gl.glDisable(Gl.GL_TEXTURE_2D); Gl.glDisable(Gl.GL_BLEND); //set the Projection matrix Gl.glMatrixMode(Gl.GL_PROJECTION); Gl.glLoadIdentity(); //use perspective view Glu.gluPerspective(45.0f, 1.0f, 0.1f, 100.0f); //set the ModelView matrix Gl.glMatrixMode(Gl.GL_MODELVIEW); Gl.glLoadIdentity(); //set the observation position Glu.gluLookAt(0, 0, 3, 0, 0, 0, 0, 1, 0); Gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f); Gl.glClear(Gl.GL_COLOR_BUFFER_BIT | Gl.GL_DEPTH_BUFFER_BIT); Gl.glColor4f(0.7f, 0.7f, 1.0f, 1.0f); //---------------------------------------------------------------------------------- //The direction of coordinate systems for OpenGL and Invensense are different //In OpenGL, the X axis is toward right on Screen, the Y axis is toward up //and the Z axis is from the center of the screen towards the viewer //In Invensesen definition, the X axis is toward right on motion device, the Y axis is toward front //and the Z axis is toward up //So, we have to transfer the direction of Invensense coordinate system to OpenGL system //In order to transfer coordinate system, have to choose a desired direction of the motion devie at first. //Assume the motino device puts on the table which is perpendicular with the screen, and the front of the motion device is toward screen //So, can have the following relation // Invensense transfer result OpenGL // X(right) X(right) X(right) // Y(to screen) Z(up) Y(up) // Z(up) -Y(from screen) Z(from screen) //---------------------------------------------------------------------------------- //the quaternion have four elements //the first element, quat[0], represents a rotation angle after using acos() //the remaining elememts quat[1], quat[2], quat[3] represnet the the rotation axis of X-Y-Z coordinate system //rotate teapot along Y axis, the rotation angle depends on ResetQuat which is used to adjust the direction Gl.glRotatef(-mEULAR_ANGLE_Z_FROM_QUAT_YXZ_CONVNETION(ResetQuat) * R2D, 0, 1, 0); //compute the rotation angle from quat[0] flt = (float)Math.Acos(qData.Quat[0]); //void glRotatef( GLfloat angle, GLfloat x, GLfloat y, GLfloat z); //rotate object "angle" degrees along (x, y, z) //should transfer the Invensense coordinate system to OpenGL coordinate system for the rotation axis (x,y,z) //OpenGL X = Invensense X <=> quat[1] //OpenGL Y = Invensense Z <=> quat[3] //OpenGL Z = Invensense -Y <=> -quat[2] Gl.glRotatef((float)(2 * flt * 180 / 3.1415), (float)qData.Quat[1], (float)qData.Quat[3], (float)-qData.Quat[2]); //rotate teapot 90 degree along Y axis, let the direction of spout equal the front of the motion device Gl.glRotatef(90, 0, 1, 0); //draw a teapot by OpengGL library Glut.glutSolidTeapot(0.6); }
private void ShowSolid(int obj) { switch (obj) { // Конус case 1: { Glut.glutSolidCone(0.2, 0.75, 16, 8); break; } // Куб case 2: { Glut.glutSolidCube(0.75); break; } //Цилиндр case 3: { Glut.glutSolidCylinder(0.2, 0.75, 16, 16); break; } // Додекаэдр case 4: { Gl.glScaled(0.5, 0.5, 0.5); Glut.glutSolidDodecahedron(); break; } // Икосаэдр case 5: { Glut.glutSolidIcosahedron(); break; } // Октаэдр case 6: { Glut.glutSolidOctahedron(); break; } // Ромбический додекаэдр case 7: { Glut.glutSolidRhombicDodecahedron(); break; } //Фрактал Губка Серпиского case 8: { double[] offset = { 0.0 }; Glut.glutSolidSierpinskiSponge(7, offset, 1); break; } // Сфера case 9: { Glut.glutSolidSphere(0.75, 16, 16); break; } // Чайник case 10: { Glut.glutSolidTeapot(0.5); break; } // Тетраэдр case 11: { Gl.glRotated(180, 0, 1, 0); Glut.glutSolidTetrahedron(); break; } // Тор case 12: { Glut.glutSolidTorus(0.15, 0.65, 16, 16); break; } } }
protected override void Particular() { double n1 = 1, n2 = 0.7, n3 = 0.57; Gl.glEnable(Gl.GL_TEXTURE_2D); Gl.glBindTexture(Gl.GL_TEXTURE_2D, GlUtils.Texture("AZULEJO")); Gl.glBegin(Gl.GL_QUADS); //lateral izquierdo //Gl.glColor3d(0.95,0.95,1); Gl.glColor3d(0.1, 0.15, .1); Gl.glNormal3d(-n3, -n3, n3); Gl.glTexCoord2d(0, 0); Gl.glVertex3d(0, 0, 0); Gl.glNormal3d(-n3, n3, n3); Gl.glTexCoord2d(6, 0); Gl.glVertex3d(0, alto * 100, 0); Gl.glNormal3d(-n3, n3, -n3); Gl.glTexCoord2d(6, 5); Gl.glVertex3d(0, alto * 100, -ancho * 100); Gl.glNormal3d(-n3, -n3, -n3); Gl.glTexCoord2d(0, 5); Gl.glVertex3d(0, 0, -ancho * 100); //lateral derecho Gl.glNormal3d(n3, -n3, n3); Gl.glTexCoord2d(0, 0); Gl.glVertex3d(largo * 100, 0, 0); Gl.glNormal3d(n3, -n3, -n3); Gl.glTexCoord2d(5, 0); Gl.glVertex3d(largo * 100, 0, -ancho * 100); Gl.glNormal3d(n3, n3, -n3); Gl.glTexCoord2d(5, 6); Gl.glVertex3d(largo * 100, alto * 100, -ancho * 100); Gl.glNormal3d(n3, n3, n3); Gl.glTexCoord2d(0, 6); Gl.glVertex3d(largo * 100, alto * 100, 0); //abajo Gl.glNormal3d(-n3, -n3, n3); Gl.glTexCoord2d(0, 0); Gl.glVertex3d(0, 0, 0); Gl.glNormal3d(n3, -n3, n3); Gl.glTexCoord2d(1, 0); Gl.glVertex3d(largo * 100, 0, 0); Gl.glNormal3d(n3, -n3, -n3); Gl.glTexCoord2d(1, 1); Gl.glVertex3d(largo * 100, 0, -ancho * 100); Gl.glNormal3d(-n3, -n3, -n3); Gl.glTexCoord2d(0, 1); Gl.glVertex3d(0, 0, -ancho * 100); //frente izquierda Gl.glNormal3d(0, 0, 1); Gl.glTexCoord2d(0, 0); Gl.glVertex3d(0, 0, 0); Gl.glNormal3d(0, 0, 1); Gl.glTexCoord2d(1, 0); Gl.glVertex3d(anchoF * 100, 0, 0); Gl.glNormal3d(0, 0, 1); Gl.glTexCoord2d(1, 6); Gl.glVertex3d(anchoF * 100, alto * 100, 0); Gl.glNormal3d(0, 0, 1); Gl.glTexCoord2d(0, 6); Gl.glVertex3d(0, alto * 100, 0); //frente derecha Gl.glNormal3d(0, 0, 1); Gl.glTexCoord2d(0, 0); Gl.glVertex3d((largo - anchoF) * 100, 0, 0); Gl.glNormal3d(0, 0, 1); Gl.glTexCoord2d(1, 0); Gl.glVertex3d(largo * 100, 0, 0); Gl.glNormal3d(0, 0, 1); Gl.glTexCoord2d(1, 6); Gl.glVertex3d(largo * 100, alto * 100, 0); Gl.glNormal3d(0, 0, 1); Gl.glTexCoord2d(0, 6); Gl.glVertex3d((largo - anchoF) * 100, alto * 100, 0); //frente arriba Gl.glNormal3d(0, 0, 1); Gl.glTexCoord2d(0, 0); Gl.glVertex3d(anchoF * 100, (alto - anchoF) * 100, 0); Gl.glNormal3d(0, 0, 1); Gl.glTexCoord2d(10, 0); Gl.glVertex3d((largo - anchoF) * 100, (alto - anchoF) * 100, 0); Gl.glNormal3d(0, 0, 1); Gl.glTexCoord2d(10, 1); Gl.glVertex3d((largo - anchoF) * 100, alto * 100, 0); Gl.glNormal3d(0, 0, 1); Gl.glTexCoord2d(0, 1); Gl.glVertex3d(anchoF * 100, alto * 100, 0); //frente abajo Gl.glNormal3d(0, 0, 1); Gl.glTexCoord2d(0, 0); Gl.glVertex3d(anchoF * 100, 0, 0); Gl.glNormal3d(0, 0, 1); Gl.glTexCoord2d(10, 0); Gl.glVertex3d((largo - anchoF) * 100, 0, 0); Gl.glNormal3d(0, 0, 1); Gl.glTexCoord2d(10, 1); Gl.glVertex3d((largo - anchoF) * 100, anchoF * 100, 0); Gl.glNormal3d(0, 0, 1); Gl.glTexCoord2d(0, 1); Gl.glVertex3d(anchoF * 100, anchoF * 100, 0); Gl.glEnd(); Gl.glBindTexture(Gl.GL_TEXTURE_2D, GlUtils.Texture("WOOD2")); Gl.glBegin(Gl.GL_QUADS); //marco izquierdo Gl.glColor3d(0.8, 0.8, 0.8); Gl.glNormal3d(0, 0, n1); Gl.glTexCoord2d(0, 0); Gl.glVertex3d(anchoF * 100, anchoF * 100, 0); Gl.glNormal3d(0, 0, n1); Gl.glTexCoord2d(1, 0); Gl.glVertex3d((anchoF + anchoM) * 100, anchoF * 100, 0); Gl.glNormal3d(0, 0, n1); Gl.glTexCoord2d(1, 1); Gl.glVertex3d((anchoF + anchoM) * 100, (alto - anchoF) * 100, 0); Gl.glNormal3d(0, 0, n1); Gl.glTexCoord2d(0, 1); Gl.glVertex3d(anchoF * 100, (alto - anchoF) * 100, 0); //marco derecho Gl.glNormal3d(0, 0, n1); Gl.glTexCoord2d(0, 0); Gl.glVertex3d((largo - anchoF - anchoM) * 100, anchoF * 100, 0); Gl.glNormal3d(0, 0, n1); Gl.glTexCoord2d(1, 0); Gl.glVertex3d((largo - anchoF) * 100, anchoF * 100, 0); Gl.glNormal3d(0, 0, n1); Gl.glTexCoord2d(1, 1); Gl.glVertex3d((largo - anchoF) * 100, (alto - anchoF) * 100, 0); Gl.glNormal3d(0, 0, n1); Gl.glTexCoord2d(0, 1); Gl.glVertex3d((largo - anchoF - anchoM) * 100, (alto - anchoF) * 100, 0); //marco arriba Gl.glNormal3d(0, 0, n1); Gl.glTexCoord2d(0, 0); Gl.glVertex3d((anchoF + anchoM) * 100, (alto - anchoF - anchoM) * 100, 0); Gl.glNormal3d(0, 0, n1); Gl.glTexCoord2d(0, 2); Gl.glVertex3d((largo - anchoF - anchoM) * 100, (alto - anchoF - anchoM) * 100, 0); Gl.glNormal3d(0, 0, n1); Gl.glTexCoord2d(1, 2); Gl.glVertex3d((largo - anchoF - anchoM) * 100, (alto - anchoF) * 100, 0); Gl.glNormal3d(0, 0, n1); Gl.glTexCoord2d(1, 0); Gl.glVertex3d((anchoF + anchoM) * 100, (alto - anchoF) * 100, 0); //marco abajo Gl.glNormal3d(0, 0, n1); Gl.glTexCoord2d(0, 0); Gl.glVertex3d((anchoF + anchoM) * 100, anchoF * 100, 0); Gl.glNormal3d(0, 0, n1); Gl.glTexCoord2d(0, 2); Gl.glVertex3d((largo - anchoF - anchoM) * 100, anchoF * 100, 0); Gl.glNormal3d(0, 0, n1); Gl.glTexCoord2d(1, 2); Gl.glVertex3d((largo - anchoF - anchoM) * 100, (anchoF + anchoM) * 100, 0); Gl.glNormal3d(0, 0, n1); Gl.glTexCoord2d(1, 0); Gl.glVertex3d((anchoF + anchoM) * 100, (anchoF + anchoM) * 100, 0); //marco medio Gl.glNormal3d(0, 0, n1); Gl.glTexCoord2d(0, 0); Gl.glVertex3d((largo / 2 - anchoM / 2) * 100, (anchoF + anchoM) * 100, 0); Gl.glNormal3d(0, 0, n1); Gl.glTexCoord2d(1, 0); Gl.glVertex3d((largo / 2 + anchoM / 2) * 100, (anchoF + anchoM) * 100, 0); Gl.glNormal3d(0, 0, n1); Gl.glTexCoord2d(1, 1); Gl.glVertex3d((largo / 2 + anchoM / 2) * 100, (alto - anchoF - anchoM) * 100, 0); Gl.glNormal3d(0, 0, n1); Gl.glTexCoord2d(0, 1); Gl.glVertex3d((largo / 2 - anchoM / 2) * 100, (alto - anchoF - anchoM) * 100, 0); Gl.glColor3d(0.85, 0.85, 0.85); //puerta izquierda Gl.glNormal3d(0, 0, n1); Gl.glTexCoord2d(0, 0); Gl.glVertex3d((anchoF + anchoM) * 100, (anchoF + anchoM) * 100, 0); Gl.glNormal3d(0, 0, n1); Gl.glTexCoord2d(2, 0); Gl.glVertex3d((largo / 2 - anchoM / 2) * 100, (anchoF + anchoM) * 100, 0); Gl.glNormal3d(0, 0, n1); Gl.glTexCoord2d(2, 1); Gl.glVertex3d((largo / 2 - anchoM / 2) * 100, (alto - anchoF - anchoM) * 100, 0); Gl.glNormal3d(0, 0, n1); Gl.glTexCoord2d(0, 1); Gl.glVertex3d((anchoF + anchoM) * 100, (alto - anchoF - anchoM) * 100, 0); //puerta derecha Gl.glNormal3d(0, 0, n1); Gl.glTexCoord2d(0, 0); Gl.glVertex3d((largo / 2 + anchoM / 2) * 100, (anchoF + anchoM) * 100, 0); Gl.glNormal3d(0, 0, n1); Gl.glTexCoord2d(2, 0); Gl.glVertex3d((largo - anchoF - anchoM) * 100, (anchoF + anchoM) * 100, 0); Gl.glNormal3d(0, 0, n1); Gl.glTexCoord2d(2, 1); Gl.glVertex3d((largo - anchoF - anchoM) * 100, (alto - anchoF - anchoM) * 100, 0); Gl.glNormal3d(0, 0, n1); Gl.glTexCoord2d(0, 1); Gl.glVertex3d((largo / 2 + anchoM / 2) * 100, (alto - anchoF - anchoM) * 100, 0); Gl.glEnd(); //Knobs Gl.glDisable(Gl.GL_TEXTURE_2D); Gl.glColor3d(0.7, 0.7, 0.7); //izquierda Gl.glBegin(Gl.GL_QUAD_STRIP); Gl.glNormal3d(-n3, -n3, n3); Gl.glVertex3d((largo / 2 - anchoM / 2 - 0.05) * 100, (alto / 2 - 0.05) * 100, 0.03 * 100); Gl.glNormal3d(-n3, n3, n3); Gl.glVertex3d((largo / 2 - anchoM / 2 - 0.05) * 100, (alto / 2 + 0.05) * 100, 0.03 * 100); Gl.glNormal3d(n3, -n3, n3); Gl.glVertex3d((largo / 2 - anchoM / 2 - 0.04) * 100, (alto / 2 - 0.05) * 100, 0.03 * 100); Gl.glNormal3d(n3, n3, n3); Gl.glVertex3d((largo / 2 - anchoM / 2 - 0.04) * 100, (alto / 2 + 0.05) * 100, 0.03 * 100); Gl.glNormal3d(n2, -n2, 0); Gl.glVertex3d((largo / 2 - anchoM / 2 - 0.04) * 100, (alto / 2 - 0.05) * 100, 0.02 * 100); Gl.glNormal3d(n2, n2, 0); Gl.glVertex3d((largo / 2 - anchoM / 2 - 0.04) * 100, (alto / 2 + 0.05) * 100, 0.02 * 100); Gl.glNormal3d(-n2, -n2, 0); Gl.glVertex3d((largo / 2 - anchoM / 2 - 0.05) * 100, (alto / 2 - 0.05) * 100, 0.02 * 100); Gl.glNormal3d(-n2, n2, 0); Gl.glVertex3d((largo / 2 - anchoM / 2 - 0.05) * 100, (alto / 2 + 0.05) * 100, 0.02 * 100); Gl.glNormal3d(-n3, -n3, n3); Gl.glVertex3d((largo / 2 - anchoM / 2 - 0.05) * 100, (alto / 2 - 0.05) * 100, 0.03 * 100); Gl.glNormal3d(-n3, n3, n3); Gl.glVertex3d((largo / 2 - anchoM / 2 - 0.05) * 100, (alto / 2 + 0.05) * 100, 0.03 * 100); Gl.glEnd(); // Gl.glColor3d(0.1,0.15,.1); Gl.glBegin(Gl.GL_QUADS); Gl.glNormal3d(-n3, n3, n3); Gl.glVertex3d((largo / 2 - anchoM / 2 - 0.05) * 100, (alto / 2 + 0.05) * 100, 0.03 * 100); Gl.glNormal3d(n3, n3, n3); Gl.glVertex3d((largo / 2 - anchoM / 2 - 0.04) * 100, (alto / 2 + 0.05) * 100, 0.03 * 100); Gl.glNormal3d(n2, n2, 0); Gl.glVertex3d((largo / 2 - anchoM / 2 - 0.04) * 100, (alto / 2 + 0.05) * 100, 0.02 * 100); Gl.glNormal3d(-n2, n2, 0); Gl.glVertex3d((largo / 2 - anchoM / 2 - 0.05) * 100, (alto / 2 + 0.05) * 100, 0.02 * 100); Gl.glNormal3d(-n3, -n3, n3); Gl.glVertex3d((largo / 2 - anchoM / 2 - 0.05) * 100, (alto / 2 - 0.05) * 100, 0.03 * 100); Gl.glNormal3d(n3, -n3, n3); Gl.glVertex3d((largo / 2 - anchoM / 2 - 0.04) * 100, (alto / 2 - 0.05) * 100, 0.03 * 100); Gl.glNormal3d(n2, -n2, 0); Gl.glVertex3d((largo / 2 - anchoM / 2 - 0.04) * 100, (alto / 2 - 0.05) * 100, 0.02 * 100); Gl.glNormal3d(-n2, -n2, 0); Gl.glVertex3d((largo / 2 - anchoM / 2 - 0.05) * 100, (alto / 2 - 0.05) * 100, 0.02 * 100); Gl.glEnd(); Gl.glBegin(Gl.GL_QUAD_STRIP); Gl.glNormal3d(-n2, -n2, 0); Gl.glVertex3d((largo / 2 - anchoM / 2 - 0.05) * 100, (alto / 2 + 0.04) * 100, 0.02 * 100); Gl.glNormal3d(-n2, n2, 0); Gl.glVertex3d((largo / 2 - anchoM / 2 - 0.05) * 100, (alto / 2 + 0.05) * 100, 0.02 * 100); Gl.glNormal3d(n2, -n2, 0); Gl.glVertex3d((largo / 2 - anchoM / 2 - 0.04) * 100, (alto / 2 + 0.04) * 100, 0.02 * 100); Gl.glNormal3d(n2, n2, 0); Gl.glVertex3d((largo / 2 - anchoM / 2 - 0.04) * 100, (alto / 2 + 0.05) * 100, 0.02 * 100); Gl.glNormal3d(n2, -n2, 0); Gl.glVertex3d((largo / 2 - anchoM / 2 - 0.04) * 100, (alto / 2 + 0.04) * 100, 0); Gl.glNormal3d(n2, n2, 0); Gl.glVertex3d((largo / 2 - anchoM / 2 - 0.04) * 100, (alto / 2 + 0.05) * 100, 0); Gl.glNormal3d(-n2, -n2, 0); Gl.glVertex3d((largo / 2 - anchoM / 2 - 0.05) * 100, (alto / 2 + 0.04) * 100, 0); Gl.glNormal3d(-n2, n2, 0); Gl.glVertex3d((largo / 2 - anchoM / 2 - 0.05) * 100, (alto / 2 + 0.05) * 100, 0); Gl.glNormal3d(-n2, -n2, 0); Gl.glVertex3d((largo / 2 - anchoM / 2 - 0.05) * 100, (alto / 2 + 0.04) * 100, 0.02 * 100); Gl.glNormal3d(-n2, n2, 0); Gl.glVertex3d((largo / 2 - anchoM / 2 - 0.05) * 100, (alto / 2 + 0.05) * 100, 0.02 * 100); Gl.glEnd(); Gl.glBegin(Gl.GL_QUADS); Gl.glNormal3d(-n2, n2, 0); Gl.glVertex3d((largo / 2 - anchoM / 2 - 0.05) * 100, (alto / 2 + 0.05) * 100, 0.02 * 100); Gl.glNormal3d(n2, n2, 0); Gl.glVertex3d((largo / 2 - anchoM / 2 - 0.04) * 100, (alto / 2 + 0.05) * 100, 0.02 * 100); Gl.glNormal3d(n2, n2, 0); Gl.glVertex3d((largo / 2 - anchoM / 2 - 0.04) * 100, (alto / 2 + 0.05) * 100, 0); Gl.glNormal3d(-n2, n2, 0); Gl.glVertex3d((largo / 2 - anchoM / 2 - 0.05) * 100, (alto / 2 + 0.05) * 100, 0); Gl.glNormal3d(-n2, -n2, 0); Gl.glVertex3d((largo / 2 - anchoM / 2 - 0.05) * 100, (alto / 2 + 0.04) * 100, 0.02 * 100); Gl.glNormal3d(n2, -n2, 0); Gl.glVertex3d((largo / 2 - anchoM / 2 - 0.04) * 100, (alto / 2 + 0.04) * 100, 0.02 * 100); Gl.glNormal3d(n2, -n2, 0); Gl.glVertex3d((largo / 2 - anchoM / 2 - 0.04) * 100, (alto / 2 + 0.04) * 100, 0); Gl.glNormal3d(-n2, -n2, 0); Gl.glVertex3d((largo / 2 - anchoM / 2 - 0.05) * 100, (alto / 2 + 0.04) * 100, 0); Gl.glEnd(); Gl.glBegin(Gl.GL_QUAD_STRIP); Gl.glNormal3d(-n2, -n2, 0); Gl.glVertex3d((largo / 2 - anchoM / 2 - 0.05) * 100, (alto / 2 - 0.05) * 100, 0.02 * 100); Gl.glNormal3d(-n2, n2, 0); Gl.glVertex3d((largo / 2 - anchoM / 2 - 0.05) * 100, (alto / 2 - 0.04) * 100, 0.02 * 100); Gl.glNormal3d(n2, -n2, 0); Gl.glVertex3d((largo / 2 - anchoM / 2 - 0.04) * 100, (alto / 2 - 0.05) * 100, 0.02 * 100); Gl.glNormal3d(n2, n2, 0); Gl.glVertex3d((largo / 2 - anchoM / 2 - 0.04) * 100, (alto / 2 - 0.04) * 100, 0.02 * 100); Gl.glNormal3d(n2, -n2, 0); Gl.glVertex3d((largo / 2 - anchoM / 2 - 0.04) * 100, (alto / 2 - 0.05) * 100, 0); Gl.glNormal3d(n2, n2, 0); Gl.glVertex3d((largo / 2 - anchoM / 2 - 0.04) * 100, (alto / 2 - 0.04) * 100, 0); Gl.glNormal3d(-n2, -n2, 0); Gl.glVertex3d((largo / 2 - anchoM / 2 - 0.05) * 100, (alto / 2 - 0.05) * 100, 0); Gl.glNormal3d(-n2, n2, 0); Gl.glVertex3d((largo / 2 - anchoM / 2 - 0.05) * 100, (alto / 2 - 0.04) * 100, 0); Gl.glNormal3d(-n2, -n2, 0); Gl.glVertex3d((largo / 2 - anchoM / 2 - 0.05) * 100, (alto / 2 - 0.05) * 100, 0.02 * 100); Gl.glNormal3d(-n2, n2, 0); Gl.glVertex3d((largo / 2 - anchoM / 2 - 0.05) * 100, (alto / 2 - 0.04) * 100, 0.02 * 100); Gl.glEnd(); Gl.glBegin(Gl.GL_QUADS); Gl.glNormal3d(-n2, n2, 0); Gl.glVertex3d((largo / 2 - anchoM / 2 - 0.05) * 100, (alto / 2 - 0.04) * 100, 0.02 * 100); Gl.glNormal3d(n2, n2, 0); Gl.glVertex3d((largo / 2 - anchoM / 2 - 0.04) * 100, (alto / 2 - 0.04) * 100, 0.02 * 100); Gl.glNormal3d(n2, n2, 0); Gl.glVertex3d((largo / 2 - anchoM / 2 - 0.04) * 100, (alto / 2 - 0.04) * 100, 0); Gl.glNormal3d(-n2, n2, 0); Gl.glVertex3d((largo / 2 - anchoM / 2 - 0.05) * 100, (alto / 2 - 0.04) * 100, 0); Gl.glNormal3d(-n2, -n2, 0); Gl.glVertex3d((largo / 2 - anchoM / 2 - 0.05) * 100, (alto / 2 - 0.05) * 100, 0.02 * 100); Gl.glNormal3d(n2, -n2, 0); Gl.glVertex3d((largo / 2 - anchoM / 2 - 0.04) * 100, (alto / 2 - 0.05) * 100, 0.02 * 100); Gl.glNormal3d(n2, -n2, 0); Gl.glVertex3d((largo / 2 - anchoM / 2 - 0.04) * 100, (alto / 2 - 0.05) * 100, 0); Gl.glNormal3d(-n2, -n2, 0); Gl.glVertex3d((largo / 2 - anchoM / 2 - 0.05) * 100, (alto / 2 - 0.05) * 100, 0); Gl.glEnd(); //derecha Gl.glBegin(Gl.GL_QUAD_STRIP); Gl.glNormal3d(-n3, -n3, n3); Gl.glVertex3d((largo / 2 + anchoM / 2 + 0.04) * 100, (alto / 2 - 0.05) * 100, 0.03 * 100); Gl.glNormal3d(-n3, n3, n3); Gl.glVertex3d((largo / 2 + anchoM / 2 + 0.04) * 100, (alto / 2 + 0.05) * 100, 0.03 * 100); Gl.glNormal3d(n3, -n3, n3); Gl.glVertex3d((largo / 2 + anchoM / 2 + 0.05) * 100, (alto / 2 - 0.05) * 100, 0.03 * 100); Gl.glNormal3d(n3, n3, n3); Gl.glVertex3d((largo / 2 + anchoM / 2 + 0.05) * 100, (alto / 2 + 0.05) * 100, 0.03 * 100); Gl.glNormal3d(n2, -n2, 0); Gl.glVertex3d((largo / 2 + anchoM / 2 + 0.05) * 100, (alto / 2 - 0.05) * 100, 0.02 * 100); Gl.glNormal3d(n2, n2, 0); Gl.glVertex3d((largo / 2 + anchoM / 2 + 0.05) * 100, (alto / 2 + 0.05) * 100, 0.02 * 100); Gl.glNormal3d(-n2, -n2, 0); Gl.glVertex3d((largo / 2 + anchoM / 2 + 0.04) * 100, (alto / 2 - 0.05) * 100, 0.02 * 100); Gl.glNormal3d(-n2, n2, 0); Gl.glVertex3d((largo / 2 + anchoM / 2 + 0.04) * 100, (alto / 2 + 0.05) * 100, 0.02 * 100); Gl.glNormal3d(-n3, -n3, n3); Gl.glVertex3d((largo / 2 + anchoM / 2 + 0.04) * 100, (alto / 2 - 0.05) * 100, 0.03 * 100); Gl.glNormal3d(-n3, n3, n3); Gl.glVertex3d((largo / 2 + anchoM / 2 + 0.04) * 100, (alto / 2 + 0.05) * 100, 0.03 * 100); Gl.glEnd(); Gl.glBegin(Gl.GL_QUADS); Gl.glNormal3d(-n3, n3, n3); Gl.glVertex3d((largo / 2 + anchoM / 2 + 0.04) * 100, (alto / 2 + 0.05) * 100, 0.03 * 100); Gl.glNormal3d(n3, n3, n3); Gl.glVertex3d((largo / 2 + anchoM / 2 + 0.05) * 100, (alto / 2 + 0.05) * 100, 0.03 * 100); Gl.glNormal3d(n2, n2, 0); Gl.glVertex3d((largo / 2 + anchoM / 2 + 0.05) * 100, (alto / 2 + 0.05) * 100, 0.02 * 100); Gl.glNormal3d(-n2, n2, 0); Gl.glVertex3d((largo / 2 + anchoM / 2 + 0.04) * 100, (alto / 2 + 0.05) * 100, 0.02 * 100); Gl.glNormal3d(-n3, -n3, n3); Gl.glVertex3d((largo / 2 + anchoM / 2 + 0.04) * 100, (alto / 2 - 0.05) * 100, 0.03 * 100); Gl.glNormal3d(n3, -n3, n3); Gl.glVertex3d((largo / 2 + anchoM / 2 + 0.05) * 100, (alto / 2 - 0.05) * 100, 0.03 * 100); Gl.glNormal3d(n2, -n2, 0); Gl.glVertex3d((largo / 2 + anchoM / 2 + 0.05) * 100, (alto / 2 - 0.05) * 100, 0.02 * 100); Gl.glNormal3d(-n2, -n2, 0); Gl.glVertex3d((largo / 2 + anchoM / 2 + 0.04) * 100, (alto / 2 - 0.05) * 100, 0.02 * 100); Gl.glEnd(); Gl.glBegin(Gl.GL_QUAD_STRIP); Gl.glNormal3d(-n2, -n2, 0); Gl.glVertex3d((largo / 2 + anchoM / 2 + 0.04) * 100, (alto / 2 + 0.04) * 100, 0.02 * 100); Gl.glNormal3d(-n2, n2, 0); Gl.glVertex3d((largo / 2 + anchoM / 2 + 0.04) * 100, (alto / 2 + 0.05) * 100, 0.02 * 100); Gl.glNormal3d(n2, -n2, 0); Gl.glVertex3d((largo / 2 + anchoM / 2 + 0.05) * 100, (alto / 2 + 0.04) * 100, 0.02 * 100); Gl.glNormal3d(n2, n2, 0); Gl.glVertex3d((largo / 2 + anchoM / 2 + 0.05) * 100, (alto / 2 + 0.05) * 100, 0.02 * 100); Gl.glNormal3d(n2, -n2, 0); Gl.glVertex3d((largo / 2 + anchoM / 2 + 0.05) * 100, (alto / 2 + 0.04) * 100, 0); Gl.glNormal3d(n2, n2, 0); Gl.glVertex3d((largo / 2 + anchoM / 2 + 0.05) * 100, (alto / 2 + 0.05) * 100, 0); Gl.glNormal3d(-n2, -n2, 0); Gl.glVertex3d((largo / 2 + anchoM / 2 + 0.04) * 100, (alto / 2 + 0.04) * 100, 0); Gl.glNormal3d(-n2, n2, 0); Gl.glVertex3d((largo / 2 + anchoM / 2 + 0.04) * 100, (alto / 2 + 0.05) * 100, 0); Gl.glNormal3d(-n2, -n2, 0); Gl.glVertex3d((largo / 2 + anchoM / 2 + 0.04) * 100, (alto / 2 + 0.04) * 100, 0.02 * 100); Gl.glNormal3d(-n2, n2, 0); Gl.glVertex3d((largo / 2 + anchoM / 2 + 0.04) * 100, (alto / 2 + 0.05) * 100, 0.02 * 100); Gl.glEnd(); Gl.glBegin(Gl.GL_QUADS); Gl.glNormal3d(-n2, n2, 0); Gl.glVertex3d((largo / 2 + anchoM / 2 + 0.04) * 100, (alto / 2 + 0.05) * 100, 0.02 * 100); Gl.glNormal3d(n2, n2, 0); Gl.glVertex3d((largo / 2 + anchoM / 2 + 0.05) * 100, (alto / 2 + 0.05) * 100, 0.02 * 100); Gl.glNormal3d(n2, n2, 0); Gl.glVertex3d((largo / 2 + anchoM / 2 + 0.05) * 100, (alto / 2 + 0.05) * 100, 0); Gl.glNormal3d(-n2, n2, 0); Gl.glVertex3d((largo / 2 + anchoM / 2 + 0.04) * 100, (alto / 2 + 0.05) * 100, 0); Gl.glNormal3d(-n2, -n2, 0); Gl.glVertex3d((largo / 2 + anchoM / 2 + 0.04) * 100, (alto / 2 + 0.04) * 100, 0.02 * 100); Gl.glNormal3d(n2, -n2, 0); Gl.glVertex3d((largo / 2 + anchoM / 2 + 0.05) * 100, (alto / 2 + 0.04) * 100, 0.02 * 100); Gl.glNormal3d(n2, -n2, 0); Gl.glVertex3d((largo / 2 + anchoM / 2 + 0.05) * 100, (alto / 2 + 0.04) * 100, 0); Gl.glNormal3d(-n2, -n2, 0); Gl.glVertex3d((largo / 2 + anchoM / 2 + 0.04) * 100, (alto / 2 + 0.04) * 100, 0); Gl.glEnd(); Gl.glBegin(Gl.GL_QUAD_STRIP); Gl.glNormal3d(-n2, -n2, 0); Gl.glVertex3d((largo / 2 + anchoM / 2 + 0.04) * 100, (alto / 2 - 0.05) * 100, 0.02 * 100); Gl.glNormal3d(-n2, n2, 0); Gl.glVertex3d((largo / 2 + anchoM / 2 + 0.04) * 100, (alto / 2 - 0.04) * 100, 0.02 * 100); Gl.glNormal3d(n2, -n2, 0); Gl.glVertex3d((largo / 2 + anchoM / 2 + 0.05) * 100, (alto / 2 - 0.05) * 100, 0.02 * 100); Gl.glNormal3d(n2, n2, 0); Gl.glVertex3d((largo / 2 + anchoM / 2 + 0.05) * 100, (alto / 2 - 0.04) * 100, 0.02 * 100); Gl.glNormal3d(n2, -n2, 0); Gl.glVertex3d((largo / 2 + anchoM / 2 + 0.05) * 100, (alto / 2 - 0.05) * 100, 0); Gl.glNormal3d(n2, n2, 0); Gl.glVertex3d((largo / 2 + anchoM / 2 + 0.05) * 100, (alto / 2 - 0.04) * 100, 0); Gl.glNormal3d(-n2, -n2, 0); Gl.glVertex3d((largo / 2 + anchoM / 2 + 0.04) * 100, (alto / 2 - 0.05) * 100, 0); Gl.glNormal3d(-n2, n2, 0); Gl.glVertex3d((largo / 2 + anchoM / 2 + 0.04) * 100, (alto / 2 - 0.04) * 100, 0); Gl.glNormal3d(-n2, -n2, 0); Gl.glVertex3d((largo / 2 + anchoM / 2 + 0.04) * 100, (alto / 2 - 0.05) * 100, 0.02 * 100); Gl.glNormal3d(-n2, n2, 0); Gl.glVertex3d((largo / 2 + anchoM / 2 + 0.04) * 100, (alto / 2 - 0.04) * 100, 0.02 * 100); Gl.glEnd(); Gl.glBegin(Gl.GL_QUADS); Gl.glNormal3d(-n2, n2, 0); Gl.glVertex3d((largo / 2 + anchoM / 2 + 0.04) * 100, (alto / 2 - 0.04) * 100, 0.02 * 100); Gl.glNormal3d(n2, n2, 0); Gl.glVertex3d((largo / 2 + anchoM / 2 + 0.05) * 100, (alto / 2 - 0.04) * 100, 0.02 * 100); Gl.glNormal3d(n2, n2, 0); Gl.glVertex3d((largo / 2 + anchoM / 2 + 0.05) * 100, (alto / 2 - 0.04) * 100, 0); Gl.glNormal3d(-n2, n2, 0); Gl.glVertex3d((largo / 2 + anchoM / 2 + 0.04) * 100, (alto / 2 - 0.04) * 100, 0); Gl.glNormal3d(-n2, -n2, 0); Gl.glVertex3d((largo / 2 + anchoM / 2 + 0.04) * 100, (alto / 2 - 0.05) * 100, 0.02 * 100); Gl.glNormal3d(n2, -n2, 0); Gl.glVertex3d((largo / 2 + anchoM / 2 + 0.05) * 100, (alto / 2 - 0.05) * 100, 0.02 * 100); Gl.glNormal3d(n2, -n2, 0); Gl.glVertex3d((largo / 2 + anchoM / 2 + 0.05) * 100, (alto / 2 - 0.05) * 100, 0); Gl.glNormal3d(-n2, -n2, 0); Gl.glVertex3d((largo / 2 + anchoM / 2 + 0.04) * 100, (alto / 2 - 0.05) * 100, 0); Gl.glEnd(); Gl.glColor3d(0.1, 0.15, .1); Gl.glEnable(Gl.GL_TEXTURE_2D); Gl.glBindTexture(Gl.GL_TEXTURE_2D, GlUtils.Texture("AZULEJO")); Gl.glBegin(Gl.GL_QUADS); // meseta derecha Gl.glNormal3d(0, 1, 0); Gl.glTexCoord2d(0, 0); Gl.glVertex3d(0, alto * 100, 0); Gl.glNormal3d(0, 1, 0); Gl.glTexCoord2d(6, 0); Gl.glVertex3d(largo / 2 * 100, alto * 100, 0); Gl.glNormal3d(0, 1, 0); Gl.glTexCoord2d(6, 5); Gl.glVertex3d(largo / 2 * 100, alto * 100, -ancho * 100); Gl.glNormal3d(0, 1, 0); Gl.glTexCoord2d(0, 5); Gl.glVertex3d(0, alto * 100, -ancho * 100); // meseta izquierda Gl.glNormal3d(0, 1, 0); Gl.glTexCoord2d(0, 0); Gl.glVertex3d((largo - anchoF) * 100, alto * 100, 0); Gl.glNormal3d(0, 1, 0); Gl.glTexCoord2d(1, 0); Gl.glVertex3d(largo * 100, alto * 100, 0); Gl.glNormal3d(0, 1, 0); Gl.glTexCoord2d(1, 5); Gl.glVertex3d(largo * 100, alto * 100, -ancho * 100); Gl.glNormal3d(0, 1, 0); Gl.glTexCoord2d(0, 5); Gl.glVertex3d((largo - anchoF) * 100, alto * 100, -ancho * 100); // meseta delante Gl.glNormal3d(0, 1, 0); Gl.glTexCoord2d(0, 0); Gl.glVertex3d(largo / 2 * 100, alto * 100, 0); Gl.glNormal3d(0, 1, 0); Gl.glTexCoord2d(5, 0); Gl.glVertex3d((largo - anchoF) * 100, alto * 100, 0); Gl.glNormal3d(0, 1, 0); Gl.glTexCoord2d(5, 1); Gl.glVertex3d((largo - anchoF) * 100, alto * 100, -0.1 * 100); Gl.glNormal3d(0, 1, 0); Gl.glTexCoord2d(0, 1); Gl.glVertex3d(largo / 2 * 100, alto * 100, -0.1 * 100); // meseta detras Gl.glNormal3d(0, 1, 0); Gl.glTexCoord2d(0, 0); Gl.glVertex3d(largo / 2 * 100, alto * 100, (-ancho + 0.1) * 100); Gl.glNormal3d(0, 1, 0); Gl.glTexCoord2d(5, 0); Gl.glVertex3d((largo - anchoF) * 100, alto * 100, (-ancho + 0.1) * 100); Gl.glNormal3d(0, 1, 0); Gl.glTexCoord2d(5, 1); Gl.glVertex3d((largo - anchoF) * 100, alto * 100, -ancho * 100); Gl.glNormal3d(0, 1, 0); Gl.glTexCoord2d(0, 1); Gl.glVertex3d(largo / 2 * 100, alto * 100, -ancho * 100); Gl.glEnd(); Gl.glColor3d(1, 1, 1); Gl.glBindTexture(Gl.GL_TEXTURE_2D, GlUtils.Texture("ALUMINIO")); Gl.glBegin(Gl.GL_QUADS); //fregadero izquierda Gl.glNormal3d(0, n1, 0); Gl.glTexCoord2d(0, 0); Gl.glVertex3d(largo / 2 * 100, alto * 100, -0.1 * 100); Gl.glNormal3d(0, n1, 0); Gl.glTexCoord2d(1, 0); Gl.glVertex3d((largo / 2 + 0.05) * 100, alto * 100, -0.1 * 100); Gl.glNormal3d(0, n1, 0); Gl.glTexCoord2d(1, 1); Gl.glVertex3d((largo / 2 + 0.05) * 100, alto * 100, (-ancho + 0.1) * 100); Gl.glNormal3d(0, n1, 0); Gl.glTexCoord2d(0, 1); Gl.glVertex3d(largo / 2 * 100, alto * 100, (-ancho + 0.1) * 100); //fregadero derecha Gl.glNormal3d(0, n1, 0); Gl.glTexCoord2d(0, 0); Gl.glVertex3d((largo - anchoF - 0.05) * 100, alto * 100, -0.1 * 100); Gl.glNormal3d(0, n1, 0); Gl.glTexCoord2d(1, 0); Gl.glVertex3d((largo - anchoF) * 100, alto * 100, -0.1 * 100); Gl.glNormal3d(0, n1, 0); Gl.glTexCoord2d(1, 1); Gl.glVertex3d((largo - anchoF) * 100, alto * 100, (-ancho + 0.1) * 100); Gl.glNormal3d(0, n1, 0); Gl.glTexCoord2d(0, 1); Gl.glVertex3d((largo - anchoF - 0.05) * 100, alto * 100, (-ancho + 0.1) * 100); //fregadero detras Gl.glNormal3d(0, n1, 0); Gl.glTexCoord2d(0, 0); Gl.glVertex3d((largo / 2 + 0.05) * 100, alto * 100, (-ancho + 0.1 + 0.05) * 100); Gl.glNormal3d(0, n1, 0); Gl.glTexCoord2d(1, 0); Gl.glVertex3d((largo - anchoF - 0.05) * 100, alto * 100, (-ancho + 0.1 + 0.05) * 100); Gl.glNormal3d(0, n1, 0); Gl.glTexCoord2d(1, 1); Gl.glVertex3d((largo - anchoF - 0.05) * 100, alto * 100, (-ancho + 0.1) * 100); Gl.glNormal3d(0, n1, 0); Gl.glTexCoord2d(0, 1); Gl.glVertex3d((largo / 2 + 0.05) * 100, alto * 100, (-ancho + 0.1) * 100); //fregadero delante Gl.glNormal3d(0, n1, 0); Gl.glTexCoord2d(0, 0); Gl.glVertex3d((largo / 2 + 0.05) * 100, alto * 100, -0.1 * 100); Gl.glNormal3d(0, n1, 0); Gl.glTexCoord2d(1, 0); Gl.glVertex3d((largo - anchoF - 0.05) * 100, alto * 100, -0.1 * 100); Gl.glNormal3d(0, n1, 0); Gl.glTexCoord2d(1, 1); Gl.glVertex3d((largo - anchoF - 0.05) * 100, alto * 100, (-0.1 - 0.05) * 100); Gl.glNormal3d(0, n1, 0); Gl.glTexCoord2d(0, 1); Gl.glVertex3d((largo / 2 + 0.05) * 100, alto * 100, (-0.1 - 0.05) * 100); Gl.glEnd(); //fregadero Gl.glColor3d(0.95, 0.95, 0.95); Gl.glBegin(Gl.GL_QUAD_STRIP); Gl.glNormal3d(n3, n3, -n3); Gl.glTexCoord2d(0, 0); Gl.glVertex3d((largo / 2 + 0.05) * 100, (alto - anchoF) * 100, (-0.1 - 0.05) * 100); Gl.glNormal3d(n3, n3, -n3); Gl.glTexCoord2d(0, 1); Gl.glVertex3d((largo / 2 + 0.05) * 100, alto * 100, (-0.1 - 0.05) * 100); Gl.glNormal3d(-n3, n3, -n3); Gl.glTexCoord2d(0.4, 0); Gl.glVertex3d((largo - anchoF - 0.05) * 100, (alto - anchoF) * 100, (-0.1 - 0.05) * 100); Gl.glNormal3d(-n3, n3, -n3); Gl.glTexCoord2d(0.4, 1); Gl.glVertex3d((largo - anchoF - 0.05) * 100, alto * 100, (-0.1 - 0.05) * 100); Gl.glNormal3d(-n3, n3, n3); Gl.glTexCoord2d(0.5, 0); Gl.glVertex3d((largo - anchoF - 0.05) * 100, (alto - anchoF) * 100, (-ancho + 0.1 + 0.05) * 100); Gl.glNormal3d(-n3, n3, n3); Gl.glTexCoord2d(0.5, 1); Gl.glVertex3d((largo - anchoF - 0.05) * 100, alto * 100, (-ancho + 0.1 + 0.05) * 100); Gl.glNormal3d(n3, n3, n3); Gl.glTexCoord2d(0.9, 0); Gl.glVertex3d((largo / 2 + 0.05) * 100, (alto - anchoF) * 100, (-ancho + 0.1 + 0.05) * 100); Gl.glNormal3d(n3, n3, n3); Gl.glTexCoord2d(0.9, 1); Gl.glVertex3d((largo / 2 + 0.05) * 100, alto * 100, (-ancho + 0.1 + 0.05) * 100); Gl.glNormal3d(n3, n3, -n3); Gl.glTexCoord2d(1, 0); Gl.glVertex3d((largo / 2 + 0.05) * 100, (alto - anchoF) * 100, (-0.1 - 0.05) * 100); Gl.glNormal3d(n3, n3, -n3); Gl.glTexCoord2d(1, 1); Gl.glVertex3d((largo / 2 + 0.05) * 100, alto * 100, (-0.1 - 0.05) * 100); Gl.glEnd(); //fondo del fregadero Gl.glColor3d(0.9, 0.9, 0.9); Gl.glBegin(Gl.GL_QUADS); Gl.glNormal3d(n3, n3, -n3); Gl.glTexCoord2d(0, 0); Gl.glVertex3d((largo / 2 + 0.05) * 100, (alto - anchoF) * 100, (-0.1 - 0.05) * 100); Gl.glNormal3d(-n3, n3, -n3); Gl.glTexCoord2d(5, 0); Gl.glVertex3d((largo - anchoF - 0.05) * 100, (alto - anchoF) * 100, (-0.1 - 0.05) * 100); Gl.glNormal3d(-n3, n3, n3); Gl.glTexCoord2d(5, 1); Gl.glVertex3d((largo - anchoF - 0.05) * 100, (alto - anchoF) * 100, (-ancho + 0.1 + 0.05) * 100); Gl.glNormal3d(n3, n3, n3); Gl.glTexCoord2d(0, 1); Gl.glVertex3d((largo / 2 + 0.05) * 100, (alto - anchoF) * 100, (-ancho + 0.1 + 0.05) * 100); Gl.glEnd(); Gl.glPushMatrix(); double tph = 10; Gl.glTranslated(largo * 100 / 4, Height + tph * .8, -ancho * 100 / 2); Gl.glRotated(30, 0, 1, 0); Glut.glutSolidTeapot(10); Gl.glPopMatrix(); }
private void simpleOpenGlControl1_Paint(object sender, PaintEventArgs e) { Gl.glClear(Gl.GL_COLOR_BUFFER_BIT | Gl.GL_DEPTH_BUFFER_BIT); Gl.glMatrixMode(Gl.GL_MODELVIEW); Gl.glLoadIdentity(); // Glu.gluLookAt(0.0, 30.0, 30.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0); Glu.gluLookAt(0.0, 45.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, -1.0); float[] mat_ambient = new float[3]; float[] mat_diffuse = new float[3]; float[] mat_specular = new float[3]; float mat_shininess; float[] light0_position = new float[4] { 0.0f, 0.0f, 0.0f, 1.0f }; float[] light0_direction = new float[] { 0.0f, 0.0f, -1.0f }; /* 製作一個中心球 會發亮 * Gl.glPushMatrix(); * Gl.glRotated(light0_rot,0,1,0); //依照Y軸旋轉 * Gl.glTranslated(0.0, 0.0, 7.5); * Gl.glDisable(Gl.GL_LIGHTING); //讓這個球不售光影計算 所以把光影計算關閉 * Gl.glColor3ub(253, 200, 0); * Gl.glLightfv(Gl.GL_LIGHT0, Gl.GL_POSITION, light0_position); * Glut.glutSolidSphere(0.3,16,16); * Gl.glEnable(Gl.GL_LIGHTING); //打開光影計算 * Gl.glPopMatrix();*/ //探照燈 Gl.glEnable(Gl.GL_COLOR_MATERIAL); Gl.glPushMatrix(); Gl.glRotated(light0_rot, 0.0, 1.0, 0.0); //let the flashlight rotate Gl.glLightfv(Gl.GL_LIGHT0, Gl.GL_POSITION, light0_position); Gl.glLightfv(Gl.GL_LIGHT0, Gl.GL_SPOT_DIRECTION, light0_direction); Gl.glLightf(Gl.GL_LIGHT0, Gl.GL_SPOT_CUTOFF, (float)(Math.Atan(0.3) * 180.0 / Math.PI)); Gl.glLightf(Gl.GL_LIGHT0, Gl.GL_SPOT_EXPONENT, 10.0f); Gl.glColor3ub(255, 0, 0); Gl.glTranslated(0.0, 0.0, -1.0); Glut.glutSolidCone(0.3, 1.0, 10, 10); Gl.glColor3ub(255, 255, 0); Gl.glScaled(1.0, 1.0, 0.01); Gl.glDisable(Gl.GL_LIGHTING); Glut.glutSolidSphere(0.3, 10, 10); Gl.glEnable(Gl.GL_LIGHTING); Gl.glPopMatrix(); Gl.glDisable(Gl.GL_COLOR_MATERIAL); double x = 10.0; Gl.glRotated(rot, 0.0, 1.0, 0.0); // Brass 黃銅 mat_ambient[0] = 0.329412f; mat_ambient[1] = 0.223529f; mat_ambient[2] = 0.027451f; Gl.glMaterialfv(Gl.GL_FRONT, Gl.GL_AMBIENT, mat_ambient); mat_diffuse[0] = 0.780392f; mat_diffuse[1] = 0.568627f; mat_diffuse[2] = 0.113725f; Gl.glMaterialfv(Gl.GL_FRONT, Gl.GL_DIFFUSE, mat_diffuse); mat_specular[0] = 0.780392f; mat_specular[1] = 0.568627f; mat_specular[2] = 0.113725f; Gl.glMaterialfv(Gl.GL_FRONT, Gl.GL_SPECULAR, mat_specular); mat_shininess = 27.8974f; Gl.glMaterialf(Gl.GL_FRONT, Gl.GL_SHININESS, mat_shininess); Gl.glEnable(Gl.GL_COLOR_MATERIAL); //打開色彩材質的功能 讓glColor3d的功能出現 Random rn = new Random(1); Gl.glColor3ub((byte)rn.Next(0, 255), (byte)rn.Next(0, 255), (byte)rn.Next(0, 255)); Gl.glPushMatrix(); Gl.glTranslated(0.0, 0.0, x); Gl.glRotated(xRot[0], 1, 0, 0); Gl.glRotated(yRot[0], 0, 1, 0); Glut.glutSolidSphere(1.0, 20, 20); Gl.glPopMatrix(); Gl.glColor3ub((byte)rn.Next(0, 255), (byte)rn.Next(0, 255), (byte)rn.Next(0, 255)); Gl.glPushMatrix(); Gl.glRotated(40.0, 0.0, 1.0, 0.0); Gl.glTranslated(0.0, 0.0, x); Gl.glRotated(xRot[1], 1, 0, 0); Gl.glRotated(yRot[1], 0, 1, 0); Glut.glutSolidCube(1.0); Gl.glPopMatrix(); Gl.glColor3ub((byte)rn.Next(0, 255), (byte)rn.Next(0, 255), (byte)rn.Next(0, 255)); Gl.glPushMatrix(); Gl.glRotated(80.0, 0.0, 1.0, 0.0); Gl.glTranslated(0.0, 0.0, x); Gl.glRotated(xRot[2], 1, 0, 0); Gl.glRotated(yRot[2], 0, 1, 0); Glut.glutSolidCone(0.5, 1.0, 20, 20); Gl.glPopMatrix(); Gl.glColor3ub((byte)rn.Next(0, 255), (byte)rn.Next(0, 255), (byte)rn.Next(0, 255)); Gl.glPushMatrix(); Gl.glRotated(120.0, 0.0, 1.0, 0.0); Gl.glTranslated(0.0, 0.0, x); Gl.glRotated(xRot[3], 1, 0, 0); Gl.glRotated(yRot[3], 0, 1, 0); Glut.glutSolidTorus(0.5, 1.0, 20, 20); Gl.glPopMatrix(); Gl.glColor3ub((byte)rn.Next(0, 255), (byte)rn.Next(0, 255), (byte)rn.Next(0, 255)); Gl.glPushMatrix(); Gl.glRotated(160.0, 0.0, 1.0, 0.0); Gl.glTranslated(0.0, 0.0, x); Gl.glRotated(xRot[4], 1, 0, 0); Gl.glRotated(yRot[4], 0, 1, 0); Glut.glutSolidDodecahedron(); Gl.glPopMatrix(); Gl.glColor3ub((byte)rn.Next(0, 255), (byte)rn.Next(0, 255), (byte)rn.Next(0, 255)); Gl.glPushMatrix(); Gl.glRotated(200.0, 0.0, 1.0, 0.0); Gl.glTranslated(0.0, 0.0, x); Gl.glRotated(xRot[5], 1, 0, 0); Gl.glRotated(yRot[5], 0, 1, 0); Glut.glutSolidOctahedron(); Gl.glPopMatrix(); Gl.glColor3ub((byte)rn.Next(0, 255), (byte)rn.Next(0, 255), (byte)rn.Next(0, 255)); Gl.glPushMatrix(); Gl.glRotated(240.0, 0.0, 1.0, 0.0); Gl.glTranslated(0.0, 0.0, x); Gl.glRotated(xRot[6], 1, 0, 0); Gl.glRotated(yRot[6], 0, 1, 0); Glut.glutSolidTetrahedron(); Gl.glPopMatrix(); Gl.glColor3ub((byte)rn.Next(0, 255), (byte)rn.Next(0, 255), (byte)rn.Next(0, 255)); Gl.glPushMatrix(); Gl.glRotated(280.0, 0.0, 1.0, 0.0); Gl.glTranslated(0.0, 0.0, x); Gl.glRotated(xRot[7], 1, 0, 0); Gl.glRotated(yRot[7], 0, 1, 0); Glut.glutSolidIcosahedron(); Gl.glPopMatrix(); Gl.glColor3ub((byte)rn.Next(0, 255), (byte)rn.Next(0, 255), (byte)rn.Next(0, 255)); Gl.glPushMatrix(); Gl.glRotated(320.0, 0.0, 1.0, 0.0); Gl.glTranslated(0.0, 0.0, x); Gl.glRotated(xRot[8], 1, 0, 0); Gl.glRotated(yRot[8], 0, 1, 0); Gl.glFrontFace(Gl.GL_CW); //所有圖形裡面 只有茶壺是順時針法則,其他的都是逆時針法則 Glut.glutSolidTeapot(0.5); Gl.glFrontFace(Gl.GL_CCW); //要把他的狀態改回逆時針法則,不改會影響到其他物件 Gl.glPopMatrix(); Gl.glDisable(Gl.GL_COLOR_MATERIAL); //關掉色彩材質的功能 }
private void openGLControl_OpenGLDraw(object sender, OpenGLEventArgs args) { OpenGL gl = openGLControl.OpenGL; gl.Clear(OpenGL.GL_COLOR_BUFFER_BIT | OpenGL.GL_DEPTH_BUFFER_BIT); gl.MatrixMode(OpenGL.GL_MODELVIEW); // Задание матричного режима, GL_MODELVIEW - объектно-видовая матрица gl.PushMatrix(); if (Y == 1) { gl.ClearColor(0.8f, 0.8f, 0.8f, 0.0f); } else if (Y == 2) { gl.ClearColor(0.5f, 0.7f, 0.9f, 0.0f); } else if (Y == 3) { gl.ClearColor(0.9f, 0.5f, 0.7f, 0.0f); } else { gl.ClearColor(0.9f, 0.5f, 0f, 0.0f); } if (G == 1) { B8.Content = "Покраска"; } else if (G == 2) { B8.Content = "Покраска и каркас"; } else { B8.Content = "Каркас"; } if (U1 == 1) { B12.Content = "Покраска 1 объекта"; } else if (U1 == 2) { B12.Content = "Покраска и каркас 1 объекта"; } else { B12.Content = "Каркас 1 объекта"; } if (U2 == 1) { B13.Content = "Покраска 2 объекта"; } else if (U2 == 2) { B13.Content = "Покраска и каркас 2 объекта"; } else { B13.Content = "Каркас 2 объекта"; } if (U3 == 1) { B14.Content = "Покраска 3 объекта"; } else if (U3 == 2) { B14.Content = "Покраска и каркас 3 объекта"; } else { B14.Content = "Каркас 3 объекта"; } if (F == 1) { gl.Color(0.9, 0, 0); // Устанавливаем цвет объекта if (G == 2) { Glut.glutSolidTeapot(2); // Отрисовка чайника с помощью библиотеки FreeGLUT } else if (G == 3) { Glut.glutSolidTeapot(2); // Отрисовка чайника с помощью библиотеки FreeGLUT gl.Color(0, 0, 0); } Glut.glutWireTeapot(2); gl.LoadIdentity(); gl.Rotate(10, 2.0f, 0.0f, -2.0f); gl.Rotate(rotation, 0.0f, 1.0f, 0.0f); } else if (F == 2) { gl.LoadIdentity(); gl.Rotate(20, 1.0f, 0.0f, 0.0f); gl.Rotate(rotation, 0.0f, 1.0f, 0.0f); gl.Color(0.9, 0, 0); if (G == 2) { Glut.glutSolidCube(3); } else if (G == 3) { Glut.glutSolidCube(3); gl.Color(0, 0, 0); } Glut.glutWireCube(3); } else if (F == 3) { gl.LoadIdentity(); gl.Rotate(80, -30.0f, 25.0f, 20.0f); gl.Rotate(rotation, 0.0f, 0.0f, 1.0f); gl.Translate(0, 0, -2); gl.Color(0.9, 0, 0); // Устанавливаем цвет объекта gl.Scale(0.4, 0.4, 0.4); if (G == 2) { Glut.glutSolidCone(2.0, 12.0, 10, 0); } else if (G == 3) { Glut.glutSolidCone(2.0, 12.0, 10, 0); gl.Color(0, 0, 0); } Glut.glutWireCone(2.0, 12.0, 10, 0); } else if (F == 4) { gl.LoadIdentity(); gl.Rotate(0, 1.0f, 1.0f, 0.0f); gl.Rotate(rotation, 0.0f, 1.0f, 0.0f); gl.Color(0.9, 0, 0); // Устанавливаем цвет объекта gl.Scale(2, 2, 2); if (G == 2) { Glut.glutSolidIcosahedron(); } else if (G == 3) { Glut.glutSolidIcosahedron(); gl.Color(0, 0, 0); } Glut.glutWireIcosahedron(); } else if (F == 5) { gl.LoadIdentity(); gl.Rotate(0, 1.0f, 1.0f, 0.0f); gl.Rotate(rotation, 0.0f, 1.0f, 0.0f); gl.Color(0.9, 0, 0); // Устанавливаем цвет объекта if (G == 2) { Glut.glutSolidDodecahedron(); } else if (G == 3) { Glut.glutSolidDodecahedron(); gl.Color(0, 0, 0); } Glut.glutWireDodecahedron(); gl.PopMatrix(); // Возврат сохраненной в стеке матрицы gl.Flush(); // Ожидание, пока библиотека OpenGL завершит визуализацию кадра, очистка буфера } else if (F == 6) { gl.LoadIdentity(); gl.Rotate(0, 1.0f, 1.0f, 0.0f); gl.Rotate(rotation, 0.0f, 1.0f, 0.0f); gl.Color(0.9, 0, 0); // Устанавливаем цвет объекта if (G == 2) { Glut.glutSolidSphere(2, 15, 15); } else if (G == 3) { Glut.glutSolidSphere(2, 15, 15); gl.Color(0, 0, 0); } Glut.glutWireSphere(2, 15, 15); gl.PopMatrix(); // Возврат сохраненной в стеке матрицы gl.Flush(); // Ожидание, пока библиотека OpenGL завершит визуализацию кадра, очистка буфера } else if (F == 7) { gl.LoadIdentity(); gl.Rotate(30, 1, 1, 0); gl.Rotate(rotation, 0.0f, 0.0f, 1.0f); gl.Scale(1.5, 1.5, 1.5); gl.Color(0, 0.9, 0); if (U1 == 2) { Glut.glutSolidDodecahedron(); } else if (U1 == 3) { Glut.glutSolidDodecahedron(); gl.Color(0, 0, 0); } Glut.glutWireDodecahedron(); gl.Scale(0.4, 0.4, 0.4); gl.Color(0, 0, 0.9); if (U2 == 2) { Glut.glutSolidCube(4); } else if (U2 == 3) { Glut.glutSolidCube(4); gl.Color(0, 0, 0); } Glut.glutWireCube(4); gl.Scale(0.7, 0.7, 0.7); gl.Color(0.9, 0, 0); if (U3 == 2) { Glut.glutSolidDodecahedron(); } else if (U3 == 3) { Glut.glutSolidDodecahedron(); gl.Color(0, 0, 0); } Glut.glutWireDodecahedron(); gl.PopMatrix(); gl.Flush(); } else if (F == 8) { gl.LoadIdentity(); gl.Rotate(90, 5, 1, 0); gl.Rotate(rotation, 0.0f, 0.0f, 1.0f); gl.Color(0.9, 0, 0); gl.Scale(0.07, 0.07, 0.07); if (U1 == 2) { Glut.glutSolidTorus(5, 10, 10, 25); } else if (U1 == 3) { Glut.glutSolidTorus(5, 10, 10, 25); gl.Color(0, 0, 0); } Glut.glutWireTorus(5, 10, 10, 15); gl.Translate(-45, -5, -5); gl.Color(0.9, 0, 0); gl.Color(0.9, 0.9, 0); if (U2 == 2) { Glut.glutSolidSphere(20, 25, 25); } else if (U2 == 3) { Glut.glutSolidSphere(20, 25, 25); gl.Color(0, 0, 0); } Glut.glutWireSphere(20, 25, 25); gl.PopMatrix(); gl.Flush(); } else { gl.LoadIdentity(); gl.Rotate(20, 2.0f, 0.0f, -2.0f); gl.Rotate(rotation, 0.0f, 1.0f, 0.0f); gl.Color(0.9, 0, 0); if (U1 == 2) { Glut.glutSolidTeapot(1.5); } else if (U1 == 3) { Glut.glutSolidTeapot(1.5); gl.Color(0, 0, 0); } Glut.glutWireTeapot(1.5); gl.Color(0.9, 0.9, 0); if (U2 == 2) { Glut.glutSolidSphere(3, 15, 15); } else if (U2 == 3) { Glut.glutSolidSphere(3, 15, 15); gl.Color(0, 0, 0); } Glut.glutWireSphere(3, 15, 15); gl.PopMatrix(); gl.Flush(); } rotation += 3.0f; }
// Рисует чайник private void drawTeapot() { Glut.glutSolidTeapot(1.0f); }