void nodeWorkings() { //navigate back to the root of tree /* * var style = new GUIStyle(GUI.skin.button); * style.normal.textColor = Color.blue; * GUILayout.Button("Label", style); */ //button color var style = new GUIStyle(GUI.skin.button); style.normal.textColor = Color.blue; if (currentNode != 0 && GUILayout.Button("Go to root", style)) { currentNode = 0; currentNodeType = currentTree.getRoot().nodeType; } GUILayout.Label("CurrentIndex: " + currentNode, EditorStyles.boldLabel); //navigate to connections if (currentNode != 0) { BlendNode prevNode = currentTree.getIndexedNode(currentTree.getIndexedNode(currentNode).prevIndex); if (prevNode != null) { if (GUILayout.Button("Previous Node")) { currentNode = prevNode.currentIndex; currentNodeType = prevNode.nodeType; } } } else if (currentNode == 0) { GUILayout.Label("IS ROOT", EditorStyles.boldLabel); } BlendNode nextNode1 = currentTree.getIndexedNode(currentTree.getIndexedNode(currentNode).nextID1); if (nextNode1 != null) { if (GUILayout.Button("Next Node branch 1")) { currentNode = nextNode1.currentIndex; currentNodeType = nextNode1.nodeType; } } BlendNode nextNode2 = currentTree.getIndexedNode(currentTree.getIndexedNode(currentNode).nextID2); if (nextNode2 != null) { if (GUILayout.Button("Next Node branch 2")) { currentNode = nextNode2.currentIndex; currentNodeType = nextNode1.nodeType; } } GUILayout.Label("Current: " + currentTree.getIndexedNode(currentNode).nodeType, EditorStyles.miniLabel); changeType = EditorGUILayout.Toggle("change node type", changeType); blendType newType = blendType.BLEND_INVALID; newType = (blendType)EditorGUILayout.EnumPopup("Type: ", newType); if (changeType) { //change type BlendNode newNode = null; GUILayout.Label("Generate new Node", EditorStyles.miniLabel); if (GUILayout.Button("New Lerp")) { newNode = new BlendNode(blendType.BLEND_LERP); } if (GUILayout.Button("New Scale")) { newNode = new BlendNode(blendType.BLEND_SCALE); } if (GUILayout.Button("New Average")) { newNode = new BlendNode(blendType.BLEND_AVG); } if (GUILayout.Button("New Add")) { newNode = new BlendNode(blendType.BLEND_ADD); } if (GUILayout.Button("New End")) { newNode = new BlendNode(blendType.BLEND_END); } if (newNode != null) { if (0 == currentNode) { currentTree.SetRoot(newNode); currentNode = 0; } else { int index = currentNode; currentTree.setIndexedNode(index, newNode); } changeType = false; } } else { GUILayout.Label("Node Data", EditorStyles.boldLabel); //do node switch (currentTree.getIndexedNode(currentNode).nodeType) { case blendType.BLEND_INVALID: GUILayout.Label("This Node is invalid, please change to a valid type", EditorStyles.miniLabel); break; case blendType.BLEND_LERP: BlendNode lerpNode = currentTree.getIndexedNode(currentNode); lerpNode.parameter1 = EditorGUILayout.Slider("Lerp Parameter", lerpNode.parameter1, 0, 1); lerpNode = checkBranchOne(lerpNode); GUILayout.Label("[======================]", EditorStyles.miniLabel); lerpNode = checkBranchTwo(lerpNode); break; case blendType.BLEND_ADD: BlendNode addNode = currentTree.getIndexedNode(currentNode); addNode = checkBranchOne(addNode); GUILayout.Label("[======================]", EditorStyles.miniLabel); addNode = checkBranchTwo(addNode); break; case blendType.BLEND_SCALE: BlendNode scaleNode = currentTree.getIndexedNode(currentNode); scaleNode.parameter1 = EditorGUILayout.Slider("Scale Parameter", scaleNode.parameter1, 0, 1); scaleNode = checkBranchOne(scaleNode); break; case blendType.BLEND_AVG: BlendNode avgNode = currentTree.getIndexedNode(currentNode); avgNode.parameter1 = EditorGUILayout.Slider("Average Parameter One", avgNode.parameter1, 0, 1); avgNode = checkBranchOne(avgNode); GUILayout.Label("[======================]", EditorStyles.miniLabel); avgNode.parameter2 = EditorGUILayout.Slider("Average Parameter Two", avgNode.parameter2, 0, 1); avgNode = checkBranchTwo(avgNode); break; case blendType.BLEND_END: BlendNode endNode = currentTree.getIndexedNode(currentNode); endNode.clip = EditorGUILayout.ObjectField("AnimationClip", endNode.clip, typeof(AnimationClip), true) as AnimationClip; break; default: break; } //delete node option } //based on type, show parameters //show next nodes-also id, if empty create new node and add index //show next nodes-also id, if empty create new ndoe and add index //note: when creating new node, it is the default end node }
public virtual blendPoseData blendOperation(BlendingTree parentTree, int currentFrameID) { blendPoseData firstPose = new blendPoseData(); blendPoseData secondPose = new blendPoseData(); int length = 0; switch (nodeType) { case blendType.BLEND_LERP: firstPose = parentTree.getIndexedNode(nextID1).blendOperation(parentTree, currentFrameID); secondPose = parentTree.getIndexedNode(nextID2).blendOperation(parentTree, currentFrameID); length = firstPose.size; for (int i = 0; i < length; i++) { animationTransformData transformData; transformData = blendStatic.lerp(firstPose.getPoseData(i), secondPose.getPoseData(i), parameter1, true); firstPose.setPoseData(transformData, i); } return(firstPose); case blendType.BLEND_ADD: firstPose = parentTree.getIndexedNode(nextID1).blendOperation(parentTree, currentFrameID); secondPose = parentTree.getIndexedNode(nextID2).blendOperation(parentTree, currentFrameID); length = firstPose.size; for (int i = 0; i < length; i++) { animationTransformData transformData; transformData = blendStatic.add(firstPose.getPoseData(i), secondPose.getPoseData(i), true); firstPose.setPoseData(transformData, i); } return(firstPose); case blendType.BLEND_SCALE: firstPose = parentTree.getIndexedNode(nextID1).blendOperation(parentTree, currentFrameID); length = firstPose.size; for (int i = 0; i < length; i++) { animationTransformData transformData = firstPose.getPoseData(i); identity newIdentity = new identity(); transformData = blendStatic.scale(newIdentity, transformData, parameter1, true); firstPose.setPoseData(transformData, i); } return(firstPose); case blendType.BLEND_AVG: firstPose = parentTree.getIndexedNode(nextID1).blendOperation(parentTree, currentFrameID); secondPose = parentTree.getIndexedNode(nextID2).blendOperation(parentTree, currentFrameID); length = firstPose.size; for (int i = 0; i < length; i++) { animationTransformData transformData; identity nIdentity = new identity(); transformData = blendStatic.average(nIdentity, firstPose.getPoseData(i), secondPose.getPoseData(i), parameter1, parameter2, true); firstPose.setPoseData(transformData, i); } return(firstPose); case blendType.BLEND_END: blendPoseData newPoseData = new blendPoseData(); newPoseData.setData(clip, currentFrameID); return(newPoseData); default: return(firstPose); } }