Very, very niche, I imagine.
Think of this question as more a curiosity, than an absolute need for a solution, as I can work around it. I’m just interested in knowing if there is a nice, clean, elegant solution.
Presume I have a simple Geometry with a Material and a Color, such as:
Box b = new Box(1, 1, 1); Geometry geom = new Geometry("blue cube", b); Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md"); mat.setColor("Color", new ColorRGBA(0.2f, 0.4f, 0.6f, 0.8f)); geom.setQueueBucket(RenderQueue.Bucket.Transparent); geom.setMaterial(mat); rootNode.attachChild(geom);
Now, in some other part of a program, a part that doesn’t know the four values passed to ColorRGBA, I would like to change, or even interpolate, one of the four channels of ColorRGBA to some other value. Like so (pretend I am doing this effectively):
((Geometry) spatial).getMaterial().setColor("Color", new ColorRGBA(????));
What would I put for “????” above if I wanted to, say, change only the Blue channel of RGBA, while leaving all other channels the same:
Math.min([Current Blue channel value]+0.5f, 1.0f)
For that matter, is there a more clean method of reading the current, for example, Blue channel value than something like:
Float.parseFloat((String.valueOf(((Geometry) spatial).getMaterial().getParam("Color")).split(" ")))
Thanks for indulging my curiosity and patience for probably bad code!
P.S. “bananapie” or something