本文整理匯總了Java中javax.media.opengl.GL.glTranslated方法的典型用法代碼示例。如果您正苦於以下問題:Java GL.glTranslated方法的具體用法?Java GL.glTranslated怎麽用?Java GL.glTranslated使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.media.opengl.GL
的用法示例。
在下文中一共展示了GL.glTranslated方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: glOrientToPlane
import javax.media.opengl.GL; //導入方法依賴的package包/類
/**
* orient the scene to the sketch plane.
* @param gl
*/
public void glOrientToPlane(GL gl){
//gl.glLoadIdentity();
// align to origin
gl.glTranslated(origin.getX(), origin.getY(), origin.getZ());
// rotate to align planes
double xRot = getRotationX();
double yRot = getRotationY();
gl.glRotated(xRot*180.0/Math.PI, 1.0, 0.0, 0.0);
gl.glRotated(yRot*180.0/Math.PI, 0.0, 1.0, 0.0);
// rotate around z-axis to align 2D grid
double zRot = getRotationZ();
gl.glRotated(zRot*180.0/Math.PI, 0.0, 0.0, 1.0);
//System.out.println("xRot:" + xRot + " yRot:" + yRot + " zRot:" + zRot);
}
示例2: renderAgent
import javax.media.opengl.GL; //導入方法依賴的package包/類
/**
* Render agent at specified position
* @param gl
* @param position
*/
private void renderAgent(GL gl, GlColor color, Location position) {
gl.glPushMatrix();
{
gl.glTranslated(position.x, position.y, position.z);
// draw sphere
gl.glColor4d(color.r, color.g, color.b, color.a);
glu.gluSphere(quadratic, SPHERE_RADIUS, SPHERE_SLICES, SPHERE_STACKS);
IPogamutEnvironments environments = Lookup.getDefault().lookup(IPogamutEnvironments.class);
if (environments != null) {
Collection c = environments.getEnvironmentSelection(map).lookupAll(this.agent.getDataSource().getClass());
for (Object o : c) {
if (agent.getDataSource().equals(o)) {
gl.glColor3d(0.3, 0.3, 0.3);
glu.gluDisk(quadratic, SPHERE_RADIUS * 1.2, SPHERE_RADIUS * 1.5, 32, 3);
}
}
}
}
gl.glPopMatrix();
Rotation rot = agent.getRotation();
if (rot != null) {
renderRotation(gl, new GlColor(1, 0, 0), position, rot);
}
/* if (window == null) {
window = new GLTextWindow(gl, 100, 20, 200, 50, "Hi, this is a test text 1234567890");
}
window.render();
*/
}
示例3: renderPlacedMapEvent
import javax.media.opengl.GL; //導入方法依賴的package包/類
/**
* Render {@link MapEvent} that is placed at fixed place (=not at the player).
* @param gl
* @param color what color should be map event drawn.
* @param mapEvent map event to render.
*/
private void renderPlacedMapEvent(GL gl, GlColor color, MapEvent mapEvent) {
LogMapMark mapMark = mapEvent.getMark();
Location position = mapMark.getLocation();
if (logger.isLoggable(Level.FINE)) logger.fine(" MSG: " + mapMark.getMessage() + ", LOC: " + position);
// gl.glEnable(GL.GL_BLEND);
// gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA);
gl.glPushMatrix();
{
gl.glTranslated(position.x, position.y, position.z + SPHERE_RADIUS * 1.1);
gl.glColor4d(color.r, color.g, color.b, color.a);
// glu.gluSphere(quadratic, SPHERE_RADIUS * 3, SPHERE_SLICES, SPHERE_STACKS);
glu.gluCylinder(quadratic, SPHERE_RADIUS, SPHERE_RADIUS, 2*SPHERE_RADIUS, 4, 1);
}
gl.glPopMatrix();
gl.glDisable(GL.GL_DEPTH_TEST);
{
gl.glColor3d(0, 0, 0);
gl.glRasterPos3d(position.x, position.y, position.z);
glut.glutBitmapString(GLUT.BITMAP_HELVETICA_12, mapEvent.getMessage());
gl.glColor3d(1, 1, 1);
}
gl.glEnable(GL.GL_DEPTH_TEST);
// gl.glDisable(GL.GL_BLEND);
}
示例4: renderRotation
import javax.media.opengl.GL; //導入方法依賴的package包/類
/**
* Draw rotation arrow
* @param gl
* @param color What color should arrow be
* @param center Where is center of arrow
* @param rotation In what direction does arrow points
*/
private void renderRotation(GL gl, GlColor color, Location center, Rotation rotation) {
gl.glPushMatrix();
{
gl.glTranslated(center.x, center.y, center.z);
Location endOfArrow = rotation.toLocation().getNormalized().scale(SPHERE_RADIUS * 2.5);
gl.glBegin(GL.GL_LINES);
gl.glColor4d(color.r, color.g, color.b, color.a);
gl.glVertex3d(0, 0, 0);
gl.glVertex3d(endOfArrow.x, endOfArrow.y, endOfArrow.z);
gl.glEnd();
gl.glTranslated(endOfArrow.x, endOfArrow.y, endOfArrow.z);
// XXX: This works only in 2D, not 3D, because I am not in the mood
// to figure out direction of Roll, Yaw and Pitch as well as order of
// transformations. And rotation.toLocation() returns 2D coords anyway.
double yaw = rotation.getYaw() / 32767 * 180; // left right, aka around z
double roll = rotation.getRoll() / 32767 * 180; // clockwise/counter? around x
double pitch = rotation.getPitch() / 32767 * 180; // up and down, around y
/*
gl.glRotated(pitch, );
gl.glRotated(yaw, );
gl.glRotated(roll, );
*/
// return res.mul(pitch).mul(yaw).mul(roll);
if (logger.isLoggable(Level.FINE)) logger.fine(" Rotation: Yaw " + yaw + " roll " + roll + " pitch " + pitch);
//gl.glRotated(roll, 1,0,0);
gl.glRotated(yaw, 0, 0, 1);
//gl.glRotated(pitch, 0,1,0);
gl.glRotated(90, 0, 1, 0);
glut.glutSolidCone(20, 40, 16, 16);
}
gl.glPopMatrix();
}
示例5: testConvexize
import javax.media.opengl.GL; //導入方法依賴的package包/類
/**
* test the "Convexize polygon" routine. This should be able
* to take an arbitrary region and tesselate the polygon
* into a set of convex polygons for rendering in openGL.
* @param gl
*/
public static void testConvexize(GL gl){
gl.glLoadIdentity();
gl.glTranslated(-5.0, 0.0, 0.0);
Point2D ptA = new Point2D(0.0, 0.0);
Point2D ptB = new Point2D(2.0, 0.0);
Point2D ptC = new Point2D(2.0, 2.0);
Point2D ptD = new Point2D(1.1, 1.0);
Point2D ptE = new Point2D(2.0, 3.0);
Point2D ptF = new Point2D(3.0, 2.0);
Point2D ptG = new Point2D(2.5, 1.0);
Point2D ptH = new Point2D(2.5, 0.0);
Point2D ptI = new Point2D(4.0, 1.0);
Point2D ptJ = new Point2D(3.0, 3.0);
Point2D ptK = new Point2D(2.0, 4.0);
Point2D ptL = new Point2D(0.0, 2.0);
Point2D ptM = new Point2D(-1.0, 1.0);
Prim2DLine l1 = new Prim2DLine(ptA, ptB);
Prim2DLine l2 = new Prim2DLine(ptB, ptC);
Prim2DLine l3 = new Prim2DLine(ptC, ptD);
Prim2DLine l4 = new Prim2DLine(ptD, ptE);
Prim2DLine l5 = new Prim2DLine(ptE, ptF);
Prim2DLine l6 = new Prim2DLine(ptF, ptG);
Prim2DLine l7 = new Prim2DLine(ptG, ptH);
Prim2DLine l8 = new Prim2DLine(ptH, ptI);
Prim2DLine l9 = new Prim2DLine(ptI, ptJ);
Prim2DLine l10 = new Prim2DLine(ptJ, ptK);
Prim2DLine l11 = new Prim2DLine(ptK, ptL);
Prim2DLine l12 = new Prim2DLine(ptL, ptM);
Prim2DLine l13 = new Prim2DLine(ptM, ptA);
Prim2DCycle cycle = new Prim2DCycle();
cycle.add(l1);
cycle.add(l2);
cycle.add(l3);
cycle.add(l4);
cycle.add(l5);
cycle.add(l6);
cycle.add(l7);
cycle.add(l8);
cycle.add(l9);
cycle.add(l10);
cycle.add(l11);
cycle.add(l12);
cycle.add(l13);
Region2D region = new Region2D(cycle);
CSG_Face face = region.getCSG_Face();
face.drawFaceForDebug(gl);
face.drawFaceLinesForDebug(gl);
//System.out.println("face area: " + face.getArea());
gl.glLoadIdentity();
}
示例6: testPerimeterFormation
import javax.media.opengl.GL; //導入方法依賴的package包/類
/**
* test the perimeter formation routine.
* This should be able to take any CSG_Face composed of
* many convex polygons and return just the points
* along hte face's perimeter for edge drawing
* purposes in open GL.
* @param gl
*/
public static void testPerimeterFormation(GL gl){
gl.glLoadIdentity();
gl.glTranslated(-5.0, 0.0, 0.0);
Point2D ptA = new Point2D(0.0, 0.0);
Point2D ptB = new Point2D(2.0, 0.0);
Point2D ptC = new Point2D(2.0, 2.0);
Point2D ptD = new Point2D(1.1, 1.0);
Point2D ptE = new Point2D(2.0, 3.0);
Point2D ptF = new Point2D(3.0, 2.0);
Point2D ptG = new Point2D(2.5, 1.0);
Point2D ptH = new Point2D(2.5, 0.0);
Point2D ptI = new Point2D(4.0, 1.0);
Point2D ptJ = new Point2D(3.0, 3.0);
Point2D ptK = new Point2D(2.0, 4.0);
Point2D ptL = new Point2D(0.0, 2.0);
Point2D ptM = new Point2D(-1.0, 1.0);
Prim2DLine l1 = new Prim2DLine(ptA, ptB);
Prim2DLine l2 = new Prim2DLine(ptB, ptC);
Prim2DLine l3 = new Prim2DLine(ptC, ptD);
Prim2DLine l4 = new Prim2DLine(ptD, ptE);
Prim2DLine l5 = new Prim2DLine(ptE, ptF);
Prim2DLine l6 = new Prim2DLine(ptF, ptG);
Prim2DLine l7 = new Prim2DLine(ptG, ptH);
Prim2DLine l8 = new Prim2DLine(ptH, ptI);
Prim2DLine l9 = new Prim2DLine(ptI, ptJ);
Prim2DLine l10 = new Prim2DLine(ptJ, ptK);
Prim2DLine l11 = new Prim2DLine(ptK, ptL);
Prim2DLine l12 = new Prim2DLine(ptL, ptM);
Prim2DLine l13 = new Prim2DLine(ptM, ptA);
Prim2DCycle cycle = new Prim2DCycle();
cycle.add(l1);
cycle.add(l2);
cycle.add(l3);
cycle.add(l4);
cycle.add(l5);
cycle.add(l6);
cycle.add(l7);
cycle.add(l8);
cycle.add(l9);
cycle.add(l10);
cycle.add(l11);
cycle.add(l12);
cycle.add(l13);
Region2D region = new Region2D(cycle);
CSG_Face face = region.getCSG_Face();
face.drawFaceForDebug(gl);
face.drawFaceLinesForDebug(gl);
gl.glTranslated(5.0, 0.0, 0.0);
// now find the perimeter and draw that...
gl.glLineWidth(3.0f);
gl.glPointSize(5.0f);
gl.glColor3d(0.9, 0.7, 0.3);
LinkedList<CSG_Vertex> perim = face.getPerimeterVertices();
for(int i=0; i<perim.size(); i++){
CSG_Vertex vA = perim.get(i);
CSG_Vertex vB = perim.get((i+1)%perim.size());
gl.glBegin(GL.GL_LINE_LOOP);
gl.glVertex3d(vA.getX(), vA.getY(), vA.getZ());
gl.glVertex3d(vB.getX(), vB.getY(), vB.getZ());
gl.glEnd();
}
//System.out.println("face area: " + face.getArea());
gl.glLoadIdentity();
}
示例7: display
import javax.media.opengl.GL; //導入方法依賴的package包/類
@Override
public void display(GLAutoDrawable glAutoDrawable) {
// System.out.println("MER.display " + time + " " + this.mapEvent.getMessage());
GL gl = glAutoDrawable.getGL();
gl.glPushMatrix();
gl.glTranslated(location.x, location.y, location.z + 60 * 1.1);
// display small
// gl.glEnable(GL.GL_BLEND);
gl.glBlendFunc(GL.GL_SRC_ALPHA,GL.GL_ONE_MINUS_SRC_ALPHA);
GlColor color = new GlColor(entity.getColor(), 0.5);
gl.glColor4d(color.r, color.g, color.b, color.a);
GLUquadric quadratic = glu.gluNewQuadric();
glu.gluSphere(quadratic, SPHERE_RADIUS, SPHERE_SLICES, SPHERE_STACKS);
gl.glPopMatrix();
gl.glDisable(GL.GL_DEPTH_TEST);
gl.glColor3d(1,1,1);
gl.glRasterPos3d(location.x, location.y, location.z);
glut.glutBitmapString(GLUT.BITMAP_HELVETICA_12, this.mapEvent.getMessage());
gl.glEnable(GL.GL_DEPTH_TEST);
// gl.glDisable(GL.GL_BLEND);
}