com.ryanm.glvisualiser
Class GLMaterial

java.lang.Object
  extended by com.ryanm.glvisualiser.GLMaterial

public class GLMaterial
extends java.lang.Object

Encapsulates OpenGL material attributes, diffuse, emission etc

Author:
ryanm

Field Summary
static int FLAT
          Selects flat shading for this material
static int SMOOTH
          Selects gouraud shading for this material
 
Constructor Summary
GLMaterial()
          Standard constructor.
GLMaterial(GLMaterial other)
          Copies the supplied GLMaterial's values
 
Method Summary
 void apply(javax.media.opengl.GL gl)
          Applies this material to the supplied GL context.
 void applyInBeginEnd(javax.media.opengl.GL gl)
          Applies as much of the material as is possible when in a glBegin/glEnd block.
 float[] getAmbient()
           
 java.awt.Color getAmbientColour()
           
 float[] getDiffuse()
           
 java.awt.Color getDiffuseColour()
           
 float[] getEmission()
           
 java.awt.Color getEmissionColour()
           
 int getShadingModel()
           
 float getShininess()
           
 float[] getSpecular()
           
 java.awt.Color getSpecularColour()
           
 void setAmbientReflectivity(float[] colour)
          Sets the ambient reflectivity colour of this object.
 void setAmbientReflectivity(float r, float g, float b, float a)
          Sets the ambient reflectivity colour of this object.
 void setAmbientReflectivity(GLColour colour)
          Sets the ambient reflectivity colour of this object.
 void setDiffuseReflectivity(float[] colour)
          Sets the diffuse reflectivity colour of this object.
 void setDiffuseReflectivity(float r, float g, float b, float a)
          Sets the diffuse reflectivity colour of this object.
 void setDiffuseReflectivity(GLColour colour)
          Sets the diffuse reflectivity colour of this object.
 void setEmission(float[] colour)
          Sets the emission colour of this object.
 void setEmission(float r, float g, float b, float a)
          Sets the emission colour of this object.
 void setEmission(GLColour colour)
          Sets the emission colour of this object.
 void setShadingMode(int mode)
          Sets the shading mode for this material
 void setShininess(float shiny)
          Sets the shininess of this material, mmmm shiny.
 void setSpecularReflectivity(float[] colour)
          Sets the specular reflectivity colour of this object.
 void setSpecularReflectivity(float r, float g, float b, float a)
          Sets the specular reflectivity colour of this object.
 void setSpecularReflectivity(GLColour colour)
          Sets the specular reflectivity colour of this object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SMOOTH

public static final int SMOOTH
Selects gouraud shading for this material

See Also:
Constant Field Values

FLAT

public static final int FLAT
Selects flat shading for this material

See Also:
Constant Field Values
Constructor Detail

GLMaterial

public GLMaterial()
Standard constructor. Leaves everything at OpenGL defaults


GLMaterial

public GLMaterial(GLMaterial other)
Copies the supplied GLMaterial's values

Parameters:
other - The material to duplicate
Method Detail

apply

public void apply(javax.media.opengl.GL gl)
Applies this material to the supplied GL context.

Parameters:
gl - The GL context to apply to.

applyInBeginEnd

public void applyInBeginEnd(javax.media.opengl.GL gl)
Applies as much of the material as is possible when in a glBegin/glEnd block. Everything but the shading model, in other words

Parameters:
gl - The GL context to apply to.

setAmbientReflectivity

public void setAmbientReflectivity(float[] colour)
Sets the ambient reflectivity colour of this object. Probably best see some OpenGL docs.

Parameters:
colour - the rgba values

setAmbientReflectivity

public void setAmbientReflectivity(float r,
                                   float g,
                                   float b,
                                   float a)
Sets the ambient reflectivity colour of this object. Probably best see some OpenGL docs.

Parameters:
r - The red component
g - The green component
b - The blue component
a - The alpha component

setAmbientReflectivity

public void setAmbientReflectivity(GLColour colour)
Sets the ambient reflectivity colour of this object. Probably best see some OpenGL docs.

Parameters:
colour - The desired colour for ambient reflectivity

setDiffuseReflectivity

public void setDiffuseReflectivity(float r,
                                   float g,
                                   float b,
                                   float a)
Sets the diffuse reflectivity colour of this object. Probably best see some OpenGL docs.

Parameters:
r - The red component
g - The green component
b - The blue component
a - The alpha component

setDiffuseReflectivity

public void setDiffuseReflectivity(GLColour colour)
Sets the diffuse reflectivity colour of this object. Probably best see some OpenGL docs.

Parameters:
colour - The desired colour for diffuse reflectivity

setDiffuseReflectivity

public void setDiffuseReflectivity(float[] colour)
Sets the diffuse reflectivity colour of this object. Probably best see some OpenGL docs.

Parameters:
colour - The desired colour for diffuse reflectivity

setSpecularReflectivity

public void setSpecularReflectivity(float r,
                                    float g,
                                    float b,
                                    float a)
Sets the specular reflectivity colour of this object. Probably best see some OpenGL docs.

Parameters:
r - The red component
g - The green component
b - The blue component
a - The alpha component

setSpecularReflectivity

public void setSpecularReflectivity(GLColour colour)
Sets the specular reflectivity colour of this object. Probably best see some OpenGL docs.

Parameters:
colour - The desired colour for specular reflectivity

setSpecularReflectivity

public void setSpecularReflectivity(float[] colour)
Sets the specular reflectivity colour of this object. Probably best see some OpenGL docs.

Parameters:
colour - The desired colour for specular reflectivity

setEmission

public void setEmission(float r,
                        float g,
                        float b,
                        float a)
Sets the emission colour of this object. Probably best see some OpenGL docs.

Parameters:
r - The red component
g - The green component
b - The blue component
a - The alpha component

setEmission

public void setEmission(GLColour colour)
Sets the emission colour of this object. Probably best see some OpenGL docs.

Parameters:
colour - The desried emision colour

setEmission

public void setEmission(float[] colour)
Sets the emission colour of this object. Probably best see some OpenGL docs.

Parameters:
colour - The desried emision colour

setShininess

public void setShininess(float shiny)
Sets the shininess of this material, mmmm shiny.

Parameters:
shiny - the shininess factor A value from 0 (big fat highlight) to 128 (little skinny highlight). Values outside this will be truncated

setShadingMode

public void setShadingMode(int mode)
Sets the shading mode for this material

Parameters:
mode - can be either GLMaterial.SMOOTH or GLMaterial.FLAT

getAmbient

public float[] getAmbient()
Returns:
Returns the ambient colour.

getDiffuse

public float[] getDiffuse()
Returns:
Returns the diffuse colour.

getEmission

public float[] getEmission()
Returns:
Returns the emission colour.

getSpecular

public float[] getSpecular()
Returns:
Returns the specular colour.

getAmbientColour

public java.awt.Color getAmbientColour()
Returns:
Returns the ambient colour.

getDiffuseColour

public java.awt.Color getDiffuseColour()
Returns:
Returns the diffuse colour.

getEmissionColour

public java.awt.Color getEmissionColour()
Returns:
Returns the emission colour.

getSpecularColour

public java.awt.Color getSpecularColour()
Returns:
Returns the specular colour.

getShadingModel

public int getShadingModel()
Returns:
Returns the shadingModel.

getShininess

public float getShininess()
Returns:
Returns the shininess.