public WadAnimation GetSavedAnimation(AnimationNode animation) { var wadAnim = animation.WadAnimation.Clone(); var directxAnim = animation.DirectXAnimation; // I need only to convert DX keyframes to Wad2 keyframes wadAnim.KeyFrames.Clear(); foreach (var directxKeyframe in directxAnim.KeyFrames) { var keyframe = new WadKeyFrame(); // Create the new bounding box keyframe.BoundingBox = new TombLib.BoundingBox(directxKeyframe.BoundingBox.Minimum, directxKeyframe.BoundingBox.Maximum); // For now we take the first translation as offset keyframe.Offset = new System.Numerics.Vector3(directxKeyframe.Translations[0].X, directxKeyframe.Translations[0].Y, directxKeyframe.Translations[0].Z); // Convert angles from radians to degrees and save them foreach (var rot in directxKeyframe.Rotations) { var angle = new WadKeyFrameRotation(); angle.Rotations = new System.Numerics.Vector3(rot.X * 180.0f / (float)Math.PI, rot.Y * 180.0f / (float)Math.PI, rot.Z * 180.0f / (float)Math.PI); keyframe.Angles.Add(angle); } wadAnim.KeyFrames.Add(keyframe); } return(wadAnim); }
public void AddAnimation(AnimationNode d) { if (!animationLookup.ContainsKey(d)) { //Debug.Log(d + " : " + d.name + " : " + d.Clip); if (animation[d.name] != null) { Debug.LogError("Cannot attach clip twice" + d.name); return; } if (d.Clip == null) { Debug.LogError("Clip is null in object: " + d.name); return; } animation.AddClip(d.Clip, d.name); AnimationState s = animation[d.name]; if (s != null) { AnimationStateData data = new AnimationStateData(s, d); stateData.Add(data); animationLookup.Add(d, data); } } }
//Plays the animation from the beginning, resetting speed values to normal public void PlayAnimation(AnimationNode d) { if (d != null) { if (!animationLookup.ContainsKey(d)) { AddAnimation(d); } AnimationStateData sData = animationLookup[d]; sData.State.speed = sData.DefaultSpeed; StopAnimationsByLayer(sData.State.layer); //Stop everything on this layer sData.targetWeight = 1; //set target weight to 1 sData.State.time = 0.0f; //Set the time to 0 sData.State.weight = 1; //Put the clip to full weight sData.State.enabled = true; //turn the animation on } else { //Debug.LogWarning("AnimationNode is null, Equipment is probably misconfigured"); } }
IEnumerator WaitForDelayRestPosTime() { yield return(new WaitForSeconds(DelayRestPosTime)); isOnDelayRestPosTime = false; isOnDelayStartMove = false; if (MoveObject) { MoveObject.position = OrginalPosition; } if (StopEffectWhenResetPosition) { if (animationNode.Count > 0) { for (int j = 0; j < animationNode.Count; j++) { AnimationNode node = animationNode[j]; foreach (EffectNode n in node.effectList) { if (n) { n.StopEffect(); } } } } } }
static private string ProcessNext(Next type, int totalProbability, AnimationNode anim, NextNode[] nexts) { string returnString = ""; var edgeColor = sequenceColor; var typeMarker = "S"; if (type == Next.Border) { edgeColor = borderColor; typeMarker = "B"; } if (type == Next.Gravity) { edgeColor = gravityColor; typeMarker = "G"; } foreach (var next in nexts) { var relative = (double)next.Probability / totalProbability; edgeColor = type == Next.Sequence ? convertProbabilityToGray(relative) : edgeColor; var relative2Decimal = relative.ToString("00%"); var probability = relative2Decimal == "100%" ? "" : $"({next.Probability})"; var label = $"[ label=\"{relative2Decimal}{probability} {next.OnlyFlag} {typeMarker}\" color=\"{edgeColor}\" fontcolor=\"{edgeColor}\" penwidth=\"1\" ]"; returnString += $" anim_{anim.Id} -> anim_{next.Value} {label}\r\n"; } return(returnString); }
public void SetAnimation(AnimationNode value) { if (value is CHR0Node) { SelectedCHR0 = value as CHR0Node; } else if (value is SRT0Node) { SelectedSRT0 = value as SRT0Node; } else if (value is SHP0Node) { SelectedSHP0 = value as SHP0Node; } else if (value is PAT0Node) { SelectedPAT0 = value as PAT0Node; } else if (value is VIS0Node) { SelectedVIS0 = value as VIS0Node; } else if (value is SCN0Node) { SelectedSCN0 = value as SCN0Node; } else if (value is CLR0Node) { SelectedCLR0 = value as CLR0Node; } }
void OnEnable() { if (subtile != null) { Transform tra = transform; grid.widgets = new GameObject[divineNum]; float width = Screen.width / divineNum; for (int i = 0; i < divineNum; i++) { GameObject tile = GameObject.Instantiate(subtile) as GameObject; Transform tileTra = tile.transform; tileTra.parent = tra; tileTra.localPosition = Vector3.zero; // tileTra.localScale = Vector3.zero;//new Vector3( width , Screen.height , 1f ); AnimationNode anim = tile.GetComponent <AnimationNode>(); anim.amountX = width; anim.amountY = 1000f; //Screen.height; anim.amountZ = 1f; // tile.SetActive( false ); grid.widgets[i] = tile; } grid.Reposition(); tra.localPosition = new Vector3(-400f, 0f, -100f); } StartCoroutine("Playing"); }
public void AnimateImage(AnimationNode node) { int index = -1; if (node.isImage) { foreach (Image img in currentImages) { if (img.sprite.name == node.toAnimName) { index = currentImages.IndexOf(img); } } } else { foreach (GameObject gO in currentObjects) { if (gO.name == node.toAnimName) { index = currentObjects.IndexOf(gO); } } } if (index != -1) { StartCoroutine(StartAnimation(index, node, true)); } }
void moveactor(Hashtable param) { // Debug.Log( "OnMoveActor" ); string actorName = param["name"] as string; string position = param["position"] as string; #if true GameObject go = GameObject.Find(actorName); if (go == null) { // Debug.LogWarning( "Actor name :" + actorName + " Object not found." ); return; } #else GameObject go = null; if (m_ActorGOMap.ContainsKey(actorName)) { go = m_ActorGOMap[actorName]; if (go == null) { Debug.LogWarning("Actor name :" + actorName + " Object not found."); return; } } #endif Vector3 toPos = go.transform.localPosition; ActorPosition pos = ActorUtility.GetActorPosition(position); toPos.x = GetPositionX(pos); // Debug.Log( "to :" + pos + " , value:" + toPos.x ); AnimationNode.MoveTo(go, toPos, 1f); // TweenPosition.Begin( go , 1f , toPos ); // iTween.MoveTo( go , toPos , 1f ); }
private void Initialize(AnimationNode animation) { _animation = animation; //Make a copy of the Animation's commands. we dont want to edit the Commands directly _animCommands = new BindingList <WadAnimCommand>(animation.WadAnimation.AnimCommands.ToList()); gridViewCommands.DataSource = _animCommands; }
private void resizeToolStripMenuItem_Click(object sender, EventArgs e) { if (TargetModel == null) { return; } AnimationNode node = TargetAnimation; if (node is CHR0Node) { (node as CHR0Node).Resize(); } else if (node is SRT0Node) { (node as SRT0Node).Resize(); } else if (node is SHP0Node) { (node as SHP0Node).Resize(); } else if (node is PAT0Node) { (node as PAT0Node).Resize(); } else if (node is VIS0Node) { (node as VIS0Node).Resize(); } AnimChanged(TargetAnimType); }
public override void createUIDescription(CutScene cutScene, SerializedObject serializedObject) { AnimationNode node = this; GUILayout.Label("<<Animation>>"); node.animation = (Animation)EditorGUILayout.ObjectField("Animation: ", node.animation, typeof(Animation), true); }
public AnimationGraph(AnimationNode[] _nodes, int[] _indexes) { nodes = _nodes; description = "new_graph\0"; boneIndexes = new int[_indexes.Length]; _indexes.CopyTo(boneIndexes, 0); }
public DGAnimNode(AnimationNode an, StateNode state, bool play) : base(an, state) { this.mAnimNode = an; this.mActor = new RefToActor(state.Scene, an == null ? null : an.Actor); this.bPlay = play; }
static public void CreateAnimationNodeOfMenu( ) { Transform parentNodeTra = (Selection.activeGameObject != null) ? Selection.activeGameObject.transform : null; AnimationNode animNode = ViNoToolUtil.AddViNodeGameObject <AnimationNode>("Animation", parentNodeTra); EditorGUIUtility.PingObject(animNode.gameObject); }
public float SyncAnimations(AnimationNode from, AnimationNode to, float weight, float blendSpeed, float masterWeight = 1) { if (!animationLookup.ContainsKey(from)) { AddAnimation(from); } if (!animationLookup.ContainsKey(to)) { AddAnimation(to); } AnimationStateData sFrom = animationLookup[from]; AnimationStateData sTo = animationLookup[to]; float normalizedTime = sTo.State.normalizedTime; float syncDelta = sFrom.State.normalizedTime - sTo.State.normalizedTime; if (Mathf.Abs(syncDelta) > SYNC_TOLERANCE) { //Debug.Log("bah Sync - " + sTo.State.normalizedTime + " : " + sFrom.State.normalizedTime + " : " + Time.time); //We always advance time, never rewind... if (sFrom.State.normalizedTime > sTo.State.normalizedTime) { // Debug.Log("time back"); normalizedTime = sTo.State.normalizedTime = sFrom.State.normalizedTime; } else { // Debug.Log("time forward"); normalizedTime = sFrom.State.normalizedTime = sTo.State.normalizedTime; } // sTo.State.normalizedTime += Mathf.Clamp01(5*Time.deltaTime)*syncDelta; } sFrom.targetWeight = masterWeight * (1 - weight); sTo.targetWeight = masterWeight * (weight); float w1Norm = (1 - weight); float w2Norm = (weight); sFrom.blendSpeed = blendSpeed; sTo.blendSpeed = blendSpeed; float factor2 = sTo.NormalizedLength / (sFrom.NormalizedLength * (w1Norm) + sTo.NormalizedLength * w2Norm); float ratio = sFrom.NormalizedLength / sTo.NormalizedLength; sTo.State.speed = sTo.DefaultSpeed * factor2; sFrom.State.speed = sFrom.DefaultSpeed * factor2 * ratio; sFrom.State.enabled = true; sTo.State.enabled = true; return(normalizedTime); }
public void Read(FileReader reader) { reader.SetByteOrder(false); reader.ReadSignature(4, "csab"); uint FileSize = reader.ReadUInt32(); uint versionNum = reader.ReadUInt32(); if (versionNum == 5) { Version = GameVersion.MM3D; } else if (versionNum == 3) { Version = GameVersion.OOT3D; } else { Version = GameVersion.LM3DS; } uint padding = reader.ReadUInt32(); //Unsure if (Version >= GameVersion.MM3D) { uint unknown = reader.ReadUInt32(); //0x42200000 uint unknown2 = reader.ReadUInt32(); //0x42200000 uint unknown3 = reader.ReadUInt32(); //0x42200000 } uint numAnimations = reader.ReadUInt32(); //Unsure uint location = reader.ReadUInt32(); //Unsure uint unknown4 = reader.ReadUInt32(); //0x00 uint unknown5 = reader.ReadUInt32(); //0x00 uint unknown6 = reader.ReadUInt32(); //0x00 uint unknown7 = reader.ReadUInt32(); //0x00 uint unknown8 = reader.ReadUInt32(); //0x00 uint duration = reader.ReadUInt32(); uint nodeCount = reader.ReadUInt32(); uint boneCount = reader.ReadUInt32(); if (nodeCount != boneCount) { throw new Exception("Unexpected bone and node count!"); } ushort[] BoneIndexTable = reader.ReadUInt16s((int)boneCount); reader.Align(4); uint[] nodeOffsets = reader.ReadUInt32s((int)nodeCount); for (int i = 0; i < nodeCount; i++) { reader.SeekBegin(nodeOffsets[i] + 0x18); AnimationNode node = new AnimationNode(); node.Read(reader, Version); Nodes.Add(node); } }
static public AnimationNode GetAnimationNodeTempl(AnimationType tp, float duration) { string path = ViNoToolUtil.GetAssetDataPath() + "Templates/AnimationNode.prefab"; GameObject animObj = AssetDatabase.LoadAssetAtPath(path, typeof(GameObject)) as GameObject; AnimationNode animNode = animObj.GetComponent <AnimationNode>(); animNode.animationType = tp; animNode.animTarget = Selection.activeGameObject; animNode.duration = duration; return(animNode); }
public override void Visit(AnimationNode node) { for (int i = 0; i < node.Pose.BoneCount; i++) { node.Pose[i].GetMatrix(boneCache, i * 16); } this.shader.SetUniform("animated", 1f); GL.UniformMatrix4(this.shader.GetUniformLocation("Bones"), node.Pose.BoneCount, false, this.boneCache); node.VisitChildren(this); this.shader.SetUniform("animated", 0f); }
public bool RetrieveAnimation(AnimType focusType, AnimType type) { AnimationNode f = GetAnimation(focusType); if (f == null) { SetSelectedBRRESFile(type, null); return(false); } SetSelectedBRRESFile(type, RetrieveAnimation(f.Name, type)); return(GetAnimation(type) != null); }
static public void LoadViNodeTemplates( ) { if (animNode == null) { animNode = LoadViNodeTempl <AnimationNode>("AnimationNode"); } if (dialogNode == null) { dialogNode = LoadViNodeTempl <DialogPartNode>("DialogPartNode"); } }
//-------------------------------------------------------------------------------------------------------------------- // - Update Animations //-------------------------------------------------------------------------------------------------------------------- public static void Update(float elapsed) { if (!Frozen) { AnimationNode node = Front; while (node != null) { node.Payload.Update(elapsed); node = node.Next; } } }
public FormAnimCommandsEditor(AnimationEditor editor, AnimationNode animation) { InitializeComponent(); animCommandEditor.Initialize(editor); _editor = editor; Initialize(animation); _editor.Tool.EditorEventRaised += Tool_EditorEventRaised; // Set window property handlers Configuration.LoadWindowProperties(this, _editor.Tool.Configuration); FormClosing += new FormClosingEventHandler((s, e) => Configuration.SaveWindowProperties(this, _editor.Tool.Configuration)); }
public void AnimChanged(AnimType type) { if (type == TargetAnimType) { UpdateEditor(); UpdateKeyframePanel(); } AnimationNode node = GetAnimation(type); if (node == null) { pnlPlayback.numFrameIndex.Maximum = _maxFrame = 0; pnlPlayback.numTotalFrames.Minimum = 0; _updating = true; pnlPlayback.numTotalFrames.Value = 0; selectedAnimationToolStripMenuItem.Enabled = false; _updating = false; pnlPlayback.btnPlay.Enabled = pnlPlayback.numTotalFrames.Enabled = pnlPlayback.numFrameIndex.Enabled = false; pnlPlayback.btnLast.Enabled = false; pnlPlayback.btnFirst.Enabled = false; pnlPlayback.Enabled = false; EnableTransformEdit = true; SetFrame(0); } else { _maxFrame = node.FrameCount; _updating = true; pnlPlayback.btnPlay.Enabled = pnlPlayback.numFrameIndex.Enabled = pnlPlayback.numTotalFrames.Enabled = true; pnlPlayback.Enabled = true; pnlPlayback.numTotalFrames.Value = _maxFrame; selectedAnimationToolStripMenuItem.Enabled = true; _updating = false; pnlPlayback.numFrameIndex.Maximum = _maxFrame; SetFrame(1); EnableTransformEdit = !_playing; UpdateToolButtons(); } }
public float GetNormalizedTime(AnimationNode d) { if (d == null) { return(0); } if (!animationLookup.ContainsKey(d)) { AddAnimation(d); } AnimationStateData sData = animationLookup[d]; return(sData.State.normalizedTime); }
public override void Update() { //Ugly move code currentPos = Vector2.Clamp(currentPos, -Vector2.One, Vector2.One); transform.position += new Vector3(currentPos.x, 0, -currentPos.y) * Time.DeltaTime; //Weight update for (uint i = 0; i < nodes.Count; i++) { AnimationNode node = nodes[(int)i]; weight.setWeight(i, new WeightTripple(node.GetWeight(currentPos))); } }
private AnimationNode[] CreateAnimationNodes(Animation anim, float[][] keys) { AnimationNode[] animationNodes = new AnimationNode[doc.Nodes.Count]; for (int i = 0; i < animationNodes.Length; i++) { var animNode = CrateAnimationNode(doc.Nodes[i]); animationNodes[i] = animNode; if (animNode != null) { anim.Nodes.Add(animNode); animNode.CurveKeys = keys; } } return(animationNodes); }
public float Weight(AnimationNode d) { if (d != null) { if (!animationLookup.ContainsKey(d)) { AddAnimation(d); } AnimationStateData sData = animationLookup[d]; return(sData.State.weight); } //Debug.LogWarning("AnimationNode is null, Equipment is probably misconfigured"); return(0); }
public bool IsPlaying(AnimationNode d) { if (d != null) { if (!animationLookup.ContainsKey(d)) { AddAnimation(d); } AnimationStateData sData = animationLookup[d]; return(sData.State.enabled); } //Debug.LogWarning("AnimationNode is null, Equipment is probably misconfigured"); return(false); }
public void SetNormalizedTime(AnimationNode d, float normalizedTime) { if (d == null) { return; } if (!animationLookup.ContainsKey(d)) { AddAnimation(d); } AnimationStateData sData = animationLookup[d]; sData.State.normalizedTime = normalizedTime; sData.State.enabled = true; }
private void mergeToolStripMenuItem_Click(object sender, EventArgs e) { if (TargetModel == null) { return; } AnimationNode node = TargetAnimation; if (node is CHR0Node) { (node as CHR0Node).MergeWith(); } AnimChanged(TargetAnimType); }
private AnimationNode GetAnim(AnimationNode[] arr, string name) { foreach (AnimationNode n in arr) if (n.Name.Contains(name)) return n; return null; }
public void SetAnimation(AnimationNode value) { if (value is CHR0Node) SelectedCHR0 = value as CHR0Node; else if (value is SRT0Node) SelectedSRT0 = value as SRT0Node; else if (value is SHP0Node) SelectedSHP0 = value as SHP0Node; else if (value is PAT0Node) SelectedPAT0 = value as PAT0Node; else if (value is VIS0Node) SelectedVIS0 = value as VIS0Node; else if (value is SCN0Node) SelectedSCN0 = value as SCN0Node; else if (value is CLR0Node) SelectedCLR0 = value as CLR0Node; }
public static void DrawAnimationNodeInspector( AnimationNode node ) { #if false node.animationName = EditorGUILayout.TextField( "AnimationName" , node.animationName ); #endif node.playAtStart = EditorGUILayout.Toggle( "PlayAtStart" , node.playAtStart ); node.playLoop = EditorGUILayout.Toggle( "PlayLoop" , node.playLoop ); node.playAtRandom = EditorGUILayout.Toggle( "PlayAtRandom" , node.playAtRandom ); node.playOnEnable = EditorGUILayout.Toggle( "playOnEnable" , node.playOnEnable ); node.playPingPong = EditorGUILayout.Toggle( "playPingPong" , node.playPingPong ); if( node.playPingPong ){ node.playLoop = true; } EditorGUILayout.LabelField( "Target GameObject in Hierarchy." ); node.animTarget = (GameObject)EditorGUILayout.ObjectField( "target" , node.animTarget , typeof(GameObject) , true ); node.animationType = (AnimationType)EditorGUILayout.EnumPopup( "AnimationType" , node.animationType ); if( node.animTarget != null ){ node.isTargetInAsset = AssetDatabase.Contains( node.animTarget ); /* if( node.isTargetInAsset ){ Debug.Log( "target is in Project folder." ); } else{ Debug.Log( "target is in Scene." ); } //*/ } node.duration = EditorGUILayout.Slider( "duration( ms )" , node.duration , 1f , 10000f ); node.waitUntilAnimationFinish = EditorGUILayout.Toggle( "Wait next Until Finish" , node.waitUntilAnimationFinish ); if( node.waitUntilAnimationFinish ){ node.delaySecToNextMessage = node.duration; // = EditorGUILayout.FloatField( "delaySecToNext" , node.delaySecToNextMessage ); } else{ node.delaySecToNextMessage = 0f; } // node.wrapMode = (WrapMode)EditorGUILayout.EnumPopup( "WrapMode" , node.wrapMode ); if( node.animationType != AnimationType.CROSS_FADE && node.animationType != AnimationType.FADE_PANEL ){ node.method = EditorGUILayout.Popup( "Method" , node.method , AnimationNode.methods ); } if( node.animTarget != null ){ node.targetName = node.animTarget.name; } node.amountX = node.amount.x; node.amountY = node.amount.y; node.amountZ = node.amount.z; node.fromAmountX = node.fromAmount.x; node.fromAmountY = node.fromAmount.y; node.fromAmountZ = node.fromAmount.z; switch( node.animationType ){ case AnimationType.FADE_PANEL: node.fadeTo = EditorGUILayout.FloatField( "fadeTo" , node.fadeTo ); node.toggleFromAmount = EditorGUILayout.Toggle( "Fade From ?" , node.toggleFromAmount ); if( node.toggleFromAmount ){ node.fadeFrom = EditorGUILayout.FloatField( "fadeFrom" , node.fadeFrom ); } break; case AnimationType.MOVE_TO: node.amount = EditorGUILayout.Vector3Field( "amount" , node.amount ); if( GUILayout.Button( "Set" ) ){ if( node.animTarget != null ){ node.animTarget.transform.localPosition = node.amount; } } node.toggleFromAmount = EditorGUILayout.Toggle( "Start From?" , node.toggleFromAmount ); if( node.toggleFromAmount ){ node.fromAmount = EditorGUILayout.Vector3Field( "from" , node.fromAmount ); if( GUILayout.Button( "Set" ) ){ if( node.animTarget != null ){ node.animTarget.transform.localPosition = node.fromAmount; } } } break; case AnimationType.ROTATE_TO: node.amount = EditorGUILayout.Vector3Field( "amount" , node.amount ); if( GUILayout.Button( "Set" ) ){ if( node.animTarget != null ){ node.animTarget.transform.localEulerAngles = node.amount; } } node.toggleFromAmount = EditorGUILayout.Toggle( "Start From?" , node.toggleFromAmount ); if( node.toggleFromAmount ){ node.fromAmount = EditorGUILayout.Vector3Field( "from" , node.fromAmount ); if( GUILayout.Button( "Set" ) ){ if( node.animTarget != null ){ node.animTarget.transform.localEulerAngles = node.fromAmount; } } } break; case AnimationType.SCALE_TO: node.amount = EditorGUILayout.Vector3Field( "amount" , node.amount ); if( GUILayout.Button( "Set" ) ){ if( node.animTarget != null ){ node.animTarget.transform.localScale = node.amount; } } node.toggleFromAmount = EditorGUILayout.Toggle( "Start From?" , node.toggleFromAmount ); if( node.toggleFromAmount ){ node.fromAmount = EditorGUILayout.Vector3Field( "from" , node.fromAmount ); if( GUILayout.Button( "Set" ) ){ if( node.animTarget != null ){ node.animTarget.transform.localScale = node.fromAmount; } } } break; case AnimationType.CROSS_FADE: node.crossfadeTargetA = (GameObject)EditorGUILayout.ObjectField( "crossFadeTargetA" , node.crossfadeTargetA , typeof( GameObject ) , true ); node.crossfadeTargetB = (GameObject)EditorGUILayout.ObjectField( "crossFadeTargetB" , node.crossfadeTargetB , typeof( GameObject ) , true ); if( node.animTarget != null ){ if( node.crossfadeTargetA != null ){ node.targetAName = node.animTarget.name + "/" + node.crossfadeTargetA.name; } if( node.crossfadeTargetB != null ){ node.targetBName = node.animTarget.name + "/" + node.crossfadeTargetB.name; } } break; } node.RestoreTargets(); GUILayout.Label( "Preview is enabled in PlayMode." ); if( Application.isPlaying ){ GUI.enabled = true; } else{ GUI.enabled = false; } if( GUILayout.Button( "Preview" ) ){ node.Preview(); } GUI.enabled = true; }
public void SetSelectedBRRESFile(AnimType type, AnimationNode value) { switch (type) { case AnimType.CHR: SelectedCHR0 = value as CHR0Node; break; case AnimType.SRT: SelectedSRT0 = value as SRT0Node; break; case AnimType.SHP: SelectedSHP0 = value as SHP0Node; break; case AnimType.PAT: SelectedPAT0 = value as PAT0Node; break; case AnimType.VIS: SelectedVIS0 = value as VIS0Node; break; case AnimType.CLR: SelectedCLR0 = value as CLR0Node; break; } }