Thanks Allen, I am sure a lot of us will find plenty of use for your code:
Sadly I have just spent the last couple of days working on a similar matter
yet more complex:
The data I get is not from a grid=> more like a cloud of surface points.

to solve this problem, the first step has to be a triangulation of the data
set ( I have used delaunay algo).
Then I been able to use j3d normal generator and stripifier.
For those interested, the results are much better than I even expected
(especially using jdk1.3 alpha!!)
--
Olivier Fillon    Minestar Project
[EMAIL PROTECTED]  Mincom Limited
Ph.+61-7-3303-3344               61 Wyandra Street
Fax+61-7-3303-3232               Teneriffe Qld. 4005.
Australia
Company home page: http://www.mincom.com/
Personal home page: http://www.home.gil.com.au/~fillon
--
The
-----Original Message-----
From: Allen McPherson <[EMAIL PROTECTED]>
To: [EMAIL PROTECTED] <[EMAIL PROTECTED]>
Date: Thursday, September 23, 1999 8:39 AM
Subject: Re: [JAVA3D] Java3D Terrain


>Duke Gard wrote:
>>
>> Does anyone have a recommended way of depicting crude looking terrain
with
>> Java3D.
>
>        Attached are a couple of classes from my forthcoming book.
>
>        The first is Mesh.java which constructs a tri-strip mesh
>        using a passed array of post heights.  The post heights
>        can represent anything from a 2-D mathematical function
>        to terrain elevations.  Post heights should be scaled into
>        [0-1] (or even [0-0.3]) range before the Mesh is created.
>
>        The second is a simple default appearance I use--Chrome.java.
>
>        You'll need to remove the package statements to use them.
>
>        I've also attached a screen dump showing the Mesh being used to
>        display some digital terrain.  It's a 1200x1200 DEM file
>        of the area in northern New Mexico where I live.
>
>        Here's a snippet of code that shows how to load the post
>        arrays and create the mesh.  If you use really big meshes
>        you'll need to run java with the -Xms128m and -Xmx256m
>        switches.
>
>=================================
>  protected void  addScene() {
>    final int    ROWS = 1200;
>    final int    COLS = 1201;
>    float        posts[][] = new float[ROWS][COLS];   //  Heights
>
>    //  Open DEM file and read terrain elevations.  Keep track of the
>    //  Maximum elevation to properly scale the unit-size mesh.
>    try {
>      FileInputStream  fis = new FileInputStream(demFile);
>      DataInputStream  din = new DataInputStream(fis);
>      for (int r=0; r<ROWS; r++) {
>        for (int c=0; c<COLS; c++) {
>          int  elev = din.readShort();
>          posts[r][c] = (float)elev;
>        }
>      }
>    }
>    catch (IOException e) {
>      System.err.println(e);
>    }
>
>    //  Find maximum elevation
>    float  maxElev = 0.0f;
>    float  minElev = 0.0f;
>    for (int r=0; r<ROWS; r++) {
>      for (int c=0; c<COLS; c++) {
>        if (posts[r][c] > maxElev) {
>          maxElev = posts[r][c];
>          System.out.println("max to: " + maxElev);
>        }
>        if (posts[r][c] < minElev) {
>          minElev = posts[r][c];
>          System.out.println("min to: " + minElev);
>        }
>      }
>    }
>    System.out.println("Max elevation: " + maxElev);
>    System.out.println("Min elevation: " + minElev);
>
>    //  Scale the elevations to maximum of 1.0
>    for (int r=0; r<ROWS; r++) {
>      for (int c=0; c<COLS; c++) {
>        if (posts[r][c] < 0)
>          posts[r][c] = 0;
>        posts[r][c] = posts[r][c] / (maxElev * 12);
>      }
>    }
>
>    Mesh  filledMesh = new Mesh(posts);
>    //  Use the following to try different appearances.
>    if (false) {
>      Appearance  app = filledMesh.getAppearance();
>      app.setMaterial(new Material(
>        new Color3f(0.65f, 0.45f, 0.25f),            //  ambient
>        new Color3f(0.0f, 0.0f, 0.0f),               //  emmisive
>        new Color3f(0.65f, 0.45f, 0.25f),            //  diffuse
>        new Color3f(0.4f, 0.4f, 0.4f),               //  specular
>        128.0f * 0.7f));                             //  shininess
>    }
>    top.addChild(filledMesh);
>  }
>=======================
>
>        Bug reports and feedback are welcome.  I haven't tried to compile
>        it outside of my framework, so let me know if you're unable to
>        build it.
>
>--
>Allen L. McPherson               Member Holstein Aerobatic Club
>Los Alamos National Laboratory   Scientific Viz / Advanced Computing Lab
>Box 1663 Group:CIC-ACL MS:B287   [EMAIL PROTECTED]
>Los Alamos, NM   87545           Voice: (505) 665-6548  Fax: (505) 665-4939
>[Personal mail to:               [EMAIL PROTECTED]]

===========================================================================
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".

Reply via email to