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


Java NodePart类代码示例

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


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

示例1: setNavmesh

import com.badlogic.gdx.graphics.g3d.model.NodePart; //导入依赖的package包/类
/**
 * Creates and adds the navmesh to this scene.
 */
private void setNavmesh(GameObjectBlueprint bp) {
	// We need to set the node transforms before calculating the navmesh shape
	GameModel gameModel = new GameModel(bp.model, bp.name, bp.position, bp.rotation, bp.scale);

	Array<NodePart> nodes = gameModel.modelInstance.model.getNode("navmesh").parts;
	// Sort the model meshParts array according to material name
	nodes.sort(new NavMeshNodeSorter());

	// The model transform must be applied to the meshparts for shape generation to work correctly.
	gameModel.modelInstance.calculateTransforms();
	Matrix4 transform = new Matrix4();
	for (Node node : gameModel.modelInstance.nodes) {
		transform.set(node.globalTransform).inv();
		for (NodePart nodePart : node.parts) {
			nodePart.meshPart.mesh.transform(transform);
		}
	}
	navMesh = new NavMesh(gameModel.modelInstance.model);
	btCollisionShape shape = navMesh.getShape();

	navmeshBody = new InvisibleBody("navmesh",
			shape, 0, gameModel.modelInstance.transform, GameEngine.NAVMESH_FLAG, GameEngine.NAVMESH_FLAG, false, false);
	worldBounds.set(gameModel.boundingBox);
	gameModel.dispose();
}
 
开发者ID:jsjolund,项目名称:GdxDemo3D,代码行数:29,代码来源:GameScene.java

示例2: createFromMesh

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

示例3: copyNode

import com.badlogic.gdx.graphics.g3d.model.NodePart; //导入依赖的package包/类
private Node copyNode (Node node) {
	Node copy = new Node();
	copy.id = node.id;
	copy.inheritTransform = node.inheritTransform;
	copy.translation.set(node.translation);
	copy.rotation.set(node.rotation);
	copy.scale.set(node.scale);
	copy.localTransform.set(node.localTransform);
	copy.globalTransform.set(node.globalTransform);
	for (NodePart nodePart : node.parts) {
		copy.parts.add(copyNodePart(nodePart));
	}
	for (Node child : node.getChildren()) {
		copy.addChild(copyNode(child));
	}
	return copy;
}
 
开发者ID:basherone,项目名称:libgdxcn,代码行数:18,代码来源:ModelInstance.java

示例4: copyNodePart

import com.badlogic.gdx.graphics.g3d.model.NodePart; //导入依赖的package包/类
private NodePart copyNodePart (NodePart nodePart) {
	NodePart copy = new NodePart();
	copy.meshPart = new MeshPart();
	copy.meshPart.id = nodePart.meshPart.id;
	copy.meshPart.indexOffset = nodePart.meshPart.indexOffset;
	copy.meshPart.numVertices = nodePart.meshPart.numVertices;
	copy.meshPart.primitiveType = nodePart.meshPart.primitiveType;
	copy.meshPart.mesh = nodePart.meshPart.mesh;

	if (nodePart.invBoneBindTransforms != null) nodePartBones.put(copy, nodePart.invBoneBindTransforms);

	final int index = materials.indexOf(nodePart.material, false);
	if (index < 0)
		materials.add(copy.material = nodePart.material.copy());
	else
		copy.material = materials.get(index);

	return copy;
}
 
开发者ID:basherone,项目名称:libgdxcn,代码行数:20,代码来源:ModelInstance.java

示例5: createFromMesh

import com.badlogic.gdx.graphics.g3d.model.NodePart; //导入依赖的package包/类
@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.offset = indexOffset;
    meshPart.size = 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;
}
 
开发者ID:langurmonkey,项目名称:gaiasky,代码行数:25,代码来源:ModelBuilder2.java

示例6: copyNode

import com.badlogic.gdx.graphics.g3d.model.NodePart; //导入依赖的package包/类
private Node copyNode(Node parent, Node node) {
	Node copy = new Node();
	copy.id = node.id;
	//copy.boneId = node.boneId;
	copy.parent = parent;
	copy.translation.set(node.translation);
	copy.rotation.set(node.rotation);
	copy.scale.set(node.scale);
	copy.localTransform.set(node.localTransform);
	copy.globalTransform.set(node.globalTransform);
	for(NodePart nodePart: node.parts) {
		copy.parts.add(copyNodePart(nodePart));
	}
	for(Node child: node.children) {
		copy.children.add(copyNode(copy, child));
	}
	return copy;
}
 
开发者ID:opensciencemap,项目名称:vtm,代码行数:19,代码来源:SharedModel.java

示例7: copyNodePart

import com.badlogic.gdx.graphics.g3d.model.NodePart; //导入依赖的package包/类
private NodePart copyNodePart (NodePart nodePart) {
		NodePart copy = new NodePart();
		copy.meshPart = new MeshPart();
		copy.meshPart.id = nodePart.meshPart.id;
		copy.meshPart.indexOffset = nodePart.meshPart.indexOffset;
		copy.meshPart.numVertices = nodePart.meshPart.numVertices;
		copy.meshPart.primitiveType = nodePart.meshPart.primitiveType;
		copy.meshPart.mesh = nodePart.meshPart.mesh;
		
		if (nodePart.invBoneBindTransforms != null)
			nodePartBones.put(copy, nodePart.invBoneBindTransforms);
		
//		final int index = materials.indexOf(nodePart.material, false);
//		if (index < 0)
//			materials.add(copy.material = nodePart.material.copy());
//		else
//			copy.material = materials.get(index);
//		
		copy.material = nodePart.material;
		
		return copy;
	}
 
开发者ID:opensciencemap,项目名称:vtm,代码行数:23,代码来源:SharedModel.java

示例8: collectModelNodeVertexPositions

import com.badlogic.gdx.graphics.g3d.model.NodePart; //导入依赖的package包/类
protected void collectModelNodeVertexPositions(Node node, Array<Vector3> destVertices, Vector3 scaleFactor, Vector3 positionOffset) {
	final Matrix4 transform = node.globalTransform;

	for (int i = 0; i < node.parts.size; ++i) {
		NodePart nodePart = node.parts.get(i);
		MeshPart meshPart = nodePart.meshPart;
		ShortBuffer indices = meshPart.mesh.getIndicesBuffer();
		FloatBuffer vertices = meshPart.mesh.getVerticesBuffer();
		final int strideInFloats = meshPart.mesh.getVertexSize() / (Float.SIZE / 8);

		for (int j = 0; j < meshPart.numVertices; ++j) {
			int index = indices.get(meshPart.indexOffset + j);
			int offset = index * strideInFloats;

			tmpPosition.set(vertices.get(offset), vertices.get(offset + 1), vertices.get(offset + 2))
			           .add(positionOffset)
			           .scl(scaleFactor)
			           .mul(transform);
			destVertices.add(new Vector3(tmpPosition));
		}
	}

	for (int i = 0; i < node.children.size; ++i)
		collectModelNodeVertexPositions(node.children.get(i), destVertices, scaleFactor, positionOffset);
}
 
开发者ID:gered,项目名称:gdx-tilemap3d,代码行数:26,代码来源:BaseModelTileMesh.java

示例9: getPart

import com.badlogic.gdx.graphics.g3d.model.NodePart; //导入依赖的package包/类
private NodePart getPart(int index) {
    ModelInstance inst = gameWorld.renderer().getRenderable(selected());
    int i = 0;
    for (Node node : inst.nodes) {
        for (NodePart part : node.parts) {
            if(i == index) return part;
            i++;
        }
    }
    return null;
}
 
开发者ID:ncguy2,项目名称:Argent,代码行数:12,代码来源:MaterialPanel.java

示例10: setVColorBlendAttributes

import com.badlogic.gdx.graphics.g3d.model.NodePart; //导入依赖的package包/类
private void setVColorBlendAttributes() {
	Array<String> modelsIdsInScene = assets.getPlaceholderIdsByType(BlenderModel.class);
	Array<BlenderModel> instancesWithId = new Array<BlenderModel>();
	for (String id : modelsIdsInScene) {
		instancesWithId.clear();
		assets.getPlaceholders(id, BlenderModel.class, instancesWithId);
		for (BlenderModel blenderModel : instancesWithId) {
			// Maybe check if
			// renderable.meshPart.mesh.getVertexAttribute(VertexAttributes.Usage.ColorUnpacked) != null
			if (blenderModel.custom_properties.containsKey("v_color_material_blend")) {
				Model model = assets.getAsset(id, Model.class);
				String redMaterialName = blenderModel.custom_properties.get("v_color_material_red");
				String greenMaterialName = blenderModel.custom_properties.get("v_color_material_green");
				String blueMaterialName = blenderModel.custom_properties.get("v_color_material_blue");

				TextureAttribute redTexAttr = (TextureAttribute)
						model.getMaterial(redMaterialName).get(TextureAttribute.Diffuse);
				TextureAttribute greenTexAttr = (TextureAttribute)
						model.getMaterial(greenMaterialName).get(TextureAttribute.Diffuse);
				TextureAttribute blueTexAttr = (TextureAttribute)
						model.getMaterial(blueMaterialName).get(TextureAttribute.Diffuse);
				VertexColorTextureBlend redAttribute =
						new VertexColorTextureBlend(VertexColorTextureBlend.Red,
								redTexAttr.textureDescription.texture);
				VertexColorTextureBlend greenAttribute =
						new VertexColorTextureBlend(VertexColorTextureBlend.Green,
								greenTexAttr.textureDescription.texture);
				VertexColorTextureBlend blueAttribute =
						new VertexColorTextureBlend(VertexColorTextureBlend.Blue,
								blueTexAttr.textureDescription.texture);
				for (Node node : model.nodes) {
					for (NodePart nodePart : node.parts) {
						nodePart.material.set(redAttribute, greenAttribute, blueAttribute);
					}
				}
				break;
			}
		}
	}
}
 
开发者ID:jsjolund,项目名称:GdxDemo3D,代码行数:41,代码来源:GameScene.java

示例11: fatten

import com.badlogic.gdx.graphics.g3d.model.NodePart; //导入依赖的package包/类
/**
 * Translate each vertex along its normal by specified amount.
 *
 * @param model
 * @param amount
 */
public static void fatten(Model model, float amount) {
	Vector3 pos = new Vector3();
	Vector3 nor = new Vector3();
	for (Node node : model.nodes) {
		for (NodePart n : node.parts) {
			Mesh mesh = n.meshPart.mesh;
			FloatBuffer buf = mesh.getVerticesBuffer();
			int lastFloat = mesh.getNumVertices() * mesh.getVertexSize() / 4;
			int vertexFloats = (mesh.getVertexSize() / 4);
			VertexAttribute posAttr = mesh.getVertexAttributes().findByUsage(VertexAttributes.Usage.Position);
			VertexAttribute norAttr = mesh.getVertexAttributes().findByUsage(VertexAttributes.Usage.Normal);
			if (posAttr == null || norAttr == null) {
				throw new IllegalArgumentException("Position/normal vertex attribute not found");
			}
			int pOff = posAttr.offset / 4;
			int nOff = norAttr.offset / 4;

			for (int i = 0; i < lastFloat; i += vertexFloats) {
				pos.x = buf.get(pOff + i);
				pos.y = buf.get(pOff + i + 1);
				pos.z = buf.get(pOff + i + 2);

				nor.x = buf.get(nOff + i);
				nor.y = buf.get(nOff + i + 1);
				nor.z = buf.get(nOff + i + 2);

				nor.nor().scl(amount);

				buf.put(pOff + i, pos.x + nor.x);
				buf.put(pOff + i + 1, pos.y + nor.y);
				buf.put(pOff + i + 2, pos.z + nor.z);
			}
		}
	}
}
 
开发者ID:jsjolund,项目名称:GdxDemo3D,代码行数:42,代码来源:ModelFactory.java

示例12: areAllPartsValid

import com.badlogic.gdx.graphics.g3d.model.NodePart; //导入依赖的package包/类
/**
 * Returns true if all parts of the assigned node can be used to create collision shapes
 * @param node The node to check.
 * @return True if the node is valid.
 */
private boolean areAllPartsValid(Node node) {
	if (node == null) {
		return false;
	}
	for (NodePart nodePart : node.parts) {
		boolean usesTriangles = (nodePart.meshPart.primitiveType == GL20.GL_TRIANGLES);
		if ((nodePart.meshPart.size <= 0) || !usesTriangles) {
			return false;
		}
	}
	return true;
}
 
开发者ID:aphex-,项目名称:Alien-Ark,代码行数:18,代码来源:PlanetPart.java

示例13: rebuildReferences

import com.badlogic.gdx.graphics.g3d.model.NodePart; //导入依赖的package包/类
private static void rebuildReferences (final Model model, final Node node) {
	for (final NodePart mpm : node.parts) {
		if (!model.materials.contains(mpm.material, true)) model.materials.add(mpm.material);
		if (!model.meshParts.contains(mpm.meshPart, true)) {
			model.meshParts.add(mpm.meshPart);
			if (!model.meshes.contains(mpm.meshPart.mesh, true)) model.meshes.add(mpm.meshPart.mesh);
			model.manageDisposable(mpm.meshPart.mesh);
		}
	}
	for (final Node child : node.getChildren())
		rebuildReferences(model, child);
}
 
开发者ID:basherone,项目名称:libgdxcn,代码行数:13,代码来源:ModelBuilder.java

示例14: loadNodes

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

示例15: setBones

import com.badlogic.gdx.graphics.g3d.model.NodePart; //导入依赖的package包/类
private void setBones () {
	for (ObjectMap.Entry<NodePart, ArrayMap<Node, Matrix4>> e : nodePartBones.entries()) {
		if (e.key.invBoneBindTransforms == null)
			e.key.invBoneBindTransforms = new ArrayMap<Node, Matrix4>(true, e.value.size, Node.class, Matrix4.class);
		e.key.invBoneBindTransforms.clear();

		for (final ObjectMap.Entry<Node, Matrix4> b : e.value.entries())
			e.key.invBoneBindTransforms.put(getNode(b.key.id), b.value); // Share the inv bind matrix with the model

		e.key.bones = new Matrix4[e.value.size];
		for (int i = 0; i < e.key.bones.length; i++)
			e.key.bones[i] = new Matrix4();
	}
}
 
开发者ID:basherone,项目名称:libgdxcn,代码行数:15,代码来源:ModelInstance.java


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