/** * 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); }
/** * Sets the colors of all ranges, overriding any color tags * that were in the original text. */ void setBaseColor( ColorRGBA color ) { // There are times when the alpha is directly modified // and the caller may have passed a constant... so we // should clone it. color = color.clone(); for( Range r : colors ) { r.color = color; } }
@Override public void onAction(String name, boolean isPressed, float tpf) { if ((name.equals("ShadowUp") || name.equals("ShadowDown")) && isPressed) { al.setColor(ColorRGBA.White.mult((1 - plsr.getShadowIntensity()) * 0.2f)); } } }
@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); }
/** * Generate a new FloatBuffer using the given array of ColorRGBA objects. * The FloatBuffer will be 4 * data.length long and contain the color data. * * @param data * array of ColorRGBA objects to place into a new FloatBuffer */ public static FloatBuffer createFloatBuffer(ColorRGBA... data) { if (data == null) { return null; } FloatBuffer buff = createFloatBuffer(4 * data.length); for (int x = 0; x < data.length; x++) { if (data[x] != null) { buff.put(data[x].getRed()).put(data[x].getGreen()).put(data[x].getBlue()).put(data[x].getAlpha()); } else { buff.put(0).put(0).put(0).put(0); } } buff.flip(); return buff; }
private Image createTestImage() { Image testImage = new Image(Format.BGR8, 4, 3, BufferUtils.createByteBuffer(4 * 4 * 3), null, ColorSpace.Linear); ImageRaster io = ImageRaster.create(testImage); io.setPixel(0, 0, ColorRGBA.Black); io.setPixel(1, 0, ColorRGBA.Gray); io.setPixel(2, 0, ColorRGBA.White); io.setPixel(3, 0, ColorRGBA.White.mult(4)); // HDR color io.setPixel(0, 1, ColorRGBA.Red); io.setPixel(1, 1, ColorRGBA.Green); io.setPixel(2, 1, ColorRGBA.Blue); io.setPixel(3, 1, new ColorRGBA(0, 0, 0, 0)); io.setPixel(0, 2, ColorRGBA.Yellow); io.setPixel(1, 2, ColorRGBA.Magenta); io.setPixel(2, 2, ColorRGBA.Cyan); io.setPixel(3, 2, new ColorRGBA(1, 1, 1, 0)); return testImage; }
float yRatio = ((float)(input.getHeight() - 1)) / output.getHeight(); ColorRGBA outputColor = new ColorRGBA(0, 0, 0, 0); ColorRGBA bottomLeft = new ColorRGBA(); ColorRGBA bottomRight = new ColorRGBA(); ColorRGBA topLeft = new ColorRGBA(); ColorRGBA topRight = new ColorRGBA(); input.getPixel(x2 + 1, y2 + 1, topRight); outputColor.set(bottomLeft).addLocal(bottomRight) .addLocal(topLeft).addLocal(topRight); outputColor.multLocal(1f / 4f); output.setPixel(x, y, outputColor);
public void simpleInitApp() { this.flyCam.setMoveSpeed(50); Node mainScene=new Node(); cam.setLocation(new Vector3f(-34.74095f, 95.21318f, -287.4945f)); cam.setRotation(new Quaternion(0.023536969f, 0.9361278f, -0.016098259f, -0.35050195f)); // load sky mainScene.attachChild(SkyFactory.createSky(assetManager, "Textures/Sky/Bright/BrightSky.dds", SkyFactory.EnvMapType.CubeMap)); createTerrain(mainScene); DirectionalLight sun = new DirectionalLight(); Vector3f lightDir=new Vector3f(-0.37352666f, -0.50444174f, -0.7784704f); sun.setDirection(lightDir); sun.setColor(ColorRGBA.White.clone().multLocal(2)); mainScene.addLight(sun); rootNode.attachChild(mainScene); fpp=new FilterPostProcessor(assetManager); //fpp.setNumSamples(4); int numSamples = getContext().getSettings().getSamples(); if( numSamples > 0 ) { fpp.setNumSamples(numSamples); } fog=new FogFilter(); fog.setFogColor(new ColorRGBA(0.9f, 0.9f, 0.9f, 1.0f)); fog.setFogDistance(155); fog.setFogDensity(1.0f); fpp.addFilter(fog); viewPort.addProcessor(fpp); initInputs(); }
Vector3f lightDir = new Vector3f(-0.37352666f, -0.50444174f, -0.7784704f); sun.setDirection(lightDir); sun.setColor(ColorRGBA.White.clone().multLocal(2)); scene.addLight(sun); water.setUseRipples(false); water.setDeepWaterColor(ColorRGBA.Brown); water.setWaterColor(ColorRGBA.Brown.mult(2.0f)); water.setWaterTransparency(0.2f); water.setMaxAmplitude(0.3f);
/** * Set the start color of the particles spawned. * * <p>The particle color at any time is determined by blending the start color * and end color based on the particle's current time of life relative * to its end of life. * * @param startColor the start color of the particles spawned */ public void setStartColor(ColorRGBA startColor) { this.startColor.set(startColor); }
protected static ColorRGBA getAmbientColor(LightList lightList, boolean removeLights, ColorRGBA ambientLightColor) { ambientLightColor.set(0, 0, 0, 1); for (int j = 0; j < lightList.size(); j++) { Light l = lightList.get(j); if (l instanceof AmbientLight) { ambientLightColor.addLocal(l.getColor()); if (removeLights) { lightList.remove(l); } } } ambientLightColor.a = 1.0f; return ambientLightColor; }
return false; if (this.color != other.color && (this.color == null || !this.color.equals(other.color))) { return false;
/** * Writes the value to the data buffer. * * @param data the data buffer. * @param value the value. */ protected void writeVec4(final ByteBuffer data, final Object value) { if (value == null) { data.putLong(0).putLong(0); } else if (value instanceof Vector4f) { final Vector4f vec4 = (Vector4f) value; data.putFloat(vec4.getX()) .putFloat(vec4.getY()) .putFloat(vec4.getZ()) .putFloat(vec4.getW()); } else if(value instanceof Quaternion) { final Quaternion vec4 = (Quaternion) value; data.putFloat(vec4.getX()) .putFloat(vec4.getY()) .putFloat(vec4.getZ()) .putFloat(vec4.getW()); } else if(value instanceof ColorRGBA) { final ColorRGBA vec4 = (ColorRGBA) value; data.putFloat(vec4.getRed()) .putFloat(vec4.getGreen()) .putFloat(vec4.getBlue()) .putFloat(vec4.getAlpha()); } }
Range(int start, String colorStr) { this.start = start; this.color = new ColorRGBA(); if (colorStr.length() >= 6) { color.set(Integer.parseInt(colorStr.subSequence(0,2).toString(), 16) / 255f, Integer.parseInt(colorStr.subSequence(2,4).toString(), 16) / 255f, Integer.parseInt(colorStr.subSequence(4,6).toString(), 16) / 255f, 1); if (baseAlpha != -1) { color.a = baseAlpha; } else if (colorStr.length() == 8) { color.a = Integer.parseInt(colorStr.subSequence(6,8).toString(), 16) / 255f; } } else { color.set(Integer.parseInt(Character.toString(colorStr.charAt(0)), 16) / 15f, Integer.parseInt(Character.toString(colorStr.charAt(1)), 16) / 15f, Integer.parseInt(Character.toString(colorStr.charAt(2)), 16) / 15f, 1); if (baseAlpha != -1) { color.a = baseAlpha; } else if (colorStr.length() == 4) { color.a = Integer.parseInt(Character.toString(colorStr.charAt(3)), 16) / 15f; } } } }