本文整理汇总了Java中javax.media.j3d.DirectionalLight类的典型用法代码示例。如果您正苦于以下问题:Java DirectionalLight类的具体用法?Java DirectionalLight怎么用?Java DirectionalLight使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DirectionalLight类属于javax.media.j3d包,在下文中一共展示了DirectionalLight类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: J3dTest
import javax.media.j3d.DirectionalLight; //导入依赖的package包/类
public J3dTest(){
// 创建一个虚拟空间
SimpleUniverse universe = new SimpleUniverse();
// 创建一个用来包含对象的数据结构
BranchGroup group = new BranchGroup();
// 创建一个球并把它加入到group中
Sphere sphere = new Sphere(0.5f); // 小球的半径为0.5米
group.addChild(sphere);
Color3f light1Color = new Color3f(1.8f, 0.1f, 0.1f);
// 设置光线的颜色
BoundingSphere bounds = new BoundingSphere(new Point3d(0.0,0.0,0.0), 100.0);
// 设置光线的作用范围
Vector3f light1Direction = new Vector3f(4.0f, -7.0f, -12.0f);
// 设置光线的方向
DirectionalLight light1= new DirectionalLight(light1Color, light1Direction);
// 指定颜色和方向,产生单向光源
light1.setInfluencingBounds(bounds);
// 把光线的作用范围加入光源中
group.addChild(light1);
// 将光源加入group组,安放观察点
universe.getViewingPlatform().setNominalViewingTransform();
// 把group加入到虚拟空间中
universe.addBranchGraph(group);
}
开发者ID:cowthan,项目名称:JavaAyo,代码行数:27,代码来源:J3dTest.java
示例2: lightScene
import javax.media.j3d.DirectionalLight; //导入依赖的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);
}
开发者ID:glaudiston,项目名称:project-bianca,代码行数:25,代码来源:Points3DPanel.java
示例3: setLighting
import javax.media.j3d.DirectionalLight; //导入依赖的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);
}
开发者ID:NeuroBox3D,项目名称:NeuGen,代码行数:25,代码来源:VRLDensityVisualization.java
示例4: setLightingRecon
import javax.media.j3d.DirectionalLight; //导入依赖的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);
}
开发者ID:NeuroBox3D,项目名称:NeuGen,代码行数:25,代码来源:NeuGenVisualization.java
示例5: setLightingNet
import javax.media.j3d.DirectionalLight; //导入依赖的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);
}
开发者ID:NeuroBox3D,项目名称:NeuGen,代码行数:23,代码来源:NeuGenVisualization.java
示例6: lightScene
import javax.media.j3d.DirectionalLight; //导入依赖的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);
}
开发者ID:MyRobotLab,项目名称:myrobotlab,代码行数:25,代码来源:Points3DPanel.java
示例7: lightScene
import javax.media.j3d.DirectionalLight; //导入依赖的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);
}
开发者ID:aidiary,项目名称:javagame,代码行数:19,代码来源:MainPanel.java
示例8: createHeadlight
import javax.media.j3d.DirectionalLight; //导入依赖的package包/类
protected void createHeadlight( )
{
final Color3f lightColor = new Color3f( 0.9f , 0.9f , 0.9f );
final DirectionalLight light = new DirectionalLight( );
light.setCapability( Light.ALLOW_STATE_WRITE );
light.setColor( lightColor );
final BoundingSphere worldBounds = new BoundingSphere( new Point3d( 0.0 , 0.0 , 0.0 ) , 100000.0 ); // Center, Extent
light.setInfluencingBounds( worldBounds );
m_headlight = light;
final BranchGroup bg = new BranchGroup( );
m_lightGroup = new TransformGroup( );
m_lightGroup.setCapability( TransformGroup.ALLOW_TRANSFORM_WRITE );
bg.addChild( m_lightGroup );
m_lightGroup.addChild( m_headlight );
m_transformGroup.addChild( bg );
}
开发者ID:jedwards1211,项目名称:breakout,代码行数:19,代码来源:Camera3D.java
示例9: addAmbientLight
import javax.media.j3d.DirectionalLight; //导入依赖的package包/类
/**
* Add 3 directional lights (a primary and 2 secondary) to increase 3D sensation
* @param root where to add the lights
* @param bounds bounds
*/
private void addAmbientLight(BranchGroup root, BoundingSphere bounds) {
// Lumiere principale
Color3f lightColor1 = new Color3f(1.0f, 1.0f, 1.0f);
Vector3f lightDirection1 = new Vector3f(2.0f, -3.0f, -6.0f);
DirectionalLight light1 = new DirectionalLight(lightColor1, lightDirection1);
light1.setInfluencingBounds(bounds);
root.addChild(light1);
// Lumiere de support 1
Color3f lightColor2 = new Color3f(0.25f, 0.25f, 0.25f);
Vector3f lightDirection2 = new Vector3f(-2.0f, 3.0f, 6.0f);
DirectionalLight light2 = new DirectionalLight(lightColor2, lightDirection2);
light2.setInfluencingBounds(bounds);
root.addChild(light2);
// Lumiere de support 2
Color3f lightColor3 = new Color3f(0.3f, 0.3f, 0.3f);
Vector3f lightDirection3 = new Vector3f(2.0f, -3.0f, 6.0f);
DirectionalLight light3 = new DirectionalLight(lightColor3, lightDirection3);
light3.setInfluencingBounds(bounds);
root.addChild(light3);
}
开发者ID:mnip91,项目名称:proactive-component-monitoring,代码行数:28,代码来源:NBody3DFrame.java
示例10: createLights
import javax.media.j3d.DirectionalLight; //导入依赖的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;
}
开发者ID:valsr,项目名称:SweetHome3D,代码行数:18,代码来源:ModelPreviewComponent.java
示例11: createDirectionalLight
import javax.media.j3d.DirectionalLight; //导入依赖的package包/类
public Light createDirectionalLight() {
BoundingSphere bounds = new BoundingSphere();
Light light = new DirectionalLight(new Color3f(1.0f, 1.0f, 1.0f),
new Vector3f(1.0f, -1.0f, -1.0f));
light.setInfluencingBounds(bounds);
return light;
}
开发者ID:aidiary,项目名称:javagame,代码行数:8,代码来源:Main.java
示例12: createDirectionalLight
import javax.media.j3d.DirectionalLight; //导入依赖的package包/类
public Light createDirectionalLight() {
BoundingSphere bounds = new BoundingSphere(new Point3d(), Double.POSITIVE_INFINITY);
Light light = new DirectionalLight(new Color3f(1.0f, 1.0f, 1.0f),
new Vector3f(1.0f, -1.0f, -1.0f));
light.setInfluencingBounds(bounds);
return light;
}
开发者ID:aidiary,项目名称:javagame,代码行数:8,代码来源:Main.java
示例13: createSceneGraph
import javax.media.j3d.DirectionalLight; //导入依赖的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;
}
开发者ID:HOMlab,项目名称:QN-ACTR-Release,代码行数:54,代码来源:LineTypes.java
示例14: createSceneGraph
import javax.media.j3d.DirectionalLight; //导入依赖的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;
}
开发者ID:wolfmanstout,项目名称:jene,代码行数:79,代码来源:SurfacePanel.java
示例15: ObjectLoader
import javax.media.j3d.DirectionalLight; //导入依赖的package包/类
public ObjectLoader() {
setLayout(new BorderLayout());
GraphicsConfiguration graphicsConfig = SimpleUniverse
.getPreferredConfiguration();
Canvas3D canvas3D = new Canvas3D(graphicsConfig);
add(canvas3D);
canvas3D.setSize(1200, 800);
canvas3D.setVisible(true);
BranchGroup scene = new BranchGroup();
ObjectFile loader = new ObjectFile(ObjectFile.LOAD_ALL);
loader.setFlags(ObjectFile.RESIZE);
Color3f light1Color = new Color3f(1.8f, 0.1f, 0.1f);
BoundingSphere bounds =
new BoundingSphere(new Point3d(0.0, 0.0, 0.0), 100.0);
Vector3f light1Direction = new Vector3f(2.0f, 12.0f, -12.0f);
DirectionalLight light1
= new DirectionalLight(light1Color, light1Direction);
light1.setInfluencingBounds(bounds);
scene.addChild(light1);
Scene modelScene = null;
try {
modelScene = loader.load("Images/gargoyle.obj");
} catch (Exception e) {
}
scene.addChild(modelScene.getSceneGroup());
SimpleUniverse universe = new SimpleUniverse(canvas3D);
universe.getViewingPlatform().setNominalViewingTransform();
universe.addBranchGraph(scene);
ViewingPlatform viewPlatform = universe.getViewingPlatform();
TransformGroup viewTransform = viewPlatform.getViewPlatformTransform();
Transform3D t3d = new Transform3D();
viewTransform.getTransform(t3d);
t3d.lookAt(new Point3d(0, 0, 4), new Point3d(0, 0, 0), new Vector3d(0, 1, 0));
t3d.invert();
viewTransform.setTransform(t3d);
}
开发者ID:GettingNifty,项目名称:Heavy-Evil,代码行数:58,代码来源:ObjectLoader.java
注:本文中的javax.media.j3d.DirectionalLight类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论