Hi,

I am creating an IndexedTriangleStripArray using the following method:


        int vertexCount = points.length;
        int vertexFormat =  GeometryArray.COORDINATES   |
                            GeometryArray.NORMALS       |
                            GeometryArray.TEXTURE_COORDINATE_2 ;

        int indexCount  = indicesArray.length;
        IndexedTriangleStripArray itsArray =
                new IndexedTriangleStripArray (vertexCount, vertexFormat,
                                                        indexCount,
stripCount);

        itsArray.setCapability (GeometryArray.ALLOW_COUNT_READ);
        itsArray.setCapability (GeometryArray.ALLOW_FORMAT_READ);
        itsArray.setCapability (GeometryArray.ALLOW_COORDINATE_READ);
        itsArray.setCapability (GeometryArray.ALLOW_COORDINATE_WRITE);
        itsArray.setCapability
(IndexedGeometryArray.ALLOW_COORDINATE_INDEX_READ);

        itsArray.setCoordinates (0, points);
        itsArray.setNormals (0, normalsArray);
        itsArray.setTextureCoordinates (0, 0, texCoordsArray);

        itsArray.setCoordinateIndices (0, indicesArray);
        itsArray.setNormalIndices (0, indicesArray);
        itsArray.setTextureCoordinateIndices(0, 0, indicesArray);

This works perfectly fine.

Now, I want to make this geometry to work byReference,
so, I change this to:


        int vertexCount = points.length;
        //int vertexFormat =  GeometryArray.COORDINATES;
        int vertexFormat =  GeometryArray.COORDINATES   |
                            GeometryArray.NORMALS       |
                            GeometryArray.BY_REFERENCE  |
                            GeometryArray.TEXTURE_COORDINATE_2 ;
        int indexCount  = indicesArray.length;
        IndexedTriangleStripArray itsArray =
                new IndexedTriangleStripArray (vertexCount, vertexFormat,
                                                        indexCount,
stripCount);

        itsArray.setCapability (GeometryArray.ALLOW_COUNT_READ);
        itsArray.setCapability (GeometryArray.ALLOW_FORMAT_READ);
        itsArray.setCapability (GeometryArray.ALLOW_COORDINATE_READ);
        itsArray.setCapability (GeometryArray.ALLOW_COORDINATE_WRITE);
        itsArray.setCapability (GeometryArray.ALLOW_REF_DATA_READ);
        itsArray.setCapability (GeometryArray.ALLOW_REF_DATA_WRITE);
        itsArray.setCapability
(IndexedGeometryArray.ALLOW_COORDINATE_INDEX_READ);

        itsArray.setCoordRef3d (points);
        itsArray.setNormalRef3f (normalsArray);
        itsArray.setTexCoordRef2f (0, texCoordsArray);

        itsArray.setCoordinateIndices (0, indicesArray);
        itsArray.setNormalIndices (0, indicesArray);
        itsArray.setTextureCoordinateIndices(0, 0, indicesArray);


Now, the problem begins. On running test program that only creates this
object and adds it to the universe, I get the following error.


java.lang.ArrayIndexOutOfBoundsException
        at
javax.media.j3d.GeometryStripArrayRetained.unIndexify(GeometryStripArrayReta
ined.java:291)
        at
javax.media.j3d.IndexedGeometryStripArrayRetained.cloneNonIndexedGeometry(In
dexedGeometryStripArrayRetained.java:66)
        at
javax.media.j3d.GeometryArrayRetained.update(GeometryArrayRetained.java:419)
        at javax.media.j3d.GeometryRetained.doSetLive(GeometryRetained.java:181)
        at
javax.media.j3d.GeometryArrayRetained.setLive(GeometryArrayRetained.java:206
)
        at javax.media.j3d.Shape3DRetained.setLive(Shape3DRetained.java:1000)
        at javax.media.j3d.GroupRetained.doSetLive(GroupRetained.java:1475)
        at
javax.media.j3d.TransformGroupRetained.setLive(TransformGroupRetained.java:3
22)
        at javax.media.j3d.GroupRetained.doSetLive(GroupRetained.java:1475)
        at
javax.media.j3d.BranchGroupRetained.setLive(BranchGroupRetained.java:101)
        at javax.media.j3d.Locale.doAddBranchGraph(Locale.java:183)
        at javax.media.j3d.Locale.addBranchGraph(Locale.java:159)
        at
com.sun.j3d.utils.universe.SimpleUniverse.addBranchGraph(SimpleUniverse.java
:235)
        at IndexTest.<init>(IndexTest.java:174)
        at IndexTest.main(IndexTest.java:182)
Exception in thread "main"


In another scenario, I get the following error,
Here, I am creating multiple such geometry arrays and creating a morph
object
out of those.


java.lang.NullPointerException
        at
javax.media.j3d.GeometryArrayRetained.getCoordinate(GeometryArrayRetained.ja
va:3221)
        at
javax.media.j3d.MorphRetained.updateMorphedGeometryArray(MorphRetained.java:
586)
        at
javax.media.j3d.MorphRetained.initMorphedGeometry(MorphRetained.java:1119)
        at javax.media.j3d.MorphRetained.setGeometryArrays(MorphRetained.java:247)
        at javax.media.j3d.Morph.<init>(Morph.java:124)
        at Start.createMorphNode(Start.java:456)
        at Start.createSceneGraph(Start.java:263)
        at Start.<init>(Start.java:127)
        at Main.main(Main.java:60)


Any clue of why this might happen? Anything I have missed out in convering
the
byCopy GeometryArray to byReference?

Thanks in advance,

Regards,
Sameer

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