Probably best if you just take a look for yourself. It hangs, inexplicably, once it’s live and I call the updateData method for the geometry (down near the end.) All the appropriate capability bits seem to be set, I’m at a loss.
/* Very basic rectangular piece of geometry that displays a single texture. */
static class Element extends Shape3D implements GeometryUpdater {
final static Color3f WHITE = new Color3f(1, 1, 1);
final static Color3f BLACK = new Color3f(0, 0, 0);
final static int CAPABILITIES = GeometryArray.COORDINATES |
GeometryArray.BY_REFERENCE |
GeometryArray.TEXTURE_COORDINATE_2;
final static TransparencyAttributes TRANSATT = TRANSATT();
final static TransparencyAttributes TRANSATT() {
TransparencyAttributes transAtt = new TransparencyAttributes();
transAtt.setTransparencyMode(TransparencyAttributes.BLENDED);
return transAtt;
}
final static TextureAttributes TEXATT = TEXATT();
final static TextureAttributes TEXATT() {
TextureAttributes texAtt = new TextureAttributes();
texAtt.setTextureMode(TextureAttributes.MODULATE);
texAtt.setTextureBlendColor(1, 1, 1, 1);
return texAtt;
}
final static RenderingAttributes RENDATT = RENDATT();
final static RenderingAttributes RENDATT() {
RenderingAttributes rendAtt = new RenderingAttributes();
rendAtt.setIgnoreVertexColors(true);
return rendAtt;
}
final static PolygonAttributes POLYATT = POLYATT();
final static PolygonAttributes POLYATT() {
PolygonAttributes polyatt = new PolygonAttributes();
polyatt.setCullFace(PolygonAttributes.CULL_NONE);
return polyatt;
} //Should be common to all elements.
final static Material MATERIAL = new Material(BLACK, WHITE, BLACK, BLACK, 0); //only emissive colour shows.
final static float UV[] = {
0, 0,
0, 1,
1, 0,
0, 1,
1, 0,
1, 1
};
//final static Vector3f NORMALS[] = { NORMAL, NORMAL, NORMAL, NORMAL, NORMAL, NORMAL };
float xpos, ypos, xdim, ydim, depth;
Point3f c1 = new Point3f(), c2 = new Point3f(), c3 = new Point3f(), c4 = new Point3f(), corners[] = new Point3f[6];
float coordinates[] = new float[18];
TriangleArray geometry;
Appearance surface;
Element(float xp, float xd, float yp, float yd, float deep, Texture texture) {
depth = 0 - deep;
corners[0] = c1;
corners[1] = c2;
corners[2] = c3;
corners[3] = c2;
corners[4] = c3;
corners[5] = c4;
surface = new Appearance();
surface.setTexture(texture);
surface.setTextureAttributes(TEXATT);
surface.setMaterial(MATERIAL);
surface.setTransparencyAttributes(TRANSATT);
surface.setRenderingAttributes(RENDATT);
surface.setPolygonAttributes(POLYATT);
geometry = new TriangleArray(6, CAPABILITIES);
geometry.setCoordRefFloat(coordinates);
geometry.setTexCoordRefFloat(0, UV);
setGeometry(geometry);
setAppearance(surface);
geometry.setCapability(GeometryArray.ALLOW_REF_DATA_READ);
geometry.setCapability(GeometryArray.ALLOW_REF_DATA_WRITE);
reset(xp, xd, yp, yd);
}
void position(float xp, float yp) {
xpos = xp;
ypos = yp;
reset();
}
void resize(float xd, float yd) {
xdim = xd;
ydim = yd;
reset();
}
void reset(float xp, float xd, float yp, float yd) {
xpos = xp;
ypos = yp;
xdim = xd;
ydim = yd;
reset();
}
void reset() {
float xmax = xpos + xdim, ymax = ypos + ydim;
c1.set(xpos, ypos, depth);
c2.set(xpos, ymax, depth);
c3.set(xmax, ypos, depth);
c4.set(xmax, ymax, depth);
update();
}
void update() {
System.out.println("updating data?");
geometry.updateData(this); //_HANGS HERE._
System.out.println("done.");
}
public void updateData(Geometry data) { //argument unused.
System.out.println("updating data!");
int entry = 0, c = 0;
Point3f corner;
while(c < 6) {
corner = corners[c++];
coordinates[entry++] = corner.x;
coordinates[entry++] = corner.y;
coordinates[entry++] = corner.z;
}
}
}