本文整理汇总了Java中javax.media.j3d.AmbientLight类的典型用法代码示例。如果您正苦于以下问题:Java AmbientLight类的具体用法?Java AmbientLight怎么用?Java AmbientLight使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AmbientLight类属于javax.media.j3d包,在下文中一共展示了AmbientLight类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: lightScene
import javax.media.j3d.AmbientLight; //导入依赖的package包/类
private void lightScene()
/* One ambient light, 2 directional lights */
{
Color3f white = new Color3f(1.0f, 1.0f, 1.0f);
// Set up the ambient light
AmbientLight ambientLightNode = new AmbientLight(white);
ambientLightNode.setInfluencingBounds(bounds);
sceneBG.addChild(ambientLightNode);
// Set up the directional lights
Vector3f light1Direction = new Vector3f(-1.0f, -1.0f, -1.0f);
// left, down, backwards
Vector3f light2Direction = new Vector3f(1.0f, -1.0f, 1.0f);
// right, down, forwards
DirectionalLight light1 = new DirectionalLight(white, light1Direction);
light1.setInfluencingBounds(bounds);
sceneBG.addChild(light1);
DirectionalLight light2 = new DirectionalLight(white, light2Direction);
light2.setInfluencingBounds(bounds);
sceneBG.addChild(light2);
}
示例2: setLighting
import javax.media.j3d.AmbientLight; //导入依赖的package包/类
private void setLighting(TransformGroup objMove) {
// Set up the ambient light
Color3f ambientColor = new Color3f(0.1f, 0.1f, 0.1f);
AmbientLight ambientLightNode = new AmbientLight(ambientColor);
ambientLightNode.setInfluencingBounds(boundingSphere);
objMove.addChild(ambientLightNode);
// Set up the directional lights
Color3f light1Color = new Color3f(1.0f, 1.0f, 0.9f);
Vector3f light1Direction = new Vector3f(1.0f, 1.0f, 1.0f);
//light1Direction.scale(scale * 10.0f);
Color3f light2Color = new Color3f(1.0f, 1.0f, 1.0f);
Vector3f light2Direction = new Vector3f(-1.0f, -1.0f, -1.0f);
//light2Direction.scale(scale * 10.0f);
DirectionalLight light1 = new DirectionalLight(light1Color, light1Direction);
light1.setInfluencingBounds(boundingSphere);
objMove.addChild(light1);
DirectionalLight light2 = new DirectionalLight(light2Color, light2Direction);
light2.setInfluencingBounds(boundingSphere);
objMove.addChild(light2);
}
示例3: setLightingRecon
import javax.media.j3d.AmbientLight; //导入依赖的package包/类
private void setLightingRecon(TransformGroup objMove) {
// Set up the ambient light
Color3f ambientColor = new Color3f(0.1f, 0.1f, 0.1f);
AmbientLight ambientLightNode = new AmbientLight(ambientColor);
ambientLightNode.setInfluencingBounds(bounds);
objMove.addChild(ambientLightNode);
// Set up the directional lights
Color3f light1Color = new Color3f(1.0f, 1.0f, 0.9f);
Vector3f light1Direction = new Vector3f(1.0f, 1.0f, 1.0f);
//light1Direction.scale(scale * 10.0f);
Color3f light2Color = new Color3f(1.0f, 1.0f, 1.0f);
Vector3f light2Direction = new Vector3f(-1.0f, -1.0f, -1.0f);
//light2Direction.scale(scale * 10.0f);
DirectionalLight light1 = new DirectionalLight(light1Color, light1Direction);
light1.setInfluencingBounds(bounds);
objMove.addChild(light1);
DirectionalLight light2 = new DirectionalLight(light2Color, light2Direction);
light2.setInfluencingBounds(bounds);
objMove.addChild(light2);
}
示例4: setLightingNet
import javax.media.j3d.AmbientLight; //导入依赖的package包/类
private void setLightingNet(TransformGroup objMove) {
// Set up the ambient light
Color3f ambientColor = Utils3D.lightBlue1;
AmbientLight ambientLightNode = new AmbientLight(ambientColor);
ambientLightNode.setInfluencingBounds(bounds);
objMove.addChild(ambientLightNode);
// Set up the directional lights
Color3f light1Color = Utils3D.brown;
Vector3f light1Direction = new Vector3f(1.0f, 1.0f, 1.0f);
light1Direction.scale(scale * 10.0f);
//Color3f light2Color = Utils3D.brown;
//Vector3f light2Direction = new Vector3f(-1.0f, -1.0f, -1.0f);
//light2Direction.scale(scale * 10.0f);
DirectionalLight light1 = new DirectionalLight(light1Color, light1Direction);
light1.setInfluencingBounds(bounds);
objMove.addChild(light1);
//DirectionalLight light2 = new DirectionalLight(light2Color, light2Direction);
//light2.setInfluencingBounds(bounds);
//objMove.addChild(light2);
//objMove.addChild(lgt1);
}
示例5: lightScene
import javax.media.j3d.AmbientLight; //导入依赖的package包/类
private void lightScene()
/* One ambient light, 2 directional lights */
{
Color3f white = new Color3f(1.0f, 1.0f, 1.0f);
// Set up the ambient light
AmbientLight ambientLightNode = new AmbientLight(white);
ambientLightNode.setInfluencingBounds(bounds);
sceneBG.addChild(ambientLightNode);
// Set up the directional lights
Vector3f light1Direction = new Vector3f(-1.0f, -1.0f, -1.0f);
// left, down, backwards
Vector3f light2Direction = new Vector3f(1.0f, -1.0f, 1.0f);
// right, down, forwards
DirectionalLight light1 = new DirectionalLight(white, light1Direction);
light1.setInfluencingBounds(bounds);
sceneBG.addChild(light1);
DirectionalLight light2 = new DirectionalLight(white, light2Direction);
light2.setInfluencingBounds(bounds);
sceneBG.addChild(light2);
}
示例6: lightScene
import javax.media.j3d.AmbientLight; //导入依赖的package包/类
/**
* ������sceneBG�ɒlj�
*/
private void lightScene() {
Color3f white = new Color3f(1.0f, 1.0f, 1.0f);
// �����iAmbientLight�j
// �ڂ���Ƃ������A���ꂪ�Ȃ��Ɛ^����
AmbientLight ambientLight = new AmbientLight(white);
ambientLight.setInfluencingBounds(bounds); // �����̋y�Ԕ͈͂�ݒ�
sceneBG.addChild(ambientLight); // sceneBG�Ɍ�����lj�
// ���s�����i�\�ʂ������ƌ���j
Vector3f lightDirection = new Vector3f(-1.0f, -1.0f, -1.0f); // �����̌���
DirectionalLight dirLight = new DirectionalLight(white, lightDirection);
dirLight.setInfluencingBounds(bounds);
sceneBG.addChild(dirLight);
}
示例7: createLights
import javax.media.j3d.AmbientLight; //导入依赖的package包/类
/**
* Returns the lights of the scene.
*/
private Light[] createLights()
{
Light[] lights = { new DirectionalLight(new Color3f(0.9f, 0.9f, 0.9f), new Vector3f(1.732f, -0.8f, -1)),
new DirectionalLight(new Color3f(0.9f, 0.9f, 0.9f), new Vector3f(-1.732f, -0.8f, -1)),
new DirectionalLight(new Color3f(0.9f, 0.9f, 0.9f), new Vector3f(0, -0.8f, 1)),
new DirectionalLight(new Color3f(0.66f, 0.66f, 0.66f), new Vector3f(0, 1f, 0)),
new AmbientLight(new Color3f(0.2f, 0.2f, 0.2f)) };
for (Light light : lights)
{
light.setInfluencingBounds(new BoundingSphere(new Point3d(0, 0, 0), 100));
}
return lights;
}
示例8: createSceneGraph
import javax.media.j3d.AmbientLight; //导入依赖的package包/类
BranchGroup createSceneGraph() {
// Create the root of the branch graph
BranchGroup objRoot = new BranchGroup();
// Create a TransformGroup to scale the scene down by 3.5x
// TODO: move view platform instead of scene using orbit behavior
TransformGroup objScale = new TransformGroup();
Transform3D scaleTrans = new Transform3D();
//scaleTrans.set(1 / 3.5f); // scale down by 3.5x
objScale.setTransform(scaleTrans);
objRoot.addChild(objScale);
// Create a TransformGroup and initialize it to the
// identity. Enable the TRANSFORM_WRITE capability so that
// the mouse behaviors code can modify it at runtime. Add it to the
// root of the subgraph.
TransformGroup objTrans = new TransformGroup();
objTrans.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
objTrans.setCapability(TransformGroup.ALLOW_TRANSFORM_READ);
objScale.addChild(objTrans);
// Add the primitives to the scene
objTrans.addChild(createLineTypes());
BoundingSphere bounds = new BoundingSphere(new Point3d(), 100.0);
Background bg = new Background(new Color3f(1.0f, 1.0f, 1.0f));
bg.setApplicationBounds(bounds);
objTrans.addChild(bg);
// set up the mouse rotation behavior
MouseRotate mr = new MouseRotate();
mr.setTransformGroup(objTrans);
mr.setSchedulingBounds(bounds);
mr.setFactor(0.007);
objTrans.addChild(mr);
// Set up the ambient light
Color3f ambientColor = new Color3f(0.1f, 0.1f, 0.1f);
AmbientLight ambientLightNode = new AmbientLight(ambientColor);
ambientLightNode.setInfluencingBounds(bounds);
objRoot.addChild(ambientLightNode);
// Set up the directional lights
Color3f light1Color = new Color3f(1.0f, 1.0f, 1.0f);
Vector3f light1Direction = new Vector3f(0.0f, -0.2f, -1.0f);
DirectionalLight light1 = new DirectionalLight(light1Color,
light1Direction);
light1.setInfluencingBounds(bounds);
objRoot.addChild(light1);
return objRoot;
}
示例9: createSceneBranch
import javax.media.j3d.AmbientLight; //导入依赖的package包/类
/**
* Creates the branch for the visible content of the scenegraph. Used only
* in the creation phase.
*/
private void createSceneBranch(EnvironmentDescription wd) {
sceneBranch = new BranchGroup();
sceneRot = new TransformGroup();
sceneRot.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
sceneRot.setCapability(TransformGroup.ALLOW_TRANSFORM_READ);
sceneRot.setCapability(Group.ALLOW_CHILDREN_EXTEND);
// add transform
sceneTrans = new TransformGroup();
// allow transform access
sceneTrans.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
sceneTrans.setCapability(TransformGroup.ALLOW_TRANSFORM_READ);
sceneTrans.setCapability(Group.ALLOW_CHILDREN_EXTEND);
sceneBranch.addChild(sceneRot);
sceneRot.addChild(sceneTrans);
// bounds (lights,background, behaviors)
BoundingSphere bounds = new BoundingSphere(new Point3d(0.0, 0.0, 0.0), worldSize * 3);
// background
Color3f bgColor = wd.backgroundColor;
Background bgNode = new Background(bgColor);
bgNode.setApplicationBounds(bounds);
sceneTrans.addChild(bgNode);
// ambient light
TransformGroup tga = new TransformGroup();
AmbientLight ambientLight = new AmbientLight(wd.ambientLightColor);
ambientLight.setInfluencingBounds(bounds);
tga.addChild(ambientLight);
sceneBranch.addChild(tga);
// directional lights
light1 = addLight(wd.light1Position, wd.light1Color);
light2 = addLight(wd.light2Position, wd.light2Color);
light1.setEnable(wd.light1IsOn);
light2.setEnable(wd.light2IsOn);
createFloor(wd);
if (wd.hasAxis)
createAxis();
pickableSceneBranch = new BranchGroup();
sceneTrans.addChild(pickableSceneBranch);
pickableSceneBranch.setCapability(Group.ALLOW_CHILDREN_EXTEND);
pickableSceneBranch.setCapability(BranchGroup.ALLOW_DETACH);
pickableSceneBranch.setCapability(Group.ALLOW_CHILDREN_WRITE);
}
示例10: init
import javax.media.j3d.AmbientLight; //导入依赖的package包/类
/**
* Initialisiert die Welt
*/
private void init() {
// Die Wurzel des Ganzen:
scene = new BranchGroup();
scene.setName("World");
scene.setUserData(new String("World"));
Transform3D worldTransform = new Transform3D();
worldTransform.setTranslation(new Vector3f(0.0f, 0.0f, -2.0f));
worldTG = new TransformGroup(worldTransform);
worldTG.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
worldTG.setCapability(TransformGroup.ALLOW_TRANSFORM_READ);
worldTG.setCapability(Node.ENABLE_PICK_REPORTING);
worldTG.setCapability(Node.ALLOW_PICKABLE_READ);
worldTG.setCapability(Group.ALLOW_CHILDREN_EXTEND);
worldTG.setPickable(true);
scene.addChild(worldTG);
// Lichtquellen einfuegen
// Streulicht (ambient light)
BoundingSphere ambientLightBounds = new BoundingSphere(new Point3d(0d, 0d, 0d), 100d);
Color3f ambientLightColor = new Color3f(0.33f, 0.33f, 0.33f);
AmbientLight ambientLightNode = new AmbientLight(ambientLightColor);
ambientLightNode.setInfluencingBounds(ambientLightBounds);
ambientLightNode.setEnable(true);
worldTG.addChild(ambientLightNode);
// Die Branchgroup fuer die Lichtquellen
lightBG = new BranchGroup();
lightBG.setCapability(Node.ALLOW_PICKABLE_WRITE);
lightBG.setPickable(true);
worldTG.addChild(lightBG);
// Die Branchgroup fuer BPS (IR-Licht)
bpsBG = new BranchGroup();
bpsBG.setPickable(true);
worldTG.addChild(this.bpsBG);
// Die Branchgroup fuer den Boden
terrainBG = new BranchGroup();
terrainBG.setCapability(Node.ALLOW_PICKABLE_WRITE);
terrainBG.setPickable(true);
worldTG.addChild(terrainBG);
// Damit spaeter Bots hinzugefuegt werden koennen:
obstBG = new BranchGroup();
obstBG.setCapability(Group.ALLOW_CHILDREN_EXTEND);
obstBG.setCapability(BranchGroup.ALLOW_DETACH);
obstBG.setCapability(Group.ALLOW_CHILDREN_WRITE);
obstBG.setCapability(Node.ALLOW_PICKABLE_WRITE);
obstBG.setPickable(true);
worldTG.addChild(obstBG);
int tickrate = 0;
try {
tickrate = Integer.parseInt(Config.getValue("ctSimTickRate"));
} catch (NumberFormatException exc) {
// NOP
}
setSimStepIntervalInMs(tickrate);
}
示例11: createSceneGraph
import javax.media.j3d.AmbientLight; //导入依赖的package包/类
private BranchGroup createSceneGraph() {
BranchGroup objRoot = new BranchGroup();
//Set up node for rotating the surface based on mouse drags
TransformGroup objTransform = new TransformGroup();
objTransform.setCapability(TransformGroup.ALLOW_TRANSFORM_READ);
objTransform.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
//Set up node for translating and scaling the surface
TransformGroup surfaceTranslate = new TransformGroup();
TransformGroup surfaceScale = new TransformGroup();
surfaceTranslate.setBoundsAutoCompute(true);
surfaceScale.setBoundsAutoCompute(true);
surfaceTranslate.addChild(new Surface(_organism, 32, 32));
BoundingSphere bSphere = new BoundingSphere(surfaceTranslate.getBounds());
Point3d center = new Point3d();
bSphere.getCenter(center);
double radius = bSphere.getRadius();
Matrix3d rotate = new Matrix3d();
rotate.setIdentity();
Vector3d translate = new Vector3d(center);
translate.negate();
double scale = 1/radius;
surfaceTranslate.setTransform(new Transform3D(rotate,translate,1.0));
surfaceScale.setTransform(new Transform3D(rotate,new Vector3d(),scale));
surfaceScale.addChild(surfaceTranslate);
//random rotation
Transform3D rotX = new Transform3D();
Transform3D rotY = new Transform3D();
Transform3D rotZ = new Transform3D();
rotX.rotX(2*Math.PI*Math.random());
rotY.rotY(2*Math.PI*Math.random());
rotZ.rotZ(2*Math.PI*Math.random());
rotX.mul(rotY);
rotX.mul(rotZ);
TransformGroup randRot = new TransformGroup(rotX);
randRot.addChild(surfaceScale);
//Add nodes to root tree
objTransform.addChild(randRot);
objRoot.addChild(objTransform);
//Set up lights
DirectionalLight dirLight =
new DirectionalLight(new Color3f(.9f,.9f,.9f),new Vector3f(0,0,-1));
dirLight.setInfluencingBounds(surfaceScale.getBounds());
objRoot.addChild(dirLight);
AmbientLight ambLight = new AmbientLight(new Color3f(.3f,.3f,.3f));
ambLight.setInfluencingBounds(surfaceScale.getBounds());
objRoot.addChild(ambLight);
//Set up mouse interactions
MouseRotate myMouseRotate = new MouseRotate();
myMouseRotate.setTransformGroup(objTransform);
myMouseRotate.setSchedulingBounds(surfaceScale.getBounds());
objRoot.addChild(myMouseRotate);
MouseZoom myMouseZoom = new MouseZoom();
myMouseZoom.setTransformGroup(objTransform);
myMouseZoom.setSchedulingBounds(surfaceScale.getBounds());
objRoot.addChild(myMouseZoom);
MouseTranslate myMouseTranslate = new MouseTranslate();
myMouseTranslate.setTransformGroup(objTransform);
myMouseTranslate.setSchedulingBounds(surfaceScale.getBounds());
objRoot.addChild(myMouseTranslate);
objRoot.compile();
return objRoot;
}
示例12: createSceneBranch
import javax.media.j3d.AmbientLight; //导入依赖的package包/类
/**
* Creates the branch for the visible content of the scenegraph. Used only in
* the creation phase.
*/
private void createSceneBranch(EnvironmentDescription wd) {
sceneBranch = new BranchGroup();
sceneRot = new TransformGroup();
sceneRot.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
sceneRot.setCapability(TransformGroup.ALLOW_TRANSFORM_READ);
sceneRot.setCapability(Group.ALLOW_CHILDREN_EXTEND);
// add transform
sceneTrans = new TransformGroup();
// allow transform access
sceneTrans.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
sceneTrans.setCapability(TransformGroup.ALLOW_TRANSFORM_READ);
sceneTrans.setCapability(Group.ALLOW_CHILDREN_EXTEND);
sceneBranch.addChild(sceneRot);
sceneRot.addChild(sceneTrans);
// bounds (lights,background, behaviors)
BoundingSphere bounds = new BoundingSphere(new Point3d(0.0, 0.0, 0.0), worldSize * 3);
// background
Color3f bgColor = wd.backgroundColor;
Background bgNode = new Background(bgColor);
bgNode.setApplicationBounds(bounds);
sceneTrans.addChild(bgNode);
// ambient light
TransformGroup tga = new TransformGroup();
AmbientLight ambientLight = new AmbientLight(wd.ambientLightColor);
ambientLight.setInfluencingBounds(bounds);
tga.addChild(ambientLight);
sceneBranch.addChild(tga);
// directional lights
light1 = addLight(wd.light1Position, wd.light1Color);
light2 = addLight(wd.light2Position, wd.light2Color);
light1.setEnable(wd.light1IsOn);
light2.setEnable(wd.light2IsOn);
createFloor(wd);
if (wd.hasAxis)
createAxis();
pickableSceneBranch = new BranchGroup();
sceneTrans.addChild(pickableSceneBranch);
pickableSceneBranch.setCapability(Group.ALLOW_CHILDREN_EXTEND);
pickableSceneBranch.setCapability(BranchGroup.ALLOW_DETACH);
pickableSceneBranch.setCapability(Group.ALLOW_CHILDREN_WRITE);
}
示例13: createAmbientLight
import javax.media.j3d.AmbientLight; //导入依赖的package包/类
public Light createAmbientLight() {
BoundingSphere bounds = new BoundingSphere();
Light light = new AmbientLight();
light.setInfluencingBounds(bounds);
return light;
}
示例14: createAmbientLight
import javax.media.j3d.AmbientLight; //导入依赖的package包/类
public Light createAmbientLight() {
BoundingSphere bounds = new BoundingSphere(new Point3d(), Double.POSITIVE_INFINITY);
Light light = new AmbientLight();
light.setInfluencingBounds(bounds);
return light;
}
示例15: init
import javax.media.j3d.AmbientLight; //导入依赖的package包/类
private void init( )
{
canvasComponent.setPreferredSize( new Dimension( 400 , 400 ) );
canvasComponent.setSize( new Dimension( 400 , 400 ) );
universe = new SimpleUniverse( this.canvas );
frame = new JFrame( );
frame.getContentPane( ).setLayout( new BorderLayout( ) );
frame.getContentPane( ).add( BorderLayout.CENTER , canvas );
vp = universe.getViewingPlatform( );
camera = new Camera3D( vp );
camera.setLocation( new Point3d( 0 , 2 , 0 ) , true );
camera.lookAt( new Point3d( 0 , 0 , 0 ) , true );
sceneRoot = new BranchGroup( );
sceneRoot.setCapability( BranchGroup.ALLOW_CHILDREN_EXTEND );
sceneRoot.setCapability( BranchGroup.ALLOW_CHILDREN_READ );
sceneRoot.setCapability( BranchGroup.ALLOW_CHILDREN_WRITE );
axes = new XyzAxes2( .05f , 1f );
sceneRoot.addChild( axes );
ambientLight = new AmbientLight( new Color3f( .3f , .3f , .3f ) );
worldBounds = new BoundingSphere( new Point3d( ) , 10000.0 );
ambientLight.setInfluencingBounds( worldBounds );
ambientLight.setCapability( Light.ALLOW_STATE_WRITE );
sceneRoot.addChild( ambientLight );
sceneTrans = new TransformGroup( );
sceneTrans.setCapability( TransformGroup.ALLOW_TRANSFORM_WRITE );
sceneTrans.addChild( sceneRoot );
worldRoot = new BranchGroup( );
worldRoot.addChild( sceneTrans );
orbiter = new OrbitBehavior( universe.getCanvas( ) );
orbiter.setSchedulingBounds( worldBounds );
vp.setViewPlatformBehavior( orbiter );
universe.addBranchGraph( worldRoot );
frame.pack( );
}