当前位置: 首页>>代码示例>>Java>>正文


Java GL2.glMaterialf方法代码示例

本文整理汇总了Java中javax.media.opengl.GL2.glMaterialf方法的典型用法代码示例。如果您正苦于以下问题:Java GL2.glMaterialf方法的具体用法?Java GL2.glMaterialf怎么用?Java GL2.glMaterialf使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.media.opengl.GL2的用法示例。


在下文中一共展示了GL2.glMaterialf方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: drawVertex

import javax.media.opengl.GL2; //导入方法依赖的package包/类
private Vector3f drawVertex(Vector3f vert, double size, float[] color, GL2 gl, GLUT glut) {
    gl.glMaterialfv(GL.GL_FRONT_AND_BACK, GL2.GL_AMBIENT, color, 0);
    gl.glMaterialfv(GL.GL_FRONT_AND_BACK, GL2.GL_DIFFUSE, color, 0);
    gl.glMaterialf(GL.GL_FRONT_AND_BACK, GL2.GL_SHININESS, 10);

    gl.glPushAttrib(GL2.GL_LIGHTING_BIT);
    gl.glDisable(GL2.GL_TEXTURE_2D);
    gl.glEnable(GL2.GL_LIGHTING);

    gl.glPushMatrix();
    gl.glTranslatef(vert.getX(), vert.getY(), vert.getZ());

    glut.glutSolidSphere(size, 20, 20);
    gl.glPopMatrix();

    gl.glEnable(GL2.GL_TEXTURE_2D);
    gl.glDisable(GL2.GL_LIGHTING);
    gl.glPopAttrib();

    return vert;
}
 
开发者ID:Fidentis,项目名称:Analyst,代码行数:22,代码来源:PApainting.java

示例2: drawArrow

import javax.media.opengl.GL2; //导入方法依赖的package包/类
private void drawArrow(Vector3f from, Vector3f to, float[] color, GL2 gl, GLUT glut) {
    Vector3f zAxis = new Vector3f(0, 0, 1);
    Vector3f vector = new Vector3f(to.x - from.x, to.y - from.y, to.z - from.z);
    float length = vector.length();
    vector.normalize();
    float angle = zAxis.angle(vector);
    Vector3f axis = new Vector3f();
    axis.cross(zAxis, vector);
    float convert = (float) (180f / Math.PI);

    gl.glPushAttrib(GL2.GL_LIGHTING_BIT);
    gl.glDisable(GL2.GL_TEXTURE_2D);
    gl.glEnable(GL2.GL_LIGHTING);

    gl.glMaterialfv(GL.GL_FRONT_AND_BACK, GL2.GL_AMBIENT, color, 0);
    gl.glMaterialfv(GL.GL_FRONT_AND_BACK, GL2.GL_DIFFUSE, color, 0);
    gl.glMaterialf(GL.GL_FRONT_AND_BACK, GL2.GL_SHININESS, 10);

    gl.glPushMatrix();

    gl.glTranslatef(from.x, from.y, from.z);
    gl.glRotatef(angle * convert, axis.x, axis.y, axis.z);
    glut.glutSolidCylinder(info.getPointSize() / 3, length - info.getPointSize(), 20, 20);
    gl.glTranslatef(0, 0, length - info.getPointSize());
    glut.glutSolidCone(info.getPointSize(), info.getPointSize(), 20, 20);

    gl.glPopMatrix();

    gl.glEnable(GL2.GL_TEXTURE_2D);
    gl.glDisable(GL2.GL_LIGHTING);
    gl.glPopAttrib();
}
 
开发者ID:Fidentis,项目名称:Analyst,代码行数:33,代码来源:PApainting.java

示例3: useWhiteMtl

import javax.media.opengl.GL2; //导入方法依赖的package包/类
private void useWhiteMtl(GL2 gl) {
    float[] color = {1f, 1f, 1f, 1f};
    //  float[] color = {0.868f, 0.64f, 0.548f, 1f};
    gl.glMaterialfv(GL2.GL_FRONT_AND_BACK, GL2.GL_AMBIENT, color, 0);
    gl.glMaterialfv(GL2.GL_FRONT_AND_BACK, GL2.GL_DIFFUSE, color, 0);
    gl.glMaterialf(GL2.GL_FRONT_AND_BACK, GL2.GL_SHININESS, 10);
    float[] colorKs = {0, 0, 0, 1.0f};
    gl.glMaterialfv(GL2.GL_FRONT_AND_BACK, GL2.GL_SPECULAR, colorKs, 0);
}
 
开发者ID:Fidentis,项目名称:Analyst,代码行数:10,代码来源:Materials.java

示例4: plotObject

import javax.media.opengl.GL2; //导入方法依赖的package包/类
@Override
public void plotObject( final GLAutoDrawable drawable,
		final org.openimaj.vis.general.XYZVisualisation3D.LocatedObject3D<ColouredDot> object,
		final AxesRenderer3D renderer )
{
	final double[] p = renderer.calculatePosition( new double[]
			{ object.x, object.y, object.z } );

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

	gl.glPushMatrix();

	// Translate to the position of the dot
	gl.glMatrixMode( GLMatrixFunc.GL_MODELVIEW );
	gl.glTranslated( p[0], p[1], p[2] );

	final double[] s = renderer.scaleDimension(
		new double[] {object.object.size, object.object.size, object.object.size} );
	gl.glScaled( s[0], s[1], s[2] );

	// Create a sphere
	if( !this.isEnableLights() )
		gl.glColor3f( object.object.colour[0], object.object.colour[1], object.object.colour[2] );
	else
	{
        final float[] rgba = { object.object.colour[0], object.object.colour[1], object.object.colour[2] };
        gl.glMaterialfv( GL.GL_FRONT, GLLightingFunc.GL_AMBIENT, rgba, 0);
        gl.glMaterialfv( GL.GL_FRONT, GLLightingFunc.GL_SPECULAR, rgba, 0);
        gl.glMaterialf( GL.GL_FRONT, GLLightingFunc.GL_SHININESS, 0.05f);
	}

	final GLUquadric qobj0 = this.glu.gluNewQuadric();
	this.glu.gluQuadricDrawStyle( qobj0, GLU.GLU_FILL );
	this.glu.gluQuadricNormals( qobj0, GLU.GLU_SMOOTH );
	this.glu.gluSphere( qobj0, 1, 12, 12 );
	this.glu.gluDeleteQuadric( qobj0 );

	gl.glPopMatrix();
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:40,代码来源:DotPlotVisualisation3D.java

示例5: drawFaceShape

import javax.media.opengl.GL2; //导入方法依赖的package包/类
private void drawFaceShape(List<Vector3f> fps, float[] color, GL2 gl, GLUT glut) {

        gl.glMaterialfv(GL.GL_FRONT_AND_BACK, GL2.GL_AMBIENT, color, 0);
        gl.glMaterialfv(GL.GL_FRONT_AND_BACK, GL2.GL_DIFFUSE, color, 0);
        gl.glMaterialf(GL.GL_FRONT_AND_BACK, GL2.GL_SHININESS, 10);

        //gl.glPushAttrib(GL2.GL_LIGHTING_BIT);
        gl.glDisable(GL2.GL_TEXTURE_2D);
        gl.glDisable(GL2.GL_LIGHTING);
        gl.glEnable(GL2.GL_LIGHTING);
        gl.glEnable(GL2.GL_NORMALIZE);

        
        //celo nos
        drawCylinder(fps.get(4), fps.get(8), gl, glut);
        drawCylinder(fps.get(8), fps.get(9), gl, glut);
        drawCylinder(fps.get(4), fps.get(10), gl, glut);

        //brada
        drawCylinder(fps.get(11), fps.get(12), gl, glut);
        drawCylinder(fps.get(12), fps.get(13), gl, glut);

        //usta
        drawCylinder(fps.get(6), fps.get(5), gl, glut);
        drawCylinder(fps.get(5), fps.get(7), gl, glut);

        drawCylinder(fps.get(6), fps.get(10), gl, glut);
        drawCylinder(fps.get(10), fps.get(7), gl, glut);

        drawCylinder(fps.get(6), fps.get(11), gl, glut);
        drawCylinder(fps.get(11), fps.get(7), gl, glut);

        drawCylinder(fps.get(10), fps.get(5), gl, glut);
        drawCylinder(fps.get(5), fps.get(11), gl, glut);
        //oci -- zanedbava nespecifikovane body v strede oka
        /*drawCylinder(fps.get(1), fps.get(14), gl, glut);
        drawCylinder(fps.get(14), fps.get(3), gl, glut);*/
        
        drawCylinder(fps.get(1), fps.get(3), gl, glut);
        //drawCylinder(fps.get(3), fps.get(8), gl, glut);

        /*drawCylinder(fps.get(0), fps.get(15), gl, glut);
        drawCylinder(fps.get(15), fps.get(2), gl, glut);*/
        drawCylinder(fps.get(0), fps.get(2), gl, glut);
        //drawCylinder(fps.get(2), fps.get(8), gl, glut);

        gl.glEnable(GL2.GL_TEXTURE_2D);
        gl.glDisable(GL2.GL_LIGHTING);
        gl.glPopAttrib();
    }
 
开发者ID:Fidentis,项目名称:Analyst,代码行数:51,代码来源:PApainting.java

示例6: paintNormals

import javax.media.opengl.GL2; //导入方法依赖的package包/类
public void paintNormals(GL2 gl) {
    info.c.assignGl(gl);
    Faces faces = info.getModel().getFaces();
    
    List<Vector3f> mesh = info.getModel().getVerts();
    List<Vector3f> normals = info.getModel().getNormals();

    List<Float> distanceCopy = new ArrayList<>(info.getDistance().size());

    for (Float f : info.getDistance()) {
        if (!info.isUseRelative()) {
            distanceCopy.add(Math.abs(f));
        } else {
            distanceCopy.add(f);
        }
    }

    float[] color = new float[3];
    color[0] = 0.8667f;
    color[1] = 0.7176f;
    color[2] = 0.6275f;

    gl.glPushAttrib(GL_ALL_ATTRIB_BITS);

    Vector3f normal;

    gl.glDisable(GL2.GL_TEXTURE_2D);
    gl.glEnable(GL2.GL_LIGHTING);
    
    for (int i = 0; i < faces.getNumFaces(); i++) {

        int[] facesInd = faces.getFaceVertIdxs(i);
        int[] faceNormIndex = faces.getFaceNormalIdxs(i);

        gl.glBegin(GL.GL_TRIANGLES);
        for (int f = 0; f < facesInd.length; f++) {
            if (faceNormIndex[f] != 0) {  // if there are normals, render them
                normal = normals.get(faceNormIndex[f] - 1);
                gl.glNormal3d(normal.getX(), normal.getY(), normal.getZ());
            }

            float[] ambient = {0.1f, 0.1f, 0.1f, 0.0f};
            gl.glMaterialfv(GL2.GL_FRONT_AND_BACK, GL2.GL_AMBIENT, ambient, 0);
            gl.glMaterialfv(GL2.GL_FRONT_AND_BACK, GL2.GL_DIFFUSE, color, 0);
            gl.glMaterialf(GL2.GL_FRONT_AND_BACK, GL2.GL_SHININESS, 10);

            float[] colorKs = {0, 0, 0, 1.0f};
            gl.glMaterialfv(GL2.GL_FRONT_AND_BACK, GL2.GL_SPECULAR, colorKs, 0);
            gl.glVertex3f(mesh.get(facesInd[f] - 1).getX(), mesh.get(facesInd[f] - 1).getY(), mesh.get(facesInd[f] - 1).getZ());
        }
        gl.glEnd();
    }

    if (info.getRecompute()) {
        recomputeNormals(gl, info, distanceCopy);
        info.setRecompute(false);
    }
    gl.glEnableClientState(gl.GL_VERTEX_ARRAY);
        info.c.draw();
    gl.glDisableClientState(gl.GL_VERTEX_ARRAY);
 
    gl.glPopAttrib();
}
 
开发者ID:Fidentis,项目名称:Analyst,代码行数:64,代码来源:HDpainting.java

示例7: drawEarth

import javax.media.opengl.GL2; //导入方法依赖的package包/类
private void drawEarth(GL2 gl) {
	// set material properties
	float[] rgba = { 1f, 1f, 1f }; // neutral white surface
	gl.glMaterialfv(GL2.GL_FRONT, GL2.GL_AMBIENT, rgba, 0);
	gl.glMaterialfv(GL2.GL_FRONT, GL2.GL_SPECULAR, rgba, 0);
	gl.glMaterialf(GL2.GL_FRONT, GL2.GL_SHININESS, 0.5f);

	if (!texturesCreated) {
		earth.scheduleAvailableTextures(gl.getGLProfile());
		earth.createScheduledTextures(gl);
		List<String> textureNames = earth.getAvailableTextureNames();
		if (!textureNames.isEmpty()) {
			earth.setCurrentTexture(earth.getDefaultTexture());
		}

		texturesCreated = true;
	}
	
	if(skydomeTexture == null) {
		loadSkydomeTexture();
		
	} else {
		skydomeTexture.enable(gl);
		skydomeTexture.bind(gl);
		
		// create the earth ball
		GLUquadric skydome = glu.gluNewQuadric();
		glu.gluQuadricTexture(skydome, true); // apply texture to the sphere
		glu.gluQuadricDrawStyle(skydome, GLU.GLU_FILL);
		glu.gluQuadricNormals(skydome, GLU.GLU_FLAT);
		glu.gluQuadricOrientation(skydome, GLU.GLU_INSIDE);
		
		glu.gluSphere(skydome, this.currentRadius()*5, SKYDOME_RESOLUTION, SKYDOME_RESOLUTION);
		glu.gluDeleteQuadric(skydome);
	}
	
	if(credits != null && !wasLastFrame2D()) {
		credits.render(gl);
	} else {

		// apply the texture
		Texture texture = earth.getCurrentTexture();
		if (texture != null) {
			texture.enable(gl);
			texture.bind(gl);
		}

		
		
		// create the earth ball
		GLUquadric earthQuad = glu.gluNewQuadric();
		glu.gluQuadricTexture(earthQuad, true); // apply texture to the sphere
		glu.gluQuadricDrawStyle(earthQuad, GLU.GLU_FILL);
		glu.gluQuadricNormals(earthQuad, GLU.GLU_FLAT);
		glu.gluQuadricOrientation(earthQuad, GLU.GLU_OUTSIDE);

		// size of sphere depends on zoom
		glu.gluSphere(earthQuad, this.currentRadius(), EARTH_RESOLUTION, EARTH_RESOLUTION);
		glu.gluDeleteQuadric(earthQuad);
	}
}
 
开发者ID:johb,项目名称:GAIA,代码行数:62,代码来源:Mode3D.java

示例8: drawMinorTickGridline

import javax.media.opengl.GL2; //导入方法依赖的package包/类
@Override
public void drawMinorTickGridline( final double location, final AxisConfig<float[]> config )
{
	final GL2 gl = this.glad.getGL().getGL2();

	gl.glPushMatrix();

	this.orient( gl );

	gl.glLineWidth( (float)config.getRenderingConfig().getMinorGridThickness() );
	gl.glColor3f( config.getRenderingConfig().getMinorGridColour()[0],
			config.getRenderingConfig().getMinorGridColour()[1],
			config.getRenderingConfig().getMinorGridColour()[2] );
       final float[] rgba = { config.getRenderingConfig().getMinorGridColour()[0],
			config.getRenderingConfig().getMinorGridColour()[1],
			config.getRenderingConfig().getMinorGridColour()[2] };
       gl.glMaterialfv( GL.GL_FRONT, GLLightingFunc.GL_AMBIENT, rgba, 0);
       gl.glMaterialfv( GL.GL_FRONT, GLLightingFunc.GL_SPECULAR, rgba, 0);
       gl.glMaterialf( GL.GL_FRONT, GLLightingFunc.GL_SHININESS, 0f);

	final float ll = this.calculatePosition( location ).floatValue();

	final float zero = 0.001f;
	gl.glBegin( GL.GL_LINE_STRIP );
	{
		// We draw in the x axis, so the orientation has to be set appropriately
		gl.glVertex3f( ll, zero, zero );
		gl.glVertex3f( ll, 1, zero );
	}
	gl.glEnd();

	gl.glBegin( GL.GL_LINE_STRIP );
	{
		// We draw in the x axis, so the orientation has to be set appropriately
		gl.glVertex3f( ll, zero, zero );
		gl.glVertex3f( ll, zero, 1*this.gridDirection );
	}
	gl.glEnd();

	gl.glPopMatrix();
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:42,代码来源:AxisRenderer3D.java

示例9: setMaterial

import javax.media.opengl.GL2; //导入方法依赖的package包/类
/**
 * Sets the given material values on the given GL2 instance. This will set
 * the light reflective properties (and thus colour) for any object drawn
 * henceforth.
 *
 * @param gl       The GL2 instance responsible for drawing the scene.
 * @param material The material to set.
 * @param uniColor If the material should be unicolorized.
 *
 * @see #setColor Use this method to set colours without needing a Material.
 * Note that using glColor* has been turned off and doesn't work.
 */
public void setMaterial(GL2 gl, Material material, boolean uniColor) {
    if (uniColor) {
        material = material.uniColorize();
    }
    gl.glMaterialfv(GL_FRONT, GL_AMBIENT, material.ambient, 0);
    gl.glMaterialfv(GL_FRONT, GL_DIFFUSE, material.diffuse, 0);
    gl.glMaterialfv(GL_FRONT, GL_SPECULAR, material.specular, 0);
    gl.glMaterialf(GL_FRONT, GL_SHININESS, material.shininess);
}
 
开发者ID:ABoschman,项目名称:2IV60_RobotRace,代码行数:22,代码来源:Lighting.java

示例10: setColor

import javax.media.opengl.GL2; //导入方法依赖的package包/类
/**
 * Sets the current colour on the given GL2 instance. This will set the
 * light reflective properties (and thus colour) for any object drawn
 * henceforth.
 *
 * The given colour will be used for both ambient and diffuse light.
 * Specular light will be turned off.
 *
 * @param gl    The GL2 instance responsible for drawing the scene.
 * @param red   The red component of the colour, between [0,1].
 * @param green The green component of the colour, between [0,1].
 * @param blue  The blue component of the colour, between [0,1].
 * @param alpha The alpha component of the colour, between [0,1].
 *
 * @see #setMaterial Use this alternative method to set the colour if you
 * want more fine grained control over the values. You will need a Material
 * constant though.
 */
public void setColor(GL2 gl, float red, float green, float blue, float alpha) {
    gl.glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, new float[]{red, green, blue, alpha}, 0);
    gl.glMaterialfv(GL_FRONT, GL_SPECULAR, COLOUR_OFF, 0);
    gl.glMaterialf(GL_FRONT, GL_SHININESS, 0);
}
 
开发者ID:ABoschman,项目名称:2IV60_RobotRace,代码行数:24,代码来源:Lighting.java


注:本文中的javax.media.opengl.GL2.glMaterialf方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。