Scatter effect

what i have:

  • a node, containing other nodes, meshes, texture coordinates, everything is made of triangles
  • this code:

  private void scatter(final TriangleBatch p_trBatch) {
    final int l_triangleCount = p_trBatch.getTriangleCount();
    final Vector3f[] l_allVerts = p_trBatch.getMeshAsTrianglesVertices(null);
    for (int j = 0;j<l_triangleCount;j++)
    {
      for (int i = 0; i < p_trBatch.getTriangleCount();i++) {
          TriMesh l_triMesh = new TriMesh
             (
                "I am a triangle",
                BufferUtils.createFloatBuffer(l_allVerts[i*3+0], l_allVerts[i * 3 + 1], l_allVerts[i * 3 + 2]),
             );


      }
    }
  }



what i want to do:
move every triangle, keeping the normal and tex coords, indepently from each other. for example, i take one triangle, move it by 1,0,0, then take the next one, move it by 2,0,0 and so on. i also need to remove the old node for reasons that don't matter here.

for this, i need to access the triangle data contained deep in a node. i already found a way to get them, but as you can see, i still need to extract the normals, colors, tex coords and so on. i don't know how the data is stored and there is no method to extract it like i could do with the triangle vertices. it might be a triangle strip, might be indexed, might be whatever it might be.
do i have to make a huge if/elseif/elseif here, or is there a more efficient way to do it?

I don't know about triangle strips/fans, I just ignore them and access by index:


IntBuffer ib = mesh.getIndexBuffer(0);
FloatBuffer vb = mesh.getVertexBuffer(0);
int len = ib.limit() / 3;
ib.rewind();

Vector3f vert[] = new Vector3f[3];
vert[0] = new Vector3f();
vert[1] = new Vector3f();
vert[2] = new Vector3f();

for (int i = 0; i < len; i++){
    int i1 = ib.get(), i2 = ib.get(), i3 = ib.get();
    BufferUtils.populateFromBuffer(vert[0], vb, i1);
    BufferUtils.populateFromBuffer(vert[1], vb, i2);
    BufferUtils.populateFromBuffer(vert[2], vb, i3);
    // triangle vertex coordinates are located in vert[]
}