• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java ModelData类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: loadModelData

import com.badlogic.gdx.graphics.g3d.model.data.ModelData; //导入依赖的package包/类
/**
 * Directly load the raw model data on the calling thread.
 */
public ModelData loadModelData(final FileHandle fileHandle) {
    return loadModelData(fileHandle, null);
}
 
开发者ID:MovementSpeed,项目名称:nhglib,代码行数:7,代码来源:NhgModelLoader.java


示例17: loadModel

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


示例18: loadModelData

import com.badlogic.gdx.graphics.g3d.model.data.ModelData; //导入依赖的package包/类
@Override
public ModelData loadModelData(FileHandle fileHandle, ModelLoader.ModelParameters parameters) {
    return parseModel(fileHandle);
}
 
开发者ID:mbrlabs,项目名称:Mundus,代码行数:5,代码来源:MG3dModelLoader.java


示例19: parseMeshes

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


示例20: parseMaterials

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



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java EntitySmallFireball类代码示例发布时间:2022-05-22
下一篇:
Java AmazonSimpleWorkflowClient类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap