當前位置: 首頁>>代碼示例>>Java>>正文


Java GL10.GL_FLOAT屬性代碼示例

本文整理匯總了Java中javax.microedition.khronos.opengles.GL10.GL_FLOAT屬性的典型用法代碼示例。如果您正苦於以下問題:Java GL10.GL_FLOAT屬性的具體用法?Java GL10.GL_FLOAT怎麽用?Java GL10.GL_FLOAT使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在javax.microedition.khronos.opengles.GL10的用法示例。


在下文中一共展示了GL10.GL_FLOAT屬性的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getModelUVElements

private static float[] getModelUVElements(InputStream modelStream)
    throws IOException, UVTypeNotSupportedException {
  byte[] uvBufferSize32Bits = new byte[4];
  byte[] dataTypeBytes = new byte[4];
  byte[] primTypeBytes = new byte[4];
  byte[] sizePerElementBytes = new byte[4];
  byte[] numUVs32Bits = new byte[4];

  modelStream.read(uvBufferSize32Bits, 0, 4);
  modelStream.read(dataTypeBytes, 0, 4);
  modelStream.read(primTypeBytes, 0, 4);
  modelStream.read(sizePerElementBytes, 0, 4);
  modelStream.read(numUVs32Bits, 0, 4);

  int uvBufferSize = ByteBuffer.wrap(uvBufferSize32Bits).order(ByteOrder.LITTLE_ENDIAN).getInt();
  int dataType = ByteBuffer.wrap(dataTypeBytes).order(ByteOrder.LITTLE_ENDIAN).getInt();
  int sizePerElement = ByteBuffer.wrap(sizePerElementBytes).order(ByteOrder.LITTLE_ENDIAN).getInt();
  int numUVs = ByteBuffer.wrap(numUVs32Bits).order(ByteOrder.LITTLE_ENDIAN).getInt();

  if (dataType != GL10.GL_FLOAT) {
    throw new UVTypeNotSupportedException("Only float UVs are supported");
  }

  // We have multiple elements per uv
  int numUVElements = numUVs * sizePerElement;
  int uvElementTypeSize = uvBufferSize / numUVElements;
  float[] uvElements = new float[numUVElements];
  byte[] currentUVElement32Bit = new byte[uvElementTypeSize];

  // Read the indices into a buffer
  for (int i = 0; i < numUVElements; i++) {
    modelStream.read(currentUVElement32Bit, 0, uvElementTypeSize);
    float currentUVElement = ByteBuffer.wrap(currentUVElement32Bit).order(ByteOrder.LITTLE_ENDIAN).getFloat();
    uvElements[i] = currentUVElement;
  }

  return uvElements;
}
 
開發者ID:rastapasta,項目名稱:react-native-gl-model-view,代碼行數:38,代碼來源:RNGLModelViewModelLoader.java

示例2: getModelNormalElements

private static float[] getModelNormalElements(InputStream modelStream)
    throws IOException, NormalTypeNotSupportedException {
  byte[] normalElementBufferSize32Bit = new byte[4];
  byte[] dataTypeBytes = new byte[4];
  byte[] primTypeBytes = new byte[4];
  byte[] sizePerElementBytes = new byte[4];
  byte[] numNormalElements32Bit = new byte[4];

  modelStream.read(normalElementBufferSize32Bit, 0, 4);
  modelStream.read(dataTypeBytes, 0, 4);
  modelStream.read(primTypeBytes, 0, 4);
  modelStream.read(sizePerElementBytes, 0, 4);
  modelStream.read(numNormalElements32Bit, 0, 4);

  int normalElementBufferSize = ByteBuffer.wrap(normalElementBufferSize32Bit).order(ByteOrder.LITTLE_ENDIAN).getInt();
  int dataType = ByteBuffer.wrap(dataTypeBytes).order(ByteOrder.LITTLE_ENDIAN).getInt();
  int sizePerElement = ByteBuffer.wrap(sizePerElementBytes).order(ByteOrder.LITTLE_ENDIAN).getInt();
  int numNormals = ByteBuffer.wrap(numNormalElements32Bit).order(ByteOrder.LITTLE_ENDIAN).getInt();

  if (dataType != GL10.GL_FLOAT) {
    throw new NormalTypeNotSupportedException("Only float normals are supported");
  }

  // We have multiple elements per normal
  int numNormalElements = numNormals * sizePerElement;
  int normalElementSize = normalElementBufferSize / numNormalElements;
  float[] normalElements = new float[numNormalElements];
  byte[] currentNormalElement32Bit = new byte[normalElementSize];

  // Read the indices into a buffer
  for (int i = 0; i < numNormalElements; i++) {
    modelStream.read(currentNormalElement32Bit, 0, normalElementSize);
    float currentNormalElement = ByteBuffer.wrap(currentNormalElement32Bit).order(ByteOrder.LITTLE_ENDIAN).getFloat();
    normalElements[i] = currentNormalElement;
  }

  return normalElements;
}
 
開發者ID:rastapasta,項目名稱:react-native-gl-model-view,代碼行數:38,代碼來源:RNGLModelViewModelLoader.java

示例3: getModelVertexElements

private static float[] getModelVertexElements(InputStream modelStream)
    throws IOException, VertexTypeNotSupportedException {
  byte[] vertexELementBufferSize32Bits = new byte[4];
  byte[] dataTypeBytes = new byte[4];
  byte[] primTypeBytes = new byte[4];
  byte[] sizePerElementBytes = new byte[4];
  byte[] numVertexElements32Bits = new byte[4];

  modelStream.read(vertexELementBufferSize32Bits, 0, 4);
  modelStream.read(dataTypeBytes, 0, 4);
  modelStream.read(primTypeBytes, 0, 4);
  modelStream.read(sizePerElementBytes, 0, 4);
  modelStream.read(numVertexElements32Bits, 0, 4);

  int vertexElementBufferSize = ByteBuffer.wrap(vertexELementBufferSize32Bits).order(ByteOrder.LITTLE_ENDIAN).getInt();
  int dataType = ByteBuffer.wrap(dataTypeBytes).order(ByteOrder.LITTLE_ENDIAN).getInt();
  int sizePerElement = ByteBuffer.wrap(sizePerElementBytes).order(ByteOrder.LITTLE_ENDIAN).getInt();
  int numVertices = ByteBuffer.wrap(numVertexElements32Bits).order(ByteOrder.LITTLE_ENDIAN).getInt();

  if (dataType != GL10.GL_FLOAT) {
    throw new VertexTypeNotSupportedException("Only float vertices are supported");
  }

  // We have multiple elements per vertex and we will eventually throw away the fourth elements (w)
  int numVertexElements = numVertices * (sizePerElement == 4 ? 3 : sizePerElement);
  int vertexElementSize = vertexElementBufferSize / numVertices / sizePerElement;
  float[] vertexElements = new float[numVertexElements];
  byte[] currentVertexElement32Bit = new byte[vertexElementSize];

  // Read the indices into a buffer
  for (int i = 0; i < numVertexElements; i++) {
    modelStream.read(currentVertexElement32Bit, 0, vertexElementSize);
    float currentVertexElement = ByteBuffer.wrap(currentVertexElement32Bit).order(ByteOrder.LITTLE_ENDIAN).getFloat();
    vertexElements[i] = currentVertexElement;

    // If the model contains Vector4s, we need to throw away the fourth element (w) here
    if (sizePerElement == 4 && (i + 1) % 3 == 0) {
      modelStream.read(currentVertexElement32Bit, 0, vertexElementSize);
    }
  }

  return vertexElements;
}
 
開發者ID:rastapasta,項目名稱:react-native-gl-model-view,代碼行數:43,代碼來源:RNGLModelViewModelLoader.java


注:本文中的javax.microedition.khronos.opengles.GL10.GL_FLOAT屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。