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


Java GL2.glRotated方法代碼示例

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


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

示例1: draw

import javax.media.opengl.GL2; //導入方法依賴的package包/類
/**
 * Draws this robot on the screen.
 *
 * @param gl          The instance of GL2 responsible for drawing the robot
 *                    on the screen.
 * @param glut        An instance of GLUT to optionally aid in drawing the
 *                    robot body.
 * @param stickFigure If true, the robot must draw itself as a stick figure
 *                    rather than a solid body.
 * @param tAnim       Time since the start of the animation in seconds.
 * @param lighting    The Lighting instance responsible for calculating the
 *                    lighting in this scene. Can be used to set the color
 *                    of bodies before drawing them.
 */
public void draw(GL2 gl, GLUT glut, boolean stickFigure, float tAnim, Lighting lighting) {
    lighting.setMaterial(gl, getMaterial());
    gl.glPushMatrix();
    {
        gl.glTranslated(position.x(), position.y(), position.z());
        final double rotationDotY = direction.dot(Vector.Y) / (direction.length() * Vector.Y.length());
        final double rotationDotX = direction.dot(Vector.X) / (direction.length() * Vector.X.length());
        final double rotationAngle = Math.toDegrees(Math.acos(rotationDotY));
        gl.glRotated((rotationDotX > 0d) ? (-rotationAngle) : (rotationAngle), Vector.Z.x(), Vector.Z.y(), Vector.Z.z());
        final double elevationDot = direction.dot(Vector.Z) / (direction.length() * Vector.Z.length());
        final double elevationAngle = Math.toDegrees(Math.asin(elevationDot));
        gl.glRotated(elevationAngle, Vector.X.x(), Vector.X.y(), Vector.X.z());
        robotBody.draw(gl, glut, stickFigure, tAnim);
    }
    gl.glPopMatrix();
}
 
開發者ID:ABoschman,項目名稱:2IV60_RobotRace,代碼行數:31,代碼來源:Robot.java

示例2: render

import javax.media.opengl.GL2; //導入方法依賴的package包/類
protected void render(DrawContext dc, Vec4 point, double radius)
		{
			dc.getView().pushReferenceCenter(dc, point);
			
			//GL gl = dc.getGL();
			GL2 gl = dc.getGL().getGL2(); // GL initialization checks for GL2 compatibility.

			gl.glScaled(radius, radius, radius);
			gl.glRotated(lon, 0, 1, 0);
			gl.glRotated(lat, -1, 0, 0);

//			drawFMS(dc, strike, dip, rake, strike2, dip2, rake2);
			
			if (dc.isPickingMode())
			{
				Color color = dc.getUniquePickColor();
				pickSupport.addPickableObject(color.getRGB(),
						eq, 
						position, 
						false);
				gl.glColor3ub((byte) color.getRed(), (byte) color.getGreen(), (byte) color.getBlue());
			} else
				gl.glColor3f(1,1,1);
			
			gl.glCallList(this.glListId);
			gl.glCallList(this.glListId+1);
			
			if (!dc.isPickingMode())
				gl.glColor3f(0,0,0);
			gl.glCallList(this.glListId+2);
			gl.glCallList(this.glListId+3);
			
//			GL gl = dc.getGL();
//			gl.glBegin(GL.GL_LINES);
//			gl.glVertex2f(0, 4);
//			gl.glVertex2d(0, 0);
//			gl.glEnd();
			
			dc.getView().popReferenceCenter(dc);
		}
 
開發者ID:iedadata,項目名稱:geomapapp,代碼行數:41,代碼來源:FMSRenderer.java

示例3: drawHips

import javax.media.opengl.GL2; //導入方法依賴的package包/類
private void drawHips(GL2 gl, GLUT glut, boolean stickFigure, Animation animation) {
    for (int i = 0; i < NR_HIP_JOINTS; i++) {
        gl.glRotated(getPartialHipAngle(animation), -1d, 0d, 0d);
        limb.drawSegment(gl, glut, stickFigure);
        gl.glTranslated(0d, 0d, Limb.HEIGHT_OUTER_SEGMENT);
    }
}
 
開發者ID:ABoschman,項目名稱:2IV60_RobotRace,代碼行數:8,代碼來源:Leg.java

示例4: drawKnees

import javax.media.opengl.GL2; //導入方法依賴的package包/類
private void drawKnees(GL2 gl, GLUT glut, boolean stickFigure, Animation animation) {
    for (int i = 0; i < NR_KNEE_JOINTS; i++) {
        gl.glRotated(getPartialKneeAngle(animation), -1d, 0d, 0d);
        limb.drawSegment(gl, glut, stickFigure);
        gl.glTranslated(0d, 0d, Limb.HEIGHT_OUTER_SEGMENT);
    }
}
 
開發者ID:ABoschman,項目名稱:2IV60_RobotRace,代碼行數:8,代碼來源:Leg.java

示例5: drawAnkles

import javax.media.opengl.GL2; //導入方法依賴的package包/類
private void drawAnkles(GL2 gl, GLUT glut, boolean stickFigure, Animation animation) {
    for (int i = 0; i < NR_ANKLE_JOINTS + 1; i++) {
        gl.glRotated(getPartialAnkleAngle(animation), -1d, 0d, 0d);
        if (i == NR_ANKLE_JOINTS) {
            limb.drawFoot(gl, stickFigure);
        } else {
            limb.drawSegment(gl, glut, stickFigure);
            gl.glTranslated(0d, 0d, Limb.HEIGHT_OUTER_SEGMENT);
        }
    }
}
 
開發者ID:ABoschman,項目名稱:2IV60_RobotRace,代碼行數:12,代碼來源:Leg.java

示例6: drawFoot

import javax.media.opengl.GL2; //導入方法依賴的package包/類
public void drawFoot(GL2 gl, boolean stickFigure) {
    gl.glPushMatrix();
    {
        gl.glTranslated(0d, 0d, HEIGHT_FOOT);
        gl.glRotated(180d, 1d, 0d, 0d);
        footBody.draw(gl);
    }
    gl.glPopMatrix();
}
 
開發者ID:ABoschman,項目名稱:2IV60_RobotRace,代碼行數:10,代碼來源:Limb.java

示例7: drawShoulders

import javax.media.opengl.GL2; //導入方法依賴的package包/類
private void drawShoulders(GL2 gl, GLUT glut, boolean stickFigure, Animation animation) {
    for (int i = 0; i < NR_SHOULDER_JOINTS; i++) {
        gl.glRotated(getPartialShoulderAngle(animation), horizontalTurningAxis.x(), horizontalTurningAxis.y(), horizontalTurningAxis.z());
        gl.glRotated(45, verticalTurningAxis.x(), verticalTurningAxis.y(), verticalTurningAxis.z());
        limb.drawSegment(gl, glut, stickFigure);
        gl.glTranslated(0, 0, Limb.HEIGHT_OUTER_SEGMENT);
    }
}
 
開發者ID:ABoschman,項目名稱:2IV60_RobotRace,代碼行數:9,代碼來源:Arm.java

示例8: drawElbows

import javax.media.opengl.GL2; //導入方法依賴的package包/類
private void drawElbows(GL2 gl, GLUT glut, boolean stickFigure, Animation animation) {
    for (int i = 0; i < NR_ELBOW_JOINTS; i++) {
        gl.glRotated(getPartialElbowAngle(animation), 1f, 0f, 0.7f * horizontalTurningAxis.z());
        limb.drawSegment(gl, glut, stickFigure);
        gl.glTranslated(0d, 0d, Limb.HEIGHT_OUTER_SEGMENT);
    }
}
 
開發者ID:ABoschman,項目名稱:2IV60_RobotRace,代碼行數:8,代碼來源:Arm.java

示例9: drawWrists

import javax.media.opengl.GL2; //導入方法依賴的package包/類
private void drawWrists(GL2 gl, GLUT glut, boolean stickFigure, Animation animation) {
    for (int i = 0; i < NR_WRIST_JOINTS + 1; i++) {
        gl.glRotated(getPartialWristAngle(animation), 0.1f, 0.5f * horizontalTurningAxis.z(), 0d);
        if (i == NR_WRIST_JOINTS) {
            limb.drawHand(gl, stickFigure);
        } else {
            limb.drawSegment(gl, glut, stickFigure);
            gl.glTranslated(0d, 0d, Limb.HEIGHT_OUTER_SEGMENT);
        }
    }
}
 
開發者ID:ABoschman,項目名稱:2IV60_RobotRace,代碼行數:12,代碼來源:Arm.java

示例10: draw

import javax.media.opengl.GL2; //導入方法依賴的package包/類
public void draw(GL2 gl, Lighting lighting, Foliage foliage, int requiredDetailLevel, int depth) {
    gl.glPushMatrix();
    gl.glTranslated(0d, 0d, zTranslation);
    gl.glRotated(zRotation, 0d, 0d, 1d);
    gl.glRotated(yRotation, 0d, 1d, 0d);
    gl.glPushMatrix();
    if (isLeaf) {
        final float scaleMultiplier = (requiredDetailLevel == 0) ? (4f) : ((requiredDetailLevel == 1) ? (2f) : (1f));
        gl.glScaled(scale.x() * scaleMultiplier, scale.y() * scaleMultiplier, scale.z() * scaleMultiplier);
        gl.glTranslated(sidewaysTranslation, 0d, 0d);
        gl.glRotated(zRotation, 0d, 0d, 1d);
        foliage.drawLeaf(gl);
    } else {
        gl.glScaled(scale.x(), scale.y(), scale.z());
        foliage.drawBranch(gl, calcRequiredDetailForBranch(requiredDetailLevel, (float) scale.x()));
    }
    gl.glPopMatrix();
    final int maxNodes = (requiredDetailLevel == 0) ? (1)
            : ((requiredDetailLevel == 1) ? (4)
                    : ((requiredDetailLevel == 2) ? (10)
                            : (Integer.MAX_VALUE)));
    if (!childLeafs.isEmpty()) {
        lighting.setMaterial(gl, Material.LEAF);
        childLeafs.stream().limit(maxNodes).forEach((node) -> node.draw(gl, lighting, foliage, requiredDetailLevel, depth + 1));
        lighting.setMaterial(gl, Material.BARK);
    }
    if (!keepGoing(requiredDetailLevel, depth)) {
        gl.glPopMatrix();
        return;
    }
    childBranches.stream().limit(maxNodes).forEach((child) -> child.draw(gl, lighting, foliage, requiredDetailLevel, depth + 1));
    gl.glPopMatrix();
}
 
開發者ID:ABoschman,項目名稱:2IV60_RobotRace,代碼行數:34,代碼來源:Tree.java

示例11: drawAxisLabel

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

		gl.glPushMatrix();
//		this.orient( gl );

		final double[] o = this.config.getRenderingConfig().getNameOrientation();
		if( o != null )
		{
			for( int i = 0; i < o.length; i += 4 )
				gl.glRotated( o[i], o[i+1],	o[i+2], o[i+3] );
		}

		this.textRenderer.begin3DRendering();
		{
			gl.glMatrixMode( GLMatrixFunc.GL_MODELVIEW );

			// TODO: Text colour and size
			this.textRenderer.setColor( 1.0f, 0.2f, 0.2f, 0.8f );
			final float scale = 0.003f;

			final Rectangle2D nameBounds = this.textRenderer.getBounds( config.getName() );
			this.textRenderer.draw3D( config.getName(), (float)(1-nameBounds.getWidth()*scale),
					(float)(-nameBounds.getHeight()*scale)
					*config.getRenderingConfig().getNameDirection(), 0.1f, scale );
		}
		this.textRenderer.end3DRendering();
		gl.glPopMatrix();
	}
 
開發者ID:openimaj,項目名稱:openimaj,代碼行數:32,代碼來源:AxisRenderer3D.java

示例12: orient

import javax.media.opengl.GL2; //導入方法依賴的package包/類
private void orient( final GL2 gl )
{
	if( this.config.getOrientation()[0] != 0 )
	{
		gl.glMatrixMode( GLMatrixFunc.GL_MODELVIEW );
		final double[] o = this.config.getOrientation();
		for( int i = 0; i < o.length; i+=4 )
			gl.glRotated( o[i], o[i+1], o[i+2], o[i+3] );
	}
}
 
開發者ID:openimaj,項目名稱:openimaj,代碼行數:11,代碼來源:AxisRenderer3D.java

示例13: applyRunningTransformation

import javax.media.opengl.GL2; //導入方法依賴的package包/類
private void applyRunningTransformation(GL2 gl, Animation animation) {
    final double fractionInRadians = animation.getLinearInterpolation() * 2f * Math.PI;
    final double bobbingUpAndDownHeight = 0.05f * Math.abs(Math.sin(fractionInRadians));
    gl.glTranslated(0d, 0d, bobbingUpAndDownHeight);
    gl.glRotated(RUNNING_ANGLE, 1d, 0d, 0d);
}
 
開發者ID:ABoschman,項目名稱:2IV60_RobotRace,代碼行數:7,代碼來源:Torso.java

示例14: plotObject

import javax.media.opengl.GL2; //導入方法依賴的package包/類
/**
 *	{@inheritDoc}
 * 	@see org.openimaj.vis.general.ItemPlotter3D#plotObject(javax.media.opengl.GLAutoDrawable, org.openimaj.vis.general.XYZVisualisation3D.LocatedObject3D, org.openimaj.vis.general.AxesRenderer3D)
 */
@Override
public void plotObject( final GLAutoDrawable drawable, final LocatedObject3D<Rectangle3D> object,
		final AxesRenderer3D renderer )
{
	// object.object.x,y,z is where we plot the rectangle.
	// object.x,y,z is the data point position.
	final double[] p = renderer.calculatePosition( new double[]
			{ object.object.x, object.object.y, object.object.z } );
	final double[] p2 = renderer.calculatePosition( new double[]
			{ object.x, object.y, object.z } );

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

	gl.glPushMatrix();

	// Translate to the position of the rectangle
	gl.glMatrixMode( GLMatrixFunc.GL_MODELVIEW );
	gl.glTranslated( p2[0], p2[1], p2[2] );
	gl.glRotated( object.object.xRotation, 1, 0, 0 );
	gl.glRotated( object.object.yRotation, 0, 1, 0 );
	gl.glRotated( object.object.zRotation, 0, 0, 1 );

	final double[] dims = renderer.scaleDimension( new double[]{object.object.width,object.object.height,0} );
	final double w = dims[0];
	final double h = dims[1];

	gl.glBegin( GL.GL_LINE_LOOP );
	gl.glVertex3d( p2[0]-p[0], p2[1]-p[1], 0 );
	gl.glVertex3d( p2[0]-p[0]-w, p2[1]-p[1], 0 );
	gl.glVertex3d( p2[0]-p[0]-w, p2[1]-p[1]-h, 0 );
	gl.glVertex3d( p2[0]-p[0], p2[1]-p[1]-h, 0 );
	gl.glEnd();

	gl.glPopMatrix();

	if( this.pos == RectanglePlotPosition.CENTRAL && this.drawDotAtPoint )
	{
		gl.glPushMatrix();
		gl.glMatrixMode( GLMatrixFunc.GL_MODELVIEW );
		gl.glBegin( GL.GL_POINTS );
		gl.glVertex3d( p2[0], p2[1], p2[2] );
		gl.glEnd();
		gl.glPopMatrix();
	}
}
 
開發者ID:openimaj,項目名稱:openimaj,代碼行數:50,代碼來源:Rectangle3DPlotter.java

示例15: setRightLegMountPoint

import javax.media.opengl.GL2; //導入方法依賴的package包/類
/**
 * Adds a transformation to the given GL2 instance. It is assumed that the
 * current coordinate system is based at the torso anchor point. This method
 * will transform to the mounting point of the right leg.
 *
 * @param gl The instance of GL2 responsible for drawing the body.
 */
public void setRightLegMountPoint(GL2 gl) {
    gl.glTranslated(LEG_OFFCENTER, 0d, 0d);
    gl.glRotated(180d, 1d, 0d, 0d);
}
 
開發者ID:ABoschman,項目名稱:2IV60_RobotRace,代碼行數:12,代碼來源:Torso.java


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