Пример #1
0
  @Override
  void updateFromNative() {
    super.updateFromNative();
    int vtxCount = mRS.nMeshGetVertexBufferCount(getID(mRS));
    int idxCount = mRS.nMeshGetIndexCount(getID(mRS));

    long[] vtxIDs = new long[vtxCount];
    long[] idxIDs = new long[idxCount];
    int[] primitives = new int[idxCount];

    mRS.nMeshGetVertices(getID(mRS), vtxIDs, vtxCount);
    mRS.nMeshGetIndices(getID(mRS), idxIDs, primitives, idxCount);

    mVertexBuffers = new Allocation[vtxCount];
    mIndexBuffers = new Allocation[idxCount];
    mPrimitives = new Primitive[idxCount];

    for (int i = 0; i < vtxCount; i++) {
      if (vtxIDs[i] != 0) {
        mVertexBuffers[i] = new Allocation(vtxIDs[i], mRS, null, Allocation.USAGE_SCRIPT);
        mVertexBuffers[i].updateFromNative();
      }
    }

    for (int i = 0; i < idxCount; i++) {
      if (idxIDs[i] != 0) {
        mIndexBuffers[i] = new Allocation(idxIDs[i], mRS, null, Allocation.USAGE_SCRIPT);
        mIndexBuffers[i].updateFromNative();
      }
      mPrimitives[i] = Primitive.values()[primitives[i]];
    }
  }
Пример #2
0
  @Override
  void updateFromNative() {
    super.updateFromNative();

    // we will pack mType; mKind; mNormalized; mVectorSize; NumSubElements
    int[] dataBuffer = new int[5];
    mRS.nElementGetNativeData(getID(mRS), dataBuffer);

    mNormalized = dataBuffer[2] == 1 ? true : false;
    mVectorSize = dataBuffer[3];
    mSize = 0;
    for (DataType dt : DataType.values()) {
      if (dt.mID == dataBuffer[0]) {
        mType = dt;
        mSize = mType.mSize * mVectorSize;
      }
    }
    for (DataKind dk : DataKind.values()) {
      if (dk.mID == dataBuffer[1]) {
        mKind = dk;
      }
    }

    int numSubElements = dataBuffer[4];
    if (numSubElements > 0) {
      mElements = new Element[numSubElements];
      mElementNames = new String[numSubElements];
      mArraySizes = new int[numSubElements];
      mOffsetInBytes = new int[numSubElements];

      int[] subElementIds = new int[numSubElements];
      mRS.nElementGetSubElements(getID(mRS), subElementIds, mElementNames, mArraySizes);
      for (int i = 0; i < numSubElements; i++) {
        mElements[i] = new Element(subElementIds[i], mRS);
        mElements[i].updateFromNative();
        mOffsetInBytes[i] = mSize;
        mSize += mElements[i].mSize * mArraySizes[i];
      }
    }
    updateVisibleSubElements();
  }