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


Java GL.glBegin方法代碼示例

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


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

示例1: renderWaypoints

import javax.media.opengl.GL; //導入方法依賴的package包/類
/**
 * Render all waypoints (the circles in the map), data generated in createWaypointsList
 * @param gl
 * @param triangles
 */
private synchronized void renderWaypoints(GL gl, List<BlendTriangle> triangles) {
    GlColor color = new GlColor(new Color(NbPreferences.forModule(TimelinePanel.class).getInt(TimelinePanel.MapColor.WAYPOINTS_COLOR_KEY.getPrefKey(), TimelinePanel.MapColor.WAYPOINTS_COLOR_KEY.getDegaultARGB())));

    gl.glEnable(GL.GL_COLOR_MATERIAL);
    gl.glShadeModel(GL.GL_SMOOTH);

    gl.glBegin(GL.GL_TRIANGLES);
    for (BlendTriangle triangle : triangles) {
        for (BlendVertex v : triangle.getVerts()) {
            // take color according to width
            gl.glColor4d(color.r, color.g, color.b, color.a);
            gl.glVertex3d(v.getLocation().x, v.getLocation().y, v.getLocation().z + 0.1);
        }
    }
    gl.glEnd();
}
 
開發者ID:kefik,項目名稱:Pogamut3,代碼行數:22,代碼來源:MapRenderer.java

示例2: drawFaceLinesForDebug

import javax.media.opengl.GL; //導入方法依賴的package包/類
public void drawFaceLinesForDebug(GL gl){
	for(CSG_Polygon poly : polygons){			
		if(poly.type == CSG_Polygon.POLY_TYPE.POLY_INSIDE){ 	// red
			gl.glColor3d(0.5, 0.2, 0.2);
		}
		if(poly.type == CSG_Polygon.POLY_TYPE.POLY_OUTSIDE){ 	// green
			gl.glColor3d(0.2, 0.5, 0.2);
		}
		if(poly.type == CSG_Polygon.POLY_TYPE.POLY_OPPOSITE){	// blue
			gl.glColor3d(0.2, 0.2, 0.5);
		}
		if(poly.type == CSG_Polygon.POLY_TYPE.POLY_SAME){		// purple
			gl.glColor3d(0.5, 0.2, 0.5);
		}
		if(poly.type == CSG_Polygon.POLY_TYPE.POLY_UNKNOWN){	// gray
			gl.glColor3d(0.25, 0.25, 0.25);
		}
		Iterator<CSG_Vertex> iterV = poly.getVertexIterator();
		gl.glBegin(GL.GL_LINE_LOOP);
		while(iterV.hasNext()){
			gl.glVertex3dv(iterV.next().getXYZ(), 0);
		}
		gl.glEnd();
	}
}
 
開發者ID:avoCADo-3d,項目名稱:avoCADo,代碼行數:26,代碼來源:CSG_Face.java

示例3: drawSegmentForDebug

import javax.media.opengl.GL; //導入方法依賴的package包/類
public void drawSegmentForDebug(GL gl){
	gl.glBegin(GL.GL_LINES);
		gl.glColor3f(0.5f,0.5f,0.5f);
		gl.glVertex3d(startVert.getX(), startVert.getY(), startVert.getZ());
		gl.glVertex3d(endVert.getX(), endVert.getY(), endVert.getZ());			
	gl.glEnd();
	gl.glBegin(GL.GL_POINTS);
		gl.glColor3f(0.0f,1.0f,0.0f);
		gl.glVertex3d(startVert.getX(), startVert.getY(), startVert.getZ());
		gl.glColor3f(1.0f,0.0f,0.0f);
		gl.glVertex3d(endVert.getX(), endVert.getY(), endVert.getZ());	
	gl.glEnd();
}
 
開發者ID:avoCADo-3d,項目名稱:avoCADo,代碼行數:14,代碼來源:CSG_Segment.java

示例4: drawPolygonForDebug

import javax.media.opengl.GL; //導入方法依賴的package包/類
public void drawPolygonForDebug(GL gl){
	gl.glColor3f(0.5f, 0.7f, 0.7f);
	gl.glBegin(GL.GL_POLYGON);
	for(CSG_Vertex v : vertices){
		gl.glVertex3dv(v.getXYZ(), 0);
	}
	gl.glEnd();
}
 
開發者ID:avoCADo-3d,項目名稱:avoCADo,代碼行數:9,代碼來源:CSG_Polygon.java

示例5: renderFade

import javax.media.opengl.GL; //導入方法依賴的package包/類
/**
 * Render passed fade line in passed color.
 * @param gl
 * @param fadeline Data about fadeline
 * @param color what color should fadeline be drawn
 */
private void renderFade(GL gl, GlColor color, IFadeLine fadeline) {
    gl.glEnable(GL.GL_BLEND);
    gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA);

    gl.glBegin(GL.GL_QUADS);

    Location lastLocation = null;
    double lastAlpha = 0; // how much is point opaque

    for (long ms = 0; ms < fadeline.getDuration(); ms += 100) {
        Location currentLocation = fadeline.getPosition(ms);
        double currentAlpha = ((double) ms) / fadeline.getDuration();

        if (lastLocation == null) {
            lastLocation = currentLocation;
            lastAlpha = currentAlpha;
            continue;
        }

        if (currentLocation != null) {
            pushFadeQuad(gl, color, currentLocation, lastLocation, currentAlpha, lastAlpha);

            lastLocation = currentLocation;
            lastAlpha = currentAlpha;
        }
    }

    gl.glEnd();

    gl.glDisable(GL.GL_BLEND);
}
 
開發者ID:kefik,項目名稱:Pogamut3,代碼行數:38,代碼來源:UTAgentSubGLRenderer.java

示例6: drawPlaneForDebug

import javax.media.opengl.GL; //導入方法依賴的package包/類
public void drawPlaneForDebug(GL gl){
	// 3x5 rectangle (aligned along var 1);
	CSG_Vertex a = origin.addToVertex(xAxis.getScaledCopy( 2.5)).addToVertex(yAxis.getScaledCopy( 1.5));
	CSG_Vertex b = origin.addToVertex(xAxis.getScaledCopy(-2.5)).addToVertex(yAxis.getScaledCopy( 1.5));
	CSG_Vertex c = origin.addToVertex(xAxis.getScaledCopy(-2.5)).addToVertex(yAxis.getScaledCopy(-1.5));
	CSG_Vertex d = origin.addToVertex(xAxis.getScaledCopy( 2.5)).addToVertex(yAxis.getScaledCopy(-1.5));
	gl.glColor3f(0.5f, 1.0f, 1.0f);
	gl.glBegin(GL.GL_LINE_LOOP);
		gl.glVertex3dv(a.getXYZ(), 0);
		gl.glVertex3dv(b.getXYZ(), 0);
		gl.glVertex3dv(c.getXYZ(), 0);
		gl.glVertex3dv(d.getXYZ(), 0);
	gl.glEnd();
}
 
開發者ID:avoCADo-3d,項目名稱:avoCADo,代碼行數:15,代碼來源:SketchPlane.java

示例7: drawFaceWireframe

import javax.media.opengl.GL; //導入方法依賴的package包/類
public void drawFaceWireframe(GL gl){
	for(CSG_Polygon poly : polygons){			
		Iterator<CSG_Vertex> iterV = poly.getVertexIterator();
		gl.glBegin(GL.GL_LINE_LOOP);
		while(iterV.hasNext()){
			gl.glVertex3dv(iterV.next().getXYZ(), 0);
		}
		gl.glEnd();
	}
}
 
開發者ID:avoCADo-3d,項目名稱:avoCADo,代碼行數:11,代碼來源:CSG_Face.java

示例8: drawPolygonNormalsForDebug

import javax.media.opengl.GL; //導入方法依賴的package包/類
public void drawPolygonNormalsForDebug(GL gl){
	float[] currentColor=new float[]{0,0,0,0};
	gl.glGetFloatv(GL.GL_CURRENT_COLOR, currentColor, 0);
	gl.glColor3d(1.0, 0.0, 0.0);
	CSG_Vertex fCenter = getBarycenterVertex();
	CSG_Vertex norm = getPlane().getNormal();
	double scale = 10;
	fCenter.addToVertex(norm.getScaledCopy(scale));
	CSG_Vertex nShifted = fCenter.addToVertex(norm.getScaledCopy(scale));
	gl.glBegin(GL.GL_LINES);
		gl.glVertex3dv(fCenter.getXYZ(), 0);
		gl.glVertex3dv(nShifted.getXYZ(), 0);
	gl.glEnd();
	gl.glColor3d(currentColor[0], currentColor[1], currentColor[2]);
}
 
開發者ID:avoCADo-3d,項目名稱:avoCADo,代碼行數:16,代碼來源:CSG_Polygon.java

示例9: drawNormalFromOriginForDegug

import javax.media.opengl.GL; //導入方法依賴的package包/類
public void drawNormalFromOriginForDegug(GL gl){
	gl.glColor3d(1.0, 0.0, 0.0);
	double scale = 1.0;
	gl.glBegin(GL.GL_LINES);
		gl.glVertex3dv(normal.getScaledCopy(scale).getXYZ(), 0);
		gl.glVertex3d(0.0, 0.0, 0.0);
	gl.glEnd();
	
}
 
開發者ID:avoCADo-3d,項目名稱:avoCADo,代碼行數:10,代碼來源:CSG_Plane.java

示例10: drawLineForDebug

import javax.media.opengl.GL; //導入方法依賴的package包/類
/**
 * just for debug purposes... 
 * a simple way to visualize the ray in 3D space. 
 * @param gl the GL context on which to render
 * @param length the total length of the line
 */
public void drawLineForDebug(GL gl, double length){
	CSG_Vertex begin = basePoint;
	CSG_Vertex end   = basePoint.addToVertex(direction.getScaledCopy(length));
	gl.glBegin(GL.GL_LINES);
		gl.glVertex3d(begin.getX(), begin.getY(), begin.getZ());
		gl.glVertex3d(end.getX(), end.getY(), end.getZ());			
	gl.glEnd();
	gl.glBegin(GL.GL_POINTS);
		gl.glVertex3d(basePoint.getX(), basePoint.getY(), basePoint.getZ());
	gl.glEnd();
}
 
開發者ID:avoCADo-3d,項目名稱:avoCADo,代碼行數:18,代碼來源:CSG_Ray.java

示例11: glDrawPolygon

import javax.media.opengl.GL; //導入方法依賴的package包/類
public void glDrawPolygon(GL gl){
	// TODO: put this in a GL lib of somekind..
	gl.glBegin(GL.GL_POLYGON);
	for(CSG_Vertex v : vertices){
		gl.glVertex3dv(v.getXYZ(), 0);
	}
	gl.glEnd();
}
 
開發者ID:avoCADo-3d,項目名稱:avoCADo,代碼行數:9,代碼來源:CSG_Polygon.java

示例12: 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();

    }
 
開發者ID:kefik,項目名稱:Pogamut3,代碼行數:51,代碼來源:UTAgentSubGLRenderer.java

示例13: testRotation

import javax.media.opengl.GL; //導入方法依賴的package包/類
/**
 * test the sketch plane rotation and CSG_Vertex rotation code.
 * If things are working correctly, every line should end at
 * a point of the same color. (purple lines -> purple points; 
 * orange lines -> orange/green points).S
 * @param gl
 */
public static void testRotation(GL gl){
	
	System.out.println(" ------  GL Rotation Test -------- ");
	
	gl.glLoadIdentity();
	gl.glLineWidth(2.0f);
	gl.glPointSize(5.0f);
	
	CSG_Vertex v1 = new CSG_Vertex(1.0, 1.0, 0.0);
	CSG_Vertex v2 = new CSG_Vertex(2.0, 1.0, 0.0);
	CSG_Vertex v3 = new CSG_Vertex(2.0, 2.0, 0.0);
	CSG_Vertex v4 = new CSG_Vertex(1.0, 2.0, 0.0);
	
	CSG_Vertex vX = new CSG_Vertex(1.0, 0.0, 0.0);
	CSG_Vertex vY = new CSG_Vertex(0.0, 1.0, 0.0);
	CSG_Vertex vZ = new CSG_Vertex(0.0, 0.0, 1.0);
	
	vX.drawPointForDebug(gl);
	vY.drawPointForDebug(gl);
	vZ.drawPointForDebug(gl);

	for(double yInc= -0.25; yInc<0.26; yInc+= 0.1){
		for(double rot=-3.10; rot<3.14; rot+= 0.1){
			
			CSG_Vertex normal = new CSG_Vertex(Math.sin(rot), yInc, Math.cos(rot)).getUnitLength();
			//CSG_Vertex normal = new CSG_Vertex(1.0, 0.0, 0.0);
			CSG_Plane plane = new CSG_Plane(normal, 0.0);
			SketchPlane sP  = new SketchPlane(plane);
		
			//System.out.println("--> normal: " + normal);
			Translation3D translation = new Translation3D(0.0, 0.0, 0.0);
			Rotation3D rotation    = new Rotation3D(sP.getRotationX(), sP.getRotationY(), sP.getRotationZ());
			CSG_Face f1 = new CSG_Face(new CSG_Polygon(v1, v2, v3, v4));
			CSG_Face f2 = f1.getTranslatedCopy(new CSG_Vertex(-3.0,  0.0, 0.0));
			CSG_Face f3 = f1.getTranslatedCopy(new CSG_Vertex(-3.0, -3.0, 0.0));
			CSG_Face f4 = f1.getTranslatedCopy(new CSG_Vertex( 0.0, -3.0, 0.0));
			gl.glColor3d(rot, 0.5, 0.0);
			gl.glPointSize(7.0f);
			//vX.getTranslatedRotatedCopy(translation, rotation).glDrawVertex(gl);
			//vY.getTranslatedRotatedCopy(translation, rotation).glDrawVertex(gl);
			vZ.getTranslatedRotatedCopy(translation, rotation).glDrawVertex(gl);
			f1.applyTranslationRotation(translation, rotation);
			f2.applyTranslationRotation(translation, rotation);
			f3.applyTranslationRotation(translation, rotation);
			f4.applyTranslationRotation(translation, rotation);
			//f1.glDrawFace(gl); // 
			//f2.glDrawFace(gl); // uncomment these faces to see how
			//f3.glDrawFace(gl); // planar regions are rotated.
			//f4.glDrawFace(gl); //
			
			gl.glColor3d(0.8, 0.0, 0.8);
			sP.getVar1Axis().glDrawVertex(gl);
			
			plane.drawNormalFromOriginForDegug(gl);
			gl.glRotatef((float)(rotation.getXRot()*180.0/Math.PI), 1.0f, 0.0f, 0.0f);
		    gl.glRotatef((float)(rotation.getYRot()*180.0/Math.PI), 0.0f, 1.0f, 0.0f);
		    gl.glRotatef((float)(rotation.getZRot()*180.0/Math.PI), 0.0f, 0.0f, 1.0f);
		    gl.glColor3d(0.9, 0.7, 0.3);
		    gl.glPointSize(5.0f);
		    //vZ.glDrawVertex(gl);
		    gl.glBegin(GL.GL_LINES);
		    	gl.glColor3d(0.9, 0.7, 0.3); // normal
		    	gl.glVertex3d(0.0, 0.0, 0.0);
		    	gl.glVertex3d(vZ.getX(), vZ.getY(), vZ.getZ());
		    	gl.glColor3d(0.9, 0.3, 0.9); // x-axis
		    	gl.glVertex3d(0.0, 0.0, 0.0);
		    	gl.glVertex3d(1.0, 0.0, 0.0);		    	
		    gl.glEnd();
		    gl.glLoadIdentity();
		    gl.glColor3d(0.7, 0.7, 0.7);
		}
	}		
}
 
開發者ID:avoCADo-3d,項目名稱:avoCADo,代碼行數:81,代碼來源:GLTests.java

示例14: 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();
}
 
開發者ID:avoCADo-3d,項目名稱:avoCADo,代碼行數:79,代碼來源:GLTests.java

示例15: line3D

import javax.media.opengl.GL; //導入方法依賴的package包/類
public static void line3D(GL gl, Point3D ptA, Point3D ptB){
	gl.glBegin(GL.GL_LINES);
		gl.glVertex3d(ptA.getX(), ptA.getY(), ptA.getZ());
		gl.glVertex3d(ptB.getX(), ptB.getY(), ptB.getZ());
	gl.glEnd();
}
 
開發者ID:avoCADo-3d,項目名稱:avoCADo,代碼行數:7,代碼來源:GLDynPrim.java


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