org.lwjglb.engine.graph.Mesh.<init>()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(15.5k)|赞(0)|评价(0)|浏览(111)

本文整理了Java中org.lwjglb.engine.graph.Mesh.<init>()方法的一些代码示例,展示了Mesh.<init>()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Mesh.<init>()方法的具体详情如下:
包路径:org.lwjglb.engine.graph.Mesh
类名称:Mesh
方法名:<init>

Mesh.<init>介绍

暂无

代码示例

代码示例来源:origin: lwjglgamedev/lwjglbook

@Override
public void init() throws Exception {
  renderer.init();
  float[] positions = new float[]{
    -0.5f, 0.5f, 0.0f,
    -0.5f, -0.5f, 0.0f,
    0.5f, -0.5f, 0.0f,
    0.5f, 0.5f, 0.0f,};
  int[] indices = new int[]{
    0, 1, 3, 3, 1, 2,};
  mesh = new Mesh(positions, indices);
}

代码示例来源:origin: lwjglgamedev/lwjglbook

@Override
public void init() throws Exception {
  renderer.init();
  float[] positions = new float[]{
    -0.5f,  0.5f, 0.0f,
    -0.5f, -0.5f, 0.0f,
     0.5f, -0.5f, 0.0f,
     0.5f,  0.5f, 0.0f,
  };
  float[] colours = new float[]{
    0.5f, 0.0f, 0.0f,
    0.0f, 0.5f, 0.0f,
    0.0f, 0.0f, 0.5f,
    0.0f, 0.5f, 0.5f,
  };
  int[] indices = new int[]{
    0, 1, 3, 3, 1, 2,
  };
  mesh = new Mesh(positions, colours, indices);
}

代码示例来源:origin: lwjglgamedev/lwjglbook

@Override
public void init(Window window) throws Exception {
  renderer.init(window);
  float[] positions = new float[]{
    -0.5f,  0.5f, -1.05f,
    -0.5f, -0.5f, -1.05f,
     0.5f, -0.5f, -1.05f,
     0.5f,  0.5f, -1.05f,
  };
  float[] colours = new float[]{
    0.5f, 0.0f, 0.0f,
    0.0f, 0.5f, 0.0f,
    0.0f, 0.0f, 0.5f,
    0.0f, 0.5f, 0.5f,
  };
  int[] indices = new int[]{
    0, 1, 3, 3, 1, 2,
  };
  mesh = new Mesh(positions, colours, indices);
}

代码示例来源:origin: lwjglgamedev/lwjglbook

private static Mesh reorderLists(List<Vector3f> posList, List<Vector2f> textCoordList,
    List<Vector3f> normList, List<Face> facesList) {
  List<Integer> indices = new ArrayList();
  // Create position array in the order it has been declared
  float[] posArr = new float[posList.size() * 3];
  int i = 0;
  for (Vector3f pos : posList) {
    posArr[i * 3] = pos.x;
    posArr[i * 3 + 1] = pos.y;
    posArr[i * 3 + 2] = pos.z;
    i++;
  }
  float[] textCoordArr = new float[posList.size() * 2];
  float[] normArr = new float[posList.size() * 3];
  for (Face face : facesList) {
    IdxGroup[] faceVertexIndices = face.getFaceVertexIndices();
    for (IdxGroup indValue : faceVertexIndices) {
      processFaceVertex(indValue, textCoordList, normList,
          indices, textCoordArr, normArr);
    }
  }
  int[] indicesArr = new int[indices.size()];
  indicesArr = indices.stream().mapToInt((Integer v) -> v).toArray();
  Mesh mesh = new Mesh(posArr, textCoordArr, normArr, indicesArr);
  return mesh;
}

代码示例来源:origin: lwjglgamedev/lwjglbook

private static Mesh reorderLists(List<Vector3f> posList, List<Vector2f> textCoordList,
    List<Vector3f> normList, List<Face> facesList) {
  List<Integer> indices = new ArrayList();
  // Create position array in the order it has been declared
  float[] posArr = new float[posList.size() * 3];
  int i = 0;
  for (Vector3f pos : posList) {
    posArr[i * 3] = pos.x;
    posArr[i * 3 + 1] = pos.y;
    posArr[i * 3 + 2] = pos.z;
    i++;
  }
  float[] textCoordArr = new float[posList.size() * 2];
  float[] normArr = new float[posList.size() * 3];
  for (Face face : facesList) {
    IdxGroup[] faceVertexIndices = face.getFaceVertexIndices();
    for (IdxGroup indValue : faceVertexIndices) {
      processFaceVertex(indValue, textCoordList, normList,
          indices, textCoordArr, normArr);
    }
  }
  int[] indicesArr = new int[indices.size()];
  indicesArr = indices.stream().mapToInt((Integer v) -> v).toArray();
  Mesh mesh = new Mesh(posArr, textCoordArr, normArr, indicesArr);
  return mesh;
}

代码示例来源:origin: lwjglgamedev/lwjglbook

private static Mesh reorderLists(List<Vector3f> posList, List<Vector2f> textCoordList,
    List<Vector3f> normList, List<Face> facesList) {
  List<Integer> indices = new ArrayList();
  // Create position array in the order it has been declared
  float[] posArr = new float[posList.size() * 3];
  int i = 0;
  for (Vector3f pos : posList) {
    posArr[i * 3] = pos.x;
    posArr[i * 3 + 1] = pos.y;
    posArr[i * 3 + 2] = pos.z;
    i++;
  }
  float[] textCoordArr = new float[posList.size() * 2];
  float[] normArr = new float[posList.size() * 3];
  for (Face face : facesList) {
    IdxGroup[] faceVertexIndices = face.getFaceVertexIndices();
    for (IdxGroup indValue : faceVertexIndices) {
      processFaceVertex(indValue, textCoordList, normList,
          indices, textCoordArr, normArr);
    }
  }
  int[] indicesArr = new int[indices.size()];
  indicesArr = indices.stream().mapToInt((Integer v) -> v).toArray();
  Mesh mesh = new Mesh(posArr, textCoordArr, normArr, indicesArr);
  return mesh;
}

代码示例来源:origin: lwjglgamedev/lwjglbook

private static Mesh reorderLists(List<Vector3f> posList, List<Vector2f> textCoordList,
    List<Vector3f> normList, List<Face> facesList) {
  List<Integer> indices = new ArrayList();
  // Create position array in the order it has been declared
  float[] posArr = new float[posList.size() * 3];
  int i = 0;
  for (Vector3f pos : posList) {
    posArr[i * 3] = pos.x;
    posArr[i * 3 + 1] = pos.y;
    posArr[i * 3 + 2] = pos.z;
    i++;
  }
  float[] textCoordArr = new float[posList.size() * 2];
  float[] normArr = new float[posList.size() * 3];
  for (Face face : facesList) {
    IdxGroup[] faceVertexIndices = face.getFaceVertexIndices();
    for (IdxGroup indValue : faceVertexIndices) {
      processFaceVertex(indValue, textCoordList, normList,
          indices, textCoordArr, normArr);
    }
  }
  int[] indicesArr = new int[indices.size()];
  indicesArr = indices.stream().mapToInt((Integer v) -> v).toArray();
  Mesh mesh = new Mesh(posArr, textCoordArr, normArr, indicesArr);
  return mesh;
}

代码示例来源:origin: lwjglgamedev/lwjglbook

private static Mesh reorderLists(List<Vector3f> posList, List<Vector2f> textCoordList,
    List<Vector3f> normList, List<Face> facesList) {
  List<Integer> indices = new ArrayList();
  // Create position array in the order it has been declared
  float[] posArr = new float[posList.size() * 3];
  int i = 0;
  for (Vector3f pos : posList) {
    posArr[i * 3] = pos.x;
    posArr[i * 3 + 1] = pos.y;
    posArr[i * 3 + 2] = pos.z;
    i++;
  }
  float[] textCoordArr = new float[posList.size() * 2];
  float[] normArr = new float[posList.size() * 3];
  for (Face face : facesList) {
    IdxGroup[] faceVertexIndices = face.getFaceVertexIndices();
    for (IdxGroup indValue : faceVertexIndices) {
      processFaceVertex(indValue, textCoordList, normList,
          indices, textCoordArr, normArr);
    }
  }
  int[] indicesArr = new int[indices.size()];
  indicesArr = indices.stream().mapToInt((Integer v) -> v).toArray();
  Mesh mesh = new Mesh(posArr, textCoordArr, normArr, indicesArr);
  return mesh;
}

代码示例来源:origin: lwjglgamedev/lwjglbook

private static Mesh reorderLists(List<Vector3f> posList, List<Vector2f> textCoordList,
    List<Vector3f> normList, List<Face> facesList) {
  List<Integer> indices = new ArrayList();
  // Create position array in the order it has been declared
  float[] posArr = new float[posList.size() * 3];
  int i = 0;
  for (Vector3f pos : posList) {
    posArr[i * 3] = pos.x;
    posArr[i * 3 + 1] = pos.y;
    posArr[i * 3 + 2] = pos.z;
    i++;
  }
  float[] textCoordArr = new float[posList.size() * 2];
  float[] normArr = new float[posList.size() * 3];
  for (Face face : facesList) {
    IdxGroup[] faceVertexIndices = face.getFaceVertexIndices();
    for (IdxGroup indValue : faceVertexIndices) {
      processFaceVertex(indValue, textCoordList, normList,
          indices, textCoordArr, normArr);
    }
  }
  int[] indicesArr = new int[indices.size()];
  indicesArr = indices.stream().mapToInt((Integer v) -> v).toArray();
  Mesh mesh = new Mesh(posArr, textCoordArr, normArr, indicesArr);
  return mesh;
}

代码示例来源:origin: lwjglgamedev/lwjglbook

private static Mesh reorderLists(List<Vector3f> posList, List<Vector2f> textCoordList,
    List<Vector3f> normList, List<Face> facesList) {
  List<Integer> indices = new ArrayList();
  // Create position array in the order it has been declared
  float[] posArr = new float[posList.size() * 3];
  int i = 0;
  for (Vector3f pos : posList) {
    posArr[i * 3] = pos.x;
    posArr[i * 3 + 1] = pos.y;
    posArr[i * 3 + 2] = pos.z;
    i++;
  }
  float[] textCoordArr = new float[posList.size() * 2];
  float[] normArr = new float[posList.size() * 3];
  for (Face face : facesList) {
    IdxGroup[] faceVertexIndices = face.getFaceVertexIndices();
    for (IdxGroup indValue : faceVertexIndices) {
      processFaceVertex(indValue, textCoordList, normList,
          indices, textCoordArr, normArr);
    }
  }
  int[] indicesArr = Utils.listIntToArray(indices);
  Mesh mesh = new Mesh(posArr, textCoordArr, normArr, indicesArr);
  return mesh;
}

代码示例来源:origin: lwjglgamedev/lwjglbook

private static Mesh reorderLists(List<Vector3f> posList, List<Vector2f> textCoordList,
    List<Vector3f> normList, List<Face> facesList) {
  List<Integer> indices = new ArrayList();
  // Create position array in the order it has been declared
  float[] posArr = new float[posList.size() * 3];
  int i = 0;
  for (Vector3f pos : posList) {
    posArr[i * 3] = pos.x;
    posArr[i * 3 + 1] = pos.y;
    posArr[i * 3 + 2] = pos.z;
    i++;
  }
  float[] textCoordArr = new float[posList.size() * 2];
  float[] normArr = new float[posList.size() * 3];
  for (Face face : facesList) {
    IdxGroup[] faceVertexIndices = face.getFaceVertexIndices();
    for (IdxGroup indValue : faceVertexIndices) {
      processFaceVertex(indValue, textCoordList, normList,
          indices, textCoordArr, normArr);
    }
  }
  int[] indicesArr = Utils.listIntToArray(indices);
  Mesh mesh = new Mesh(posArr, textCoordArr, normArr, indicesArr);
  return mesh;
}

代码示例来源:origin: lwjglgamedev/lwjglbook

private static Mesh reorderLists(List<Vector3f> posList, List<Vector2f> textCoordList,
    List<Vector3f> normList, List<Face> facesList) {
  List<Integer> indices = new ArrayList();
  // Create position array in the order it has been declared
  float[] posArr = new float[posList.size() * 3];
  int i = 0;
  for (Vector3f pos : posList) {
    posArr[i * 3] = pos.x;
    posArr[i * 3 + 1] = pos.y;
    posArr[i * 3 + 2] = pos.z;
    i++;
  }
  float[] textCoordArr = new float[posList.size() * 2];
  float[] normArr = new float[posList.size() * 3];
  for (Face face : facesList) {
    IdxGroup[] faceVertexIndices = face.getFaceVertexIndices();
    for (IdxGroup indValue : faceVertexIndices) {
      processFaceVertex(indValue, textCoordList, normList,
          indices, textCoordArr, normArr);
    }
  }
  int[] indicesArr = Utils.listIntToArray(indices);
  Mesh mesh = new Mesh(posArr, textCoordArr, normArr, indicesArr);
  return mesh;
}

代码示例来源:origin: lwjglgamedev/lwjglbook

private static Mesh reorderLists(List<Vector3f> posList, List<Vector2f> textCoordList,
    List<Vector3f> normList, List<Face> facesList) {
  List<Integer> indices = new ArrayList();
  // Create position array in the order it has been declared
  float[] posArr = new float[posList.size() * 3];
  int i = 0;
  for (Vector3f pos : posList) {
    posArr[i * 3] = pos.x;
    posArr[i * 3 + 1] = pos.y;
    posArr[i * 3 + 2] = pos.z;
    i++;
  }
  float[] textCoordArr = new float[posList.size() * 2];
  float[] normArr = new float[posList.size() * 3];
  for (Face face : facesList) {
    IdxGroup[] faceVertexIndices = face.getFaceVertexIndices();
    for (IdxGroup indValue : faceVertexIndices) {
      processFaceVertex(indValue, textCoordList, normList,
          indices, textCoordArr, normArr);
    }
  }
  int[] indicesArr = Utils.listIntToArray(indices);
  Mesh mesh = new Mesh(posArr, textCoordArr, normArr, indicesArr);
  return mesh;
}

代码示例来源:origin: lwjglgamedev/lwjglbook

private static Mesh reorderLists(List<Vector3f> posList, List<Vector2f> textCoordList,
    List<Vector3f> normList, List<Face> facesList) {
  List<Integer> indices = new ArrayList();
  // Create position array in the order it has been declared
  float[] posArr = new float[posList.size() * 3];
  int i = 0;
  for (Vector3f pos : posList) {
    posArr[i * 3] = pos.x;
    posArr[i * 3 + 1] = pos.y;
    posArr[i * 3 + 2] = pos.z;
    i++;
  }
  float[] textCoordArr = new float[posList.size() * 2];
  float[] normArr = new float[posList.size() * 3];
  for (Face face : facesList) {
    IdxGroup[] faceVertexIndices = face.getFaceVertexIndices();
    for (IdxGroup indValue : faceVertexIndices) {
      processFaceVertex(indValue, textCoordList, normList,
          indices, textCoordArr, normArr);
    }
  }
  int[] indicesArr = Utils.listIntToArray(indices);
  Mesh mesh = new Mesh(posArr, textCoordArr, normArr, indicesArr);
  return mesh;
}

代码示例来源:origin: lwjglgamedev/lwjglbook

@Override
public void init(Window window) throws Exception {
  renderer.init(window);
  // Create the Mesh
  float[] positions = new float[]{
    -0.5f,  0.5f,  0.5f,
    -0.5f, -0.5f,  0.5f,
     0.5f, -0.5f,  0.5f,
     0.5f,  0.5f,  0.5f,
  };
  float[] colours = new float[]{
    0.5f, 0.0f, 0.0f,
    0.0f, 0.5f, 0.0f,
    0.0f, 0.0f, 0.5f,
    0.0f, 0.5f, 0.5f,
  };
  int[] indices = new int[]{
    0, 1, 3, 3, 1, 2,
  };
  Mesh mesh = new Mesh(positions, colours, indices);
  GameItem gameItem = new GameItem(mesh);
  gameItem.setPosition(0, 0, -2);
  gameItems = new GameItem[] { gameItem };
}

代码示例来源:origin: lwjglgamedev/lwjglbook

private static Mesh processMesh(AIMesh aiMesh, List<Material> materials) {
  List<Float> vertices = new ArrayList<>();
  List<Float> textures = new ArrayList<>();
  List<Float> normals = new ArrayList<>();
  List<Integer> indices = new ArrayList();
  processVertices(aiMesh, vertices);
  processNormals(aiMesh, normals);
  processTextCoords(aiMesh, textures);
  processIndices(aiMesh, indices);
  Mesh mesh = new Mesh(Utils.listToArray(vertices), Utils.listToArray(textures),
      Utils.listToArray(normals), Utils.listIntToArray(indices));
  Material material;
  int materialIdx = aiMesh.mMaterialIndex();
  if (materialIdx >= 0 && materialIdx < materials.size()) {
    material = materials.get(materialIdx);
  } else {
    material = new Material();
  }
  mesh.setMaterial(material);
  return mesh;
}

代码示例来源:origin: lwjglgamedev/lwjglbook

private static Mesh processMesh(AIMesh aiMesh, List<Material> materials) {
  List<Float> vertices = new ArrayList<>();
  List<Float> textures = new ArrayList<>();
  List<Float> normals = new ArrayList<>();
  List<Integer> indices = new ArrayList();
  processVertices(aiMesh, vertices);
  processNormals(aiMesh, normals);
  processTextCoords(aiMesh, textures);
  processIndices(aiMesh, indices);
  Mesh mesh = new Mesh(Utils.listToArray(vertices), Utils.listToArray(textures),
      Utils.listToArray(normals), Utils.listIntToArray(indices));
  Material material;
  int materialIdx = aiMesh.mMaterialIndex();
  if (materialIdx >= 0 && materialIdx < materials.size()) {
    material = materials.get(materialIdx);
  } else {
    material = new Material();
  }
  mesh.setMaterial(material);
  return mesh;
}

代码示例来源:origin: lwjglgamedev/lwjglbook

private static Mesh processMesh(AIMesh aiMesh, List<Material> materials) {
  List<Float> vertices = new ArrayList<>();
  List<Float> textures = new ArrayList<>();
  List<Float> normals = new ArrayList<>();
  List<Integer> indices = new ArrayList();
  processVertices(aiMesh, vertices);
  processNormals(aiMesh, normals);
  processTextCoords(aiMesh, textures);
  processIndices(aiMesh, indices);
  Mesh mesh = new Mesh(Utils.listToArray(vertices),
      Utils.listToArray(textures),
      Utils.listToArray(normals),
      Utils.listIntToArray(indices)
  );
  Material material;
  int materialIdx = aiMesh.mMaterialIndex();
  if (materialIdx >= 0 && materialIdx < materials.size()) {
    material = materials.get(materialIdx);
  } else {
    material = new Material();
  }
  mesh.setMaterial(material);
  return mesh;
}

代码示例来源:origin: lwjglgamedev/lwjglbook

private static Mesh processMesh(AIMesh aiMesh, List<Material> materials, List<Bone> boneList) {
  List<Float> vertices = new ArrayList<>();
  List<Float> textures = new ArrayList<>();
  List<Float> normals = new ArrayList<>();
  List<Integer> indices = new ArrayList<>();
  List<Integer> boneIds = new ArrayList<>();
  List<Float> weights = new ArrayList<>();
  processVertices(aiMesh, vertices);
  processNormals(aiMesh, normals);
  processTextCoords(aiMesh, textures);
  processIndices(aiMesh, indices);
  processBones(aiMesh, boneList, boneIds, weights);
  Mesh mesh = new Mesh(Utils.listToArray(vertices), Utils.listToArray(textures),
      Utils.listToArray(normals), Utils.listIntToArray(indices),
      Utils.listIntToArray(boneIds), Utils.listToArray(weights));
  Material material;
  int materialIdx = aiMesh.mMaterialIndex();
  if (materialIdx >= 0 && materialIdx < materials.size()) {
    material = materials.get(materialIdx);
  } else {
    material = new Material();
  }
  mesh.setMaterial(material);
  return mesh;
}

代码示例来源:origin: lwjglgamedev/lwjglbook

private static Mesh processMesh(AIMesh aiMesh, List<Material> materials, List<Bone> boneList) {
  List<Float> vertices = new ArrayList<>();
  List<Float> textures = new ArrayList<>();
  List<Float> normals = new ArrayList<>();
  List<Integer> indices = new ArrayList<>();
  List<Integer> boneIds = new ArrayList<>();
  List<Float> weights = new ArrayList<>();
  processVertices(aiMesh, vertices);
  processNormals(aiMesh, normals);
  processTextCoords(aiMesh, textures);
  processIndices(aiMesh, indices);
  processBones(aiMesh, boneList, boneIds, weights);
  Mesh mesh = new Mesh(Utils.listToArray(vertices), Utils.listToArray(textures),
      Utils.listToArray(normals), Utils.listIntToArray(indices),
      Utils.listIntToArray(boneIds), Utils.listToArray(weights));
  Material material;
  int materialIdx = aiMesh.mMaterialIndex();
  if (materialIdx >= 0 && materialIdx < materials.size()) {
    material = materials.get(materialIdx);
  } else {
    material = new Material();
  }
  mesh.setMaterial(material);
  return mesh;
}

相关文章