I use a simple table of materials taken from OpenGL demo code and a
search
for 'OpenGL' and 'Material'.
Note that it does not have values for the emissive color.
Regards,
Robert
public static java.util.Hashtable materials = new
java.util.Hashtable();
public static void initializeMaterials() {
String[] names = new String[] {
"emerald",
"jade",
"obsidian",
"pearl",
"ruby",
"turquoise",
"brass",
"bronze",
"chrome",
"copper",
"gold",
"silver",
"black plastic",
"cyan plastic",
"green plastic",
"red plastic",
"white plastic",
"yellow plastic",
"black rubber",
"cyan rubber",
"green rubber",
"red rubber",
"white rubber",
"yellow rubber",
"pewter",
"black rubber"
};
// Ambient r, g, b Diffuse r, g, b
Specular r, g, b Shininess
double[] colorValues = new double[] {
0.0215, 0.1745, 0.0215, 0.07568, 0.61424, 0.07568,
0.633, 0.727811, 0.633, 0.6,
0.135, 0.2225, 0.1575, 0.54, 0.89, 0.63,
0.316228, 0.316228, 0.316228, 0.1,
0.05375, 0.05, 0.06625, 0.18275, 0.17, 0.22525,
0.332741, 0.328634, 0.346435, 0.3,
0.25, 0.20725, 0.20725, 1, 0.829, 0.829,
0.296648, 0.296648, 0.296648, 0.088,
0.1745, 0.01175, 0.01175, 0.61424, 0.04136, 0.04136,
0.727811, 0.626959, 0.626959, 0.6,
0.1, 0.18725, 0.1745, 0.396, 0.74151, 0.69102,
0.297254, 0.30829, 0.306678, 0.1,
0.329412, 0.223529, 0.027451, 0.780392, 0.568627,
0.113725, 0.992157, 0.941176, 0.807843, 0.21794872,
0.2125, 0.1275, 0.054, 0.714, 0.4284, 0.18144,
0.393548, 0.271906, 0.166721, 0.2,
0.25, 0.25, 0.25, 0.4, 0.4, 0.4,
0.774597, 0.774597, 0.774597, 0.6,
0.19125, 0.0735, 0.0225, 0.7038, 0.27048, 0.0828,
0.256777, 0.137622, 0.086014, 0.1,
0.24725, 0.1995, 0.0745, 0.75164, 0.60648, 0.22648,
0.628281, 0.555802, 0.366065, 0.4,
0.19225, 0.19225, 0.19225, 0.50754, 0.50754, 0.50754,
0.508273, 0.508273, 0.508273, 0.4,
0.0, 0.0, 0.0, 0.01, 0.01, 0.01,
0.50, 0.50, 0.50, .25,
0.0, 0.1, 0.06, 0.0, 0.50980392,
0.50980392, 0.50196078, 0.50196078, 0.50196078, .25,
0.0, 0.0, 0.0, 0.1, 0.35, 0.1,
0.45, 0.55, 0.45, .25,
0.0, 0.0, 0.0, 0.5, 0.0, 0.0,
0.7, 0.6, 0.6, .25,
0.0, 0.0, 0.0, 0.55, 0.55, 0.55,
0.70, 0.70, 0.70, .25,
0.0, 0.0, 0.0, 0.5, 0.5, 0.0,
0.60, 0.60, 0.50, .25,
0.02, 0.02, 0.02, 0.01, 0.01, 0.01,
0.4, 0.4, 0.4, .078125,
0.0, 0.05, 0.05, 0.4, 0.5, 0.5,
0.04, 0.7, 0.7, .078125,
0.0, 0.05, 0.0, 0.4, 0.5, 0.4,
0.04, 0.7, 0.04, .078125,
0.05, 0.0, 0.0, 0.5, 0.4, 0.4,
0.7, 0.04, 0.04, .078125,
0.05, 0.05, 0.05, 0.5, 0.5, 0.5,
0.7, 0.7, 0.7, .078125,
0.05, 0.05, 0.0, 0.5, 0.5, 0.4,
0.7, 0.7, 0.04, .078125,
0.105882, 0.058824, 0.113725, 0.427451, 0.470588,
0.541176, 0.3333333, 0.3333333, 0.521569, 0.1,
0.02, 0.02, 0.02, 0.01, 0.01, 0.01,
0.4, 0.4, 0.4, 0.1
};
javax.media.j3d.Material material;
javax.vecmath.Color3f ambient;
javax.vecmath.Color3f diffuse;
javax.vecmath.Color3f specular;
javax.vecmath.Color3f emissive;
javax.vecmath.Color3f black = new javax.vecmath.Color3f(0.0f,
0.0f, 0.0f);
float shininess;
int ci=0;
for (int i=0; i<names.length; i++) {
ambient = new javax.vecmath.Color3f((float)colorValues[ci],
(float)colorValues[ci+1], (float)colorValues[ci+2]); ci+=3;
diffuse = new javax.vecmath.Color3f((float)colorValues[ci],
(float)colorValues[ci+1], (float)colorValues[ci+2]); ci+=3;
emissive = black;
specular = new javax.vecmath.Color3f((float)colorValues[ci],
(float)colorValues[ci+1], (float)colorValues[ci+2]); ci+=3;
shininess = linearTransform((float)colorValues[ci++], 0.0f,
1.0f, 1.0f, 128f);
material = new javax.media.j3d.Material(ambient, emissive,
diffuse, specular, shininess);
materials.put(names[i], material);
}
}
public static float linearTransform(float value, float s_min, float
s_max, float d_min, float d_max) {
float multFactor = (d_max - d_min) / (s_max - s_min);
float shift = multFactor * s_min - d_min;
return multFactor * value - shift;
}
===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA3D-INTEREST". For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".