use of com.jme3.math.ColorRGBA in project jmonkeyengine by jMonkeyEngine.
the class TestEverything method setupLighting.
public void setupLighting() {
boolean hdr = false;
if (hdrRender != null) {
hdr = hdrRender.isEnabled();
}
DirectionalLight dl = new DirectionalLight();
dl.setDirection(lightDir);
if (hdr) {
dl.setColor(new ColorRGBA(3, 3, 3, 1));
} else {
dl.setColor(new ColorRGBA(.9f, .9f, .9f, 1));
}
rootNode.addLight(dl);
dl = new DirectionalLight();
dl.setDirection(new Vector3f(1, 0, -1).normalizeLocal());
if (hdr) {
dl.setColor(new ColorRGBA(1, 1, 1, 1));
} else {
dl.setColor(new ColorRGBA(.4f, .4f, .4f, 1));
}
rootNode.addLight(dl);
}
use of com.jme3.math.ColorRGBA in project jmonkeyengine by jMonkeyEngine.
the class TestExplosionEffect method createFlame.
private void createFlame() {
flame = new ParticleEmitter("Flame", EMITTER_TYPE, 32 * COUNT_FACTOR);
flame.setSelectRandomImage(true);
flame.setStartColor(new ColorRGBA(1f, 0.4f, 0.05f, (float) (1f / COUNT_FACTOR_F)));
flame.setEndColor(new ColorRGBA(.4f, .22f, .12f, 0f));
flame.setStartSize(1.3f);
flame.setEndSize(2f);
flame.setShape(new EmitterSphereShape(Vector3f.ZERO, 1f));
flame.setParticlesPerSec(0);
flame.setGravity(0, -5, 0);
flame.setLowLife(.4f);
flame.setHighLife(.5f);
flame.getParticleInfluencer().setInitialVelocity(new Vector3f(0, 7, 0));
flame.getParticleInfluencer().setVelocityVariation(1f);
flame.setImagesX(2);
flame.setImagesY(2);
Material mat = new Material(assetManager, "Common/MatDefs/Misc/Particle.j3md");
mat.setTexture("Texture", assetManager.loadTexture("Effects/Explosion/flame.png"));
mat.setBoolean("PointSprite", POINT_SPRITE);
flame.setMaterial(mat);
explosionEffect.attachChild(flame);
}
use of com.jme3.math.ColorRGBA in project jmonkeyengine by jMonkeyEngine.
the class TestExplosionEffect method createFlash.
private void createFlash() {
flash = new ParticleEmitter("Flash", EMITTER_TYPE, 24 * COUNT_FACTOR);
flash.setSelectRandomImage(true);
flash.setStartColor(new ColorRGBA(1f, 0.8f, 0.36f, (float) (1f / COUNT_FACTOR_F)));
flash.setEndColor(new ColorRGBA(1f, 0.8f, 0.36f, 0f));
flash.setStartSize(.1f);
flash.setEndSize(3.0f);
flash.setShape(new EmitterSphereShape(Vector3f.ZERO, .05f));
flash.setParticlesPerSec(0);
flash.setGravity(0, 0, 0);
flash.setLowLife(.2f);
flash.setHighLife(.2f);
flash.setInitialVelocity(new Vector3f(0, 5f, 0));
flash.setVelocityVariation(1);
flash.setImagesX(2);
flash.setImagesY(2);
Material mat = new Material(assetManager, "Common/MatDefs/Misc/Particle.j3md");
mat.setTexture("Texture", assetManager.loadTexture("Effects/Explosion/flash.png"));
mat.setBoolean("PointSprite", POINT_SPRITE);
flash.setMaterial(mat);
explosionEffect.attachChild(flash);
}
use of com.jme3.math.ColorRGBA in project jmonkeyengine by jMonkeyEngine.
the class TestExplosionEffect method createShockwave.
private void createShockwave() {
shockwave = new ParticleEmitter("Shockwave", Type.Triangle, 1 * COUNT_FACTOR);
// shockwave.setRandomAngle(true);
shockwave.setFaceNormal(Vector3f.UNIT_Y);
shockwave.setStartColor(new ColorRGBA(.48f, 0.17f, 0.01f, (float) (.8f / COUNT_FACTOR_F)));
shockwave.setEndColor(new ColorRGBA(.48f, 0.17f, 0.01f, 0f));
shockwave.setStartSize(0f);
shockwave.setEndSize(7f);
shockwave.setParticlesPerSec(0);
shockwave.setGravity(0, 0, 0);
shockwave.setLowLife(0.5f);
shockwave.setHighLife(0.5f);
shockwave.setInitialVelocity(new Vector3f(0, 0, 0));
shockwave.setVelocityVariation(0f);
shockwave.setImagesX(1);
shockwave.setImagesY(1);
Material mat = new Material(assetManager, "Common/MatDefs/Misc/Particle.j3md");
mat.setTexture("Texture", assetManager.loadTexture("Effects/Explosion/shockwave.png"));
shockwave.setMaterial(mat);
explosionEffect.attachChild(shockwave);
}
use of com.jme3.math.ColorRGBA in project jmonkeyengine by jMonkeyEngine.
the class TestManyLightsSingle method simpleInitApp.
@Override
public void simpleInitApp() {
renderManager.setPreferredLightMode(lm);
renderManager.setSinglePassLightBatchSize(6);
flyCam.setMoveSpeed(10);
Node scene = (Node) assetManager.loadModel("Scenes/ManyLights/Main.scene");
rootNode.attachChild(scene);
Node n = (Node) rootNode.getChild(0);
final LightList lightList = n.getWorldLightList();
final Geometry g = (Geometry) n.getChild("Grid-geom-1");
g.getMaterial().setColor("Ambient", new ColorRGBA(0.2f, 0.2f, 0.2f, 1f));
/* A colored lit cube. Needs light source! */
Box boxMesh = new Box(1f, 1f, 1f);
final Geometry boxGeo = new Geometry("Colored Box", boxMesh);
Material boxMat = g.getMaterial().clone();
boxMat.clearParam("DiffuseMap");
boxMat.setBoolean("UseMaterialColors", true);
boxMat.setColor("Ambient", new ColorRGBA(0.2f, 0.2f, 0.2f, 1f));
boxMat.setColor("Diffuse", ColorRGBA.Blue);
boxGeo.setMaterial(boxMat);
final Node cubeNodes = new Node();
n.attachChild(cubeNodes);
int nb = 0;
for (Light light : lightList) {
nb++;
PointLight p = (PointLight) light;
if (nb > 60) {
n.removeLight(light);
} else {
LightNode ln = new LightNode("l", light);
n.attachChild(ln);
ln.setLocalTranslation(p.getPosition());
int rand = FastMath.nextRandomInt(0, 3);
switch(rand) {
case 0:
light.setColor(ColorRGBA.Red);
// ln.addControl(new MoveControl(5f));
break;
case 1:
light.setColor(ColorRGBA.Yellow);
// ln.addControl(new MoveControl(5f));
break;
case 2:
light.setColor(ColorRGBA.Green);
//ln.addControl(new MoveControl(-5f));
break;
case 3:
light.setColor(ColorRGBA.Orange);
//ln.addControl(new MoveControl(-5f));
break;
}
}
Geometry b = boxGeo.clone(false);
cubeNodes.attachChild(b);
b.setLocalTranslation(p.getPosition().x, 2, p.getPosition().z);
}
// cam.setLocation(new Vector3f(3.1893547f, 17.977385f, 30.8378f));
// cam.setRotation(new Quaternion(0.14317635f, 0.82302624f, -0.23777823f, 0.49557027f));
cam.setLocation(new Vector3f(-1.8901939f, 29.34097f, 73.07533f));
cam.setRotation(new Quaternion(0.0021000702f, 0.971012f, -0.23886925f, 0.008527749f));
BasicProfilerState profiler = new BasicProfilerState(true);
profiler.setGraphScale(1000f);
// getStateManager().attach(profiler);
// guiNode.setCullHint(CullHint.Always);
flyCam.setDragToRotate(true);
flyCam.setMoveSpeed(50);
final MaterialDebugAppState debug = new MaterialDebugAppState();
stateManager.attach(debug);
inputManager.addListener(new ActionListener() {
public void onAction(String name, boolean isPressed, float tpf) {
if (name.equals("toggle") && isPressed) {
if (lm == TechniqueDef.LightMode.SinglePass) {
lm = TechniqueDef.LightMode.MultiPass;
helloText.setText("(Multi pass)");
} else {
lm = TechniqueDef.LightMode.SinglePass;
helloText.setText("(Single pass) nb lights per batch : " + renderManager.getSinglePassLightBatchSize());
}
renderManager.setPreferredLightMode(lm);
reloadScene(g, boxGeo, cubeNodes);
}
if (name.equals("lightsUp") && isPressed) {
renderManager.setSinglePassLightBatchSize(renderManager.getSinglePassLightBatchSize() + 1);
helloText.setText("(Single pass) nb lights per batch : " + renderManager.getSinglePassLightBatchSize());
}
if (name.equals("lightsDown") && isPressed) {
renderManager.setSinglePassLightBatchSize(renderManager.getSinglePassLightBatchSize() - 1);
helloText.setText("(Single pass) nb lights per batch : " + renderManager.getSinglePassLightBatchSize());
}
if (name.equals("toggleOnOff") && isPressed) {
for (final Light light : lightList) {
if (light instanceof AmbientLight) {
continue;
}
light.setEnabled(!light.isEnabled());
}
}
}
}, "toggle", "lightsUp", "lightsDown", "toggleOnOff");
inputManager.addMapping("toggle", new KeyTrigger(KeyInput.KEY_SPACE));
inputManager.addMapping("lightsUp", new KeyTrigger(KeyInput.KEY_UP));
inputManager.addMapping("lightsDown", new KeyTrigger(KeyInput.KEY_DOWN));
inputManager.addMapping("toggleOnOff", new KeyTrigger(KeyInput.KEY_L));
SpotLight spot = new SpotLight();
spot.setDirection(new Vector3f(-1f, -1f, -1f).normalizeLocal());
spot.setColor(ColorRGBA.Blue.mult(5));
spot.setSpotOuterAngle(FastMath.DEG_TO_RAD * 20);
spot.setSpotInnerAngle(FastMath.DEG_TO_RAD * 5);
spot.setPosition(new Vector3f(10, 10, 20));
rootNode.addLight(spot);
DirectionalLight dl = new DirectionalLight();
dl.setDirection(new Vector3f(-1, -1, 1));
rootNode.addLight(dl);
AmbientLight al = new AmbientLight();
al.setColor(new ColorRGBA(0.2f, 0.2f, 0.2f, 1f));
rootNode.addLight(al);
/**
* Write text on the screen (HUD)
*/
guiNode.detachAllChildren();
guiFont = assetManager.loadFont("Interface/Fonts/Default.fnt");
helloText = new BitmapText(guiFont, false);
helloText.setSize(guiFont.getCharSet().getRenderedSize());
helloText.setText("(Single pass) nb lights per batch : " + renderManager.getSinglePassLightBatchSize());
helloText.setLocalTranslation(300, helloText.getLineHeight(), 0);
guiNode.attachChild(helloText);
}
Aggregations