again :o(
I changed my code parts for using J3DBuffer's, but again I got a problem.
I have compared my code with the 'GeometryByReferenceNIOBuffer' Example and I
can't figure out any differences in principle..
code bellow works fine with useBuffers false, but setting it to true nothing is
rendered.. i played it bit with the code and noticed that
geomArray.getCoordRefBuffer() returns a null-reference.. but before setting
J3DBuffer everything is fine..
any ideas what I have done wrong ?
(also removed USE_COORD_INDEX_ONLY and set all indices, but didn't change
anything..)
greetings
-Michael Nischt
CODE:
------------------------------------
boolean useBuffers = false;
if(useBuffers)
vertexFormat = GeometryArray.BY_REFERENCE |
GeometryArray.USE_NIO_BUFFER | GeometryArray.USE_COORD_INDEX_ONLY |
GeometryArray.COORDINATES | GeometryArray.NORMALS |
GeometryArray.TEXTURE_COORDINATE_2;
else
vertexFormat = GeometryArray.BY_REFERENCE |
GeometryArray.USE_COORD_INDEX_ONLY | GeometryArray.COORDINATES |
GeometryArray.NORMALS | GeometryArray.TEXTURE_COORDINATE_2;
IndexedTriangleArray geomArray = new IndexedTriangleArray(numVertices,
vertexFormat, texCoordSetCount, texCoordSetMap , numIndices);
geomArray.setCapability(GeometryArray.ALLOW_REF_DATA_READ);
geomArray.setCapability(GeometryArray.ALLOW_REF_DATA_WRITE);
float[] coords = mesh.getCoords(0);
float[] normals = mesh.getNormals(0);
ByteOrder order = ByteOrder.nativeOrder();
if(useBuffers) {
FloatBuffer coordBuffer = ByteBuffer.allocateDirect(coords.length *
4).order(order).asFloatBuffer();
FloatBuffer normalBuffer = ByteBuffer.allocateDirect(normals.length
* 4).order(order).asFloatBuffer();
coordBuffer.put(coords, 0, coords.length);
normalBuffer.put(normals, 0, normals.length);
geomArray.setColorRefBuffer(new J3DBuffer(coordBuffer));
geomArray.setNormalRefBuffer(new J3DBuffer(normalBuffer));
}
else {
geomArray.setCoordRefFloat(coords);
geomArray.setNormalRefFloat(normals);
}
geomArray.setCoordinateIndices(0, mesh.getIndices());
//geomArray.setNormalIndices(0, mesh.getIndices());
TextureUnitState[] texUnits = new TextureUnitState[texCoordSetCount];
Appearance ap = new Appearance();
ap.setMaterial(DEFAULT_MATERIAL);
ap.setPolygonAttributes(DEFAULT_POLYGON_ATTRIBUTES);
ap.setTextureUnitState(texUnits);
for(int i=0; i<texCoordSetCount; i++) {
float[] texCoords = mesh.getTexCoords();
if(useBuffers) {
FloatBuffer texCoordBuffer =
ByteBuffer.allocateDirect(texCoords.length * 4).order(order).asFloatBuffer();
texCoordBuffer.put(texCoords, 0, texCoords.length);
geomArray.setTexCoordRefBuffer(i, new
J3DBuffer(texCoordBuffer));
}
else
geomArray.setTexCoordRefFloat(i, texCoords);
//geomArray.setTextureCoordinateIndices(i, 0, mesh.getIndices());
TextureUnitState texUnit = new TextureUnitState();
texUnit.setTexture(mesh.getTexture(i));
ap.setTextureUnitState(i, texUnit);
}
shape.setAppearance(ap);
shape.setGeometry(geomArray);
this.getNode().addChild(shape);
------------------------------------
===========================================================================
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".