Java Code Examples for com.jogamp.opengl.GL2#glColor3f()

The following examples show how to use com.jogamp.opengl.GL2#glColor3f() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JRotation.java    From MeteoInfo with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public void display(GLAutoDrawable drawable) {

    final GL2 gl = drawable.getGL().getGL2();
    gl.glClear(GL2.GL_COLOR_BUFFER_BIT | GL2.GL_DEPTH_BUFFER_BIT);

    // Clear The Screen And The Depth Buffer   
    gl.glLoadIdentity();  // Reset The View       

    //triangle rotation        
    gl.glRotatef(rotation, 0.0f, 1.0f, 0.0f);

    gl.glBegin(GL2.GL_TRIANGLES);
    //Green Color  
    gl.glColor3f(0.0f, 1.0f, 0.0f);
    gl.glVertex2d(0, 0.5);
    gl.glVertex2d(-0.5, -0.5);
    gl.glVertex2d(0.5, -0.5);

    gl.glEnd();

    gl.glFlush();
    //Assign the angle  
    rotation += 0.6f;
}
 
Example 2
Source File: JMColor.java    From MeteoInfo with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public void display(GLAutoDrawable drawable) {

    final GL2 gl = drawable.getGL().getGL2();

    gl.glBegin(GL2.GL_TRIANGLES);
    //Yellow Color  
    gl.glColor3f(1.0f, 1.0f, 0f);
    gl.glVertex2d(0, 0.5);
    //Red Color  
    gl.glColor3f(1f, 0f, 0f);
    gl.glVertex2d(-0.5, -0.5);
    //Blue Color  
    gl.glColor3f(0f, 0f, 1f);
    gl.glVertex2d(0.5, -0.5);

    gl.glEnd();
}
 
Example 3
Source File: MatrixHelper.java    From Robot-Overlord-App with GNU General Public License v2.0 6 votes vote down vote up
/**
 * See drawMatrix(gl2,p,u,v,w,1)
 * @param gl2
 * @param m
 * @param scale
 */
public static void drawMatrix2(GL2 gl2,Matrix4d m,double scale) {
	boolean depthWasOn = gl2.glIsEnabled(GL2.GL_DEPTH_TEST);
	gl2.glDisable(GL2.GL_DEPTH_TEST);
	boolean lightWasOn = gl2.glIsEnabled(GL2.GL_LIGHTING);
	gl2.glDisable(GL2.GL_LIGHTING);
	
	gl2.glPushMatrix();
		gl2.glTranslated(m.m03,m.m13,m.m23);
		gl2.glScaled(scale, scale, scale);
		
		gl2.glBegin(GL2.GL_LINES);
		gl2.glColor3f(1,1,0);		gl2.glVertex3f(0,0,0);		gl2.glVertex3d(m.m00,m.m10,m.m20);  // 1,1,0 = yellow
		gl2.glColor3f(0,1,1);		gl2.glVertex3f(0,0,0);		gl2.glVertex3d(m.m01,m.m11,m.m21);  // 0,1,1 = teal 
		gl2.glColor3f(1,0,1);		gl2.glVertex3f(0,0,0);		gl2.glVertex3d(m.m02,m.m12,m.m22);  // 1,0,1 = magenta
		gl2.glEnd();

	gl2.glPopMatrix();
	if(lightWasOn) gl2.glEnable(GL2.GL_LIGHTING);
	if(depthWasOn) gl2.glEnable(GL2.GL_DEPTH_TEST);
}
 
Example 4
Source File: MatrixHelper.java    From Robot-Overlord-App with GNU General Public License v2.0 6 votes vote down vote up
/**
 * See drawMatrix(gl2,p,u,v,w,1)
 * @param gl2
 * @param m
 * @param scale
 */
public static void drawMatrix(GL2 gl2,Matrix4d m,double scale) {
	boolean depthWasOn = gl2.glIsEnabled(GL2.GL_DEPTH_TEST);
	gl2.glDisable(GL2.GL_DEPTH_TEST);
	boolean lightWasOn = gl2.glIsEnabled(GL2.GL_LIGHTING);
	gl2.glDisable(GL2.GL_LIGHTING);
	
	gl2.glPushMatrix();
		gl2.glTranslated(m.m03,m.m13,m.m23);
		gl2.glScaled(scale, scale, scale);
		
		gl2.glBegin(GL2.GL_LINES);
		gl2.glColor3f(1,0,0);		gl2.glVertex3f(0,0,0);		gl2.glVertex3d(m.m00,m.m10,m.m20);  // 1,0,0 = red
		gl2.glColor3f(0,1,0);		gl2.glVertex3f(0,0,0);		gl2.glVertex3d(m.m01,m.m11,m.m21);  // 0,1,0 = green 
		gl2.glColor3f(0,0,1);		gl2.glVertex3f(0,0,0);		gl2.glVertex3d(m.m02,m.m12,m.m22);  // 0,0,1 = blue
		gl2.glEnd();

	gl2.glPopMatrix();
	if(lightWasOn) gl2.glEnable(GL2.GL_LIGHTING);
	if(depthWasOn) gl2.glEnable(GL2.GL_DEPTH_TEST);
}
 
Example 5
Source File: Main.java    From aparapi-examples with Apache License 2.0 6 votes vote down vote up
/**
 * Render all particles to the OpenGL context
 * 
 * @param gl
 */

protected void render(GL2 gl) {
   gl.glBegin(GL2.GL_QUADS);
   int sz = range.getGlobalSize(0);
   for (int i = 0; i < sz; i++) {

      Body currBody = bodies[i];
      if(currBody.isHeavy())
         gl.glColor3f(1f, 0f, 0f);
      else
         gl.glColor3f(0f, 0f, 1f);

      gl.glTexCoord2f(0, 1);
      gl.glVertex3f(currBody.getX(), currBody.getY() + 1, currBody.getZ());
      gl.glTexCoord2f(0, 0);
      gl.glVertex3f(currBody.getX(), currBody.getY(), currBody.getZ());
      gl.glTexCoord2f(1, 0);
      gl.glVertex3f(currBody.getX() + 1, currBody.getY(), currBody.getZ());
      gl.glTexCoord2f(1, 1);
      gl.glVertex3f(currBody.getX() + 1, currBody.getY() + 1, currBody.getZ());

   }
   gl.glEnd();
}
 
Example 6
Source File: JColor.java    From MeteoInfo with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void display(GLAutoDrawable drawable) {

    final GL2 gl = drawable.getGL().getGL2();

    gl.glBegin(GL2.GL_TRIANGLES);
    //Green Color  
    gl.glColor3f(0.0f, 1.0f, 0.0f);
    gl.glVertex2d(0, 0.5);
    gl.glVertex2d(-0.5, -0.5);
    gl.glVertex2d(0.5, -0.5);

    gl.glEnd();
}
 
Example 7
Source File: JPaddle.java    From MeteoInfo with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void display(GLAutoDrawable drawable) {

    GL2 gl = drawable.getGL().getGL2();
    gl.glClear(GL2.GL_COLOR_BUFFER_BIT);
    gl.glLoadIdentity();
    gl.glTranslatef(0f, 0f, -2.0f);
    gl.glRotatef(rotation, 1f, 0f, 0f);

    gl.glColor3f(1f, 0f, 0f);
    gl.glBegin(GL2.GL_POLYGON);
    gl.glVertex3d(-0.5, 0.3, 0.8);
    gl.glVertex3d(0.5, 0.3, 0.8);
    gl.glVertex3d(0.8, 0.7, 0.8);
    gl.glVertex3d(-0.8, 0.7, 0.8);
    gl.glEnd();

    int paddles = 40;
    for (int i = 0; i < paddles; i++) {
        gl.glRotated(360.0 / paddles, 1, 0, 0);
        gl.glBegin(GL2.GL_POLYGON);
        gl.glVertex3d(-0.5, 0.3, 0.8);
        gl.glVertex3d(0.5, 0.3, 0.8);
        gl.glVertex3d(0.8, 0.7, 0.8);
        gl.glVertex3d(-0.8, 0.7, 0.8);

        gl.glEnd();

    }

    rotation -= 0.2f;

}
 
Example 8
Source File: JLight.java    From MeteoInfo with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void display(GLAutoDrawable drawable) {

    final GL2 gl = drawable.getGL().getGL2();
    gl.glColor3f(1f, 0f, 0f);
    gl.glClear(GL2.GL_COLOR_BUFFER_BIT | GL2.GL_DEPTH_BUFFER_BIT);
    gl.glLoadIdentity();
    gl.glRotatef(rotation, 1.0f, 1.0f, 0.0f);

    gl.glBegin(GL2.GL_TRIANGLES);

    gl.glVertex2d(0, 0.5);

    gl.glVertex2d(-0.5, -0.5);

    gl.glVertex2d(0.5, -0.5);

    gl.glEnd();

    gl.glFlush();
    //Angle  
    rotation += 0.6f;

    gl.glEnable(GL2.GL_LIGHTING);
    gl.glEnable(GL2.GL_LIGHT0);
    gl.glEnable(GL2.GL_DEPTH_TEST);

    float[] ambientLight = {0f, 0f, 1f, 0f};
    gl.glLightfv(GL2.GL_LIGHT0, GL2.GL_AMBIENT, ambientLight, 0);

    float[] specularLight = {1f, 0f, 0f, 0f};
    gl.glLightfv(GL2.GL_LIGHT0, GL2.GL_SPECULAR, specularLight, 0);

    float[] diffuseLight = {1f, 0f, 0f, 0f};
    gl.glLightfv(GL2.GL_LIGHT0, GL2.GL_DIFFUSE, diffuseLight, 0);
}
 
Example 9
Source File: CubeSample2.java    From MeteoInfo with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
	public void display(GLAutoDrawable drawable) {
		GL2 gl = drawable.getGL().getGL2();
		gl.glClear(GL.GL_COLOR_BUFFER_BIT);

		gl.glLoadIdentity();

		// 視点位置と視線方向
//		glu.gluLookAt(3.0, 4.0, 5.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0);

		// 図形の回転
		gl.glTranslatef(0.5f, 0.5f, 0.5f);
		gl.glRotatef(r, 0.0f, 1.0f, 0.0f);
		gl.glTranslatef(-0.5f, -0.5f, -0.5f);
		// 図形の描画
		gl.glColor3f(0.0f, 0.0f, 0.0f);
		gl.glBegin(GL_LINES);
		for (int i = 0; i < 12; i++) {
			gl.glVertex3fv(vertex[edge[i][0]], 0);
			gl.glVertex3fv(vertex[edge[i][1]], 0);
		}
		gl.glEnd();

		//一周回ったら回転角を 0 に戻す
		if (r++ >= 360.0f) r = 0;
		System.out.println("anim:" + animator.isAnimating() + ", r:" + r);
		if(willAnimatorPause) {
			animator.pause();
			System.out.println("animoator paused:");
			willAnimatorPause = false;
		}
		drawable.swapBuffers();
	}
 
Example 10
Source File: OneTriangle.java    From MeteoInfo with GNU Lesser General Public License v3.0 5 votes vote down vote up
protected static void render( GL2 gl2, int width, int height ) {
    gl2.glClear( GL.GL_COLOR_BUFFER_BIT );

    // draw a triangle filling the window
    gl2.glLoadIdentity();
    gl2.glBegin( GL.GL_TRIANGLES );
    gl2.glColor3f( 1, 0, 0 );
    gl2.glVertex2f( 0, 0 );
    gl2.glColor3f( 0, 1, 0 );
    gl2.glVertex2f( width, 0 );
    gl2.glColor3f( 0, 0, 1 );
    gl2.glVertex2f( width / 2, height );
    gl2.glEnd();
}
 
Example 11
Source File: DragBallEntity.java    From Robot-Overlord-App with GNU General Public License v2.0 4 votes vote down vote up
public void renderTranslation(GL2 gl2) {
	// camera forward is -z axis 
	RobotOverlord ro = (RobotOverlord)getRoot();
	PoseEntity camera = ro.viewport.getAttachedTo();
	Vector3d lookAtVector = subject.getPosition();
	lookAtVector.sub(camera.getPosition());
	lookAtVector.normalize();

	float r = (majorAxis==Axis.X) ? 1 : 0.5f;
	float g = (majorAxis==Axis.Y) ? 1 : 0.5f;
	float b = (majorAxis==Axis.Z) ? 1 : 0.5f;

	Vector3d fx = MatrixHelper.getXAxis(FOR);
	Vector3d fy = MatrixHelper.getYAxis(FOR);
	Vector3d fz = MatrixHelper.getZAxis(FOR);
	// should we hide an axis if it points almost the same direction as the camera?
	boolean drawX = (Math.abs(lookAtVector.dot(fx))<0.95);
	boolean drawY = (Math.abs(lookAtVector.dot(fy))<0.95);
	boolean drawZ = (Math.abs(lookAtVector.dot(fz))<0.95);

	if(drawX) {
		gl2.glColor3f(r,0,0);
		renderTranslationHandle(gl2,new Vector3d(1,0,0));
	}
	if(drawY) {
		gl2.glColor3f(0,g,0);
		renderTranslationHandle(gl2,new Vector3d(0,1,0));
	}
	if(drawZ) {
		gl2.glColor3f(0,0,b);
		renderTranslationHandle(gl2,new Vector3d(0,0,1));
	}
	
	if(isActivelyMoving) {
		// the distance moved.
		gl2.glBegin(GL2.GL_LINES);
		gl2.glColor3f(255,255,255);
		gl2.glVertex3d(0,0,0);
		gl2.glVertex3d(
				(startMatrix.m03-resultMatrix.m03)/ballSize.get(),
				(startMatrix.m13-resultMatrix.m13)/ballSize.get(),
				(startMatrix.m23-resultMatrix.m23)/ballSize.get());
		gl2.glEnd();
	}
}
 
Example 12
Source File: Tessellation.java    From MeteoInfo with GNU Lesser General Public License v3.0 4 votes vote down vote up
public void display(GLAutoDrawable drawable) {
    GL2 gl = drawable.getGL().getGL2();

    gl.glClear(GL2.GL_COLOR_BUFFER_BIT);
    gl.glColor3f(1.0f, 1.0f, 1.0f);
    
    /*
 * jogl specific addition for tessellation
     */
    tessellCallBack tessCallback = new tessellCallBack(gl, glu);

    double rect[][] = new double[][]{ // [4][3] in C; reverse here
        {50.0, 50.0, 0.0},
        {200.0, 50.0, 0.0},
        {200.0, 200.0, 0.0},
        {50.0, 200.0, 0.0}};
    double tri[][] = new double[][]{// [3][3]
        {75.0, 75.0, 0.0},
        {125.0, 175.0, 0.0},
        {175.0, 75.0, 0.0}};
    double star[][] = new double[][]{// [5][6]; 6x5 in java
        {250.0, 50.0, 0.0, 1.0, 0.0, 1.0},
        {325.0, 200.0, 0.0, 1.0, 1.0, 0.0},
        {400.0, 50.0, 0.0, 0.0, 1.0, 1.0},
        {250.0, 150.0, 0.0, 1.0, 0.0, 0.0},
        {400.0, 150.0, 0.0, 0.0, 1.0, 0.0}};

    gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);

    startList = gl.glGenLists(2);

    GLUtessellator tobj = glu.gluNewTess();

    glu.gluTessCallback(tobj, GLU.GLU_TESS_VERTEX, tessCallback);// glVertex3dv);
    glu.gluTessCallback(tobj, GLU.GLU_TESS_BEGIN, tessCallback);// beginCallback);
    glu.gluTessCallback(tobj, GLU.GLU_TESS_END, tessCallback);// endCallback);
    glu.gluTessCallback(tobj, GLU.GLU_TESS_ERROR, tessCallback);// errorCallback);

    /* rectangle with triangular hole inside */
    gl.glNewList(startList, GL2.GL_COMPILE);
    gl.glShadeModel(GL2.GL_FLAT);
    glu.gluTessBeginPolygon(tobj, null);
    glu.gluTessBeginContour(tobj);
    glu.gluTessVertex(tobj, rect[0], 0, rect[0]);
    glu.gluTessVertex(tobj, rect[1], 0, rect[1]);
    glu.gluTessVertex(tobj, rect[2], 0, rect[2]);
    glu.gluTessVertex(tobj, rect[3], 0, rect[3]);
    glu.gluTessEndContour(tobj);
    glu.gluTessBeginContour(tobj);
    glu.gluTessVertex(tobj, tri[0], 0, tri[0]);
    glu.gluTessVertex(tobj, tri[1], 0, tri[1]);
    glu.gluTessVertex(tobj, tri[2], 0, tri[2]);
    glu.gluTessEndContour(tobj);
    glu.gluTessEndPolygon(tobj);
    gl.glEndList();

    glu.gluTessCallback(tobj, GLU.GLU_TESS_VERTEX, tessCallback);// vertexCallback);
    glu.gluTessCallback(tobj, GLU.GLU_TESS_BEGIN, tessCallback);// beginCallback);
    glu.gluTessCallback(tobj, GLU.GLU_TESS_END, tessCallback);// endCallback);
    glu.gluTessCallback(tobj, GLU.GLU_TESS_ERROR, tessCallback);// errorCallback);
    glu.gluTessCallback(tobj, GLU.GLU_TESS_COMBINE, tessCallback);// combineCallback);

    /* smooth shaded, self-intersecting star */
    gl.glNewList(startList + 1, GL2.GL_COMPILE);
    gl.glShadeModel(GL2.GL_SMOOTH);
    glu.gluTessProperty(tobj, //
            GLU.GLU_TESS_WINDING_RULE, //
            GLU.GLU_TESS_WINDING_POSITIVE);
    glu.gluTessBeginPolygon(tobj, null);
    glu.gluTessBeginContour(tobj);
    glu.gluTessVertex(tobj, star[0], 0, star[0]);
    glu.gluTessVertex(tobj, star[1], 0, star[1]);
    glu.gluTessVertex(tobj, star[2], 0, star[2]);
    glu.gluTessVertex(tobj, star[3], 0, star[3]);
    glu.gluTessVertex(tobj, star[4], 0, star[4]);
    glu.gluTessEndContour(tobj);
    glu.gluTessEndPolygon(tobj);
    gl.glEndList();
    glu.gluDeleteTess(tobj);
    
    gl.glCallList(startList);
    gl.glCallList(startList + 1);
    gl.glFlush();
}
 
Example 13
Source File: SkyBoxEntity.java    From Robot-Overlord-App with GNU General Public License v2.0 4 votes vote down vote up
public void render(GL2 gl2,CameraEntity camera) {		
	//gl2.glDisable(GL2.GL_DEPTH_TEST);
	gl2.glDisable(GL2.GL_LIGHTING);
	gl2.glDisable(GL2.GL_COLOR_MATERIAL);
	gl2.glEnable(GL2.GL_TEXTURE_2D);
	gl2.glPushMatrix();
		gl2.glColor3f(1, 1, 1);
		Vector3d p = camera.getPosition();
		gl2.glTranslated(-p.x,-p.y,-p.z);

		skyboxtextureXPos.render(gl2);
		gl2.glBegin(GL2.GL_TRIANGLE_FAN);
			gl2.glTexCoord2d(0,1);  gl2.glVertex3d(10, 10, 10);
			gl2.glTexCoord2d(1,1);  gl2.glVertex3d(10, -10, 10);
			gl2.glTexCoord2d(1,0);  gl2.glVertex3d(10, -10, -10);
			gl2.glTexCoord2d(0,0);  gl2.glVertex3d(10, 10, -10);
		gl2.glEnd();

		skyboxtextureXNeg.render(gl2);
		gl2.glBegin(GL2.GL_TRIANGLE_FAN);
			gl2.glTexCoord2d(0,1);  gl2.glVertex3d(-10, -10, 10);
			gl2.glTexCoord2d(1,1);  gl2.glVertex3d(-10, 10, 10);
			gl2.glTexCoord2d(1,0);  gl2.glVertex3d(-10, 10, -10);
			gl2.glTexCoord2d(0,0);  gl2.glVertex3d(-10, -10, -10);
		gl2.glEnd();

		skyboxtextureYPos.render(gl2);
		gl2.glBegin(GL2.GL_TRIANGLE_FAN);
			gl2.glTexCoord2d(0,1);  gl2.glVertex3d(-10, 10, 10);
			gl2.glTexCoord2d(1,1);  gl2.glVertex3d(10, 10, 10);
			gl2.glTexCoord2d(1,0);  gl2.glVertex3d(10, 10, -10);
			gl2.glTexCoord2d(0,0);  gl2.glVertex3d(-10, 10, -10);
		gl2.glEnd();

		skyboxtextureYNeg.render(gl2);
		gl2.glBegin(GL2.GL_TRIANGLE_FAN);
			gl2.glTexCoord2d(0,1);  gl2.glVertex3d(10, -10, 10);
			gl2.glTexCoord2d(1,1);  gl2.glVertex3d(-10, -10, 10);
			gl2.glTexCoord2d(1,0);  gl2.glVertex3d(-10, -10, -10);
			gl2.glTexCoord2d(0,0);  gl2.glVertex3d(10, -10, -10);
		gl2.glEnd();

		skyboxtextureZPos.render(gl2);
		gl2.glBegin(GL2.GL_TRIANGLE_FAN);
			gl2.glTexCoord2d(0,0);  gl2.glVertex3d(-10, 10, 10);
			gl2.glTexCoord2d(1,0);  gl2.glVertex3d( 10, 10, 10);
			gl2.glTexCoord2d(1,1);  gl2.glVertex3d( 10,-10, 10);
			gl2.glTexCoord2d(0,1);  gl2.glVertex3d(-10,-10, 10);
		gl2.glEnd();

		skyboxtextureZNeg.render(gl2);
		gl2.glBegin(GL2.GL_TRIANGLE_FAN);
			gl2.glTexCoord2d(0,0);  gl2.glVertex3d(-10,-10, -10);
			gl2.glTexCoord2d(1,0);  gl2.glVertex3d( 10,-10, -10);
			gl2.glTexCoord2d(1,1);  gl2.glVertex3d( 10, 10, -10);
			gl2.glTexCoord2d(0,1);  gl2.glVertex3d(-10, 10, -10);
		gl2.glEnd();
		
	gl2.glPopMatrix();
	gl2.glEnable(GL2.GL_DEPTH_TEST);
}
 
Example 14
Source File: SpideeLeg.java    From Robot-Overlord-App with GNU General Public License v2.0 4 votes vote down vote up
void render(GL2 gl2,int color_index) {
 float [] colors = {
   1,0,0,
   0,1,0,
   0,0,1,
   1,1,0,
   0,1,1,
   1,0,1
 };

 //*
 gl2.glDisable(GL2.GL_LIGHTING);

 gl2.glColor3f(colors[color_index*3],
	  colors[color_index*3+1],
	  colors[color_index*3+2]);
 // last point of contact
 gl2.glBegin(GL2.GL_LINE_LOOP);
 gl2.glVertex3d(lpoc.x+0.5f, lpoc.y-0.5f, 0);
 gl2.glVertex3d(lpoc.x+0.5f, lpoc.y+0.5f, 0);
 gl2.glVertex3d(lpoc.x-0.5f, lpoc.y+0.5f, 0);
 gl2.glVertex3d(lpoc.x-0.5f, lpoc.y-0.5f, 0);
 gl2.glEnd();
 gl2.glBegin(GL2.GL_LINES);
 gl2.glVertex3d(npoc.x-1.0f, npoc.y, 0);
 gl2.glVertex3d(npoc.x+1.0f, npoc.y, 0);
 gl2.glVertex3d(npoc.x, npoc.y-1.0f, 0);
 gl2.glVertex3d(npoc.x, npoc.y+1.0f, 0);
 gl2.glEnd();

 // next point of contact
 gl2.glBegin(GL2.GL_LINE_LOOP);
 gl2.glVertex3d(npoc.x+0.75f, npoc.y-0.75f, 0);
 gl2.glVertex3d(npoc.x+0.75f, npoc.y+0.75f, 0);
 gl2.glVertex3d(npoc.x-0.75f, npoc.y+0.75f, 0);
 gl2.glVertex3d(npoc.x-0.75f, npoc.y-0.75f, 0);
 gl2.glEnd();

 gl2.glBegin(GL2.GL_LINES);
 gl2.glVertex3d(ankle_joint.pos.x,ankle_joint.pos.y,ankle_joint.pos.z);
 gl2.glVertex3d(ankle_joint.pos.x,ankle_joint.pos.y,0);
 gl2.glEnd();

 pan_joint.Draw(gl2,2);
 tilt_joint.Draw(gl2,1);
 knee_joint.Draw(gl2,3);

 gl2.glEnable(GL2.GL_LIGHTING);
}
 
Example 15
Source File: J3DTriangle.java    From MeteoInfo with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public void display(GLAutoDrawable drawable) {
    final GL2 gl = drawable.getGL().getGL2();

    gl.glClear(GL2.GL_COLOR_BUFFER_BIT | GL2.GL_DEPTH_BUFFER_BIT);
    gl.glLoadIdentity();
    // Move triangle  
    gl.glTranslatef(-0.5f, 0.0f, -6.0f);
    gl.glRotatef(rotation, 0.0f, 1.0f, 0.0f);
    gl.glBegin(GL2.GL_TRIANGLES);

    // Front  
    gl.glColor3f(1.0f, 1.0f, 0.0f); // Yellow  
    gl.glVertex3f(1.5f, 2f, 0.0f); // Top Of Triangle   

    gl.glColor3f(0.0f, 1.5f, 0.0f); // Green  
    gl.glVertex3f(-1.5f, -1.5f, 1.5f); // Left Of Triangle   

    gl.glColor3f(1.0f, 0.0f, 1.0f); // Purple  
    gl.glVertex3f(1.5f, -1.5f, 1.5f); // Right Of Triangle   

    // Right  
    gl.glColor3f(1.0f, 1.0f, 0.0f); // Yellow  
    gl.glVertex3f(1.5f, 2.0f, 0.0f); // Top Of Triangle   

    gl.glColor3f(1.0f, 0.0f, 1.0f); // Purple  
    gl.glVertex3f(1.5f, -1.5f, 1.5f); // Left Of Triangle   

    gl.glColor3f(0.0f, 1.0f, 0.0f); // Green  
    gl.glVertex3f(1.5f, -1.5f, -1.5f); // Right Of Triangle   

    // Back  
    gl.glColor3f(1.0f, 1.0f, 0.0f); // Yellow  
    gl.glVertex3f(1.5f, 2.0f, 0.0f); // Top Of Triangle   

    gl.glColor3f(0.0f, 1.0f, 0.0f); // Green  
    gl.glVertex3f(1.5f, -1.5f, -1.5f); // Left Of Triangle   

    gl.glColor3f(1.0f, 0.0f, 1.0f); // Purple  
    gl.glVertex3f(-1.5f, -1.5f, -1.5f); // Right Of Triangle   

    //left  
    gl.glColor3f(1.0f, 1.0f, 0.0f); // Yellow  
    gl.glVertex3f(1.5f, 2.0f, 0.0f); // Top Of Triangle   

    gl.glColor3f(1.0f, 0.0f, 1.0f); // Purple  
    gl.glVertex3f(-1.5f, -1.5f, -1.5f); // Left Of Triangle   

    gl.glColor3f(0.0f, 1.0f, 0.0f); // Green  
    gl.glVertex3f(-1.5f, -1.5f, 1.5f); // Right Of Triangle   

    gl.glEnd();
    gl.glFlush();
    rotation += 0.6f;
}
 
Example 16
Source File: CubeTexture.java    From MeteoInfo with GNU Lesser General Public License v3.0 4 votes vote down vote up
private void drawImage(GL2 gl) {        
    
    gl.glColor3f(1f, 1f, 1f);
    gl.glBindTexture(GL2.GL_TEXTURE_2D, texture);
    gl.glBegin(GL2.GL_QUADS);
    // Front Face
    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.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.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.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.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.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();
}
 
Example 17
Source File: CubeTexture.java    From MeteoInfo with GNU Lesser General Public License v3.0 4 votes vote down vote up
private void drawBoxGridsTicksLabels(GL2 gl) {
        gl.glColor3f(0.0f, 0.0f, 0.0f);
        gl.glLineWidth(1.0f);
        gl.glBegin(GL2.GL_LINES);
        gl.glVertex3f(1f, 1f, -1f);
        gl.glVertex3f(-1.0f, 1.0f, -1.0f);
        gl.glEnd();
        gl.glBegin(GL2.GL_LINES);
        gl.glVertex3f(-1.0f, 1.0f, -1.0f);
        gl.glVertex3f(-1.0f, 1.0f, 1.0f);
        gl.glEnd();
        gl.glBegin(GL2.GL_LINES);
        gl.glVertex3f(-1.0f, 1.0f, 1.0f);
        gl.glVertex3f(1.0f, 1.0f, 1.0f);
        gl.glEnd();
        gl.glBegin(GL2.GL_LINES);
        gl.glVertex3f(1.0f, 1.0f, 1.0f);
        gl.glVertex3f(1f, 1f, -1f);
        gl.glEnd();

        gl.glBegin(GL2.GL_LINES);
        gl.glVertex3f(1f, 1f, -1f);
        gl.glVertex3f(1f, -1f, -1f);
        gl.glEnd();
        gl.glBegin(GL2.GL_LINES);
        gl.glVertex3f(1f, -1f, -1f);
        gl.glVertex3f(1f, -1f, 1f);
        gl.glEnd();
        gl.glBegin(GL2.GL_LINES);
        gl.glVertex3f(1f, -1f, 1f);
        gl.glVertex3f(1f, 1f, 1f);
        gl.glEnd();

        gl.glBegin(GL2.GL_LINES);
        gl.glVertex3f(-1f, 1f, -1f);
        gl.glVertex3f(-1f, -1f, -1f);
        gl.glEnd();
        gl.glBegin(GL2.GL_LINES);
        gl.glVertex3f(-1f, -1f, -1f);
        gl.glVertex3f(1f, -1f, -1f);
        gl.glEnd();

        gl.glBegin(GL2.GL_LINES);
        gl.glVertex3f(-1f, 1f, 1f);
        gl.glVertex3f(-1f, -1f, 1f);
        gl.glEnd();
        gl.glBegin(GL2.GL_LINES);
        gl.glVertex3f(-1f, -1f, 1f);
        gl.glVertex3f(-1f, -1f, -1f);
        gl.glEnd();

        gl.glBegin(GL2.GL_LINES);
        gl.glVertex3f(-1f, -1f, 1f);
        gl.glVertex3f(1f, -1f, 1f);
        gl.glEnd();

//        gl.glColor3f(1.0f, 0.0f, 0.0f);
//        gl.glBegin(GL2.GL_LINES);
//        gl.glVertex3f(0f, 0f, -1f);
//        gl.glVertex3f(0f, 0f, 0f);
//        gl.glEnd();
    }
 
Example 18
Source File: J3DCube.java    From MeteoInfo with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public void display(GLAutoDrawable drawable) {

    final GL2 gl = drawable.getGL().getGL2();
    gl.glClear(GL2.GL_COLOR_BUFFER_BIT | GL2.GL_DEPTH_BUFFER_BIT);
    gl.glLoadIdentity();
    gl.glTranslatef(0f, 0f, -2.0f);

    gl.glRotatef(rotation, 1.0f, 1.0f, 1.0f);

    gl.glBegin(GL2.GL_QUADS);
    gl.glColor3f(0f, 0f, 1f); //Blue color  
    //Top Quadrilateral  
    gl.glVertex3f(0.5f, 0.5f, -0.5f); //Upper Right  
    gl.glVertex3f(-0.5f, 0.5f, -0.5f); // Upper Left  
    gl.glVertex3f(-0.5f, 0.5f, 0.5f); // Bottom Left  
    gl.glVertex3f(0.5f, 0.5f, 0.5f); // Bottom Right  
    //Below Quadrilateral  
    gl.glColor3f(1f, 0f, 0f); //Red color  
    gl.glVertex3f(0.5f, -0.5f, 0.5f); // Upper Right   
    gl.glVertex3f(-0.5f, -0.5f, 0.5f); // Upper Left   
    gl.glVertex3f(-0.5f, -0.5f, -0.5f); // Bottom Left   
    gl.glVertex3f(0.5f, -0.5f, -0.5f); // Bottom Right   
    //Front Quadrilateral  
    gl.glColor3f(0f, 1f, 0f); //Green color  
    gl.glVertex3f(0.5f, 0.5f, 0.5f); // Upper Right   
    gl.glVertex3f(-0.5f, 0.5f, 0.5f); // Upper Left   
    gl.glVertex3f(-0.5f, -0.5f, 0.5f); // Bottom Left   
    gl.glVertex3f(0.5f, -0.5f, 0.5f); // Bottom Right  
    //Back Quadrilateral  
    gl.glColor3f(1f, 1f, 0f); //Yellow  
    gl.glVertex3f(0.5f, -0.5f, -0.5f); // Bottom Left   
    gl.glVertex3f(-0.5f, -0.5f, -0.5f); // Bottom Right   
    gl.glVertex3f(-0.5f, 0.5f, -0.5f); // Upper Right   
    gl.glVertex3f(0.5f, 0.5f, -0.5f); // Upper Left   
    //Left Quadrilateral  
    gl.glColor3f(1f, 0f, 1f); //Purple  
    gl.glVertex3f(-0.5f, 0.5f, 0.5f); // Upper Right  
    gl.glVertex3f(-0.5f, 0.5f, -0.5f); // Upper Left   
    gl.glVertex3f(-0.5f, -0.5f, -0.5f); // Bottom Left   
    gl.glVertex3f(-0.5f, -0.5f, 0.5f); // Bottom Right   
    //Right Quadrilateral  
    gl.glColor3f(0f, 1f, 1f); //Cyan  
    gl.glVertex3f(0.5f, 0.5f, -0.5f); // Upper Right   
    gl.glVertex3f(0.5f, 0.5f, 0.5f); // Upper Left   
    gl.glVertex3f(0.5f, -0.5f, 0.5f); // Bottom Left   
    gl.glVertex3f(0.5f, -0.5f, -0.5f); // Bottom Right   
    gl.glEnd();
    gl.glFlush();

    rotation += 0.6f;
}
 
Example 19
Source File: JCuboid.java    From MeteoInfo with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public void display(GLAutoDrawable drawable) {

    final GL2 gl = drawable.getGL().getGL2();
    gl.glClear(GL2.GL_COLOR_BUFFER_BIT | GL2.GL_DEPTH_BUFFER_BIT);
    gl.glLoadIdentity();
    gl.glTranslatef(0f, 0f, -5.0f);

    gl.glRotatef(rotation, 1.0f, 1.0f, 1.0f);

    gl.glBegin(GL2.GL_QUADS);
    gl.glColor3f(1f, 0f, 0f); //red color  

    //Top  
    gl.glVertex3f(-1f, 0.8f, 0.5f);
    gl.glVertex3f(-0.5f, 0.8f, 0.5f);
    gl.glVertex3f(-1f, 0.5f, 0.5f);
    gl.glVertex3f(-0.5f, 0.5f, 0.5f);

    //Bottom  
    gl.glVertex3f(-1f, 0.8f, 0.9f);
    gl.glVertex3f(-1f, 0.5f, 0.9f);
    gl.glVertex3f(-0.5f, 0.5f, 0.9f);
    gl.glVertex3f(-0.5f, 0.8f, 0.9f);

    //Front  
    gl.glVertex3f(-0.5f, 0.8f, 0.5f);
    gl.glVertex3f(-1f, 0.8f, 0.5f);
    gl.glVertex3f(-1f, 0.8f, 0.9f);
    gl.glVertex3f(-0.5f, 0.8f, 0.9f);
    //Back  

    gl.glVertex3f(-0.5f, 0.5f, 0.5f);
    gl.glVertex3f(-1f, 0.5f, 0.5f);
    gl.glVertex3f(-1f, 0.5f, 0.9f);
    gl.glVertex3f(-0.5f, 0.5f, 0.9f);

    //Left  
    gl.glVertex3f(-0.5f, 0.8f, 0.9f);
    gl.glVertex3f(-0.5f, 0.8f, 0.5f);
    gl.glVertex3f(-0.5f, 0.5f, 0.9f);
    gl.glVertex3f(-0.5f, 0.5f, 0.5f);

    //Right  
    gl.glVertex3f(-1f, 0.8f, 0.9f);
    gl.glVertex3f(-1f, 0.8f, 0.5f);
    gl.glVertex3f(-1f, 0.5f, 0.5f);
    gl.glVertex3f(-1f, 0.5f, 0.9f);
    gl.glEnd();
    gl.glFlush();

    rotation -= 0.15f;
}