This is my first time using a forum, so please bear with me and my ignorance.

I'm a 3rd year university student, and am currently tackling a dissertation project in a Visualisation of a 3D terrain using Java 3d.

I am currently trying to create a 3D Array to hold elevation data for my landscape. I am using the StringTokenizer to read in a elevation data set file, and store it in my array. The Data file contains [3] - colums [51] - rows and [51] sets of these data values. This has been taken from a map of a landscape, where i broke the map down into a grid of 51 * 51 squares. Each square has data pertaining to x, height, and y values - eg. (2, 11400, 12)with an "a" separating each column of information, and a "b"

I am currently getting compiler errors which i cannot understand, and was hoping someone could give me some advice on the section of code which i am about to show.

//recognize the ) and go to next token token = Tokenizer.nextToken(); System.out.println(token);

//access the instance of arraymaker made as a field to access the array and set values ArrayMaker.myarray[0][col][row] = col; ArrayMaker.myarray[1][col][row] = row; ArrayMaker.myarray[2][col][row] = height;

//need to put these inside loop, may need to play about with it //dataLine = new StringTokenizer(fileInput.readLine()); if (Tokenizer.nextToken().compareTo("a")==0){ token = Tokenizer.nextToken(); }//space between brackets else { }

Before I get to the question, I can't help but wonder why a 3 dimensional array is being used to describe a height map. Typically, a 2 dimensional array is used with the value of the array entry being the height.

This appears to be a fundamental Java concepts issue rather than a Java3D issue. The code: MyClass.aVariable is used to access a static variable aVariable in the class MyClass. For your particular situation ArrayMaker.myarray appears to the compiler as an attempt to access the static variable myarray in the class ArrayMaker. However, the myarray variable is not static so you get the error.

It appears to me that the myarray name is used far too much in the code to keep straight (for me anyway).

Unfortunately, i tried to specify the arrayMaker as static, and the compiler returned with the error that "inner classes cannot have static declarations".

I've removed the unnecessary calls to arraymaker and my array from my source, but am still having some dificulty.

Basically, i'm not sure if the code i've posted will even begin to do what i need. I have a txt file With a list of coordinate vertices in the form (0,11400,-12) and i want to read these into an array, so that i can create a TringleStrip(ARRAY maybe) of these vertices, to create the points required, to create the object of my landscape.

Wud i be correct in suggesting that it would be better not to have the array in an inner class, and just put it in the Reader or ReaderTokenizer class?

Finally, to comment on why i chose a 3D array. The values i have are 3 vertices (x,y,z) (one dimension). There is a column (the first set of values for the left hand side of the map i am modelling) of 51 of these values. And there are 51 columns in total.

If you think about your classic object oriented programming stuff the terrain array sounds to me like a classic example of the type of thing that should have it's own class. You could use this to contain the terrain data and any specifically relevant operations you might perform on it - finding the height at a given location and so on.

I'm not entirely sure I understand your arrays - It is quite common in terrain modelling to have a regular grid so that for example you are measuring the height every metre. If you're doing that there is no point in recording the x and z co-ordinates because they will always be the same as your position in the array and the only irregular quantity will be the height.

I took on board the last comments posted about my project. Thank you for the advice given. Since then i have managed to get an File reader class working to read in the int values of my height map, into the created array, and working well.

I have now come accross a problem, in that i am not so sure how to read in the stored height values into a triangle strip array.

I have realised that in the timeframe i have left (until next thurs 21st april) i wont be able to complete the scope of my project.

However, it has been brought to my attention that creating a wire mesh for display, will get me sufficient marks to pass.

Unfortunately, as i said, i'm having trouble creating the triangle strip array, so that i can place this into my Canvas3D as a wireframe object.

I was wondering if anyone has any example code showing how this maybe done, or even any recommended tutorials which can explain the essentials of the process.

Any help would be much appreciated, as i am quickly running out of time.

I spent the last few weeks of each term in my last year at uni staying awake approximately 24/7 and desperately wishing I'd planned ahead better, or that all our programming projects hadn't been set in the last fortnight of the course...

This doesn't do what you need but it is not a thousand miles away - this actually generates a Shape3D which you can display however you want- there are a few tutorials about this to be found around the place.

The method belongs to an object that extends Shape3D- hence the setGeometry() call at the end.

The ArrayList it expects is organised into squares, as far as I can recall (haven't had much time for j3d for a few weeks) if your grid is like this:

java-gaming.org is not responsible for the content posted by its members, including references to external websites,
and other references that may or may not have a relation with our primarily
gaming and game production oriented community.
inquiries and complaints can be sent via email to the info‑account of the
company managing the website of java‑gaming.org