當前位置: 首頁>>代碼示例>>Java>>正文


Java GL2.glPushMatrix方法代碼示例

本文整理匯總了Java中javax.media.opengl.GL2.glPushMatrix方法的典型用法代碼示例。如果您正苦於以下問題:Java GL2.glPushMatrix方法的具體用法?Java GL2.glPushMatrix怎麽用?Java GL2.glPushMatrix使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.media.opengl.GL2的用法示例。


在下文中一共展示了GL2.glPushMatrix方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: drawVertex

import javax.media.opengl.GL2; //導入方法依賴的package包/類
private Vector3f drawVertex(Vector3f vert, double size, float[] color, GL2 gl, GLUT glut) {
    gl.glMaterialfv(GL.GL_FRONT_AND_BACK, GL2.GL_AMBIENT, color, 0);
    gl.glMaterialfv(GL.GL_FRONT_AND_BACK, GL2.GL_DIFFUSE, color, 0);
    gl.glMaterialf(GL.GL_FRONT_AND_BACK, GL2.GL_SHININESS, 10);

    gl.glPushAttrib(GL2.GL_LIGHTING_BIT);
    gl.glDisable(GL2.GL_TEXTURE_2D);
    gl.glEnable(GL2.GL_LIGHTING);

    gl.glPushMatrix();
    gl.glTranslatef(vert.getX(), vert.getY(), vert.getZ());

    glut.glutSolidSphere(size, 20, 20);
    gl.glPopMatrix();

    gl.glEnable(GL2.GL_TEXTURE_2D);
    gl.glDisable(GL2.GL_LIGHTING);
    gl.glPopAttrib();

    return vert;
}
 
開發者ID:Fidentis,項目名稱:Analyst,代碼行數:22,代碼來源:PApainting.java

示例2: drawCylinder

import javax.media.opengl.GL2; //導入方法依賴的package包/類
private void drawCylinder(Vector3f from, Vector3f to, GL2 gl, GLUT glut) {
    Vector3f zAxis = new Vector3f(0, 0, 1);
    Vector3f vector = new Vector3f(to.x - from.x, to.y - from.y, to.z - from.z);
    float length = vector.length();
    vector.normalize();
    float angle = zAxis.angle(vector);
    Vector3f axis = new Vector3f();
    axis.cross(zAxis, vector);
    float convert = (float) (180f / Math.PI);

    gl.glPushMatrix();

    gl.glTranslatef(from.x, from.y, from.z);
    gl.glRotatef(angle * convert, axis.x, axis.y, axis.z);
    glut.glutSolidCylinder(info.getPointSize() / 4.5, length - info.getPointSize(), 20, 20);
    gl.glPopMatrix();

}
 
開發者ID:Fidentis,項目名稱:Analyst,代碼行數:19,代碼來源:PApainting.java

示例3: drawCylinder

import javax.media.opengl.GL2; //導入方法依賴的package包/類
private void drawCylinder(GLUT glut, GL2 gl, Vector3f from, Vector3f to) {

        Vector3f zAxis = new Vector3f(0, 0, 1);
        Vector3f vector1 = new Vector3f(to.x - from.x, to.y - from.y, to.z - from.z);
        float length = vector1.length();
        vector1.normalize();
        float angle = zAxis.angle(vector1);
        Vector3f axis = new Vector3f();
        axis.cross(zAxis, vector1);
        float convert = (float) (180f / Math.PI);

        gl.glPushMatrix();
        gl.glTranslatef(from.x, from.y, from.z);
        gl.glRotatef(angle * convert, axis.x, axis.y, axis.z);
        glut.glutSolidCylinder(0.5f, length - 0.5f, 20, 5);
        //glut.glutSolidCylinder(0.5f, 10, 20, 5);
        gl.glPopMatrix();

    }
 
開發者ID:Fidentis,項目名稱:Analyst,代碼行數:20,代碼來源:HDpainting.java

示例4: drawWithoutTextures

import javax.media.opengl.GL2; //導入方法依賴的package包/類
/**
 *
 * @param gl
 * @param dropFaces faces to be hidden when rendering model.
 */
public void drawWithoutTextures(GL2 gl, ArrayList<Integer> dropFaces) {

    gl.glPushMatrix();
    gl.glPushAttrib(GL2.GL_LIGHTING_BIT);
    for (int i = 0; i < faces.getNumFaces(); i++) {

        gl.glDisable(GL2.GL_TEXTURE_2D);
        gl.glEnable(GL2.GL_LIGHTING);

        faces.renderFace(i, flipTexCoords, gl);

        gl.glEnable(GL2.GL_TEXTURE_2D);
        gl.glDisable(GL2.GL_LIGHTING);

    }
    gl.glPopAttrib();
    gl.glPopMatrix();

}
 
開發者ID:Fidentis,項目名稱:Analyst,代碼行數:25,代碼來源:Model.java

示例5: renderVis

import javax.media.opengl.GL2; //導入方法依賴的package包/類
@Override
protected void renderVis( final GLAutoDrawable drawable )
{
	if( drawable == null || this.axesRenderer == null ) return;

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

	this.axesRenderer.renderAxis( drawable );

	final List<LocatedObject3D<D>> x = new ArrayList<XYZVisualisation3D.LocatedObject3D<D>>();
	x.addAll( this.data );
	for( final LocatedObject3D<D> d : x )
	{
		gl.glPushMatrix();
		this.plotter.plotObject( drawable, d, this.axesRenderer );
		gl.glPopMatrix();
	}
}
 
開發者ID:openimaj,項目名稱:openimaj,代碼行數:19,代碼來源:XYZVisualisation3D.java

示例6: draw

import javax.media.opengl.GL2; //導入方法依賴的package包/類
/**
 * Draws the terrain.
 *
 * @param gl       The instance of GL2 responsible for drawing the body.
 * @param glut     An instance of GLUT that can be optionally used to assist
 *                 in drawing.
 * @param camPos   The position of the camera in world coordinates.
 * @param lighting The Lighting instance responsible for calculating the
 *                 lighting in this scene. Can be used to set the colours of
 *                 bodies before drawing them.
 */
public void draw(GL2 gl, GLUT glut, Vector camPos, Lighting lighting) {
    gl.glPushMatrix();
    {
        gl.glTranslated(TERRAIN_LEVEL.x(), TERRAIN_LEVEL.y(), TERRAIN_LEVEL.z());
        gl.glEnable(GL_CULL_FACE);
        lighting.setMaterial(gl, Material.DIRT, true);
        terrainBody.draw(gl);
        lighting.setMaterial(gl, Material.WATER);
        waterBody.draw(gl);
        gl.glDisable(GL_CULL_FACE);
        final Vector camPosRelativeToTerrain = camPos.subtract(TERRAIN_LEVEL);
        trees.stream().forEach((tree) -> tree.draw(gl, camPosRelativeToTerrain, lighting));
    }
    gl.glPopMatrix();
}
 
開發者ID:ABoschman,項目名稱:2IV60_RobotRace,代碼行數:27,代碼來源:Terrain.java

示例7: display

import javax.media.opengl.GL2; //導入方法依賴的package包/類
public void display(GLAutoDrawable drawable) 
{
  GL2 gl = drawable.getGL().getGL2();
  switch(cmd)
    {
    case UPDATE:
      drawScene(gl);
      break;
    case SELECT:
      int buffsize = 512;
      double x = (double) mouse_x, y = (double) mouse_y;
      int[] viewPort = new int[4];
      IntBuffer selectBuffer = Buffers.newDirectIntBuffer(buffsize);
      int hits = 0;
      gl.glGetIntegerv(GL2.GL_VIEWPORT, viewPort, 0);
      gl.glSelectBuffer(buffsize, selectBuffer);
      gl.glRenderMode(GL2.GL_SELECT);
      gl.glInitNames();
      gl.glMatrixMode(GL2.GL_PROJECTION);
      gl.glPushMatrix();
      gl.glLoadIdentity();
      glu.gluPickMatrix(x, (double) viewPort[3] - y, 5.0d, 5.0d, viewPort, 0);
      glu.gluOrtho2D(0.0d, 1.0d, 0.0d, 1.0d);
      drawScene(gl);
      gl.glMatrixMode(GL2.GL_PROJECTION);
      gl.glPopMatrix();
      gl.glFlush();
      hits = gl.glRenderMode(GL2.GL_RENDER);
      processHits(hits, selectBuffer);
      cmd = UPDATE;
      break;
    }
}
 
開發者ID:ec-europa,項目名稱:sumo,代碼行數:34,代碼來源:Picking.java

示例8: beginDrawLasso

import javax.media.opengl.GL2; //導入方法依賴的package包/類
private void beginDrawLasso(DrawContext dc) {
	//GL gl = dc.getGL();
	GL2 gl = dc.getGL().getGL2(); // GL initialization checks for GL2 compatibility.

	int attributeMask =
		GL.GL_DEPTH_BUFFER_BIT // for depth test, depth mask and depth func
			| GL2.GL_TRANSFORM_BIT // for modelview and perspective
			| GL2.GL_VIEWPORT_BIT // for depth range
			| GL2.GL_CURRENT_BIT // for current color
			| GL2.GL_COLOR_BUFFER_BIT // for alpha test func and ref, and blend
			| GL2.GL_DEPTH_BUFFER_BIT // for depth func
			| GL2.GL_ENABLE_BIT; // for enable/disable changes
	gl.glPushAttrib(attributeMask);

	// Apply the depth buffer but don't change it.
	gl.glEnable(GL.GL_DEPTH_TEST);
	gl.glDepthFunc(GL.GL_ALWAYS);
	gl.glDepthMask(false);

	// Load a parallel projection with dimensions (viewportWidth, viewportHeight)
	int[] viewport = new int[4];
	gl.glGetIntegerv(GL.GL_VIEWPORT, viewport, 0);
	gl.glMatrixMode(GL2.GL_PROJECTION);
	gl.glPushMatrix();
	gl.glLoadIdentity();
	gl.glOrtho(0d, viewport[2], 0d, viewport[3], -1d, 1d);

	gl.glMatrixMode(GL2.GL_MODELVIEW);
	gl.glPushMatrix();
}
 
開發者ID:iedadata,項目名稱:geomapapp,代碼行數:31,代碼來源:LassoSelectionHandler.java

示例9: displace

import javax.media.opengl.GL2; //導入方法依賴的package包/類
/**
 *
 * @param openGl
 */
public void displace(final GL2 openGl) {
    openGl.glPushMatrix();
    openGl.glTranslatef(position[0], position[1], position[2]);
    xAxis.rotateAround(openGl);
    yAxis.rotateAround(openGl);
    zAxis.rotateAround(openGl);

}
 
開發者ID:Fidentis,項目名稱:Analyst,代碼行數:13,代碼來源:MeshDisplacment.java

示例10: drawArrow

import javax.media.opengl.GL2; //導入方法依賴的package包/類
private void drawArrow(Vector3f from, Vector3f to, float[] color, GL2 gl, GLUT glut) {
    Vector3f zAxis = new Vector3f(0, 0, 1);
    Vector3f vector = new Vector3f(to.x - from.x, to.y - from.y, to.z - from.z);
    float length = vector.length();
    vector.normalize();
    float angle = zAxis.angle(vector);
    Vector3f axis = new Vector3f();
    axis.cross(zAxis, vector);
    float convert = (float) (180f / Math.PI);

    gl.glPushAttrib(GL2.GL_LIGHTING_BIT);
    gl.glDisable(GL2.GL_TEXTURE_2D);
    gl.glEnable(GL2.GL_LIGHTING);

    gl.glMaterialfv(GL.GL_FRONT_AND_BACK, GL2.GL_AMBIENT, color, 0);
    gl.glMaterialfv(GL.GL_FRONT_AND_BACK, GL2.GL_DIFFUSE, color, 0);
    gl.glMaterialf(GL.GL_FRONT_AND_BACK, GL2.GL_SHININESS, 10);

    gl.glPushMatrix();

    gl.glTranslatef(from.x, from.y, from.z);
    gl.glRotatef(angle * convert, axis.x, axis.y, axis.z);
    glut.glutSolidCylinder(info.getPointSize() / 3, length - info.getPointSize(), 20, 20);
    gl.glTranslatef(0, 0, length - info.getPointSize());
    glut.glutSolidCone(info.getPointSize(), info.getPointSize(), 20, 20);

    gl.glPopMatrix();

    gl.glEnable(GL2.GL_TEXTURE_2D);
    gl.glDisable(GL2.GL_LIGHTING);
    gl.glPopAttrib();
}
 
開發者ID:Fidentis,項目名稱:Analyst,代碼行數:33,代碼來源:PApainting.java

示例11: drawForShaders

import javax.media.opengl.GL2; //導入方法依賴的package包/類
public void drawForShaders(GL2 gl, ArrayList<VertexInfo> info, int shaderVertices, int shaderNormals, int shaderPrincipal, int shaderSecondary) {

        gl.glPushMatrix();
        for (int i = 0; i < faces.getNumFaces(); i++) {
            faces.renderFace(i, gl, info, shaderVertices, shaderNormals, shaderPrincipal, shaderSecondary);
        }
        gl.glPopMatrix();

    }
 
開發者ID:Fidentis,項目名稱:Analyst,代碼行數:10,代碼來源:Model.java

示例12: draw

import javax.media.opengl.GL2; //導入方法依賴的package包/類
/**
 *
 * @param gl
 */
public void draw(GL2 gl) {
    gl.glPushMatrix();
    gl.glPushAttrib(GL2.GL_LIGHTING_BIT);

    gl.glEnable(GL2.GL_LIGHTING);
    gl.glEnable(GL2.GL_TEXTURE_2D);

    if (materials != null) {
        materials.clearUsedMaterials();
    }
    // render the model face-by-face
    String faceMat;

    for (int i = 0; i < faces.getNumFaces(); i++) {

        faceMat = faces.findMaterial(i);      // get material used by face i
        if (faceMat != null && materials != null) {
            flipTexCoords = materials.renderWithMaterial(faceMat, gl);
        }  // render using that material

        faces.renderFace(i, flipTexCoords, gl);                  // draw face i
    }

    gl.glDisable(GL2.GL_TEXTURE_2D);
    gl.glEnable(GL2.GL_LIGHTING);

    gl.glPopAttrib();
    gl.glPopMatrix();

}
 
開發者ID:Fidentis,項目名稱:Analyst,代碼行數:35,代碼來源:Model.java

示例13: drawMinorTick

import javax.media.opengl.GL2; //導入方法依賴的package包/類
@Override
	public void drawMinorTick( final double location, final AxisConfig<float[]> config )
	{
		final GL2 gl = this.glad.getGL().getGL2();

		gl.glPushMatrix();

		this.orient( gl );

		final float zero = 0.001f;
		gl.glBegin( GL.GL_LINE_STRIP );
		{
//			gl.glEnable( GL2.GL_LINE_STIPPLE );
//			gl.glLineStipple( 2, (short) 0x00FF );
			gl.glLineWidth( (float)config.getRenderingConfig().getMinorTickThickness() );
			gl.glColor3f( config.getRenderingConfig().getMinorTickColour()[0],
					config.getRenderingConfig().getMinorTickColour()[1],
					config.getRenderingConfig().getMinorTickColour()[2] );

			final float l = (float)config.getRenderingConfig().getMinorTickLength();
			final float l2 = -l;

			final float ll = this.calculatePosition( location ).floatValue();

			// We draw in the x axis, so the orientation has to be set appropriately
			gl.glVertex3f( ll, l, zero );
			gl.glVertex3f( ll, l2, zero );
		}
		gl.glEnd();

		gl.glPopMatrix();
	}
 
開發者ID:openimaj,項目名稱:openimaj,代碼行數:33,代碼來源:AxisRenderer3D.java

示例14: draw

import javax.media.opengl.GL2; //導入方法依賴的package包/類
@Override
public void draw(GL2 gl, GLUT glut, boolean stickFigure, float tAnim) {
    animation.update(tAnim);
    gl.glPushMatrix();
    {
        final double legHeight = Limb.HEIGHT_OUTER_SEGMENT * Limb.RING_COUNT + Limb.HEIGHT_FOOT;
        gl.glTranslated(0d, 0d, legHeight);

        torso.draw(gl, glut, stickFigure, animation, backNumber);

        gl.glPushMatrix();
        {
            torso.setRightLegMountPoint(gl);
            rightLeg.draw(gl, glut, stickFigure, animation);
        }
        gl.glPopMatrix();
        gl.glPushMatrix();
        {
            torso.setLeftLegMountPoint(gl);
            leftLeg.draw(gl, glut, stickFigure, animation);
        }
        gl.glPopMatrix();
        gl.glPushMatrix();
        {
            torso.setRightArmMountPoint(gl);
            rightArm.draw(gl, glut, stickFigure, animation);
        }
        gl.glPopMatrix();
        gl.glPushMatrix();
        {
            torso.setLeftArmMountPoint(gl);
            leftArm.draw(gl, glut, stickFigure, animation);
        }
        gl.glPopMatrix();
    }
    gl.glPopMatrix();
}
 
開發者ID:ABoschman,項目名稱:2IV60_RobotRace,代碼行數:38,代碼來源:Bender.java

示例15: drawSegment

import javax.media.opengl.GL2; //導入方法依賴的package包/類
public void drawSegment(GL2 gl, GLUT glut, boolean stickFigure) {
    gl.glPushMatrix();
    if (stickFigure) {
        gl.glTranslated(0d, 0d, HEIGHT_OUTER_SEGMENT / 2f);
        gl.glScaled(RobotBody.STICK_THICKNESS, RobotBody.STICK_THICKNESS, HEIGHT_OUTER_SEGMENT);
        glut.glutSolidCube(1f);
    } else {
        outerSegmentBody.draw(gl);
        final double heightDifference = HEIGHT_OUTER_SEGMENT - HEIGHT_INNER_SEGMENT;
        gl.glTranslated(0d, 0d, heightDifference / 2f);
        innerSegmentBody.draw(gl);
    }
    gl.glPopMatrix();
}
 
開發者ID:ABoschman,項目名稱:2IV60_RobotRace,代碼行數:15,代碼來源:Limb.java


注:本文中的javax.media.opengl.GL2.glPushMatrix方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。