本文整理匯總了Java中javax.media.opengl.GL2.glMaterialfv方法的典型用法代碼示例。如果您正苦於以下問題:Java GL2.glMaterialfv方法的具體用法?Java GL2.glMaterialfv怎麽用?Java GL2.glMaterialfv使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.media.opengl.GL2
的用法示例。
在下文中一共展示了GL2.glMaterialfv方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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;
}
示例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();
}
示例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);
}
示例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();
}
示例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();
}
示例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();
}
示例7: bind
import javax.media.opengl.GL2; //導入方法依賴的package包/類
public void bind(GL2 gl) {
gl.glMaterialfv(GL_FRONT, GL_DIFFUSE, diffuse, 0);
gl.glMaterialfv(GL_FRONT, GL_SPECULAR, specular, 0);
gl.glMaterialfv(GL_FRONT, GL_AMBIENT, ambient, 0);
gl.glMaterialfv(GL_FRONT, GL_SHININESS, shine, 0);
}
示例8: 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);
}
}
示例9: 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();
}
示例10: 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);
}
示例11: 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);
}