protected override void destroy() { if (bone != null) { AnimationManipulatorController.removeAnimationManipulator(this); } }
protected override void constructed() { SimObject targetObject = Owner.getOtherSimObject(targetSimObject); if (targetObject == null) { blacklist("Could not find Target SimObject {0}.", targetSimObject); } SceneNodeElement node = targetObject.getElement(targetNode) as SceneNodeElement; if (node == null) { blacklist("Could not find target SceneNodeElement {0}.", targetNode); } Entity entity = node.getNodeObject(targetEntity) as Entity; if (entity == null) { blacklist("Could not find Entity {0}.", targetEntity); } mesh = entity.getMesh(); OgrePlugin.Animation anim; VertexAnimationTrack track; if (mesh.Value.hasAnimation(manualAnimationName)) { anim = mesh.Value.getAnimation(manualAnimationName); track = anim.getVertexTrack(1); manualKeyFrame = track.getKeyFrame(0) as VertexPoseKeyFrame; } else { blacklist("Could not find animation {0}.", manualAnimationName); } //Must look this up this way to get the correct pose index. int poseCount = mesh.Value.getPoseCount(); OgrePlugin.Pose pose = null; for (ushort i = 0; i < poseCount; ++i) { OgrePlugin.Pose innerPose = mesh.Value.getPose(i); if (innerPose.getName() == poseName) { pose = innerPose; poseIndex = i; break; } } if (pose == null) { blacklist("Cannot find pose {0}.", poseName); } manualKeyFrame.addPoseReference(poseIndex, 0.0f); manualAnimationState = entity.getAnimationState(manualAnimationName); manualAnimationState.setLength(0.0f); manualAnimationState.setTimePosition(0.0f); manualAnimationState.setEnabled(true); AnimationManipulatorController.addAnimationManipulator(this); }
protected override void destroy() { if (mesh != null) { mesh.Dispose(); } AnimationManipulatorController.removeAnimationManipulator(this); }
public void blend(AnimationManipulatorStateEntry target, float percent) { BoneScalarStateEntry rotateTarget = target as BoneScalarStateEntry; BoneScalar bone = AnimationManipulatorController.getManipulator(name) as BoneScalar; if (bone != null) { bone.Scale = scale.lerp(ref rotateTarget.scale, ref percent); } }
public void blend(AnimationManipulatorStateEntry target, float percent) { PoseManipulatorStateEntry poseTarget = target as PoseManipulatorStateEntry; float start = position; float end = poseTarget.position; float delta = end - start; PoseManipulator bone = AnimationManipulatorController.getManipulator(name) as PoseManipulator; if (bone != null) { bone.Position = start + delta * percent; } }
protected override void constructed() { SimObject targetObject = Owner.getOtherSimObject(targetSimObject); if (targetObject != null) { SceneNodeElement node = targetObject.getElement(targetNode) as SceneNodeElement; if (node != null) { Entity entity = node.getNodeObject(targetEntity) as Entity; if (entity != null) { if (entity.hasSkeleton()) { skeleton = entity.getSkeleton(); if (skeleton.hasBone(targetBone)) { bone = skeleton.getBone(targetBone); bone.setManuallyControlled(true); AnimationManipulatorController.addAnimationManipulator(this); } else { blacklist("Entity {0} does not have a bone named {1}.", targetEntity, targetBone); } } else { blacklist("Entity {0} does not have a skeleton.", targetEntity); } } else { blacklist("Could not find Entity {0}.", targetEntity); } } else { blacklist("Could not find target SceneNodeElement {0}.", targetNode); } } else { blacklist("Could not find Target SimObject {0}.", targetSimObject); } }
public void blend(AnimationManipulatorStateEntry target, float percent) { BoneRotatorStateEntry rotateTarget = target as BoneRotatorStateEntry; Quaternion blendRot = rotation.slerp(ref rotateTarget.rotation, percent); BoneRotator bone = AnimationManipulatorController.getManipulator(name) as BoneRotator; if (bone != null) { if (blendRot.isNumber()) { bone.Rotation = blendRot; } else { bone.Rotation = rotateTarget.rotation; } } }
/// <summary> /// Get the AnimationManipultor attached to this Mandible with the given /// name. Will return null if the manipulator does not exist. /// </summary> /// <param name="name">The name of the manipultor.</param> /// <returns>The attached AnimationManipulator or null if it does not exist.</returns> public AnimationManipulator getAnimationManipulator(String name) { return(AnimationManipulatorController.getManipulator(name)); //return Owner.getElement(name) as AnimationManipulator; }