private void copyNodes (Array<Node> nodes, final Array<String> nodeIds) { for (int i = 0, n = nodes.size; i < n; ++i) { final Node node = nodes.get(i); for (final String nodeId : nodeIds) { if (nodeId.equals(node.id)) { this.nodes.add(node.copy()); break; } } } invalidate(); }
private void copyNodes (Array<Node> nodes, final String... nodeIds) { for (int i = 0, n = nodes.size; i < n; ++i) { final Node node = nodes.get(i); for (final String nodeId : nodeIds) { if (nodeId.equals(node.id)) { this.nodes.add(node.copy()); break; } } } invalidate(); }
private void copyNodes (Array<Node> nodes, final String... nodeIds) { for (int i = 0, n = nodes.size; i < n; ++i) { final Node node = nodes.get(i); for (final String nodeId : nodeIds) { if (nodeId.equals(node.id)) { this.nodes.add(node.copy()); break; } } } invalidate(); }
private void copyNodes (Array<Node> nodes, final Array<String> nodeIds) { for (int i = 0, n = nodes.size; i < n; ++i) { final Node node = nodes.get(i); for (final String nodeId : nodeIds) { if (nodeId.equals(node.id)) { this.nodes.add(node.copy()); break; } } } invalidate(); }
private void copyNodes (Array<Node> nodes) { for (int i = 0, n = nodes.size; i < n; ++i) { final Node node = nodes.get(i); this.nodes.add(node.copy()); } invalidate(); }
private void copyNodes (Array<Node> nodes) { for (int i = 0, n = nodes.size; i < n; ++i) { final Node node = nodes.get(i); this.nodes.add(node.copy()); } invalidate(); }
/** Creates a nested copy of this Node, any child nodes are copied using the {@link #copy()} method. This will detach this node * from its parent, but does not attach it to the parent of node being copied. The {@link #parts} are copied using the * {@link NodePart#copy()} method. Note that that method copies the material and nodes (bones) by reference. If you intend to * use this node in a different node tree (e.g. a different Model or ModelInstance) then you will need to update these * references afterwards. * * Override this method in your custom Node class to copy any additional fields you've added. * @return This Node for chaining */ protected Node set (Node other) { detach(); id = other.id; isAnimated = other.isAnimated; inheritTransform = other.inheritTransform; translation.set(other.translation); rotation.set(other.rotation); scale.set(other.scale); localTransform.set(other.localTransform); globalTransform.set(other.globalTransform); parts.clear(); for (NodePart nodePart : other.parts) { parts.add(nodePart.copy()); } children.clear(); for (Node child : other.getChildren()) { addChild(child.copy()); } return this; }
/** @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; Node copy, node = model.getNode(nodeId, recursive); this.nodes.add(copy = node.copy()); 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); invalidate(); copyAnimations(model.animations, shareKeyframes); calculateTransforms(); }
/** @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; Node copy, node = model.getNode(nodeId, recursive); this.nodes.add(copy = node.copy()); 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); invalidate(); copyAnimations(model.animations, shareKeyframes); calculateTransforms(); }
/** Creates a nested copy of this Node, any child nodes are copied using the {@link #copy()} method. This will detach this node * from its parent, but does not attach it to the parent of node being copied. The {@link #parts} are copied using the * {@link NodePart#copy()} method. Note that that method copies the material and nodes (bones) by reference. If you intend to * use this node in a different node tree (e.g. a different Model or ModelInstance) then you will need to update these * references afterwards. * * Override this method in your custom Node class to copy any additional fields you've added. * @return This Node for chaining */ protected Node set (Node other) { detach(); id = other.id; isAnimated = other.isAnimated; inheritTransform = other.inheritTransform; translation.set(other.translation); rotation.set(other.rotation); scale.set(other.scale); localTransform.set(other.localTransform); globalTransform.set(other.globalTransform); parts.clear(); for (NodePart nodePart : other.parts) { parts.add(nodePart.copy()); } children.clear(); for (Node child : other.getChildren()) { addChild(child.copy()); } return this; }
Gdx.app.log("Test", anim.id); ship = assets.get("data/g3d/ship.obj", Model.class).nodes.get(0).copy(); ship.detach(); ship.translation.x = 10f; // offset from the sword node to the tip of the sword, in rest pose
private void copyNodes (Array<Node> nodes, final String... nodeIds) { for (int i = 0, n = nodes.size; i < n; ++i) { final Node node = nodes.get(i); for (final String nodeId : nodeIds) { if (nodeId.equals(node.id)) { this.nodes.add(node.copy()); break; } } } invalidate(); }
private void copyNodes (Array<Node> nodes, final Array<String> nodeIds) { for (int i = 0, n = nodes.size; i < n; ++i) { final Node node = nodes.get(i); for (final String nodeId : nodeIds) { if (nodeId.equals(node.id)) { this.nodes.add(node.copy()); break; } } } invalidate(); }
private void copyNodes (Array<Node> nodes) { for (int i = 0, n = nodes.size; i < n; ++i) { final Node node = nodes.get(i); this.nodes.add(node.copy()); } invalidate(); }
/** @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; Node copy, node = model.getNode(nodeId, recursive); this.nodes.add(copy = node.copy()); 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); invalidate(); copyAnimations(model.animations, shareKeyframes); calculateTransforms(); }
/** Creates a nested copy of this Node, any child nodes are copied using the {@link #copy()} method. This will detach this node * from its parent, but does not attach it to the parent of node being copied. The {@link #parts} are copied using the * {@link NodePart#copy()} method. Note that that method copies the material and nodes (bones) by reference. If you intend to * use this node in a different node tree (e.g. a different Model or ModelInstance) then you will need to update these * references afterwards. * * Override this method in your custom Node class to copy any additional fields you've added. * @return This Node for chaining */ protected Node set (Node other) { detach(); id = other.id; isAnimated = other.isAnimated; inheritTransform = other.inheritTransform; translation.set(other.translation); rotation.set(other.rotation); scale.set(other.scale); localTransform.set(other.localTransform); globalTransform.set(other.globalTransform); parts.clear(); for (NodePart nodePart : other.parts) { parts.add(nodePart.copy()); } children.clear(); for (Node child : other.getChildren()) { addChild(child.copy()); } return this; }