当前位置: 首页>>代码示例>>Java>>正文


Java ModelData类代码示例

本文整理汇总了Java中com.badlogic.gdx.graphics.g3d.model.data.ModelData的典型用法代码示例。如果您正苦于以下问题:Java ModelData类的具体用法?Java ModelData怎么用?Java ModelData使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ModelData类属于com.badlogic.gdx.graphics.g3d.model.data包,在下文中一共展示了ModelData类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: parseModel

import com.badlogic.gdx.graphics.g3d.model.data.ModelData; //导入依赖的package包/类
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;
}
 
开发者ID:mbrlabs,项目名称:Mundus,代码行数:17,代码来源:MG3dModelLoader.java

示例2: parseModel

import com.badlogic.gdx.graphics.g3d.model.data.ModelData; //导入依赖的package包/类
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;
}
 
开发者ID:basherone,项目名称:libgdxcn,代码行数:17,代码来源:G3dModelLoader.java

示例3: getDependencies

import com.badlogic.gdx.graphics.g3d.model.data.ModelData; //导入依赖的package包/类
@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;
}
 
开发者ID:basherone,项目名称:libgdxcn,代码行数:26,代码来源:ModelLoader.java

示例4: loadSync

import com.badlogic.gdx.graphics.g3d.model.data.ModelData; //导入依赖的package包/类
@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;
}
 
开发者ID:basherone,项目名称:libgdxcn,代码行数:26,代码来源:ModelLoader.java

示例5: parseModel

import com.badlogic.gdx.graphics.g3d.model.data.ModelData; //导入依赖的package包/类
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;
}
 
开发者ID:jrenner,项目名称:gdx-proto,代码行数:17,代码来源:HeadlessG3dModelLoader.java

示例6: getDependencies

import com.badlogic.gdx.graphics.g3d.model.data.ModelData; //导入依赖的package包/类
@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;
}
 
开发者ID:jrenner,项目名称:gdx-proto,代码行数:26,代码来源:HeadlessModelLoader.java

示例7: loadSync

import com.badlogic.gdx.graphics.g3d.model.data.ModelData; //导入依赖的package包/类
@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;
}
 
开发者ID:jrenner,项目名称:gdx-proto,代码行数:26,代码来源:HeadlessModelLoader.java

示例8: getDependencies

import com.badlogic.gdx.graphics.g3d.model.data.ModelData; //导入依赖的package包/类
@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;
}
 
开发者ID:MovementSpeed,项目名称:nhglib,代码行数:35,代码来源:NhgModelLoader.java

示例9: loadSync

import com.badlogic.gdx.graphics.g3d.model.data.ModelData; //导入依赖的package包/类
@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;
}
 
开发者ID:MovementSpeed,项目名称:nhglib,代码行数:36,代码来源:NhgModelLoader.java

示例10: parseNodes

import com.badlogic.gdx.graphics.g3d.model.data.ModelData; //导入依赖的package包/类
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;
}
 
开发者ID:mbrlabs,项目名称:Mundus,代码行数:12,代码来源:MG3dModelLoader.java

示例11: parseNodes

import com.badlogic.gdx.graphics.g3d.model.data.ModelData; //导入依赖的package包/类
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;
}
 
开发者ID:basherone,项目名称:libgdxcn,代码行数:12,代码来源:G3dModelLoader.java

示例12: parseAnimations

import com.badlogic.gdx.graphics.g3d.model.data.ModelData; //导入依赖的package包/类
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));
			}
		}
	}
}
 
开发者ID:basherone,项目名称:libgdxcn,代码行数:40,代码来源:G3dModelLoader.java

示例13: load

import com.badlogic.gdx.graphics.g3d.model.data.ModelData; //导入依赖的package包/类
private void load (ModelData modelData, TextureProvider textureProvider) {
	loadMeshes(modelData.meshes);
	loadMaterials(modelData.materials, textureProvider);
	loadNodes(modelData.nodes);
	loadAnimations(modelData.animations);
	calculateTransforms();
}
 
开发者ID:basherone,项目名称:libgdxcn,代码行数:8,代码来源:Model.java

示例14: parseNodes

import com.badlogic.gdx.graphics.g3d.model.data.ModelData; //导入依赖的package包/类
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;
}
 
开发者ID:jrenner,项目名称:gdx-proto,代码行数:13,代码来源:HeadlessG3dModelLoader.java

示例15: parseAnimations

import com.badlogic.gdx.graphics.g3d.model.data.ModelData; //导入依赖的package包/类
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));
			}
		}
	}
}
 
开发者ID:jrenner,项目名称:gdx-proto,代码行数:40,代码来源:HeadlessG3dModelLoader.java


注:本文中的com.badlogic.gdx.graphics.g3d.model.data.ModelData类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。