Using SceneForm, I am displaying a 3D object which I obtain from an SFB file stored externally and I need to change its color. Is there a way to modify the file so as to change its color?
The material is just color:
newmtl Steel_-_Satin
Kd 0.627451 0.627451 0.627451
I would like to avoid:
Thanks in advance!
One way to set the color of a renderable at runtime is by changing the "baseColorTint" material parameter. below is an example of how to tint a renderable red:
renderable.getMaterial().setFloat4("baseColorTint", new Color(1.0f, 0.0f, 0.0f, 1.0f));
Also, if you want to have multiple copies of the renderable each set to a different color, you can do this:
Renderable tintedRenderable = originalRenderable.makeCopy();
tintedRenderable.getMaterial().setFloat4("baseColorTint", new Color(1.0f, 0.0f, 0.0f, 1.0f));
Note, this works by multiplying the "baseColor" coming from the object's texture. this will work best if the object is pure white before it is tinted.
Also, different sfbs can have different sets of material parameters. You can get an idea of what material parameters exist in your sfb by looking at the "parameters" block of the .sfa file. You can also write a custom material with your own material parameters and use that to control how your sfb looks and feels at runtime.