Exemple #1
0
  public void testBaseObj() {
    Style S = Font.Style.NORMAL;
    Font F = Font.create(mRS, mRes, "sans-serif", S, 8);
    assertTrue(F != null);
    BaseObj B = F;
    B.setName("sans-serif");
    try {
      B.setName("sans-serif");
      fail("set name twice for a BaseObj");
    } catch (RSIllegalArgumentException e) {
    }
    B.destroy();

    F = Font.create(mRS, mRes, "serif", S, 8);
    assertTrue(F != null);
    B = F;
    try {
      B.setName("");
      fail("set empty name for a BaseObj");
    } catch (RSIllegalArgumentException e) {
    }
    B.setName("serif");
    B.destroy();

    F = Font.create(mRS, mRes, "mono", S, 8);
    assertTrue(F != null);
    B = F;
    try {
      B.setName(null);
      fail("set name as null string reference for a BaseObj");
    } catch (RSIllegalArgumentException e) {
    }
    B.setName("mono");
    B.destroy();
  }
  @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]];
    }
  }
Exemple #3
0
 public void addObj(BaseObj obj) {
   if (obj != null) {
     addI32(obj.getID(null));
   } else {
     addI32(0);
   }
 }
Exemple #4
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();
  }
 long safeID(BaseObj o) {
   if (o != null) {
     return o.getID(this);
   }
   return 0;
 }