trianglestriparray, and modelling wire frames

Hi,

I see that i didnt make it that clear what i was asking about.

firstly, the line

MS3D.setGeometry(Geometry gi);

is the one that is giving the error. But as u’ve explained, the gi is from GeometryInfo, and that isnt related to Geomtry

Well, u see, this is the part of my prog that i cant figure out, hence the poor explanation.

So basically i am asking, how do i need to specify Shape3D before i call the setGeometry method?

Or by extending Shape in my SetStripA() method will i be able to call setGeometry without a problem? Extending is not so clear in the java text books or notes i have, even though, its fairly fundamental java i suppose.

I could keep asking questions, but i feel i could have the total wrong end of the stick, and the questions just seem to be way off target from what i shud really be asking!

Thanks for being so patient dude…

Well i’ve also put the code from the class i attempted to write below. Maybe that might be clearer than my questions

public class SetStripA extends Geometry{

private static Color3f matColor = new Color3f(.9f,.7f,.2f);


//******************FIELDS*****************************//
/** The integer array to hold the height of the terrain at each point on the grid*/
int[][] m_nTerrainHeightArray;
/** Terrain grid width (x)*/
int m_nTerrainGridX = 0;
/** Terrain grid height/length (y)*/
int m_nTerrainGridY = 0;

int[] stripCounts;

// The number of vertices (or coordinates) is based on the
// number of horizontal strips (height - 1)(50) times the
// number of vertices per strip (width * 2)(102).
Point3d[] coords = new Point3d[5100];

    
TriangleStripArray tris = new TriangleStripArray(
            coords.length,
            GeometryArray.COORDINATES,
            stripCounts );

//*********Constructors*****************
    
/** Creates a new instance of TriangleStripArrayClass */

public SetStripA(int vertexCount,
int[] stripVertexCounts,
int[] mystripCounts) {

//New instance of shape3d
Shape3D MS3D = new Shape3D();

vertexCount = 2601;
// The strip counts handling     
this.stripCounts = new int[51];
for (int strip = 0; strip < 51; strip++) {
    stripCounts[strip] = 10;
}


int[][] hf = GetTerrainValues();
// The height field
BranchGroup objRoot = new BranchGroup();

GeometryInfo gi =
new GeometryInfo(GeometryInfo.TRIANGLE_STRIP_ARRAY);

//
// Create a stripCount array showing the number of vertices in each
// strip
//
int[] stripCounts = new int[m_nTerrainGridX-1];
    for(int strip = 0; strip < m_nTerrainGridX-1; strip++)
    stripCounts[strip] = (m_nTerrainGridY)*2;


int ci = 0; // coordinate index


for (int m_nTerrainGridX = 0; m_nTerrainGridX < m_nTerrainHeightArray.length; m_nTerrainGridX++){
    for (int m_nTerrainGridY = 0; m_nTerrainGridY < m_nTerrainHeightArray.length; m_nTerrainGridY++) {
        // use compass bearings to id the corners
        int sw = hf[m_nTerrainGridX][m_nTerrainGridY];
        int nw = hf[m_nTerrainGridX + 1][m_nTerrainGridY];

        coords[ci] = new Point3d(m_nTerrainGridY, nw, - (m_nTerrainGridX + 1));
        coords[ci + 1] = new Point3d(m_nTerrainGridY, sw, -m_nTerrainGridX);
        ci = ci + 2;
    }
}
gi.setStripCounts(stripCounts);
gi.setCoordinates(coords);  

NormalGenerator ng= new NormalGenerator();
ng.setCreaseAngle((float) Math.toRadians(30));
ng.generateNormals(gi);
//MS3D.setGeometry(Geometry gi); ********> This is where i get the ")" expected error*****
MS3D.setGeometry(tris);
}

}

There’s a couple of extra methods in my class, but this gives the basic gist, i’d say. I’ve taken a bit off the code u left in the other thread, but to be honest, i left out a fair bit that was unclear, and then tried to write it as best i cud figure out.

Cheers again

[quote]Hi,

I see that i didnt make it that clear what i was asking about.

firstly, the line

MS3D.setGeometry(Geometry gi);
[/quote]
Well if thats your code ofcourse its a syntax error.

Method definitiosn take type names, method invocations just take the parameters SO


public void method setGeometry(Geometry gi){

...



Would be legal, as would


settGeometry(gl);

But what you typed is defintiely not legal Java code.


    //MS3D.setGeometry(Geometry gi); ********> This is where i get the ")" expected error*****


Yup. See how this syntax is differnt from other method calls in your code?


    MS3D.setGeometry(tris);

This would be correct, IF you were invoking a static method on a class named MS3D.

It is not what I woudl expect to see. Rather I woudl expect to see something like this…


myShape3D = new Shape3D(tris);

Where my shape3D was declared either statically or locally like thuis:


Shape3D myShape3D;

I hope that helps.

Hi,

Thanks for the help Jk. I’m attempting to use what u’ve said to clean up my implementation process.

I’ll let u know how it goes.

Andrew

Hi,

Think i might have sorted out the problem, but not entirely sure. Still working on it really.

Have another question tho. Every time i use the statement (even when trying to run other people’s examples)
locale.addBranchGraph(viewBranch); (althought mostly with anything in the (…), ie contentBranch etc. i always get an error cannot find symbol addBranchGraph…

Now when i try and create the addBranchGraph() method, it always tells me a return type is required…

basically, i cant seem to find out what return type it wants anywhere online…

Anyone know?
ta

Are you using a SimpleUniverse or creating your own subclass of VirtualUniverse?

[quote]Hi,

Think i might have sorted out the problem, but not entirely sure. Still working on it really.

Have another question tho. Every time i use the statement (even when trying to run other people’s examples)
locale.addBranchGraph(viewBranch); (althought mostly with anything in the (…), ie contentBranch etc. i always get an error cannot find symbol addBranchGraph…

Now when i try and create the addBranchGraph() method, it always tells me a return type is required…
[/quote]
Ima bit confused again. What class is locale an instance of? A J3D class or one of your own?

All the classes in the J3D API and their fields and methods are decoumenetd in the J3D AP Javadoc:

https://j3d-core.dev.java.net/files/documents/1674/12424/java3d-1_3_2-doc.tar.gz

Hi,

I’m using a simple universe for now. Seems the more documented of the two universes.

The locale class is in the J3d API. but i’ve just seen it takes the value of virtual universe.

I suppose i need to use virtual universe then if i’m using locale.

Cheers for that

If you’re using a SimpleUniverse do you need to be making direct calls to a Locale at all?

Can you not just get by with adding your root BranchGroup directly to the SimpleUniverse?

If your using simepl unvierse, dont emss with locale, add the scenegraph direictly to your univese with

mySimpleUniverse.addBranchGraph ( myBranchGroup);

You may alsoi need to et your clipping plane in order to see anything. I set it to out of the way with this call in MDLViewer…

simpleU.getViewer().getView().setBackClipDistance(10000.0);