|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectsim.portrayal3d.SimplePortrayal3D
sim.portrayal3d.simple.LightPortrayal3D
A simple Portrayal3D which provides ambient, directional, or point light to the scene. While this could be used in a FieldPortrayal to represent its objects, it's more likely to be dropped directly into the Display3D itself. Your light can be any color, and it will have infinite bounds -- it irradiates everything regardless of where it is -- meaning there's no such thing as a shadow. LightPortrayals aren't selectable: how can you catch a moonbeam in your hand?
In fact, the default objects provided in the simulator (such as SpherePortrayal3D) don't respond to light at all -- they
just display themselves with their given color as if there were a magical light source. To get them to respond
in a different fashion, you'll need to provide them with a different Appearance object, and set that Appearance's
ColoringAttributes and Material. Here's an example which makes a green sphere that's harshly lit only on the side where it receives light, else it's jet black.
import javax.media.j3d.*;
import javax.vecmath.*;
Color3f color = new Color3f(java.awt.Color.green);
Appearance appearance = new Appearance();
appearance.setColoringAttributes(
new ColoringAttributes(color, ColoringAttributes.SHADE_GOURAUD));
Material m= new Material();
m.setAmbientColor(color);
m.setEmissiveColor(0f,0f,0f);
m.setDiffuseColor(color);
m.setSpecularColor(1f,1f,1f);
m.setShininess(128f);
appearance.setMaterial(m);
SpherePortrayal3D sphere = new SpherePortrayal3D(appearance, 1.0f);
Field Summary | |
javax.media.j3d.Light |
light
|
Fields inherited from class sim.portrayal3d.SimplePortrayal3D |
DEFAULT_APPEARANCE, parentPortrayal |
Constructor Summary | |
LightPortrayal3D(java.awt.Color color)
Ambient Light |
|
LightPortrayal3D(java.awt.Color color,
Double3D direction)
Directional Light |
|
LightPortrayal3D(java.awt.Color color,
Double3D position,
float constantAttenuation,
float linearAttenuation,
float quadraticAttenuation)
Point Light. |
|
LightPortrayal3D(javax.media.j3d.Light light)
Provide your own Light! |
Method Summary | |
javax.media.j3d.TransformGroup |
getModel(java.lang.Object obj,
javax.media.j3d.TransformGroup j3dModel)
Provides a TransformGroup which defines the node(s) to place in the scenegraph. |
Methods inherited from class sim.portrayal3d.SimplePortrayal3D |
appearanceForColor, appearanceForImage, clearPickableFlags, getInspector, getName, polygonAttributes, setParentPortrayal, setPickableFlags, setPickableFlags, setSelected |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public javax.media.j3d.Light light
Constructor Detail |
public LightPortrayal3D(java.awt.Color color, Double3D direction)
public LightPortrayal3D(java.awt.Color color)
public LightPortrayal3D(java.awt.Color color, Double3D position, float constantAttenuation, float linearAttenuation, float quadraticAttenuation)
public LightPortrayal3D(javax.media.j3d.Light light)
Method Detail |
public javax.media.j3d.TransformGroup getModel(java.lang.Object obj, javax.media.j3d.TransformGroup j3dModel)
Portrayal3D
You should hang your model off of the TransformGroup provided. You should not transform that TransformGroup in any way -- it is used elsewhere. Instead if you wish to transform your model (rotate it etc.) you should add your own additional TransformGroup as necessary.
The provided TransformGroup can be null; in this case you need to create and return the outer TransformGroup for the object. If the provided TransformGroup is non-null, you should modify it and return the same.
SimplePortrayals should assume the following contract: at the point that getModel(...) is called, the parentPortrayal will have already been set if it exists, else it will be null.
getModel
in interface Portrayal3D
getModel
in class SimplePortrayal3D
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |