/** * 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; }
/** * 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()); } }
private String formatValue(MatParam param) { Object value = param.getValue(); if (value == null) { return null; } switch (param.getVarType()) { case Vector2: Vector2f v2 = (Vector2f) value; return v2.getX() + " " + v2.getY(); case Vector3: Vector3f v3 = (Vector3f) value; return v3.getX() + " " + v3.getY() + " " + v3.getZ(); case Vector4: if (value instanceof ColorRGBA) { ColorRGBA c = (ColorRGBA) value; return c.getRed() + " " + c.getGreen() + " " + c.getBlue() + " " + c.getAlpha(); } else { Vector4f v4 = (Vector4f) value; return v4.getX() + " " + v4.getY() + " " + v4.getZ() + " " + v4.getW(); } default: return value.toString(); } } }
ColorRGBA color = (ColorRGBA) val; return color.getRed() + " " + color.getGreen() + " " + color.getBlue() + " " + color.getAlpha(); } else if (val instanceof Quaternion) { Quaternion quat = (Quaternion) val;
ColorRGBA color = (ColorRGBA) value; return color.getRed() + " " + color.getGreen() + " " + color.getBlue() + " " + color.getAlpha(); } else if (value instanceof Quaternion) { Quaternion quat = (Quaternion) value;
/** * 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 createColorTexture(ColorRGBA color){ if (color.getAlpha() == 1.0f){ // create RGB texture ByteBuffer data = BufferUtils.createByteBuffer(3); byte[] bytes = color.asBytesRGBA(); data.put(bytes[0]).put(bytes[1]).put(bytes[2]); data.flip(); return new Image(Format.RGB8, 1, 1, data); }else{ // create RGBA texture ByteBuffer data = BufferUtils.createByteBuffer(4); data.putInt(color.asIntRGBA()); data.flip(); return new Image(Format.RGBA8, 1, 1, data); } }
private String formatValue(MatParam param) { Object value = param.getValue(); if (value == null) { return null; } switch (param.getVarType()) { case Vector2: Vector2f v2 = (Vector2f) value; return v2.getX() + " " + v2.getY(); case Vector3: Vector3f v3 = (Vector3f) value; return v3.getX() + " " + v3.getY() + " " + v3.getZ(); case Vector4: if (value instanceof ColorRGBA) { ColorRGBA c = (ColorRGBA) value; return c.getRed() + " " + c.getGreen() + " " + c.getBlue() + " " + c.getAlpha(); } else { Vector4f v4 = (Vector4f) value; return v4.getX() + " " + v4.getY() + " " + v4.getZ() + " " + v4.getW(); } default: return value.toString(); } } }
ColorRGBA color = (ColorRGBA) val; return color.getRed() + " " + color.getGreen() + " " + color.getBlue() + " " + color.getAlpha(); } else if (val instanceof Quaternion) { Quaternion quat = (Quaternion) val;
ColorRGBA color = (ColorRGBA) value; return color.getRed() + " " + color.getGreen() + " " + color.getBlue() + " " + color.getAlpha(); } else if (value instanceof Quaternion) { Quaternion quat = (Quaternion) value;
ColorRGBA color = (ColorRGBA) value; return color.getRed() + " " + color.getGreen() + " " + color.getBlue() + " " + color.getAlpha(); } else if (value instanceof Quaternion) { Quaternion quat = (Quaternion) value;