part.parts.add(node.parts.get(i).meshPart); if (node.hasChildren()) { final boolean transformed = applyTransform && !Arrays.equals(transform.val, idt.val); final int o = transformed ? out.size : offset;
part.parts.add(node.parts.get(i).meshPart); if (node.hasChildren()) { final boolean transformed = applyTransform && !Arrays.equals(transform.val, idt.val); final int o = transformed ? out.size : offset;
part.parts.add(node.parts.get(i).meshPart); if (node.hasChildren()) { final boolean transformed = applyTransform && !Arrays.equals(transform.val, idt.val); final int o = transformed ? out.size : offset;
/** * Direction vector of an armature bone, in world coordinate system. * * @param nodeId Name of the bone * @param out Output vector * @return Output vector for chaining */ public Vector3 getBoneDirection(String nodeId, Vector3 out) { Node node = modelInstance.getNode(nodeId); Node endPointNode = (node.hasChildren()) ? node.getChild(0) : node; node.globalTransform.getTranslation(TMP_V1); endPointNode.globalTransform.getTranslation(TMP_V2); TMP_V1.sub(TMP_V2).scl(-1); modelInstance.transform.getRotation(TMP_Q); TMP_Q.transform(TMP_V1); return out.set(TMP_V1).nor(); }
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); } } }
/** * Midpoint of an armature bone, in world coordinate system. * * @param nodeId Name of the bone * @param out Output vector * @return Output vector for chaining */ public Vector3 getBoneMidpointWorldPosition(String nodeId, Vector3 out) { Node node = modelInstance.getNode(nodeId); Node endPointNode = (node.hasChildren()) ? node.getChild(0) : node; // Use global transform to account for model scaling node.globalTransform.getTranslation(TMP_V1); TMP_V3.set(TMP_V1); endPointNode.globalTransform.getTranslation(TMP_V2); TMP_V3.sub(TMP_V1.sub(TMP_V2).scl(0.5f)); modelInstance.transform.getRotation(TMP_Q, true).transform(TMP_V3); TMP_V3.add(getPosition()); return out.set(TMP_V3); } }