Vamshi,
I took a quick look and here are a couple of suggestions:
This line:
{ return new Color3f(0.6f, 0.9f, 0.6f);
Seems to be get mapped into a Material for your Shape3D as:
Material m = new Material(objColor,eColor,objColor,sColor,100.0f);
objColor = greenish
eColor = black
sColor = white
So, there doesn't seem to be any correlation with the height (that code is
commented out in the average_color1 method).
This approach is also going to be *very slow* as you are generating a
Shape3D for each triangle in your terrain. Instead you should use a single
TriangleArray for the entire terrain and per-vertex colors (setColor) on
each vertex rather than using Materials on Shape3Ds. Alternatively you could
generate a texture image, or just drape your input bitmap over your terrain
using texture coordinates assigned to each vertex. Take a look on
www.j3d.org, or search for DEM code. There are several people who have
posted work like this; converting height-fields into 3D geometry.
Best of luck!
Sincerely,
Daniel Selman
-----Original Message-----
From: Discussion list for Java 3D API
[mailto:[EMAIL PROTECTED]]On Behalf Of vamshi raghu
Sent: Saturday, December 29, 2001 8:05 AM
To: [EMAIL PROTECTED]
Subject: problem setting color
Hi!
I want to generate a terrain by using z = intensity(point @ x,y), and
connecting up the
points so generated with tringles.
problem 1)
I want the color of the triangle to be the average color of it's vertices -
why isn't this code working ? the color is always green
problem 2)
The terrain is positioned a little bit "behind" the screen. You can use the
keyboard to translate it (a keyboard navigate behavior is attached) - but
I'm not
able to translate the scene before displaying it.
(code attached)
thanks!
vamshi.
===========================================================================
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".