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

项目:Mundus    文件:MG3dModelLoader.java   
public ModelData parseModel(FileHandle handle) {
    JsonValue json = reader.parse(handle);
    ModelData model = new ModelData();
    JsonValue version = json.require("version");
    model.version[0] = version.getShort(0);
    model.version[1] = version.getShort(1);
    if (model.version[0] != VERSION_HI || model.version[1] != VERSION_LO)
        throw new GdxRuntimeException("Model version not supported");

    model.id = json.getString("id", "");
    parseMeshes(model, json);
    parseMaterials(model, json, handle.parent().path());
    parseNodes(model, json);
    parseAnimations(model, json);
    return model;
}
项目:libgdxcn    文件:G3dModelLoader.java   
public ModelData parseModel (FileHandle handle) {
    JsonValue json = reader.parse(handle);
    ModelData model = new ModelData();
    JsonValue version = json.require("version");
    model.version[0] = version.getShort(0);
    model.version[1] = version.getShort(1);
    if (model.version[0] != VERSION_HI || model.version[1] != VERSION_LO)
        throw new GdxRuntimeException("Model version not supported");

    model.id = json.getString("id", "");
    parseMeshes(model, json);
    parseMaterials(model, json, handle.parent().path());
    parseNodes(model, json);
    parseAnimations(model, json);
    return model;
}
项目:libgdxcn    文件:ModelLoader.java   
@Override
public Array<AssetDescriptor> getDependencies (String fileName, FileHandle file, P parameters) {
    final Array<AssetDescriptor> deps = new Array();
    ModelData data = loadModelData(file, parameters);
    if (data == null) return deps;

    ObjectMap.Entry<String, ModelData> item = new ObjectMap.Entry<String, ModelData>();
    item.key = fileName;
    item.value = data;
    synchronized (items) {
        items.add(item);
    }

    TextureLoader.TextureParameter textureParameter = (parameters != null)
            ? parameters.textureParameter
            : defaultParameters.textureParameter;

    for (final ModelMaterial modelMaterial : data.materials) {
        if (modelMaterial.textures != null) {
            for (final ModelTexture modelTexture : modelMaterial.textures)
                deps.add(new AssetDescriptor(modelTexture.fileName, Texture.class, textureParameter));
        }
    }
    return deps;
}
项目:libgdxcn    文件:ModelLoader.java   
@Override
public Model loadSync (AssetManager manager, String fileName, FileHandle file, P parameters) {
    ModelData data = null;
    synchronized (items) {
        for (int i = 0; i < items.size; i++) {
            if (items.get(i).key.equals(fileName)) {
                data = items.get(i).value;
                items.removeIndex(i);
            }
        }
    }
    if (data == null) return null;
    final Model result = new Model(data, new TextureProvider.AssetTextureProvider(manager));
    // need to remove the textures from the managed disposables, or else ref counting
    // doesn't work!
    Iterator<Disposable> disposables = result.getManagedDisposables().iterator();
    while (disposables.hasNext()) {
        Disposable disposable = disposables.next();
        if (disposable instanceof Texture) {
            disposables.remove();
        }
    }
    data = null;
    return result;
}
项目:gdx-proto    文件:HeadlessG3dModelLoader.java   
public ModelData parseModel (FileHandle handle) {
    JsonValue json = reader.parse(handle);
    ModelData model = new ModelData();
    JsonValue version = json.require("version");
    model.version[0] = version.getShort(0);
    model.version[1] = version.getShort(1);
    if (model.version[0] != VERSION_HI || model.version[1] != VERSION_LO)
        throw new GdxRuntimeException("Model version not supported");

    model.id = json.getString("id", "");
    parseMeshes(model, json);
    //parseMaterials(model, json, handle.parent().path());
    parseNodes(model, json);
    parseAnimations(model, json);
    return model;
}
项目:gdx-proto    文件:HeadlessModelLoader.java   
@Override
public Array<AssetDescriptor> getDependencies (String fileName, FileHandle file, P parameters) {
    final Array<AssetDescriptor> deps = new Array();
    ModelData data = loadModelData(file, parameters);
    if (data == null) return deps;

    ObjectMap.Entry<String, ModelData> item = new ObjectMap.Entry<String, ModelData>();
    item.key = fileName;
    item.value = data;
    synchronized (items) {
        items.add(item);
    }

    /*TextureLoader.TextureParameter textureParameter = (parameters != null)
            ? parameters.textureParameter
            : defaultParameters.textureParameter;

    for (final ModelMaterial modelMaterial : data.materials) {
        if (modelMaterial.textures != null) {
            for (final ModelTexture modelTexture : modelMaterial.textures)
                deps.add(new AssetDescriptor(modelTexture.fileName, Texture.class, textureParameter));
        }
    }*/
    return deps;
}
项目:gdx-proto    文件:HeadlessModelLoader.java   
@Override
public HeadlessModel loadSync (AssetManager manager, String fileName, FileHandle file, P parameters) {
    ModelData data = null;
    synchronized (items) {
        for (int i = 0; i < items.size; i++) {
            if (items.get(i).key.equals(fileName)) {
                data = items.get(i).value;
                items.removeIndex(i);
            }
        }
    }
    if (data == null) return null;
    final HeadlessModel result = new HeadlessModel(data, new TextureProvider.AssetTextureProvider(manager));
    // need to remove the textures from the managed disposables, or else ref counting
    // doesn't work!
    Iterator<Disposable> disposables = result.getManagedDisposables().iterator();
    while (disposables.hasNext()) {
        Disposable disposable = disposables.next();
        if (disposable instanceof Texture) {
            disposables.remove();
        }
    }
    data = null;
    return result;
}
项目:nhglib    文件:NhgModelLoader.java   
@Override
public Array<AssetDescriptor> getDependencies(String fileName, FileHandle file, P parameters) {
    final Array<AssetDescriptor> deps = new Array();
    ModelData data = loadModelData(file, parameters);
    if (data == null) return deps;

    ObjectMap.Entry<String, ModelData> item = new ObjectMap.Entry<String, ModelData>();
    item.key = fileName;
    item.value = data;

    synchronized (items) {
        items.add(item);
    }

    TextureLoader.TextureParameter textureParameter = (parameters != null)
            ? parameters.textureParameter
            : defaultParameters.textureParameter;

    for (final ModelMaterial modelMaterial : data.materials) {
        if (modelMaterial.textures != null) {
            for (final ModelTexture modelTexture : modelMaterial.textures) {
                String fName = modelTexture.fileName;

                if (fName.contains("/")) {
                    fName = fName.substring(fName.lastIndexOf("/") + 1);
                }

                deps.add(new AssetDescriptor(currentAsset.dependenciesPath + fName, Texture.class, textureParameter));
            }
        }
    }

    return deps;
}
项目:nhglib    文件:NhgModelLoader.java   
@Override
public Model loadSync(AssetManager manager, String fileName, FileHandle file, P parameters) {
    ModelData data = null;
    synchronized (items) {
        for (int i = 0; i < items.size; i++) {
            if (items.get(i).key.equals(fileName)) {
                data = items.get(i).value;
                items.removeIndex(i);
            }
        }
    }
    if (data == null) return null;
    final Model result = new Model(data, new TextureProvider.AssetTextureProvider(manager));
    // need to remove the textures from the managed disposables, or else ref counting
    // doesn't work!
    Iterator<Disposable> disposables = result.getManagedDisposables().iterator();
    while (disposables.hasNext()) {
        Disposable disposable = disposables.next();
        if (disposable instanceof Texture) {
            disposables.remove();
        }
    }

    // Automatically convert all materials to PBR
    for (Material material : result.materials) {
        TextureAttribute textureAttribute = (TextureAttribute) material.get(TextureAttribute.Diffuse);

        if (textureAttribute != null) {
            material.set(PbrTextureAttribute.createAlbedo(textureAttribute.textureDescription.texture));
        }
    }

    data = null;
    return result;
}
项目: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    文件:G3dModelLoader.java   
private void parseAnimations (ModelData model, JsonValue json) {
    JsonValue animations = json.get("animations");
    if (animations == null) return;

    model.animations.ensureCapacity(animations.size);

    for (JsonValue anim = animations.child; anim != null; anim = anim.next) {
        JsonValue nodes = anim.get("bones");
        if (nodes == null) continue;
        ModelAnimation animation = new ModelAnimation();
        model.animations.add(animation);
        animation.nodeAnimations.ensureCapacity(nodes.size);
        animation.id = anim.getString("id");
        for (JsonValue node = nodes.child; node != null; node = node.next) {
            JsonValue keyframes = node.get("keyframes");

            ModelNodeAnimation nodeAnim = new ModelNodeAnimation();
            animation.nodeAnimations.add(nodeAnim);
            nodeAnim.nodeId = node.getString("boneId");
            nodeAnim.keyframes.ensureCapacity(keyframes.size);

            for (JsonValue keyframe = keyframes.child; keyframe != null; keyframe = keyframe.next) {
                ModelNodeKeyframe kf = new ModelNodeKeyframe();
                nodeAnim.keyframes.add(kf);
                kf.keytime = keyframe.getFloat("keytime") / 1000.f;
                JsonValue translation = keyframe.get("translation");
                if (translation != null && translation.size == 3)
                    kf.translation = new Vector3(translation.getFloat(0), translation.getFloat(1), translation.getFloat(2));
                JsonValue rotation = keyframe.get("rotation");
                if (rotation != null && rotation.size == 4)
                    kf.rotation = new Quaternion(rotation.getFloat(0), rotation.getFloat(1), rotation.getFloat(2),
                        rotation.getFloat(3));
                JsonValue scale = keyframe.get("scale");
                if (scale != null && scale.size == 3)
                    kf.scale = new Vector3(scale.getFloat(0), scale.getFloat(1), scale.getFloat(2));
            }
        }
    }
}
项目:libgdxcn    文件:Model.java   
private void load (ModelData modelData, TextureProvider textureProvider) {
    loadMeshes(modelData.meshes);
    loadMaterials(modelData.materials, textureProvider);
    loadNodes(modelData.nodes);
    loadAnimations(modelData.animations);
    calculateTransforms();
}
项目: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    文件:HeadlessG3dModelLoader.java   
private void parseAnimations (ModelData model, JsonValue json) {
    JsonValue animations = json.get("animations");
    if (animations == null) return;

    model.animations.ensureCapacity(animations.size);

    for (JsonValue anim = animations.child; anim != null; anim = anim.next) {
        JsonValue nodes = anim.get("bones");
        if (nodes == null) continue;
        ModelAnimation animation = new ModelAnimation();
        model.animations.add(animation);
        animation.nodeAnimations.ensureCapacity(nodes.size);
        animation.id = anim.getString("id");
        for (JsonValue node = nodes.child; node != null; node = node.next) {
            JsonValue keyframes = node.get("keyframes");

            ModelNodeAnimation nodeAnim = new ModelNodeAnimation();
            animation.nodeAnimations.add(nodeAnim);
            nodeAnim.nodeId = node.getString("boneId");
            nodeAnim.keyframes.ensureCapacity(keyframes.size);

            for (JsonValue keyframe = keyframes.child; keyframe != null; keyframe = keyframe.next) {
                ModelNodeKeyframe kf = new ModelNodeKeyframe();
                nodeAnim.keyframes.add(kf);
                kf.keytime = keyframe.getFloat("keytime") / 1000.f;
                JsonValue translation = keyframe.get("translation");
                if (translation != null && translation.size == 3)
                    kf.translation = new Vector3(translation.getFloat(0), translation.getFloat(1), translation.getFloat(2));
                JsonValue rotation = keyframe.get("rotation");
                if (rotation != null && rotation.size == 4)
                    kf.rotation = new Quaternion(rotation.getFloat(0), rotation.getFloat(1), rotation.getFloat(2),
                            rotation.getFloat(3));
                JsonValue scale = keyframe.get("scale");
                if (scale != null && scale.size == 3)
                    kf.scale = new Vector3(scale.getFloat(0), scale.getFloat(1), scale.getFloat(2));
            }
        }
    }
}
项目:nhglib    文件:NhgModelLoader.java   
/**
 * Directly load the raw model data on the calling thread.
 */
public ModelData loadModelData(final FileHandle fileHandle) {
    return loadModelData(fileHandle, null);
}
项目:nhglib    文件:NhgModelLoader.java   
/**
 * Directly load the model on the calling thread. The model with not be managed by an {@link AssetManager}.
 */
public Model loadModel(final FileHandle fileHandle, TextureProvider textureProvider, P parameters) {
    final ModelData data = loadModelData(fileHandle, parameters);
    return data == null ? null : new Model(data, textureProvider);
}
项目:Mundus    文件:MG3dModelLoader.java   
@Override
public ModelData loadModelData(FileHandle fileHandle, ModelLoader.ModelParameters parameters) {
    return parseModel(fileHandle);
}
项目:Mundus    文件:MG3dModelLoader.java   
private void parseMeshes(ModelData model, JsonValue json) {
    JsonValue meshes = json.get("meshes");
    if (meshes != null) {

        model.meshes.ensureCapacity(meshes.size);
        for (JsonValue mesh = meshes.child; mesh != null; mesh = mesh.next) {
            ModelMesh jsonMesh = new ModelMesh();

            String id = mesh.getString("id", "");
            jsonMesh.id = id;

            JsonValue attributes = mesh.require("attributes");
            jsonMesh.attributes = parseAttributes(attributes);
            jsonMesh.vertices = mesh.require("vertices").asFloatArray();

            JsonValue meshParts = mesh.require("parts");
            Array<ModelMeshPart> parts = new Array<ModelMeshPart>();
            for (JsonValue meshPart = meshParts.child; meshPart != null; meshPart = meshPart.next) {
                ModelMeshPart jsonPart = new ModelMeshPart();
                String partId = meshPart.getString("id", null);
                if (partId == null) {
                    throw new GdxRuntimeException("Not id given for mesh part");
                }
                for (ModelMeshPart other : parts) {
                    if (other.id.equals(partId)) {
                        throw new GdxRuntimeException("Mesh part with id '" + partId + "' already in defined");
                    }
                }
                jsonPart.id = partId;

                String type = meshPart.getString("type", null);
                if (type == null) {
                    throw new GdxRuntimeException("No primitive type given for mesh part '" + partId + "'");
                }
                jsonPart.primitiveType = parseType(type);

                jsonPart.indices = meshPart.require("indices").asShortArray();
                parts.add(jsonPart);
            }
            jsonMesh.parts = parts.toArray(ModelMeshPart.class);
            model.meshes.add(jsonMesh);
        }
    }
}
项目:Mundus    文件:MG3dModelLoader.java   
private void parseMaterials(ModelData model, JsonValue json, String materialDir) {
    JsonValue materials = json.get("materials");
    if (materials == null) {
        // we should probably create some default material in this case
    } else {
        model.materials.ensureCapacity(materials.size);
        for (JsonValue material = materials.child; material != null; material = material.next) {
            ModelMaterial jsonMaterial = new ModelMaterial();

            String id = material.getString("id", null);
            if (id == null) throw new GdxRuntimeException("Material needs an id.");

            jsonMaterial.id = id;

            // Read material colors
            final JsonValue diffuse = material.get("diffuse");
            if (diffuse != null) jsonMaterial.diffuse = parseColor(diffuse);
            final JsonValue ambient = material.get("ambient");
            if (ambient != null) jsonMaterial.ambient = parseColor(ambient);
            final JsonValue emissive = material.get("emissive");
            if (emissive != null) jsonMaterial.emissive = parseColor(emissive);
            final JsonValue specular = material.get("specular");
            if (specular != null) jsonMaterial.specular = parseColor(specular);
            final JsonValue reflection = material.get("reflection");
            if (reflection != null) jsonMaterial.reflection = parseColor(reflection);
            // Read shininess
            jsonMaterial.shininess = material.getFloat("shininess", 0.0f);
            // Read opacity
            jsonMaterial.opacity = material.getFloat("opacity", 1.0f);

            // Read textures
            // JsonValue textures = material.get("textures");
            // if (textures != null) {
            // for (JsonValue texture = textures.child; texture != null;
            // texture = texture.next) {
            // ModelTexture jsonTexture = new ModelTexture();
            //
            // String textureId = texture.getString("id", null);
            // if (textureId == null) throw new GdxRuntimeException("Texture
            // has no id.");
            // jsonTexture.id = textureId;
            //
            // String fileName = texture.getString("filename", null);
            // if (fileName == null) throw new GdxRuntimeException("Texture
            // needs filename.");
            // jsonTexture.fileName = materialDir + (materialDir.length() ==
            // 0 || materialDir.endsWith("/") ? "" : "/")
            // + fileName;
            //
            // jsonTexture.uvTranslation =
            // readVector2(texture.get("uvTranslation"), 0f, 0f);
            // jsonTexture.uvScaling = readVector2(texture.get("uvScaling"),
            // 1f, 1f);
            //
            // String textureType = texture.getString("type", null);
            // if (textureType == null) throw new
            // GdxRuntimeException("Texture needs type.");
            //
            // jsonTexture.usage = parseTextureUsage(textureType);
            //
            // if (jsonMaterial.textures == null) jsonMaterial.textures =
            // new Array<ModelTexture>();
            // jsonMaterial.textures.add(jsonTexture);
            // }
            // }

            model.materials.add(jsonMaterial);
        }
    }
}
项目:ForgE    文件:ModelAsset.java   
@Override
protected Model loadObject(FileHandle file) {
  ModelData modelData = g3djLoader.loadModelData(file);
  return new Model(modelData, this);
}
项目:libgdxcn    文件:G3dModelLoader.java   
@Override
public ModelData loadModelData (FileHandle fileHandle, ModelLoader.ModelParameters parameters) {
    return parseModel(fileHandle);
}
项目:libgdxcn    文件:G3dModelLoader.java   
private void parseMeshes (ModelData model, JsonValue json) {
    JsonValue meshes = json.get("meshes");
    if (meshes != null) {

        model.meshes.ensureCapacity(meshes.size);
        for (JsonValue mesh = meshes.child; mesh != null; mesh = mesh.next) {
            ModelMesh jsonMesh = new ModelMesh();

            String id = mesh.getString("id", "");
            jsonMesh.id = id;

            JsonValue attributes = mesh.require("attributes");
            jsonMesh.attributes = parseAttributes(attributes);
            jsonMesh.vertices = mesh.require("vertices").asFloatArray();

            JsonValue meshParts = mesh.require("parts");
            Array<ModelMeshPart> parts = new Array<ModelMeshPart>();
            for (JsonValue meshPart = meshParts.child; meshPart != null; meshPart = meshPart.next) {
                ModelMeshPart jsonPart = new ModelMeshPart();
                String partId = meshPart.getString("id", null);
                if (id == null) {
                    throw new GdxRuntimeException("Not id given for mesh part");
                }
                for (ModelMeshPart other : parts) {
                    if (other.id.equals(partId)) {
                        throw new GdxRuntimeException("Mesh part with id '" + partId + "' already in defined");
                    }
                }
                jsonPart.id = partId;

                String type = meshPart.getString("type", null);
                if (type == null) {
                    throw new GdxRuntimeException("No primitive type given for mesh part '" + partId + "'");
                }
                jsonPart.primitiveType = parseType(type);

                jsonPart.indices = meshPart.require("indices").asShortArray();
                parts.add(jsonPart);
            }
            jsonMesh.parts = parts.toArray(ModelMeshPart.class);
            model.meshes.add(jsonMesh);
        }
    }
}
项目:libgdxcn    文件:G3dModelLoader.java   
private void parseMaterials (ModelData model, JsonValue json, String materialDir) {
    JsonValue materials = json.get("materials");
    if (materials == null) {
        // we should probably create some default material in this case
    } else {
        model.materials.ensureCapacity(materials.size);
        for (JsonValue material = materials.child; material != null; material = material.next) {
            ModelMaterial jsonMaterial = new ModelMaterial();

            String id = material.getString("id", null);
            if (id == null) throw new GdxRuntimeException("Material needs an id.");

            jsonMaterial.id = id;

            // Read material colors
            final JsonValue diffuse = material.get("diffuse");
            if (diffuse != null) jsonMaterial.diffuse = parseColor(diffuse);
            final JsonValue ambient = material.get("ambient");
            if (ambient != null) jsonMaterial.ambient = parseColor(ambient);
            final JsonValue emissive = material.get("emissive");
            if (emissive != null) jsonMaterial.emissive = parseColor(emissive);
            final JsonValue specular = material.get("specular");
            if (specular != null) jsonMaterial.specular = parseColor(specular);
            final JsonValue reflection = material.get("reflection");
            if (reflection != null) jsonMaterial.reflection = parseColor(reflection);
            // Read shininess
            jsonMaterial.shininess = material.getFloat("shininess", 0.0f);
            // Read opacity
            jsonMaterial.opacity = material.getFloat("opacity", 1.0f);

            // Read textures
            JsonValue textures = material.get("textures");
            if (textures != null) {
                for (JsonValue texture = textures.child; texture != null; texture = texture.next) {
                    ModelTexture jsonTexture = new ModelTexture();

                    String textureId = texture.getString("id", null);
                    if (textureId == null) throw new GdxRuntimeException("Texture has no id.");
                    jsonTexture.id = textureId;

                    String fileName = texture.getString("filename", null);
                    if (fileName == null) throw new GdxRuntimeException("Texture needs filename.");
                    jsonTexture.fileName = materialDir + (materialDir.length() == 0 || materialDir.endsWith("/") ? "" : "/")
                        + fileName;

                    jsonTexture.uvTranslation = readVector2(texture.get("uvTranslation"), 0f, 0f);
                    jsonTexture.uvScaling = readVector2(texture.get("uvScaling"), 1f, 1f);

                    String textureType = texture.getString("type", null);
                    if (textureType == null) throw new GdxRuntimeException("Texture needs type.");

                    jsonTexture.usage = parseTextureUsage(textureType);

                    if (jsonMaterial.textures == null) jsonMaterial.textures = new Array<ModelTexture>();
                    jsonMaterial.textures.add(jsonTexture);
                }
            }

            model.materials.add(jsonMaterial);
        }
    }
}
项目:libgdxcn    文件:ObjLoader.java   
@Override
public ModelData loadModelData (FileHandle file, ObjLoaderParameters parameters) {
    return loadModelData(file, parameters == null ? false : parameters.flipV);
}
项目:libgdxcn    文件:Model.java   
/** Constructs a new Model based on the {@link ModelData}. Texture files will be loaded from the internal file storage via an
 * {@link FileTextureProvider}.
 * @param modelData the {@link ModelData} got from e.g. {@link ModelLoader} */
public Model (ModelData modelData) {
    this(modelData, new FileTextureProvider());
}
项目:libgdxcn    文件:Model.java   
/** Constructs a new Model based on the {@link ModelData}.
 * @param modelData the {@link ModelData} got from e.g. {@link ModelLoader}
 * @param textureProvider the {@link TextureProvider} to use for loading the textures */
public Model (ModelData modelData, TextureProvider textureProvider) {
    load(modelData, textureProvider);
}
项目:libgdxcn    文件:ModelLoader.java   
/** Directly load the raw model data on the calling thread. */
public abstract ModelData loadModelData (final FileHandle fileHandle, P parameters);
项目:libgdxcn    文件:ModelLoader.java   
/** Directly load the raw model data on the calling thread. */
public ModelData loadModelData (final FileHandle fileHandle) {
    return loadModelData(fileHandle, null);
}
项目:libgdxcn    文件:ModelLoader.java   
/** Directly load the model on the calling thread. The model with not be managed by an {@link AssetManager}. */
public Model loadModel (final FileHandle fileHandle, TextureProvider textureProvider, P parameters) {
    final ModelData data = loadModelData(fileHandle, parameters);
    return data == null ? null : new Model(data, textureProvider);
}
项目:gaiasky    文件:ObjLoader.java   
@Override
public ModelData loadModelData(FileHandle file, ObjLoaderParameters parameters) {
    return loadModelData(file, parameters == null ? false : parameters.flipV);
}
项目:gdx-proto    文件:HeadlessG3dModelLoader.java   
@Override
public ModelData loadModelData (FileHandle fileHandle, HeadlessModelParameters parameters) {
    return parseModel(fileHandle);
}
项目:gdx-proto    文件:HeadlessG3dModelLoader.java   
private void parseMeshes (ModelData model, JsonValue json) {
    JsonValue meshes = json.require("meshes");

    model.meshes.ensureCapacity(meshes.size);
    for (JsonValue mesh = meshes.child; mesh != null; mesh = mesh.next) {
        ModelMesh jsonMesh = new ModelMesh();

        String id = mesh.getString("id", "");
        jsonMesh.id = id;

        JsonValue attributes = mesh.require("attributes");
        jsonMesh.attributes = parseAttributes(attributes);
        jsonMesh.vertices = mesh.require("vertices").asFloatArray();

        JsonValue meshParts = mesh.require("parts");
        Array<ModelMeshPart> parts = new Array<ModelMeshPart>();
        for (JsonValue meshPart = meshParts.child; meshPart != null; meshPart = meshPart.next) {
            ModelMeshPart jsonPart = new ModelMeshPart();
            String partId = meshPart.getString("id", null);
            if (id == null) {
                throw new GdxRuntimeException("Not id given for mesh part");
            }
            for (ModelMeshPart other : parts) {
                if (other.id.equals(partId)) {
                    throw new GdxRuntimeException("Mesh part with id '" + partId + "' already in defined");
                }
            }
            jsonPart.id = partId;

            String type = meshPart.getString("type", null);
            if (type == null) {
                throw new GdxRuntimeException("No primitive type given for mesh part '" + partId + "'");
            }
            jsonPart.primitiveType = parseType(type);

            jsonPart.indices = meshPart.require("indices").asShortArray();
            parts.add(jsonPart);
        }
        jsonMesh.parts = parts.toArray(ModelMeshPart.class);
        model.meshes.add(jsonMesh);
    }
}
项目:gdx-proto    文件:HeadlessModel.java   
/** Constructs a new Model based on the {@link com.badlogic.gdx.graphics.g3d.model.data.ModelData}. Texture files will be loaded from the internal file storage via an
 * {@link com.badlogic.gdx.graphics.g3d.utils.TextureProvider.FileTextureProvider}.
 * @param modelData the {@link com.badlogic.gdx.graphics.g3d.model.data.ModelData} got from e.g. {@link com.badlogic.gdx.assets.loaders.ModelLoader} */
public HeadlessModel(ModelData modelData) {
    this(modelData, new FileTextureProvider());
}
项目:gdx-proto    文件:HeadlessModel.java   
/** Constructs a new Model based on the {@link com.badlogic.gdx.graphics.g3d.model.data.ModelData}.
 * @param modelData the {@link com.badlogic.gdx.graphics.g3d.model.data.ModelData} got from e.g. {@link com.badlogic.gdx.assets.loaders.ModelLoader}
 * @param textureProvider the {@link com.badlogic.gdx.graphics.g3d.utils.TextureProvider} to use for loading the textures */
public HeadlessModel(ModelData modelData, TextureProvider textureProvider) {
    load(modelData, textureProvider);
}
项目:gdx-proto    文件:HeadlessModel.java   
private void load (ModelData modelData, TextureProvider textureProvider) {
    loadMeshes(modelData.meshes);
    loadNodes(modelData.nodes);
    loadAnimations(modelData.animations);
    calculateTransforms();
}
项目:gdx-proto    文件:HeadlessModelLoader.java   
/** Directly load the raw HeadlessModel data on the calling thread. */
public abstract ModelData loadModelData (final FileHandle fileHandle, P parameters);
项目:gdx-proto    文件:HeadlessModelLoader.java   
/** Directly load the raw HeadlessModel data on the calling thread. */
public ModelData loadModelData (final FileHandle fileHandle) {
    return loadModelData(fileHandle, null);
}
项目:gdx-proto    文件:HeadlessModelLoader.java   
/** Directly load the HeadlessModel on the calling thread. The HeadlessModel with not be managed by an {@link com.badlogic.gdx.assets.AssetManager}. */
public HeadlessModel loadHeadlessModel (final FileHandle fileHandle, TextureProvider textureProvider, P parameters) {
    final ModelData data = loadModelData(fileHandle, parameters);
    return data == null ? null : new HeadlessModel(data, textureProvider);
}
项目:nhglib    文件:NhgModelLoader.java   
/**
 * Directly load the raw model data on the calling thread.
 */
public abstract ModelData loadModelData(final FileHandle fileHandle, P parameters);