Java 类com.badlogic.gdx.graphics.g3d.model.data.ModelNode 实例源码

项目:Mundus    文件:MG3dModelLoader.java   
private Array<ModelNode> parseNodes(ModelData model, JsonValue json) {
    JsonValue nodes = json.get("nodes");
    if (nodes != null) {
        model.nodes.ensureCapacity(nodes.size);
        for (JsonValue node = nodes.child; node != null; node = node.next) {
            model.nodes.add(parseNodesRecursively(node));
        }
    }

    return model.nodes;
}
项目:libgdxcn    文件:G3dModelLoader.java   
private Array<ModelNode> parseNodes (ModelData model, JsonValue json) {
    JsonValue nodes = json.get("nodes");
    if (nodes != null) {
        model.nodes.ensureCapacity(nodes.size);
        for (JsonValue node = nodes.child; node != null; node = node.next) {
            model.nodes.add(parseNodesRecursively(node));
        }
    }

    return model.nodes;
}
项目:libgdxcn    文件:Model.java   
private void loadNodes (Iterable<ModelNode> modelNodes) {
    nodePartBones.clear();
    for (ModelNode node : modelNodes) {
        nodes.add(loadNode(node));
    }
    for (ObjectMap.Entry<NodePart, ArrayMap<String, Matrix4>> e : nodePartBones.entries()) {
        if (e.key.invBoneBindTransforms == null)
            e.key.invBoneBindTransforms = new ArrayMap<Node, Matrix4>(Node.class, Matrix4.class);
        e.key.invBoneBindTransforms.clear();
        for (ObjectMap.Entry<String, Matrix4> b : e.value.entries())
            e.key.invBoneBindTransforms.put(getNode(b.key), new Matrix4(b.value).inv());
    }
}
项目:gdx-proto    文件:HeadlessG3dModelLoader.java   
private Array<ModelNode> parseNodes (ModelData model, JsonValue json) {
    JsonValue nodes = json.get("nodes");
    if (nodes == null) {
        throw new GdxRuntimeException("At least one node is required.");
    }

    model.nodes.ensureCapacity(nodes.size);
    for (JsonValue node = nodes.child; node != null; node = node.next) {
        model.nodes.add(parseNodesRecursively(node));
    }
    return model.nodes;
}
项目:gdx-proto    文件:HeadlessModel.java   
private void loadNodes (Iterable<ModelNode> modelNodes) {
    nodePartBones.clear();
    for (ModelNode node : modelNodes) {
        nodes.add(loadNode(null, node));
    }
    for (ObjectMap.Entry<NodePart, ArrayMap<String, Matrix4>> e : nodePartBones.entries()) {
        if (e.key.invBoneBindTransforms == null)
            e.key.invBoneBindTransforms = new ArrayMap<Node, Matrix4>(Node.class, Matrix4.class);
        e.key.invBoneBindTransforms.clear();
        for (ObjectMap.Entry<String, Matrix4> b : e.value.entries())
            e.key.invBoneBindTransforms.put(getNode(b.key), new Matrix4(b.value).inv());
    }
}
项目:gdx-proto    文件:HeadlessModel.java   
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;

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

            if (meshPart == null) throw new GdxRuntimeException("Invalid node: " + node.id);
            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;
}
项目:libgdxcn    文件:Model.java   
private Node loadNode (ModelNode modelNode) {
    Node node = new Node();
    node.id = modelNode.id;

    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.addChild(loadNode(child));
        }
    }

    return node;
}