Hi,
I´m having a TriangleStripArray polygon an I want to fill it with different
colors. The colors should be correlated with the y-values an interpolated
between different y-values (in my programm the y-values of the
VirtualUniverse are named as the z-values, confusing but necessary!).
I read the manuals and tried nearly everything but I didn´t have any
success. I´ve tried to configure with ColoringAttributes, Material,
PolygonAttributes and other classes. You can see my whole createAppearance
method in the attachment.
The complete classes and source are also attached. You can start the project
with:
java -jar Matrix3dplot.jar
The VisualObject-class is Plot.java. The Appearance (in Plot.java) method
begins in line 173 and ends in line 208
Thanks for any hints and tipps,
Bernd
Matrix3dplot.jar
Matrix3dplot.java
Plot.java
Appearance createTriangleAppearance()
{
Appearance app = new Appearance();
ColoringAttributes c_att = new ColoringAttributes(0.2f, 0.1f, 0.8f,
ColoringAttributes.SHADE_GOURAUD);
//c_att.setColor(new Color3f(0.0f, 1.0f, 0.0f));
app.setColoringAttributes(c_att);
///////////////////////////////////////////////////////////////////////////////
// Material
Material mat = new Material(new Color3f(0.0f, 0.0f, 0.0f), // ambientColor -
the material's ambient color
new Color3f(0.0f, 0.8f, 0.0f), // emissiveColor -
the material's emissive color
new Color3f(0.0f, 1.0f, 0.4f), // diffuseColor -
the material's diffuse color when illuminated by a light
new Color3f(1.0f, 1.0f, 0.0f), // specularColor -
the material's specular color when illuminated to generate a highlight
128.0f) ; // shininess - the material's shininess
in the range [1.0, 128.0] with 1.0 being not shiny and 128.0 being very shiny. Values
outside this range are clamped.
app.setMaterial(mat);
// Material End
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
// Polygon attributes
PolygonAttributes TrianglePolygonAttrib = new PolygonAttributes(
PolygonAttributes.POLYGON_FILL, //polygonMode - polygon
rasterization mode; one of POLYGON_POINT, POLYGON_LINE, or POLYGON_FILL
PolygonAttributes.CULL_NONE, // Integer cullFace - polygon culling
mode; one of CULL_NONE, CULL_BACK, or CULL_FRONT
100f, // polygonOffset - constant polygon offset
false, // backFaceNormalFlip - back face normal flip flag; true or
false
100f); // polygonOffset - polygon offset factor for slope-based
polygon offset
app.setPolygonAttributes(TrianglePolygonAttrib);
//Polygon attributes end
////////////////////////////////////////////////////////////////////////////////
return app;
}