public void processNode(int nodeSubPart, int nodeTriangleIndex) {
      meshInterface.getLockedReadOnlyVertexIndexBase(data, nodeSubPart);

      // int* gfxbase = (int*)(indexbase+nodeTriangleIndex*indexstride);
      ByteBuffer gfxbase_ptr = data.indexbase;
      int gfxbase_index = (nodeTriangleIndex * data.indexstride);
      assert (data.indicestype == ScalarType.PHY_INTEGER
          || data.indicestype == ScalarType.PHY_SHORT);

      Vector3f meshScaling = meshInterface.getScaling();
      for (int j = 2; j >= 0; j--) {
        int graphicsindex;
        if (data.indicestype == ScalarType.PHY_SHORT) {
          graphicsindex = gfxbase_ptr.getShort(gfxbase_index + j * 2) & 0xFFFF;
        } else {
          graphicsindex = gfxbase_ptr.getInt(gfxbase_index + j * 4);
        }

        // float* graphicsbase = (float*)(vertexbase+graphicsindex*stride);
        ByteBuffer graphicsbase_ptr = data.vertexbase;
        int graphicsbase_index = graphicsindex * data.stride;

        triangle[j].set(
            graphicsbase_ptr.getFloat(graphicsbase_index + 4 * 0) * meshScaling.x,
            graphicsbase_ptr.getFloat(graphicsbase_index + 4 * 1) * meshScaling.y,
            graphicsbase_ptr.getFloat(graphicsbase_index + 4 * 2) * meshScaling.z);
      }

      /* Perform ray vs. triangle collision here */
      callback.processTriangle(triangle, nodeSubPart, nodeTriangleIndex);
      meshInterface.unLockReadOnlyVertexBase(nodeSubPart);

      data.unref();
    }
Esempio n. 2
0
    public void processNode(int nodeSubPart, int nodeTriangleIndex) {
      VertexData data = meshInterface.getLockedReadOnlyVertexIndexBase(nodeSubPart);

      Vector3f meshScaling = meshInterface.getScaling(new Vector3f());

      data.getTriangle(nodeTriangleIndex * 3, meshScaling, triangle);

      /* Perform ray vs. triangle collision here */
      callback.processTriangle(triangle, nodeSubPart, nodeTriangleIndex);

      meshInterface.unLockReadOnlyVertexBase(nodeSubPart);
    }