Java Code Examples for com.badlogic.gdx.graphics.g3d.model.Node#hasChildren()

The following examples show how to use com.badlogic.gdx.graphics.g3d.model.Node#hasChildren() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ArmatureDebugDrawer.java    From GdxDemo3D with Apache License 2.0 6 votes vote down vote up
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);
		}
	}
}
 
Example 2
Source File: GameCharacter.java    From GdxDemo3D with Apache License 2.0 5 votes vote down vote up
/**
 * 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();
}
 
Example 3
Source File: GameCharacter.java    From GdxDemo3D with Apache License 2.0 5 votes vote down vote up
/**
 * 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);
}