Ejemplo n.º 1
0
  protected ResourceIdentifier CreateImageMesh(int iWidth, int iHeight, int iDepth) {
    // System.err.println( iWidth + " " + iHeight + " " + iDepth );
    Attributes kAttributes = new Attributes();
    kAttributes.SetPChannels(3);

    int iVQuantity = iWidth * iHeight * iDepth;
    VertexBuffer pkVB = new VertexBuffer(kAttributes, iVQuantity);

    // generate geometry
    float fInv0 = 1.0f / (iWidth - 1.0f);
    float fInv1 = 1.0f / (iHeight - 1.0f);
    float fInv2 = 1.0f / (iDepth);
    float fU, fV, fW;
    int i0, i1, i2;

    float[] afChannels = pkVB.GetData();
    int iIndex = 0;

    for (i2 = 0; i2 < iDepth; i2++) {
      fW = i2 * fInv2;
      for (i1 = 0; i1 < iHeight; i1++) {
        fV = i1 * fInv1;
        for (i0 = 0; i0 < iWidth; i0++) {
          fU = i0 * fInv0;
          afChannels[iIndex++] = ((2.0f * fU - 1.0f));
          afChannels[iIndex++] = ((2.0f * fV - 1.0f));
          afChannels[iIndex++] = ((2.0f * fW - 1.0f));
        }
      }
    }

    m_kImagePointsDual = new Polypoint(pkVB);
    m_kAlpha = new AlphaState();
    m_kAlpha.BlendEnabled = true;
    m_kAlpha.SrcBlend = AlphaState.SrcBlendMode.SBF_ONE;
    m_kAlpha.DstBlend = AlphaState.DstBlendMode.DBF_ONE;
    m_kImagePointsDual.AttachGlobalState(m_kAlpha);
    m_kImagePointsDual.UpdateGS();
    m_kImagePointsDual.UpdateRS();

    return m_pkRenderer.LoadVBuffer(pkVB.GetAttributes(), pkVB.GetAttributes(), pkVB);
  }