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


Java GL.glColor4d方法代碼示例

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


在下文中一共展示了GL.glColor4d方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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: drawFaceForDebug

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

示例3: renderPaths

import javax.media.opengl.GL; //導入方法依賴的package包/類
/**
 * Render triangles stored in pathTriangles with info from settings
 * @param gl
 */
private synchronized void renderPaths(GL gl, List<PathTriangle> triangles) {
    // Get colors from preferences
    GlColor lowColor = new GlColor(new Color(NbPreferences.forModule(TimelinePanel.class).getInt(TimelinePanel.MapColor.LOW_COLOR_KEY.getPrefKey(), TimelinePanel.MapColor.LOW_COLOR_KEY.getDegaultARGB())));
    GlColor highColor = new GlColor(new Color(NbPreferences.forModule(TimelinePanel.class).getInt(TimelinePanel.MapColor.HIGH_COLOR_KEY.getPrefKey(), TimelinePanel.MapColor.HIGH_COLOR_KEY.getDegaultARGB())));

    boolean includeFlagBehavior = NbPreferences.forModule(TimelinePanel.class).getBoolean(TimelinePanel.INCLUDE_FLAG_KEY, true);

    double deltaZ = this.map.getBox().getDeltaZ();
    double displaceZ = this.map.getBox().minZ;

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

    gl.glBegin(GL.GL_TRIANGLES);
    for (PathTriangle triangle : triangles) {
        boolean render = false;
        if (includeFlagBehavior) {
            render = includeCanRenderPathFlag(triangle.getFlags());
        } else {
            render = excludeCanRenderFlag(triangle.getFlags());
        }
        
        if (render) {
            for (BlendVertex v : triangle.getVerts()) {
                Location vertexLoc = v.getLocation();
                GlColor color = lowColor.getMixedWith(highColor, (vertexLoc.z - displaceZ) / deltaZ);

                gl.glColor4d(color.r, color.g, color.b, color.a);
                gl.glVertex3d(vertexLoc.x, vertexLoc.y, vertexLoc.z);
            }
        }
    }
    gl.glEnd();
}
 
開發者ID:kefik,項目名稱:Pogamut3,代碼行數:39,代碼來源:MapRenderer.java

示例4: 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();
     */
}
 
開發者ID:kefik,項目名稱:Pogamut3,代碼行數:40,代碼來源:UTAgentSubGLRenderer.java

示例5: pushFadeQuad

import javax.media.opengl.GL; //導入方法依賴的package包/類
/**
 * Queue proper OGL coordinates and colors to render part of fadeline
 * from start to end as quad.
 *
 * @param gl
 * @param color What color should be used fo quad.
 * @param start Starting location
 * @param end Ending location
 * @param startAlpha How much opque should be quad at start 0(transparent)-1(opaque)
 * @param endAlpha How much should quad be at end 0(transparent)-1(opaque)
 */
private void pushFadeQuad(GL gl, GlColor color, Location start, Location end, double startAlpha, double endAlpha) {
    // directional vector from last to current
    Location dir = Location.sub(start, end).setZ(0);
    if (dir.getLength() == 0) {
        return;
    }

    dir = dir.getNormalized();

    // 90 degrees rotated vector
    Location trans = new Location(dir.y, -dir.x, 0);
    trans = trans.scale(6);

    // line at last location
    Location p1 = end.sub(trans);

    Location p2 = end.add(trans);

    gl.glColor4d(color.r, color.g, color.b, 1 - endAlpha);
    gl.glVertex3d(p1.x, p1.y, p1.z + SPHERE_RADIUS);
    gl.glVertex3d(p2.x, p2.y, p2.z + SPHERE_RADIUS);


    // line at current location
    Location p3 = start.add(trans);
    Location p4 = start.sub(trans);

    gl.glColor4d(color.r, color.g, color.b, 1 - startAlpha);
    gl.glVertex3d(p3.x, p3.y, p3.z + SPHERE_RADIUS);
    gl.glVertex3d(p4.x, p4.y, p4.z + SPHERE_RADIUS);
}
 
開發者ID:kefik,項目名稱:Pogamut3,代碼行數:43,代碼來源:UTAgentSubGLRenderer.java

示例6: 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);
    }
 
開發者ID:kefik,項目名稱:Pogamut3,代碼行數:36,代碼來源:UTAgentSubGLRenderer.java

示例7: disposeMaterial

import javax.media.opengl.GL; //導入方法依賴的package包/類
/**
 * dispose of any resources that may have been claimed from the loading of the material.
 * This should be called after the drawing of the part is complete.
 * @param gl
 */
public void disposeMaterial(GL gl){
	if(AvoGlobal.glView.OPENGL_FRAGMENT_SHADER_GLSL_ENABLED){
		// TODO: dispose material in GLSL
	}else{
		if(AvoGlobal.glView.OPENGL_FRAGMENT_PROGRAM_ARB_ENABLED){
			// TODO: dispose material in ARB 
			gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB);
		}else{
			// dispose r,g,b,a for material.. (no action really needed here)
			gl.glColor4d(0.5, 0.5, 0.5, 1.0);
		}
	}	
}
 
開發者ID:avoCADo-3d,項目名稱:avoCADo,代碼行數:19,代碼來源:PartMaterial.java

示例8: 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

示例9: glDrawSelectedElements

import javax.media.opengl.GL; //導入方法依賴的package包/類
public void glDrawSelectedElements(GL gl){
	gl.glColor4d(AvoColors.GL_COLOR4_3D_NONACT[0],AvoColors.GL_COLOR4_3D_NONACT[1],AvoColors.GL_COLOR4_3D_NONACT[2],AvoColors.GL_COLOR4_3D_NONACT[3]);
	partSolid.glDrawSelectedElements(gl);		
}
 
開發者ID:avoCADo-3d,項目名稱:avoCADo,代碼行數:5,代碼來源:Part.java

示例10: glDrawImportantEdges

import javax.media.opengl.GL; //導入方法依賴的package包/類
public void glDrawImportantEdges(GL gl){
	gl.glColor4d(AvoColors.GL_COLOR4_3D_NONACT[0],AvoColors.GL_COLOR4_3D_NONACT[1],AvoColors.GL_COLOR4_3D_NONACT[2],AvoColors.GL_COLOR4_3D_NONACT[3]);
	partSolid.glDrawImportantEdges(gl);
}
 
開發者ID:avoCADo-3d,項目名稱:avoCADo,代碼行數:5,代碼來源:Part.java

示例11: 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);
    }
 
開發者ID:kefik,項目名稱:Pogamut3,代碼行數:33,代碼來源:MapEventRenderer.java


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