/** * Causes this <code>Sphere</code> to render itself using the <code>DrawContext</code> provided. <code>dc</code> may * not be null. * * @param dc the <code>DrawContext</code> to be used * * @throws ArgumentException if <code>dc</code> is null */ public void render(DrawContext dc) { if (dc == null) { String msg = Logging.getMessage("nullValue.DrawContextIsNull"); Logging.logger().severe(msg); throw new ArgumentException(msg); } GL2 gl = dc.getGL().getGL2(); // GL initialization checks for GL2 compatibility. gl.glPushAttrib(GL2.GL_ENABLE_BIT | GL2.GL_CURRENT_BIT); gl.glMatrixMode(GL2.GL_MODELVIEW); gl.glPushMatrix(); gl.glTranslated(this.center.x, this.center.y, this.center.z); GLUquadric quadric = dc.getGLU().gluNewQuadric(); dc.getGLU().gluQuadricDrawStyle(quadric, GLU.GLU_LINE); dc.getGLU().gluSphere(quadric, this.radius, 10, 10); gl.glPopMatrix(); dc.getGLU().gluDeleteQuadric(quadric); gl.glPopAttrib(); }
/// <summary> /// hier wird gezeichnet /// </summary> public void drawScene() { // Verschieben des Koordinatensystems um -6 in Z-Richtung // also "nach hinten" // und kippen nach Oben //coordinateSystem(2); GL.glTranslated(0.0, 0.0, -6.0); GL.glRotated(-60, 1, 0, 0); //coordinateSystem(0.5); coordinateSystem(1); // Zylinderobjekt erzeugen GLUquadric zylinder = GL.gluNewQuadric(); // Zeicheneigenschaften einstellen: // Drahtgittermodell GLU.gluQuadricDrawStyle(zylinder, GLU.GLU_LINE); // ab jetzt in blau zeichnen GL.glColor3f(0.0f, 0.0f, 1.0f); // Zeichnen eines Zylinders // bottom-Durchmesser, top-Durchmesser, Höhe, // Anzahl der Linien-Segmente // Anzahl der Linien in der Höhe // Hier wird die Haupt-Kran Achse gezeichnet //GLU.gluCylinder(zylinder, 0.2, 0.2, 2, 20, 10); }
protected override void InitGLContext() { LoadTextures(); GL.glEnable(GL.GL_TEXTURE_2D); // Enable Texture Mapping GL.glShadeModel(GL.GL_SMOOTH); // Enable Smooth Shading GL.glClearColor(0.0f, 0.0f, 0.0f, 0.5f); // Black Background GL.glClearDepth(1.0f); // Depth Buffer Setup GL.glEnable(GL.GL_DEPTH_TEST); // Enables Depth Testing GL.glDepthFunc(GL.GL_LEQUAL); // The Type Of Depth Testing To Do GL.glHint(GL.GL_PERSPECTIVE_CORRECTION_HINT, GL.GL_NICEST); // Really Nice Perspective Calculations GL.glLightfv(GL.GL_LIGHT1, GL.GL_AMBIENT, this.LightAmbient); // Setup The Ambient Light GL.glLightfv(GL.GL_LIGHT1, GL.GL_DIFFUSE, this.LightDiffuse); // Setup The Diffuse Light GL.glLightfv(GL.GL_LIGHT1, GL.GL_POSITION, this.LightPosition); // Position The Light GL.glEnable(GL.GL_LIGHT1); // Enable Light One this.quadratic = GL.gluNewQuadric(); // Create A Pointer To The Quadric Object (Return 0 If No Memory) (NEW) GL.gluQuadricNormals(this.quadratic, GL.GLU_SMOOTH); // Create Smooth Normals (NEW) GL.gluQuadricTexture(this.quadratic, (byte)GL.GL_TRUE); // Create Texture Coords (NEW) if (this.light) // If lighting, enable it to start { GL.glEnable(GL.GL_LIGHTING); } }
public void getbox() { GLUquadric q = GLU.gluNewQuadric(); color c1 = new color(); GL.glScalef(0.125f, 0.125f, 0.125f); GL.glBegin(GL.GL_QUADS); // Front Face // Front Face GL.glNormal3f(0.0f, 0.0f, 1.0f); GL.glTexCoord2f(0.0f, 0.0f); GL.glVertex3f(-1.0f, -1.0f, 1.0f); GL.glTexCoord2f(1.0f, 0.0f); GL.glVertex3f(1.0f, -1.0f, 1.0f); GL.glTexCoord2f(1.0f, 1.0f); GL.glVertex3f(1.0f, 1.0f, 1.0f); GL.glTexCoord2f(0.0f, 1.0f); GL.glVertex3f(-1.0f, 1.0f, 1.0f); // Back Face GL.glNormal3f(0.0f, 0.0f, -1.0f); GL.glTexCoord2f(1.0f, 0.0f); GL.glVertex3f(-1.0f, -1.0f, -1.0f); GL.glTexCoord2f(1.0f, 1.0f); GL.glVertex3f(-1.0f, 1.0f, -1.0f); GL.glTexCoord2f(0.0f, 1.0f); GL.glVertex3f(1.0f, 1.0f, -1.0f); GL.glTexCoord2f(0.0f, 0.0f); GL.glVertex3f(1.0f, -1.0f, -1.0f); // Top Face GL.glNormal3f(0.0f, 1.0f, 0.0f); GL.glTexCoord2f(0.0f, 1.0f); GL.glVertex3f(-1.0f, 1.0f, -1.0f); GL.glTexCoord2f(0.0f, 0.0f); GL.glVertex3f(-1.0f, 1.0f, 1.0f); GL.glTexCoord2f(1.0f, 0.0f); GL.glVertex3f(1.0f, 1.0f, 1.0f); GL.glTexCoord2f(1.0f, 1.0f); GL.glVertex3f(1.0f, 1.0f, -1.0f); // Bottom Face GL.glNormal3f(0.0f, -1.0f, 0.0f); GL.glTexCoord2f(1.0f, 1.0f); GL.glVertex3f(-1.0f, -1.0f, -1.0f); GL.glTexCoord2f(0.0f, 1.0f); GL.glVertex3f(1.0f, -1.0f, -1.0f); GL.glTexCoord2f(0.0f, 0.0f); GL.glVertex3f(1.0f, -1.0f, 1.0f); GL.glTexCoord2f(1.0f, 0.0f); GL.glVertex3f(-1.0f, -1.0f, 1.0f); // Right face GL.glNormal3f(1.0f, 0.0f, 0.0f); GL.glTexCoord2f(1.0f, 0.0f); GL.glVertex3f(1.0f, -1.0f, -1.0f); GL.glTexCoord2f(1.0f, 1.0f); GL.glVertex3f(1.0f, 1.0f, -1.0f); GL.glTexCoord2f(0.0f, 1.0f); GL.glVertex3f(1.0f, 1.0f, 1.0f); GL.glTexCoord2f(0.0f, 0.0f); GL.glVertex3f(1.0f, -1.0f, 1.0f); // Left Face GL.glNormal3f(-1.0f, 0.0f, 0.0f); GL.glTexCoord2f(0.0f, 0.0f); GL.glVertex3f(-1.0f, -1.0f, -1.0f); GL.glTexCoord2f(1.0f, 0.0f); GL.glVertex3f(-1.0f, -1.0f, 1.0f); GL.glTexCoord2f(1.0f, 1.0f); GL.glVertex3f(-1.0f, 1.0f, 1.0f); GL.glTexCoord2f(0.0f, 1.0f); GL.glVertex3f(-1.0f, 1.0f, -1.0f); GL.glEnd(); GL.glScalef(8, 8, 8); GL.glTranslatef(0, -0.1f, 0.3f); GL.glColor3fv(c1.yellow); lo.LoadTextures1(5); GLU.gluQuadricNormals(q, GLU.GLU_SMOOTH); GLU.gluQuadricTexture(q, 1); GLU.gluDisk(q, 0.01, 0.1, 32, 32); GL.glTranslatef(0, -0.01f, -0.3f); GLU.gluDisk(q, 0.01, 0.1, 32, 32); }
public void schieber() { //Schieber zeichnen GL.glTranslated(0.0, 0.0, targetArmLength); GL.glRotated(0, 0, 0, 0); GL.glColor3f(1.0f, 1.0f, 0.0f); GLUquadric schieber = GL.gluNewQuadric(); GLU.gluCylinder(schieber, 0.15, 0.15, 0.1, 20, 10); }
public void ausleger() { //Ausleger zeichnen GL.glTranslated(0.0, 0.0, 0.0); GL.glRotated(90, 0, 1, 0); GL.glColor3f(1.0f, 0.0f, 0.0f); GLUquadric ausleger = GL.gluNewQuadric(); GLU.gluCylinder(ausleger, 0.1, 0.1, 2, 20, 10); }
public Tank(float positionX, float positionZ, float initialRotation) { rotation = initialRotation; posX = positionX; posZ = positionZ; destinX = positionX; destinZ = positionZ; reloadCounter = reloadTime; obj = GLU.gluNewQuadric(); }
public void seil() { //Seil zeichnen //GL.glTranslated(0.0, 0.0, targetArmLength); GL.glTranslated(-0.15, 0.0, 0.05); GL.glRotated(-90, 0, 1, 0); GL.glColor3f(0.0f, 1.0f, 0.0f); GLUquadric seil = GL.gluNewQuadric(); GLU.gluCylinder(seil, 0.01, 0.01, targetRopeLength, 20, 10); }
// --- Basecode Methods --- #region Initialize() /// <summary> /// Overrides OpenGL's initialization. /// </summary> public override void Initialize() { LoadTextures(); // Jump To Texture Loading Routine glEnable(GL_TEXTURE_2D); // Enable Texture Mapping glClearColor(0.7f, 0.7f, 0.8f, 1.0f); // Background Color glClearDepth(1.0f); // Depth Buffer Setup glEnable(GL_DEPTH_TEST); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // Type Of Blending To Perform glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); // Really Nice Perspective Calculations float[] fogColor = { 0.7f, 0.7f, 0.8f, 0.0f }; // Fog Color glFogi(GL_FOG_MODE, (int)GL_EXP2); // Fog Mode glFogfv(GL_FOG_COLOR, fogColor); // Set Fog Color glFogf(GL_FOG_DENSITY, 0.05f); // How Dense Will The Fog Be glHint(GL_FOG_HINT, GL_DONT_CARE); // Fog Hint Value glFogf(GL_FOG_START, 0.0f); // Fog Start Depth glFogf(GL_FOG_END, 10.0f); // Fog End Depth glEnable(GL_FOG); // Enables GL_FOG float[] m_ambient = { 0.1f, 0.1f, 0.1f, 1.0f }; float[] m_diffuse = { 0.5f, 0.5f, 0.5f, 1.0f }; float[] m_specular = { 1.0f, 1.0f, 1.0f, 1.0f }; float m_shininess = 10.0f; glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, m_ambient); glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, m_diffuse); glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, m_specular); glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, m_shininess); float[] LightAmbient = { 0.2f, 0.2f, 0.2f, 1.0f }; float[] LightDiffuse = { 0.5f, 0.5f, 0.5f, 1.0f }; float[] LightSpecular = { 1.0f, 1.0f, 1.0f, 1.0f }; float[] LightPosition = { 0.0f, 0.0f, -11.0f, 1.0f }; glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, (int)GL_TRUE); glLightfv(GL_LIGHT0, GL_AMBIENT, LightAmbient); // Setup The Ambient Light glLightfv(GL_LIGHT0, GL_DIFFUSE, LightDiffuse); // Setup The Diffuse Light glLightfv(GL_LIGHT0, GL_SPECULAR, LightSpecular); // Setup The Diffuse Light glLightfv(GL_LIGHT0, GL_POSITION, LightPosition); // Position The Light glEnable(GL_LIGHT0); glEnable(GL_COLOR_MATERIAL); glEnable(GL_LIGHTING); quadratic = gluNewQuadric(); // Create A Pointer To The Quadric Object (Return 0 If No Memory) gluQuadricNormals(quadratic, GLU_SMOOTH); // Create Smooth Normals gluQuadricTexture(quadratic, (byte)GL_TRUE); // Create Texture Coords timer.Start(); Time1 = TimerGetTime(); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); }
public Claw(GLUquadric i_Quadric, uint list, uint shadowList) { CableLength = 1.5f; m_Quadric = i_Quadric; LIST = list; SHADOW_LIST = shadowList; ObjectReader arcadeReader = new ObjectReader(); arcadeReader.loadFile("claw.obj"); arcadeReader.createListFace(LIST, -1, false); arcadeReader.createListFace(SHADOW_LIST, -1, true); }
public ClawMachine(GLUquadric i_Quadric, uint clawMachineList, uint shadowList, TeddyBear teddyBear, Claw claw) { ClawPosition = new double[3] { 0, 6.1, 0 }; teddyBearsLocations = new List <teddyBearLocation>(); addTeddyBearsLocations(); this.m_Quadric = i_Quadric; this.teddyBear = teddyBear; this.Claw = claw; this.HandleUpDownAngle = -45; this.HandleLeftRightAngle = 0; CreateClawMachine(clawMachineList, false); CreateClawMachine(shadowList, true); }
// --- Basecode Methods --- #region Initialize() /// <summary> /// Overrides OpenGL's initialization. /// </summary> public override void Initialize() { base.Initialize(); // Run The Base Initialization glEnable(GL_TEXTURE_2D); // Enable Texture Mapping LoadTextures(); // Jump To Texture Loading Routine glLightfv(GL_LIGHT1, GL_AMBIENT, LightAmbient); // Setup The Ambient Light glLightfv(GL_LIGHT1, GL_DIFFUSE, LightDiffuse); // Setup The Diffuse Light glLightfv(GL_LIGHT1, GL_POSITION, LightPosition); // Position The Light glEnable(GL_LIGHT1); // Enable Light One quadratic = gluNewQuadric(); // Create A Quadric Object gluQuadricNormals(quadratic, GLU_SMOOTH); // Create Smooth Normals gluQuadricTexture(quadratic, (byte)GL_TRUE); // Create Texture Coords }
public void turm() { //Perspektive 90° auf die X-Achse GL.glRotated(90, 1, 0, 0); //Turm Zeichnen //lässt den Zylinder rotieren GL.glRotated(targetAngle, 0, 1, 0); GL.glTranslated(0.0, 0.0, 0.0); GL.glRotated(90, 1, 0, 0); //Rotation des Objektes (Winkel, X, Y, Z) GL.glColor3f(0.0f, 0.0f, 1.0f); //Farbe des Objektes (R,G,B) // Zylinderobjekt erzeugen GLUquadric zylinder = GL.gluNewQuadric(); GLU.gluCylinder(zylinder, 0.1, 0.1, 3, 20, 10); }
public Bullet(float positionX, float positionY, float positionZ, float velX, float velZ, float initialRotation) { rotation = initialRotation; originalSpeedX = (float)(velX - System.Math.Sin(System.Math.PI / 180 * (initialRotation))); originalSpeedZ = (float)(velZ - System.Math.Cos(System.Math.PI / 180 * (initialRotation))); originalPositionX = positionX; originalPositionZ = positionZ; speedX = originalSpeedX; speedZ = originalSpeedZ; posX = positionX; posY = positionY; posZ = positionZ; remainingLife = 100; boom = false; boomcolor = 0.5f; obj = GLU.gluNewQuadric(); }
// --- Basecode Methods --- #region Initialize() /// <summary> /// Overrides OpenGL's initialization. /// </summary> public override void Initialize() { base.Initialize(); // Run The Base Initialization glEnable(GL_TEXTURE_2D); // Enable Texture Mapping LoadTextures(); // Jump To Texture Loading Routine glLightfv(GL_LIGHT1, GL_AMBIENT, LightAmbient); // Setup The Ambient Light glLightfv(GL_LIGHT1, GL_DIFFUSE, LightDiffuse); // Setup The Diffuse Light glLightfv(GL_LIGHT1, GL_POSITION, LightPosition); // Position The Light glEnable(GL_LIGHT1); // Enable Light One quadratic = gluNewQuadric(); // Create A Pointer To The Quadric Object gluQuadricNormals(quadratic, GLU_SMOOTH); // Create Smooth Normals gluQuadricTexture(quadratic, (byte)GL_TRUE); // Create Texture Coords glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, (int)GL_SPHERE_MAP); // Set The Texture Generation Mode For S To Sphere Mapping glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, (int)GL_SPHERE_MAP); // Set The Texture Generation Mode For T To Sphere Mapping }
// --- Basecode Methods --- #region Initialize() /// <summary> /// Overrides OpenGL's initialization. /// </summary> public override void Initialize() { base.Initialize(); // Run The Base Initialization glEnable(GL_TEXTURE_2D); // Enable Texture Mapping glClearColor(0.2f, 0.5f, 1.0f, 1.0f); // Override Background glClearStencil(0); // Clear The Stencil Buffer To 0 LoadTextures(); // Jump To Texture Loading Routine glLightfv(GL_LIGHT0, GL_AMBIENT, LightAmbient); // Set The Ambient Lighting For Light0 glLightfv(GL_LIGHT0, GL_DIFFUSE, LightDiffuse); // Set The Diffuse Lighting For Light0 glLightfv(GL_LIGHT0, GL_POSITION, LightPosition); // Set The Position For Light0 glEnable(GL_LIGHT0); // Enable Light 0 glEnable(GL_LIGHTING); // Enable Lighting quadratic = gluNewQuadric(); // Create A New Quadratic gluQuadricNormals(quadratic, GLU_SMOOTH); // Generate Smooth Normals For The Quad gluQuadricTexture(quadratic, (byte)GL_TRUE); // Enable Texture Coords For The Quad glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, (int)GL_SPHERE_MAP); // Set Up Sphere Mapping glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, (int)GL_SPHERE_MAP); // Set Up Sphere Mapping }
void makeRectangularPrism(float x1, float y1, float z1, float x2, float y2, float z2) { float width = (x2 - x1) / 2; if (width < 1) { width = -width; } float height = (y2 - y1) / 2; if (height < 1) { height = -height; } float depth = (z2 - z1) / 2; if (depth < 1) { depth = -depth; } GL.glColor3f(0.273f, 0.252f, 0.135f); //army-green light GL.glBegin(GL.GL_QUADS); //Front GL.glNormal3f(0.0f, 0.0f, -1.0f); GL.glVertex3f(-width, -height, depth); GL.glVertex3f(width, -height, depth); GL.glVertex3f(width, height, depth); GL.glVertex3f(-width, height, depth); //Top GL.glNormal3f(0.0f, 1.0f, 0.0f); GL.glVertex3f(-width, height, -depth); GL.glVertex3f(-width, height, depth); GL.glVertex3f(width, height, depth); GL.glVertex3f(width, height, -depth); //Bottom GL.glNormal3f(0.0f, -1.0f, 0.0f); GL.glVertex3f(-width, -height, -depth); GL.glVertex3f(-width, -height, depth); GL.glVertex3f(width, -height, depth); GL.glVertex3f(width, -height, -depth); //Right GL.glNormal3f(1.0f, 0.0f, 0.0f); GL.glVertex3f(width, -height, -depth); GL.glVertex3f(width, height, -depth); GL.glVertex3f(width, height, depth); GL.glVertex3f(width, -height, depth); //Left GL.glNormal3f(-1.0f, 0.0f, 0.0f); GL.glVertex3f(-width, -height, -depth); GL.glVertex3f(-width, -height, depth); GL.glVertex3f(-width, height, depth); GL.glVertex3f(-width, height, -depth); GL.glEnd(); GL.glEnable(GL.GL_TEXTURE_2D); GL.glBindTexture(GL.GL_TEXTURE_2D, cOGL.Textures[2]); GL.glColor3f(1, 1, 1); //white GL.glBegin(GL.GL_QUADS); //Back GL.glNormal3f(0.0f, 0.0f, 1.0f); GL.glTexCoord2f(0, 0); GL.glVertex3f(-width, -height, -depth); GL.glTexCoord2f(0, 1); GL.glVertex3f(-width, height, -depth); GL.glTexCoord2f(1, 1); GL.glVertex3f(width, height, -depth); GL.glTexCoord2f(1, 0); GL.glVertex3f(width, -height, -depth); GL.glEnd(); GLUquadric obj; obj = GLU.gluNewQuadric(); //!!! //barrel GL.glPushMatrix(); GL.glTranslatef(0.0f, 0.025f, -1f); GLU.gluCylinder(obj, 0.05, 0.05, 1.2, 10, 2); GL.glPopMatrix(); GL.glDisable(GL.GL_TEXTURE_2D);//!!! }
void drawDisk(double x, double y, double z, double innerradius, double outerradius, int VLineNum, int HLineNum) { GLUquadric quad_obj = new GLUquadric(); if (quad_obj.data.ToInt32() == 0) quad_obj = GL.gluNewQuadric(); GL.gluQuadricDrawStyle(quad_obj, GL.GLU_FILL); //GLU_SILHOUETTE //GLU_POINT // GLU_FILL //GLU_LINE GL.gluQuadricNormals(quad_obj, GL.GLU_SMOOTH); GL.glColor3d(1.0, 0, 0); //GL.glTranslated(x, y, z); GL.glRotated(0, 0, 0, 0); GL.gluDisk(quad_obj, innerradius, outerradius, VLineNum, HLineNum); }
/// <summary> /// Initializes a new quadric. /// </summary> private static void InitQuadObj() { quadObj = GL.gluNewQuadric(); }
/************************************************************************/ /* 带有圆柱体的上下面的半径大小的RenderBone函数 */ /************************************************************************/ void RenderBone(double x0, double y0, double z0, double x1, double y1, double z1, double topradius, double bottomradius, int VLineNum, int HLineNum) { double dir_x = x1 - x0; double dir_y = y1 - y0; double dir_z = z1 - z0; double bone_length = System.Math.Sqrt(dir_x * dir_x + dir_y * dir_y + dir_z * dir_z); GLUquadric quad_obj = new GLUquadric(); if (quad_obj.data.ToInt32() == 0) quad_obj = GL.gluNewQuadric(); GL.gluQuadricDrawStyle(quad_obj, GL.GLU_FILL); //GLU_SILHOUETTE //GLU_POINT // GLU_FILL //GLU_LINE GL.gluQuadricNormals(quad_obj, GL.GLU_SMOOTH); GL.glPushMatrix(); GL.glTranslated(x0, y0, z0); double length; length = System.Math.Sqrt(dir_x * dir_x + dir_y * dir_y + dir_z * dir_z); if (length < 0.0001) { dir_x = 0.0; dir_y = 0.0; dir_z = 1.0; length = 1.0; } dir_x /= length; dir_y /= length; dir_z /= length; double up_x, up_y, up_z; up_x = 0.0; up_y = 1.0; up_z = 0.0; double side_x, side_y, side_z; side_x = up_y * dir_z - up_z * dir_y; side_y = up_z * dir_x - up_x * dir_z; side_z = up_x * dir_y - up_y * dir_x; length = System.Math.Sqrt(side_x * side_x + side_y * side_y + side_z * side_z); if (length < 0.0001) { side_x = 1.0; side_y = 0.0; side_z = 0.0; length = 1.0; } side_x /= length; side_y /= length; side_z /= length; up_x = dir_y * side_z - dir_z * side_y; up_y = dir_z * side_x - dir_x * side_z; up_z = dir_x * side_y - dir_y * side_x; double[] m = new double[16]{ side_x, side_y, side_z, 0.0, up_x, up_y, up_z, 0.0, dir_x, dir_y, dir_z, 0.0, 0.0, 0.0, 0.0, 1.0 }; GL.glMultMatrixd(m); //double radius = 0.1;//这个值,暂时不用了 //int slices = 3; //int stack = 50; GL.gluCylinder(quad_obj, topradius, bottomradius, bone_length, VLineNum, HLineNum); //GL.gluDisk(quad_obj, bottomradius, bottomradius, VLineNum, HLineNum); GL.glPopMatrix(); }
/// <summary> /// Zeichnet die Objekte /// </summary> public void draw() { // Verschieben des Koordinatensystems um -6 in Z-Richtung // also "nach hinten" // und kippen nach Oben GL.glTranslated(0.0, 0.0, -6.0); //--------------- //BLAUER ZYLINDER1 //Vorgabe der Perspektive (90° auf die X-Achse) für das im folgenden erzeugte Objekt GL.glRotated(90, 1, 0, 0); //lässt den Zylinder (blau) rotieren mithilfe des Schiebereglers GL.glRotated(targetAngle, 0, 0, 1); // Zylinderobjekt erzeugen GLUquadric zylinder = GL.gluNewQuadric(); // Zeicheneigenschaften einstellen: // Drahtgittermodell GLU.gluQuadricDrawStyle(zylinder, GLU.GLU_LINE); // ab jetzt in blau zeichnen GL.glColor3f(0.0f, 0.0f, 1.0f); // Zeichnen des eigentlichen Zylinders // bottom-Durchmesser, top-Durchmesser, Höhe, // Anzahl der Linien-Segmente // Anzahl der Linien in der Höhe GLU.gluCylinder(zylinder, 0.2, 0.2, 2, 200, 100); //--------------- //MAGENTA ZYLINDER2 GL.glTranslated(0.0, 0.0, 0.0); GL.glRotated(120, 0, 1, 0); GL.glColor3f(1.0f, 0.0f, 1.0f); GLUquadric zylinder2 = GL.gluNewQuadric(); GLU.gluCylinder(zylinder2, 0.1, 0.1, 1.5, 20, 10); //GRÜNER ZYLINDER3 GL.glTranslated(0.0, 0.0, 1.5); GL.glRotated(-60, 0, 1, 0); GL.glColor3f(0.0f, 1.0f, 0.0f); GLUquadric zylinder3 = GL.gluNewQuadric(); GLU.gluCylinder(zylinder3, 0.1, 0.1, targetArmLength, 20, 10); //ROTER ZYLINDER4 //GL.glTranslated(0.0, 0.0, targetArmLength); targetArmLength bezieht sich hier auf die Position des Vorgängerobjekts GL.glTranslated(0.0, 0.0, targetArmLength); GL.glRotated(-60, 0, 1, 0); GL.glColor3f(1.0f, 0.0f, 0.0f); GLUquadric zylinder4 = GL.gluNewQuadric(); GLU.gluCylinder(zylinder4, 0.01, 0.01, targetRopeLength, 20, 10); //GELBE KUGEL //GL.glTranslated(0.0, 0.0, targetRopeLength); targetRopeLength bezieht sich hier auf die Position des Vorgängerobjekts GL.glTranslated(0.0, 0.0, targetRopeLength); GL.glRotated(0, 0, 0, 0); GL.glColor3f(1.0f, 1.00f, 0.00f); GLUT.glutWireSphere(targetBowlDiameter, 100, 150); }
/** * Display the cylinder. * * @param dc the current draw context. * * @throws ArgumentException if the draw context is null. */ public void render(DrawContext dc) { if (dc == null) { String msg = Logging.getMessage("nullValue.DrawContextIsNull"); Logging.logger().severe(msg); throw new ArgumentException(msg); } // Compute a matrix that will transform world coordinates to cylinder coordinates. The negative z-axis // will point from the cylinder's bottomCenter to its topCenter. The y-axis will be a vector that is // perpendicular to the cylinder's axisUnitDirection. Because the cylinder is symmetric, it does not matter // in what direction the y-axis points, as long as it is perpendicular to the z-axis. double tolerance = 1e-6; Vec4 upVector = (this.axisUnitDirection.cross3(Vec4.UNIT_Y).getLength3() <= tolerance) ? Vec4.UNIT_NEGATIVE_Z : Vec4.UNIT_Y; Matrix transformMatrix = Matrix.fromModelLookAt(this.bottomCenter, this.topCenter, upVector); double[] matrixArray = new double[16]; transformMatrix.toArray(matrixArray, 0, false); GL2 gl = dc.getGL().getGL2(); // GL initialization checks for GL2 compatibility. OGLStackHandler ogsh = new OGLStackHandler(); ogsh.pushAttrib(gl, GL2.GL_CURRENT_BIT | GL2.GL_ENABLE_BIT | GL2.GL_TRANSFORM_BIT | GL2.GL_DEPTH_BUFFER_BIT); try { // The cylinder is drawn with as a wireframe plus a center axis. It's drawn in two passes in order to // visualize the portions of the cylinder above and below an intersecting surface. gl.glEnable(GL.GL_BLEND); OGLUtil.applyBlending(gl, false); gl.glEnable(GL.GL_DEPTH_TEST); // Draw the axis gl.glDepthFunc(GL.GL_LEQUAL); // draw the part that would normally be visible gl.glColor4f(1f, 1f, 1f, 0.4f); gl.glBegin(GL2.GL_LINES); gl.glVertex3d(this.bottomCenter.x, this.bottomCenter.y, this.bottomCenter.z); gl.glVertex3d(this.topCenter.x, this.topCenter.y, this.topCenter.z); gl.glEnd(); gl.glDepthFunc(GL.GL_GREATER); // draw the part that is behind an intersecting surface gl.glColor4f(1f, 0f, 1f, 0.4f); gl.glBegin(GL2.GL_LINES); gl.glVertex3d(this.bottomCenter.x, this.bottomCenter.y, this.bottomCenter.z); gl.glVertex3d(this.topCenter.x, this.topCenter.y, this.topCenter.z); gl.glEnd(); // Draw the exterior wireframe ogsh.pushModelview(gl); gl.glMultMatrixd(matrixArray, 0); GLUquadric quadric = dc.getGLU().gluNewQuadric(); dc.getGLU().gluQuadricDrawStyle(quadric, GLU.GLU_LINE); gl.glDepthFunc(GL.GL_LEQUAL); gl.glColor4f(1f, 1f, 1f, 0.5f); dc.getGLU().gluCylinder(quadric, this.cylinderRadius, this.cylinderRadius, this.cylinderHeight, 30, 30); gl.glDepthFunc(GL.GL_GREATER); gl.glColor4f(1f, 0f, 1f, 0.4f); dc.getGLU().gluCylinder(quadric, this.cylinderRadius, this.cylinderRadius, this.cylinderHeight, 30, 30); dc.getGLU().gluDeleteQuadric(quadric); } finally { ogsh.pop(gl); } }
public Quadric() { q = gluNewQuadric(); }
public GLxDisplayQuadric() { glQuadric = GL.gluNewQuadric(); }