use of com.jme3.math.ColorRGBA in project jmonkeyengine by jMonkeyEngine.
the class TestBatchNodeCluster method randomColor.
// public BatchNode randomBatch() {
//
// int randomn = rand.nextInt(4);
// if (randomn == 0) {
// return blue;
// } else if (randomn == 1) {
// return brown;
// } else if (randomn == 2) {
// return pink;
// } else if (randomn == 3) {
// return orange;
// }
// return null;
// }
public ColorRGBA randomColor() {
ColorRGBA color = ColorRGBA.Black;
int randomn = rand.nextInt(4);
if (randomn == 0) {
color = ColorRGBA.Orange;
} else if (randomn == 1) {
color = ColorRGBA.Blue;
} else if (randomn == 2) {
color = ColorRGBA.Brown;
} else if (randomn == 3) {
color = ColorRGBA.Magenta;
}
return color;
}
use of com.jme3.math.ColorRGBA in project jmonkeyengine by jMonkeyEngine.
the class TestBlenderLoader method simpleInitApp.
@Override
public void simpleInitApp() {
viewPort.setBackgroundColor(ColorRGBA.DarkGray);
//load model with packed images
Spatial ogre = assetManager.loadModel("Blender/2.4x/Sinbad.blend");
rootNode.attachChild(ogre);
//load model with referenced images
Spatial track = assetManager.loadModel("Blender/2.4x/MountainValley_Track.blend");
rootNode.attachChild(track);
// sunset light
DirectionalLight dl = new DirectionalLight();
dl.setDirection(new Vector3f(-0.1f, -0.7f, 1).normalizeLocal());
dl.setColor(new ColorRGBA(0.44f, 0.30f, 0.20f, 1.0f));
rootNode.addLight(dl);
// skylight
dl = new DirectionalLight();
dl.setDirection(new Vector3f(-0.6f, -1, -0.6f).normalizeLocal());
dl.setColor(new ColorRGBA(0.10f, 0.22f, 0.44f, 1.0f));
rootNode.addLight(dl);
// white ambient light
dl = new DirectionalLight();
dl.setDirection(new Vector3f(1, -0.5f, -0.1f).normalizeLocal());
dl.setColor(new ColorRGBA(0.80f, 0.70f, 0.80f, 1.0f));
rootNode.addLight(dl);
}
use of com.jme3.math.ColorRGBA in project jmonkeyengine by jMonkeyEngine.
the class BombControl method prepareEffect.
private void prepareEffect(AssetManager assetManager) {
int COUNT_FACTOR = 1;
float COUNT_FACTOR_F = 1f;
effect = new ParticleEmitter("Flame", Type.Triangle, 32 * COUNT_FACTOR);
effect.setSelectRandomImage(true);
effect.setStartColor(new ColorRGBA(1f, 0.4f, 0.05f, (float) (1f / COUNT_FACTOR_F)));
effect.setEndColor(new ColorRGBA(.4f, .22f, .12f, 0f));
effect.setStartSize(1.3f);
effect.setEndSize(2f);
effect.setShape(new EmitterSphereShape(Vector3f.ZERO, 1f));
effect.setParticlesPerSec(0);
effect.setGravity(0, -5f, 0);
effect.setLowLife(.4f);
effect.setHighLife(.5f);
effect.setInitialVelocity(new Vector3f(0, 7, 0));
effect.setVelocityVariation(1f);
effect.setImagesX(2);
effect.setImagesY(2);
Material mat = new Material(assetManager, "Common/MatDefs/Misc/Particle.j3md");
mat.setTexture("Texture", assetManager.loadTexture("Effects/Explosion/flame.png"));
effect.setMaterial(mat);
}
use of com.jme3.math.ColorRGBA in project jmonkeyengine by jMonkeyEngine.
the class TestHoveringTank method simpleInitApp.
@Override
public void simpleInitApp() {
bulletAppState = new BulletAppState();
bulletAppState.setThreadingType(BulletAppState.ThreadingType.PARALLEL);
stateManager.attach(bulletAppState);
// bulletAppState.getPhysicsSpace().enableDebug(assetManager);
bulletAppState.getPhysicsSpace().setAccuracy(1f / 30f);
rootNode.attachChild(SkyFactory.createSky(assetManager, "Textures/Sky/Bright/BrightSky.dds", false));
PssmShadowRenderer pssmr = new PssmShadowRenderer(assetManager, 2048, 3);
pssmr.setDirection(new Vector3f(-0.5f, -0.3f, -0.3f).normalizeLocal());
pssmr.setLambda(0.55f);
pssmr.setShadowIntensity(0.6f);
pssmr.setCompareMode(CompareMode.Hardware);
pssmr.setFilterMode(FilterMode.Bilinear);
viewPort.addProcessor(pssmr);
setupKeys();
createTerrain();
buildPlayer();
DirectionalLight dl = new DirectionalLight();
dl.setColor(new ColorRGBA(1.0f, 0.94f, 0.8f, 1f).multLocal(1.3f));
dl.setDirection(new Vector3f(-0.5f, -0.3f, -0.3f).normalizeLocal());
rootNode.addLight(dl);
Vector3f lightDir2 = new Vector3f(0.70518064f, 0.5902297f, -0.39287305f);
DirectionalLight dl2 = new DirectionalLight();
dl2.setColor(new ColorRGBA(0.7f, 0.85f, 1.0f, 1f));
dl2.setDirection(lightDir2);
rootNode.addLight(dl2);
}
use of com.jme3.math.ColorRGBA in project jmonkeyengine by jMonkeyEngine.
the class TangentBinormalGenerator method genTangentLines.
private static Mesh genTangentLines(Mesh mesh, float scale) {
FloatBuffer vertexBuffer = (FloatBuffer) mesh.getBuffer(Type.Position).getData();
FloatBuffer normalBuffer = (FloatBuffer) mesh.getBuffer(Type.Normal).getData();
FloatBuffer tangentBuffer = (FloatBuffer) mesh.getBuffer(Type.Tangent).getData();
FloatBuffer binormalBuffer = null;
if (mesh.getBuffer(Type.Binormal) != null) {
binormalBuffer = (FloatBuffer) mesh.getBuffer(Type.Binormal).getData();
}
ColorRGBA originColor = ColorRGBA.White;
ColorRGBA tangentColor = ColorRGBA.Red;
ColorRGBA binormalColor = ColorRGBA.Green;
ColorRGBA normalColor = ColorRGBA.Blue;
Mesh lineMesh = new Mesh();
lineMesh.setMode(Mesh.Mode.Lines);
Vector3f origin = new Vector3f();
Vector3f point = new Vector3f();
Vector3f tangent = new Vector3f();
Vector3f normal = new Vector3f();
IntBuffer lineIndex = BufferUtils.createIntBuffer(vertexBuffer.limit() / 3 * 6);
FloatBuffer lineVertex = BufferUtils.createFloatBuffer(vertexBuffer.limit() * 4);
FloatBuffer lineColor = BufferUtils.createFloatBuffer(vertexBuffer.limit() / 3 * 4 * 4);
boolean hasParity = mesh.getBuffer(Type.Tangent).getNumComponents() == 4;
float tangentW = 1;
for (int i = 0; i < vertexBuffer.limit() / 3; i++) {
populateFromBuffer(origin, vertexBuffer, i);
populateFromBuffer(normal, normalBuffer, i);
if (hasParity) {
tangent.x = tangentBuffer.get(i * 4);
tangent.y = tangentBuffer.get(i * 4 + 1);
tangent.z = tangentBuffer.get(i * 4 + 2);
tangentW = tangentBuffer.get(i * 4 + 3);
} else {
populateFromBuffer(tangent, tangentBuffer, i);
}
int index = i * 4;
int id = i * 6;
lineIndex.put(id, index);
lineIndex.put(id + 1, index + 1);
lineIndex.put(id + 2, index);
lineIndex.put(id + 3, index + 2);
lineIndex.put(id + 4, index);
lineIndex.put(id + 5, index + 3);
setInBuffer(origin, lineVertex, index);
setInBuffer(originColor, lineColor, index);
point.set(tangent);
point.multLocal(scale);
point.addLocal(origin);
setInBuffer(point, lineVertex, index + 1);
setInBuffer(tangentColor, lineColor, index + 1);
if (binormalBuffer == null) {
normal.cross(tangent, point);
point.multLocal(-tangentW);
point.normalizeLocal();
} else {
populateFromBuffer(point, binormalBuffer, i);
}
point.multLocal(scale);
point.addLocal(origin);
setInBuffer(point, lineVertex, index + 2);
setInBuffer(binormalColor, lineColor, index + 2);
point.set(normal);
point.multLocal(scale);
point.addLocal(origin);
setInBuffer(point, lineVertex, index + 3);
setInBuffer(normalColor, lineColor, index + 3);
}
lineMesh.setBuffer(Type.Index, 1, lineIndex);
lineMesh.setBuffer(Type.Position, 3, lineVertex);
lineMesh.setBuffer(Type.Color, 4, lineColor);
lineMesh.setStatic();
//lineMesh.setInterleaved();
return lineMesh;
}
Aggregations