com.jmex.physics.material
Class Material

java.lang.Object
  extended by com.jmex.physics.material.Material
All Implemented Interfaces:
com.jme.util.export.Savable

public class Material
extends java.lang.Object
implements com.jme.util.export.Savable

A material specifies contact and mass details about a collision geometry or physics node.

Author:
Irrisor
See Also:
PhysicsCollisionGeometry.setMaterial(Material), PhysicsNode.setMaterial(Material)

Field Summary
static Material CONCRETE
           
static Material DEFAULT
           
static Material GHOST
           
static Material GLASS
           
static Material GRANITE
           
static Material ICE
           
static Material IRON
           
static Material OSMIUM
           
static Material PLASTIC
           
static Material RUBBER
           
static Material SPONGE
           
static Material WOOD
           
 
Constructor Summary
Material()
          Create a new material without name.
Material(java.lang.String name)
          Create a new material.
 
Method Summary
static Material checkForCommonMaterial(Material material)
          Returns whether the given material is one of the common materials (GLASS, WOOD, etc.).
 java.lang.Class getClassTag()
           
 ContactHandlingDetails getContactHandlingDetails(Material contactMaterial)
          Query contact details of this material with another material.
 com.jme.renderer.ColorRGBA getDebugColor(com.jme.renderer.ColorRGBA color)
          getter for field debugColor
 float getDensity()
          Density of this material.
 java.lang.String getName()
           
 float getSpringPenetrationDepth()
           
 com.jme.math.Vector3f getSurfaceMotion(com.jme.math.Vector3f store)
           
 void putContactHandlingDetails(Material contactMaterial, ContactHandlingDetails details)
          Specify contact details like friction (mu), bouciness etc.
 void read(com.jme.util.export.JMEImporter im)
           
 void setDebugColor(com.jme.renderer.ColorRGBA value)
          setter for field debugColor
 void setDensity(float value)
          Change the density of this material.
 void setName(java.lang.String name)
          Sets the name of the material, can be null
 void setSpringPenetrationDepth(float springPenetrationDepth)
           
 void setSurfaceMotion(com.jme.math.Vector3f motion)
          Surface motion - if set, the surface is assumed to be moving independently of the motion of the nodes.
 java.lang.String toString()
           
 void write(com.jme.util.export.JMEExporter ex)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

IRON

public static final Material IRON

WOOD

public static final Material WOOD

CONCRETE

public static final Material CONCRETE

GRANITE

public static final Material GRANITE

GLASS

public static final Material GLASS

PLASTIC

public static final Material PLASTIC

RUBBER

public static final Material RUBBER

ICE

public static final Material ICE

DEFAULT

public static final Material DEFAULT

GHOST

public static final Material GHOST

OSMIUM

public static final Material OSMIUM

SPONGE

public static final Material SPONGE
Constructor Detail

Material

public Material(java.lang.String name)
Create a new material.

Parameters:
name - name for this material, can be null

Material

public Material()
Create a new material without name.

Method Detail

getName

public java.lang.String getName()
Returns:
name for this material (might be null)

setName

public void setName(java.lang.String name)
Sets the name of the material, can be null

Parameters:
name - name of the material

getDensity

public float getDensity()
Density of this material. Default is 1.

Returns:
density

setDensity

public void setDensity(float value)
Change the density of this material.

Parameters:
value - new value

getDebugColor

public com.jme.renderer.ColorRGBA getDebugColor(com.jme.renderer.ColorRGBA color)
getter for field debugColor

Parameters:
color - where to put the debug color (null to create a new ColorRGBA)
Returns:
color set to debugcolor

setDebugColor

public void setDebugColor(com.jme.renderer.ColorRGBA value)
setter for field debugColor

Parameters:
value - new value

getContactHandlingDetails

public ContactHandlingDetails getContactHandlingDetails(Material contactMaterial)
Query contact details of this material with another material.

Parameters:
contactMaterial - the second material
Returns:
contact details if

putContactHandlingDetails

public void putContactHandlingDetails(Material contactMaterial,
                                      ContactHandlingDetails details)
Specify contact details like friction (mu), bouciness etc. for a material pair. You can specify default contact details for any unspecified contact partner by passing null as first parameter.
Not that specifying default contact details can lead to undesired behaviour as it depends on the implementation which material is queried upon contact of two different materials.

material1.getContactHandlingDetails( material2 )
could lead to different results than
material2.getContactHandlingDetails( material1 )
if only default contact details are set.

This can avoided by specifying contact details for a pair of materials. If contactMaterial parameter is not null the contact details are set for material1->material2 and material2->material1.

Parameters:
contactMaterial - contact material, null for setting default details
details - contact details for specified contact pair / default, null to clear

setSurfaceMotion

public void setSurfaceMotion(com.jme.math.Vector3f motion)
Surface motion - if set, the surface is assumed to be moving independently of the motion of the nodes. This is kind of like a conveyor belt running over the surface.

Parameters:
motion - this vector specifies the motion of the surface in geometry coordinate space. This results in a motion relative to the world rotation of the geometry but independent from the direction of the surface itself.

getSurfaceMotion

public com.jme.math.Vector3f getSurfaceMotion(com.jme.math.Vector3f store)
Parameters:
store - where to store the retrieved value (null to create a new vector)
Returns:
surface motion
See Also:
setSurfaceMotion(com.jme.math.Vector3f)

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

getSpringPenetrationDepth

public float getSpringPenetrationDepth()

setSpringPenetrationDepth

public void setSpringPenetrationDepth(float springPenetrationDepth)

checkForCommonMaterial

public static Material checkForCommonMaterial(Material material)
Returns whether the given material is one of the common materials (GLASS, WOOD, etc.). This is used when loading materials to reduce the number of material instances.

Parameters:
material - The material to check
Returns:
The common material instance, or the original material if no common one was found.

getClassTag

public java.lang.Class getClassTag()
Specified by:
getClassTag in interface com.jme.util.export.Savable

read

public void read(com.jme.util.export.JMEImporter im)
          throws java.io.IOException
Specified by:
read in interface com.jme.util.export.Savable
Throws:
java.io.IOException

write

public void write(com.jme.util.export.JMEExporter ex)
           throws java.io.IOException
Specified by:
write in interface com.jme.util.export.Savable
Throws:
java.io.IOException