本文整理汇总了Java中com.badlogic.gdx.graphics.g3d.model.Node类的典型用法代码示例。如果您正苦于以下问题:Java Node类的具体用法?Java Node怎么用?Java Node使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Node类属于com.badlogic.gdx.graphics.g3d.model包,在下文中一共展示了Node类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: init
import com.badlogic.gdx.graphics.g3d.model.Node; //导入依赖的package包/类
private void init() {
float centerX = 0f;
float centerY = ((((float) words.length) * FONT_HEIGHT) - FONT_HEIGHT) / 2f;
nodes.clear();
nodesPosition = new Array<Vector3>();
if(words != null && words.length > 0){
for(int y = 0; y < words.length; y++){
String[] word = translateSpecialCharacters(words[y]);
centerX = (((float) word.length) * FONT_WIDTH) / 2f;
for(int x = 0; x < word.length; x++){
String letter = String.valueOf(word[x]);
Node node = model.getNode(letter);
if(node != null){
Vector3 position = new Vector3((FONT_WIDTH*x) - centerX,(-FONT_HEIGHT*y) + centerY,0);
node = node.copy();
node.globalTransform.setTranslation(position);
nodes.add(node);
nodesPosition.add(position.cpy());
}
}
}
}
}
示例2: NodeComponent
import com.badlogic.gdx.graphics.g3d.model.Node; //导入依赖的package包/类
public NodeComponent() {
node = new Node();
tempVec = new Vector3();
tempVec2 = new Vector3();
tempQuat = new Quaternion();
translation = new Vector3();
rotation = new Vector3();
scale = new Vector3(1, 1, 1);
localTranslation = new Vector3();
localRotation = new Vector3();
localScale = new Vector3(1, 1, 1);
translationDelta = new Vector3();
rotationDelta = new Vector3();
scaleDelta = new Vector3();
localRotationQuaternion = new Quaternion();
rotationQuaternion = new Quaternion();
}
示例3: updateBodiesToArmature
import com.badlogic.gdx.graphics.g3d.model.Node; //导入依赖的package包/类
/**
* Updates the rigid body parts to follow nodes of the model instance
*/
private void updateBodiesToArmature() {
// Ragdoll parts should follow the model animation.
// Loop over each part and set it to the global transform of the armature node it should follow.
capsuleTransform.set(modelTransform);
for (Iterator<ObjectMap.Entry<btRigidBody, RigidBodyNodeConnection>> iterator
= bodyPartMap.iterator(); iterator.hasNext(); ) {
ObjectMap.Entry<btRigidBody, RigidBodyNodeConnection> entry = iterator.next();
RigidBodyNodeConnection data = entry.value;
btRigidBody body = entry.key;
Node followNode = data.followNode;
Vector3 offset = data.bodyNodeOffsets.get(followNode);
body.proceedToTransform(tmpMatrix.set(capsuleTransform)
.mul(followNode.globalTransform).translate(offset));
}
}
示例4: addPart
import com.badlogic.gdx.graphics.g3d.model.Node; //导入依赖的package包/类
/**
* @param bodyPart The rigid body which is to be synchronized with a node
* @param node The node which is to be synchronized with a body
*/
private void addPart(btRigidBody bodyPart, Node node) {
if (!bodyPartMap.containsKey(bodyPart)) {
bodyPartMap.put(bodyPart, new RigidBodyNodeConnection());
}
RigidBodyNodeConnection conn = bodyPartMap.get(bodyPart);
conn.followNode = node;
// Set the follow offset to the middle of the armature bone
Vector3 offsetTranslation = new Vector3();
node.getChild(0).localTransform.getTranslation(offsetTranslation).scl(0.5f);
conn.bodyNodeOffsets.put(node, offsetTranslation);
if (!ragdollMappedNodes.contains(node, true)) {
ragdollMappedNodes.add(node);
}
}
示例5: setNavmesh
import com.badlogic.gdx.graphics.g3d.model.Node; //导入依赖的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();
}
示例6: drawArmatureNodes
import com.badlogic.gdx.graphics.g3d.model.Node; //导入依赖的package包/类
private void drawArmatureNodes(Node currentNode, Vector3 modelPos,
Quaternion modelRot,
Vector3 parentNodePos, Vector3 currentNodePos) {
currentNode.globalTransform.getTranslation(currentNodePos);
modelRot.transform(currentNodePos);
currentNodePos.add(modelPos);
drawVertex(currentNodePos, 0.02f, Color.GREEN);
shapeRenderer.setColor(Color.YELLOW);
if (currentNode.hasParent()) {
shapeRenderer.line(parentNodePos, currentNodePos);
}
if (currentNode.hasChildren()) {
float x = currentNodePos.x;
float y = currentNodePos.y;
float z = currentNodePos.z;
for (Node child : currentNode.getChildren()) {
drawArmatureNodes(child, modelPos, modelRot, currentNodePos, parentNodePos);
currentNodePos.set(x, y, z);
}
}
}
示例7: createFromMesh
import com.badlogic.gdx.graphics.g3d.model.Node; //导入依赖的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;
}
示例8: createXYZCoordinates
import com.badlogic.gdx.graphics.g3d.model.Node; //导入依赖的package包/类
/** Convenience method to create a model with three orthonormal vectors shapes. The resources the Material might contain are not
* managed, use {@link Model#manageDisposable(Disposable)} to add those to the model.
* @param axisLength Length of each axis.
* @param capLength is the height of the cap in percentage, must be in (0,1)
* @param stemThickness is the percentage of stem diameter compared to cap diameter, must be in (0,1]
* @param divisions the amount of vertices used to generate the cap and stem ellipsoidal bases */
public Model createXYZCoordinates (float axisLength, float capLength, float stemThickness, int divisions, int primitiveType,
Material material, long attributes) {
begin();
MeshPartBuilder partBuilder;
Node node = node();
partBuilder = part("xyz", primitiveType, attributes, material);
partBuilder.setColor(Color.RED);
partBuilder.arrow(0, 0, 0, axisLength, 0, 0, capLength, stemThickness, divisions);
partBuilder.setColor(Color.GREEN);
partBuilder.arrow(0, 0, 0, 0, axisLength, 0, capLength, stemThickness, divisions);
partBuilder.setColor(Color.BLUE);
partBuilder.arrow(0, 0, 0, 0, 0, axisLength, capLength, stemThickness, divisions);
return end();
}
示例9: loadAnimations
import com.badlogic.gdx.graphics.g3d.model.Node; //导入依赖的package包/类
private void loadAnimations (Iterable<ModelAnimation> modelAnimations) {
for (final ModelAnimation anim : modelAnimations) {
Animation animation = new Animation();
animation.id = anim.id;
for (ModelNodeAnimation nanim : anim.nodeAnimations) {
final Node node = getNode(nanim.nodeId);
if (node == null) continue;
NodeAnimation nodeAnim = new NodeAnimation();
nodeAnim.node = node;
for (ModelNodeKeyframe kf : nanim.keyframes) {
if (kf.keytime > animation.duration) animation.duration = kf.keytime;
NodeKeyframe keyframe = new NodeKeyframe();
keyframe.keytime = kf.keytime;
keyframe.rotation.set(kf.rotation == null ? node.rotation : kf.rotation);
keyframe.scale.set(kf.scale == null ? node.scale : kf.scale);
keyframe.translation.set(kf.translation == null ? node.translation : kf.translation);
nodeAnim.keyframes.add(keyframe);
}
if (nodeAnim.keyframes.size > 0) animation.nodeAnimations.add(nodeAnim);
}
if (animation.nodeAnimations.size > 0) animations.add(animation);
}
}
示例10: ModelInstance
import com.badlogic.gdx.graphics.g3d.model.Node; //导入依赖的package包/类
/** @param model The source {@link Model}
* @param transform The {@link Matrix4} instance for this ModelInstance to reference or null to create a new matrix.
* @param nodeId The ID of the {@link Node} within the {@link Model} for the instance to contain
* @param recursive True to recursively search the Model's node tree, false to only search for a root node
* @param parentTransform True to apply the parent's node transform to the instance (only applicable if recursive is true).
* @param mergeTransform True to apply the source node transform to the instance transform, resetting the node transform. */
public ModelInstance (final Model model, final Matrix4 transform, final String nodeId, boolean recursive,
boolean parentTransform, boolean mergeTransform, boolean shareKeyframes) {
this.model = model;
this.transform = transform == null ? new Matrix4() : transform;
nodePartBones.clear();
Node copy, node = model.getNode(nodeId, recursive);
this.nodes.add(copy = copyNode(node));
if (mergeTransform) {
this.transform.mul(parentTransform ? node.globalTransform : node.localTransform);
copy.translation.set(0, 0, 0);
copy.rotation.idt();
copy.scale.set(1, 1, 1);
} else if (parentTransform && copy.hasParent()) this.transform.mul(node.getParent().globalTransform);
setBones();
copyAnimations(model.animations, shareKeyframes);
calculateTransforms();
}
示例11: copyNode
import com.badlogic.gdx.graphics.g3d.model.Node; //导入依赖的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;
}
示例12: createFromMesh
import com.badlogic.gdx.graphics.g3d.model.Node; //导入依赖的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;
}
示例13: createPlayerModel
import com.badlogic.gdx.graphics.g3d.model.Node; //导入依赖的package包/类
/** players are represented by cubes, with another cube marking the direction it is facing */
public void createPlayerModel() {
ModelBuilder mb = new ModelBuilder();
ModelBuilder mb2 = new ModelBuilder();
long attr = Usage.Position | Usage.Normal;
float r = 0.5f;
float g = 1f;
float b = 0.75f;
Material material = new Material(ColorAttribute.createDiffuse(new Color(r, g, b, 1f)));
Material faceMaterial = new Material(ColorAttribute.createDiffuse(Color.BLUE));
float w = 1f;
float d = w;
float h = 2f;
mb.begin();
//playerModel = mb.createBox(w, h, d, material, attr);
Node node = mb.node("box", mb2.createBox(w, h, d, material, attr));
// the face is just a box to show which direction the player is facing
Node faceNode = mb.node("face", mb2.createBox(w/2, h/2, d/2, faceMaterial, attr));
faceNode.translation.set(0f, 0f, d/2);
playerModel = mb.end();
}
示例14: buildStatics
import com.badlogic.gdx.graphics.g3d.model.Node; //导入依赖的package包/类
/** client builds statics, probably based on info from server */
public static void buildStatics(LevelStatic[] statics) {
if (staticGeometry == null) {
staticGeometry = new Array<>();
}
Log.debug("client building statics received from server: " + statics.length);
ModelBuilder mb = new ModelBuilder();
mb.begin();
for (LevelStatic stat : statics) {
Model model = Assets.manager.get(stat.modelName, Model.class);
setupStaticModel(model.meshParts, stat.mtx, true);
Node node = mb.node("piece", model);
stat.mtx.getTranslation(tmp);
node.translation.set(tmp);
node.rotation.set(stat.mtx.getRotation(q));
}
Model finalModel = mb.end();
ModelInstance instance = new ModelInstance(finalModel);
staticGeometry.add(instance);
}
示例15: SharedModel
import com.badlogic.gdx.graphics.g3d.model.Node; //导入依赖的package包/类
/** @param model The source {@link Model}
* @param transform The {@link Matrix4} instance for this ModelInstance to reference or null to create a new matrix.
* @param nodeId The ID of the {@link Node} within the {@link Model} for the instance to contain
* @param recursive True to recursively search the Model's node tree, false to only search for a root node
* @param parentTransform True to apply the parent's node transform to the instance (only applicable if recursive is true).
* @param mergeTransform True to apply the source node transform to the instance transform, resetting the node transform. */
public SharedModel(final Model model, final Matrix4 transform, final String nodeId, boolean recursive, boolean parentTransform, boolean mergeTransform) {
this.model = model;
this.transform = transform == null ? new Matrix4() : transform;
nodePartBones.clear();
Node copy, node = model.getNode(nodeId, recursive);
this.nodes.add(copy = copyNode(null, node));
if (mergeTransform) {
this.transform.mul(parentTransform ? node.globalTransform : node.localTransform);
copy.translation.set(0,0,0);
copy.rotation.idt();
copy.scale.set(1,1,1);
} else if (parentTransform && copy.parent != null)
this.transform.mul(node.parent.globalTransform);
setBones();
copyAnimations(model.animations);
calculateTransforms();
}