本文整理汇总了Java中com.jme3.light.DirectionalLight类的典型用法代码示例。如果您正苦于以下问题:Java DirectionalLight类的具体用法?Java DirectionalLight怎么用?Java DirectionalLight使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DirectionalLight类属于com.jme3.light包,在下文中一共展示了DirectionalLight类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: BaseMaterialEditor3DState
import com.jme3.light.DirectionalLight; //导入依赖的package包/类
public BaseMaterialEditor3DState(@NotNull final T fileEditor) {
super(fileEditor);
this.testBox = new Geometry("Box", new Box(2, 2, 2));
this.testSphere = new Geometry("Sphere", new Sphere(30, 30, 2));
this.testQuad = new Geometry("Quad", new Quad(4, 4));
this.testQuad.setLocalTranslation(QUAD_OFFSET);
this.lightEnabled = MaterialFileEditor.DEFAULT_LIGHT_ENABLED;
TangentGenerator.useMikktspaceGenerator(testBox);
TangentGenerator.useMikktspaceGenerator(testSphere);
TangentGenerator.useMikktspaceGenerator(testQuad);
final DirectionalLight light = notNull(getLightForCamera());
light.setDirection(LIGHT_DIRECTION);
final EditorCamera editorCamera = notNull(getEditorCamera());
editorCamera.setDefaultHorizontalRotation(H_ROTATION);
editorCamera.setDefaultVerticalRotation(V_ROTATION);
getModelNode().attachChild(getNodeForCamera());
}
示例2: updateLightEnabledImpl
import com.jme3.light.DirectionalLight; //导入依赖的package包/类
/**
* Update the light in the scene in the {@link EditorThread}.
*
* @param enabled true if light should be enabled.
*/
@JMEThread
protected void updateLightEnabledImpl(final boolean enabled) {
if (enabled == isLightEnabled()) return;
final DirectionalLight light = getLightForCamera();
final Node stateNode = getStateNode();
if (enabled) {
stateNode.addLight(light);
} else {
stateNode.removeLight(light);
}
setLightEnabled(enabled);
}
示例3: updateLightEnabledImpl
import com.jme3.light.DirectionalLight; //导入依赖的package包/类
/**
* The process of updating the light.
*/
@JMEThread
private void updateLightEnabledImpl(boolean enabled) {
if (enabled == isLightEnabled()) return;
final DirectionalLight light = getLightForCamera();
final Node stateNode = getStateNode();
if (enabled) {
stateNode.addLight(light);
} else {
stateNode.removeLight(light);
}
setLightEnabled(enabled);
}
示例4: buildForImpl
import com.jme3.light.DirectionalLight; //导入依赖的package包/类
@Override
@FXThread
protected void buildForImpl(@NotNull final Object object, @Nullable final Object parent, @NotNull final VBox container,
@NotNull final ModelChangeConsumer changeConsumer) {
if (object instanceof DirectionalLight) {
buildForDirectionLight((DirectionalLight) object, container, changeConsumer);
} else if (object instanceof SpotLight) {
buildForSpotLight((SpotLight) object, container, changeConsumer);
} else if (object instanceof PointLight) {
buildForPointLight((PointLight) object, container, changeConsumer);
}
if (object instanceof Light) {
buildForLight((Light) object, container, changeConsumer);
}
}
示例5: buildForDirectionLight
import com.jme3.light.DirectionalLight; //导入依赖的package包/类
@FXThread
private void buildForDirectionLight(@NotNull final DirectionalLight light, @NotNull final VBox container,
@NotNull final ModelChangeConsumer changeConsumer) {
final Vector3f direction = light.getDirection().clone();
final DirectionLightPropertyControl<DirectionalLight> directionControl =
new DirectionLightPropertyControl<>(direction, Messages.MODEL_PROPERTY_DIRECTION, changeConsumer);
directionControl.setApplyHandler(DirectionalLight::setDirection);
directionControl.setSyncHandler(DirectionalLight::getDirection);
directionControl.setEditObject(light);
FXUtils.addToPane(directionControl, container);
buildSplitLine(container);
}
示例6: simpleInitApp
import com.jme3.light.DirectionalLight; //导入依赖的package包/类
@Override
public void simpleInitApp() {
viewPort.setBackgroundColor(ColorRGBA.LightGray);
initKeys();
/** Add a light source so we can see the model */
DirectionalLight dl = new DirectionalLight();
dl.setDirection(new Vector3f(-0.1f, -1f, -1).normalizeLocal());
rootNode.addLight(dl);
/** Load a model that contains animation */
player = (Node) assetManager.loadModel("Models/Oto/Oto.mesh.xml");
player.setLocalScale(0.5f);
rootNode.attachChild(player);
/** Create a controller and channels. */
control = player.getControl(AnimControl.class);
control.addListener(this);
channel = control.createChannel();
channel.setAnim("stand");
}
示例7: simpleInitApp
import com.jme3.light.DirectionalLight; //导入依赖的package包/类
public void simpleInitApp() {
Geometry teaGeom = (Geometry) assetManager.loadModel("Models/Teapot/Teapot.obj");
DirectionalLight dl = new DirectionalLight();
dl.setColor(ColorRGBA.White);
dl.setDirection(Vector3f.UNIT_XYZ.negate());
rootNode.addLight(dl);
rootNode.attachChild(teaGeom);
// Setup first view
cam.setParallelProjection(true);
float aspect = (float) cam.getWidth() / cam.getHeight();
cam.setFrustum(-1000, 1000, -aspect * frustumSize, aspect * frustumSize, frustumSize, -frustumSize);
inputManager.addListener(this, "Size+", "Size-");
inputManager.addMapping("Size+", new KeyTrigger(KeyInput.KEY_W));
inputManager.addMapping("Size-", new KeyTrigger(KeyInput.KEY_S));
}
示例8: simpleInitApp
import com.jme3.light.DirectionalLight; //导入依赖的package包/类
@Override
public void simpleInitApp() {
flyCam.setMoveSpeed(20);
Sphere sphereMesh = new Sphere(32, 32, 1);
sphereMesh.setTextureMode(Sphere.TextureMode.Projected);
sphereMesh.updateGeometry(32, 32, 1, false, false);
addMesh("Sphere", sphereMesh, new Vector3f(-1, 0, 0));
Quad quadMesh = new Quad(1, 1);
quadMesh.updateGeometry(1, 1);
addMesh("Quad", quadMesh, new Vector3f(1, 0, 0));
Mesh strip = createTriangleStripMesh();
addMesh("strip", strip, new Vector3f(0, -3, 0));
DirectionalLight dl = new DirectionalLight();
dl.setDirection(new Vector3f(1, -1, -1).normalizeLocal());
dl.setColor(ColorRGBA.White);
rootNode.addLight(dl);
}
示例9: spatialTolight
import com.jme3.light.DirectionalLight; //导入依赖的package包/类
private void spatialTolight(Light light) {
if (light instanceof PointLight) {
((PointLight) light).setPosition(spatial.getWorldTranslation());
}
TempVars vars = TempVars.get();
if (light instanceof DirectionalLight) {
((DirectionalLight) light).setDirection(vars.vect1.set(spatial.getWorldTranslation()).multLocal(-1.0f));
}
vars.release();
//TODO add code for Spot light here when it's done
// if( light instanceof SpotLight){
// ((SpotLight)light).setPosition(spatial.getWorldTranslation());
// ((SpotLight)light).setRotation(spatial.getWorldRotation());
// }
}
示例10: updateLightCamera
import com.jme3.light.DirectionalLight; //导入依赖的package包/类
/**
* Updates the camera view direction and position based on the light
*/
public void updateLightCamera(Camera lightCam) {
if (target.getType() == Light.Type.Directional) {
DirectionalLight dl = (DirectionalLight) target;
lightCam.setParallelProjection(true);
lightCam.setLocation(Vector3f.ZERO);
lightCam.lookAtDirection(dl.getDirection(), Vector3f.UNIT_Y);
lightCam.setFrustum(-1, 1, -1, 1, 1, -1);
} else {
PointLight pl = (PointLight) target;
lightCam.setParallelProjection(false);
lightCam.setLocation(pl.getPosition());
// direction will have to be calculated automatically
lightCam.setFrustumPerspective(45, 1, 1, 300);
}
}
示例11: createDirectionalGizmo
import com.jme3.light.DirectionalLight; //导入依赖的package包/类
private static Node createDirectionalGizmo(AssetManager assetManager, JmeDirectionalLight jmeLight, Light light) {
DirectionalLightGizmo gizmo = new DirectionalLightGizmo(jmeLight);
gizmo.move(0, 5, 0);
gizmo.addControl(new LightDirectionUpdate(light, gizmo));
Node billboardNode = new Node("billboard lightGizmo");
billboardNode.addControl(new BillboardControl());
billboardNode.attachChild(createLightBulb(assetManager));
Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
mat.setColor("Color", ColorRGBA.White);
mat.getAdditionalRenderState().setLineWidth(2f);
Geometry arrow = new Geometry("direction arrow", new Arrow(((DirectionalLight) light).getDirection().mult(5f)));
arrow.setMaterial(mat);
arrow.addControl(new LightColorUpdate(light, arrow.getMaterial(), "Color"));
gizmo.attachChild(arrow);
gizmo.attachChild(billboardNode);
jmeLight.setGizmo(gizmo);
return gizmo;
}
示例12: createSheet
import com.jme3.light.DirectionalLight; //导入依赖的package包/类
@Override
protected Sheet createSheet() {
//TODO: multithreading..
Sheet sheet = super.createSheet();
Sheet.Set set = Sheet.createPropertiesSet();
set.setDisplayName("DirectionalLight");
set.setName(DirectionalLight.class.getName());
DirectionalLight obj = directionalLight;
if (obj == null) {
return sheet;
}
set.put(makeEmbedProperty(this, JmeDirectionalLight.class, Vector3f.class, "getDirection", "setDirection", "Direction"));
sheet.put(set);
return sheet;
}
示例13: actionPerformed
import com.jme3.light.DirectionalLight; //导入依赖的package包/类
@Override
public void actionPerformed(ActionEvent e) {
SceneApplication.getApplication().enqueue(new Callable<Void>() {
@Override
public Void call() throws Exception {
DirectionalLight light = new DirectionalLight();
light.setName("DirectionalLight");
light.setDirection(new Vector3f(-1, -1, -1).normalizeLocal());
light.setColor(ColorRGBA.White);
node.addLight(light);
addLightUndo(node, light);
setModified();
return null;
}
});
}
示例14: initFloor
import com.jme3.light.DirectionalLight; //导入依赖的package包/类
public Spatial initFloor() {
Material mat3 = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
Geometry floor = new Geometry("floor", new Box(Vector3f.ZERO, 100f, 0.1f, 100f));
mat3.setTexture("ColorMap", assetManager.loadTexture("Textures/test/_Pond.jpg"));
floor.setMaterial(mat3);
// Spatial floor = assetManager.loadModel("Models/env/terrain/treasure.j3o");
AmbientLight light = new AmbientLight();
light.setColor(ColorRGBA.White);
rootNode.addLight(light);
rootNode.addLight(new DirectionalLight());
GeometryUtils.makeUnshaded(floor);
this.rootNode.attachChild(floor);
return floor;
}
示例15: simpleInitApp
import com.jme3.light.DirectionalLight; //导入依赖的package包/类
@Override
public void simpleInitApp() {
inputManager.setCursorVisible(true);
flyCam.setDragToRotate(true);
flyCam.setMoveSpeed(10);
rootNode.addLight(new DirectionalLight());
rootNode.addLight(new AmbientLight());
for (int i = 0; i < 10; i++) {
Spatial sinbad = this.assetManager.loadModel("Models/Sinbad.mesh.j3o");
sinbad.setLocalScale(0.5f);
sinbad.setLocalTranslation(5 * FastMath.nextRandomFloat() - 2.5f, 5 * FastMath.nextRandomFloat() - 2.5f, 5 * FastMath.nextRandomFloat() - 2.5f);
sinbad.getControl(AnimControl.class).createChannel().setAnim("run");
this.rootNode.attachChild(sinbad);
}
System.out.println("TestJmeApp started......");
}