当前位置: 首页>>代码示例>>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;未经允许,请勿转载。