/** * Adds each r,g,b,a of this <code>ColorRGBA</code> by the corresponding * r,g,b,a of the given color and returns the result as a new <code>ColorRGBA</code>. * Used as a way of combining colors and lights. * @param c The color to add. * @return The new <code>ColorRGBA</code>. this+c */ public ColorRGBA add(ColorRGBA c) { return new ColorRGBA(c.r + r, c.g + g, c.b + b, c.a + a); }
/** * Multiplies each r,g,b,a of this <code>ColorRGBA</code> by the corresponding * r,g,b,a of the given color and returns the result as a new <code>ColorRGBA</code>. * Used as a way of combining colors and lights. * @param c The color to multiply by. * @return The new <code>ColorRGBA</code>. this*c */ public ColorRGBA mult(ColorRGBA c) { return new ColorRGBA(c.r * r, c.g * g, c.b * b, c.a * a); }
/** * Multiplies each r,g,b,a of this <code>ColorRGBA</code> by the given scalar and * returns the result as a new <code>ColorRGBA</code>. * Used as a way of making colors dimmer or brighter. * @param scalar The scalar to multiply by. * @return The new <code>ColorRGBA</code>. this*scalar */ public ColorRGBA mult(float scalar) { return new ColorRGBA(scalar * r, scalar * g, scalar * b, scalar * a); }
static ColorRGBA[] toColorRGBA(double[] data) { ColorRGBA[] colors = new ColorRGBA[data.length / 4]; for (int i = 0; i < colors.length; i++) { float r = (float) data[i * 4]; float g = (float) data[i * 4 + 1]; float b = (float) data[i * 4 + 2]; float a = (float) data[i * 4 + 3]; colors[i] = new ColorRGBA(r, g, b, a); } return colors; } }
private ColorRGBA readColor(String content){ String[] split = content.split("\\s"); ColorRGBA color = new ColorRGBA(); color.r = Float.parseFloat(split[0]); color.g = Float.parseFloat(split[1]); color.b = Float.parseFloat(split[2]); if (split.length >= 4){ color.a = Float.parseFloat(split[3]); } return color; }
public static ColorRGBA getAsColor(JsonObject parent, String name) { JsonElement el = parent.get(name); if (el == null) { return null; } JsonArray color = el.getAsJsonArray(); return new ColorRGBA(color.get(0).getAsFloat(), color.get(1).getAsFloat(), color.get(2).getAsFloat(), color.size() > 3 ? color.get(3).getAsFloat() : 1f); }
/** * Loads the background color. * @param worldStructure * the world's structure * @return the horizon color of the world which is used as a background color. */ public ColorRGBA toBackgroundColor(Structure worldStructure) { float horr = ((Number) worldStructure.getFieldValue("horr")).floatValue(); float horg = ((Number) worldStructure.getFieldValue("horg")).floatValue(); float horb = ((Number) worldStructure.getFieldValue("horb")).floatValue(); return new ColorRGBA(horr, horg, horb, 1); }
public static ColorRGBA parseColor(Attributes attribs) throws SAXException{ float r = parseFloat(attribs.getValue("r")); float g = parseFloat(attribs.getValue("g")); float b = parseFloat(attribs.getValue("b")); return new ColorRGBA(r, g, b, 1f); }
private void init(int nbSplits, int shadowMapSize) { nbShadowMaps = Math.max(Math.min(nbSplits, 4), 1); if (nbShadowMaps != nbSplits) { throw new IllegalArgumentException("Number of splits must be between 1 and 4. Given value : " + nbSplits); } splits = new ColorRGBA(); splitsArray = new float[nbSplits + 1]; shadowCam = new Camera(shadowMapSize, shadowMapSize); shadowCam.setParallelProjection(true); for (int i = 0; i < points.length; i++) { points[i] = new Vector3f(); } }
/** * <code>randomColor</code> is a utility method that generates a random * opaque color. * @return a random <code>ColorRGBA</code> with an alpha set to 1. */ public static ColorRGBA randomColor() { ColorRGBA rVal = new ColorRGBA(0, 0, 0, 1); rVal.r = FastMath.nextRandomFloat(); rVal.g = FastMath.nextRandomFloat(); rVal.b = FastMath.nextRandomFloat(); return rVal; }
@Override public void simpleUpdate(float tpf){ time += tpf; if (time > 1f){ time -= 1f; prevColor = nextColor; nextColor = ColorRGBA.randomColor(); } ColorRGBA currentColor = new ColorRGBA(); currentColor.interpolateLocal(prevColor, nextColor, time); mat.setColor("Color", currentColor); }
public void setupLighting() { dl = new DirectionalLight(); dl.setDirection(lightDir); dl.setColor(new ColorRGBA(.9f, .9f, .9f, 1)); rootNode.addLight(dl); } Material mat;
protected ColorRGBA readColor(){ ColorRGBA v = new ColorRGBA(); v.set(scan.nextFloat(), scan.nextFloat(), scan.nextFloat(), 1.0f); return v; }
public void setupLighting() { dl = new DirectionalLight(); dl.setDirection(lightDir); dl.setColor(new ColorRGBA(.9f, .9f, .9f, 1)); rootNode.addLight(dl); } Material mat;
public void setupLighting() { DirectionalLight dl = new DirectionalLight(); dl.setDirection(lightDir); dl.setColor(new ColorRGBA(.9f, .9f, .9f, 1)); rootNode.addLight(dl); dl = new DirectionalLight(); dl.setDirection(new Vector3f(1, 0, -1).normalizeLocal()); dl.setColor(new ColorRGBA(.4f, .4f, .4f, 1)); // rootNode.addLight(dl); }
private void setupLight() { // AmbientLight al = new AmbientLight(); // al.setColor(ColorRGBA.White.mult(1)); // rootNode.addLight(al); DirectionalLight dl = new DirectionalLight(); dl.setDirection(new Vector3f(-0.1f, -0.7f, -1).normalizeLocal()); dl.setColor(new ColorRGBA(1f, 1f, 1f, 1.0f)); rootNode.addLight(dl); }
private void setupLight() { DirectionalLight dl = new DirectionalLight(); dl.setDirection(new Vector3f(-0.1f, -0.7f, -1).normalizeLocal()); dl.setColor(new ColorRGBA(1f, 1f, 1f, 1.0f)); rootNode.addLight(dl); }
private void createLight() { Vector3f direction = new Vector3f(-0.1f, -0.7f, -1).normalizeLocal(); DirectionalLight dl = new DirectionalLight(); dl.setDirection(direction); dl.setColor(new ColorRGBA(1f, 1f, 1f, 1.0f)); rootNode.addLight(dl); }
public void setupLighting(){ DirectionalLight dl = new DirectionalLight(); dl.setDirection(new Vector3f(-1, -1, 1).normalizeLocal()); dl.setColor(new ColorRGBA(2,2,2,1)); rootNode.addLight(dl); }
private void setupFog() { // use fog to give more sense of depth FilterPostProcessor fpp; FogFilter fog; fpp=new FilterPostProcessor(assetManager); fog=new FogFilter(); fog.setFogColor(new ColorRGBA(0.0f, 0.0f, 0.0f, 1.0f)); fog.setFogDistance(poiRadius); fog.setFogDensity(2.0f); fpp.addFilter(fog); viewPort.addProcessor(fpp); }