コード例 #1
0
ファイル: ModelBuilder.java プロジェクト: nurmuhammad/libgdx
  @Deprecated
  public static Model createFromMesh(
      final Mesh mesh,
      int indexOffset,
      int vertexCount,
      int primitiveType,
      final Material material) {
    Model result = new Model();
    MeshPart meshPart = new MeshPart();
    meshPart.id = "part1";
    meshPart.indexOffset = indexOffset;
    meshPart.numVertices = vertexCount;
    meshPart.primitiveType = primitiveType;
    meshPart.mesh = mesh;

    NodePart partMaterial = new NodePart();
    partMaterial.material = material;
    partMaterial.meshPart = meshPart;
    Node node = new Node();
    node.id = "node1";
    node.parts.add(partMaterial);

    result.meshes.add(mesh);
    result.materials.add(material);
    result.nodes.add(node);
    result.meshParts.add(meshPart);
    result.manageDisposable(mesh);
    return result;
  }
コード例 #2
0
ファイル: Model.java プロジェクト: nessemis/libgdx
  private Node loadNode(Node parent, ModelNode modelNode) {
    Node node = new Node();
    node.id = modelNode.id;
    node.parent = parent;

    if (modelNode.translation != null) node.translation.set(modelNode.translation);
    if (modelNode.rotation != null) node.rotation.set(modelNode.rotation);
    if (modelNode.scale != null) node.scale.set(modelNode.scale);
    // FIXME create temporary maps for faster lookup?
    if (modelNode.parts != null) {
      for (ModelNodePart modelNodePart : modelNode.parts) {
        MeshPart meshPart = null;
        Material meshMaterial = null;

        if (modelNodePart.meshPartId != null) {
          for (MeshPart part : meshParts) {
            if (modelNodePart.meshPartId.equals(part.id)) {
              meshPart = part;
              break;
            }
          }
        }

        if (modelNodePart.materialId != null) {
          for (Material material : materials) {
            if (modelNodePart.materialId.equals(material.id)) {
              meshMaterial = material;
              break;
            }
          }
        }

        if (meshPart == null || meshMaterial == null)
          throw new GdxRuntimeException("Invalid node: " + node.id);

        if (meshPart != null && meshMaterial != null) {
          NodePart nodePart = new NodePart();
          nodePart.meshPart = meshPart;
          nodePart.material = meshMaterial;
          node.parts.add(nodePart);
          if (modelNodePart.bones != null) nodePartBones.put(nodePart, modelNodePart.bones);
        }
      }
    }

    if (modelNode.children != null) {
      for (ModelNode child : modelNode.children) {
        node.children.add(loadNode(node, child));
      }
    }

    return node;
  }
コード例 #3
0
ファイル: Model.java プロジェクト: moly/libgdx
  private Node loadNode(Node parent, ModelNode modelNode) {
    Node node = new Node();
    node.id = modelNode.id;
    // node.boneId = modelNode.boneId; // FIXME check meaning of this, breadth first index of node
    // hierarchy?
    node.parent = parent;
    if (modelNode.translation != null) node.translation.set(modelNode.translation);
    if (modelNode.rotation != null) node.rotation.set(modelNode.rotation);
    if (modelNode.scale != null) node.scale.set(modelNode.scale);
    // FIXME create temporary maps for faster lookup?
    if (modelNode.parts != null) {
      for (ModelNodePart modelNodePart : modelNode.parts) {
        MeshPart meshPart = null;
        Material meshMaterial = null;
        if (modelNodePart.meshPartId != null) {
          for (MeshPart part : meshParts) {
            // FIXME need to make sure this is unique by adding mesh id to mesh part id!
            if (modelNodePart.meshPartId.equals(part.id)) {
              meshPart = part;
              break;
            }
          }
        }
        if (modelNodePart.materialId != null) {
          for (Material material : materials) {
            if (modelNodePart.materialId.equals(material.id)) {
              meshMaterial = material;
              break;
            }
          }
        }

        // FIXME what if meshPart is set but meshMaterial isn't and vice versa?
        if (meshPart != null && meshMaterial != null) {
          NodePart nodePart = new NodePart();
          nodePart.meshPart = meshPart;
          nodePart.material = meshMaterial;
          node.parts.add(nodePart);
          if (modelNodePart.bones != null) nodePartBones.put(nodePart, modelNodePart.bones);
        }
      }
    }

    if (modelNode.children != null) {
      for (ModelNode child : modelNode.children) {
        node.children.add(loadNode(node, child));
      }
    }

    return node;
  }