public unsafe VIS0EntryNode CreateEntry() { VIS0EntryNode entry = new VIS0EntryNode(); entry._entryCount = -1; entry.EntryCount = FrameCount; entry.Name = FindName(null); AddChild(entry); return entry; }
/// <summary> /// Stretches or compresses all frames of the animation to fit a new frame count. /// </summary> public void Resize(int newFrameCount) { float ratio = (float)newFrameCount / (float)FrameCount; int oldFrameCount = FrameCount; bool[][] bools = new bool[Children.Count][]; foreach (VIS0EntryNode e in Children) if (!e.Constant) { bool[] newBools = new bool[newFrameCount]; for (int i = 0; i < FrameCount; i++) if (e.GetEntry(i)) { int start = i; int z = i; while ((e.GetEntry(++z))) ; int span = z - start; int newSpan = (int)((float)span * ratio + 0.5f); int newStart = (int)((float)start * ratio + 0.5f); for (int w = 0; w < newSpan; w++) newBools[newStart + w] = true; i = z + 1; } bools[e.Index] = newBools; } FrameCount = newFrameCount; int o = -1; foreach (bool[] b in bools) { o++; if (b == null) continue; VIS0EntryNode e = Children[o] as VIS0EntryNode; e._data = new byte[e._data.Length]; int u = 0; int byteIndex = 0; foreach (bool i in b) { if (u % 8 == 0) byteIndex = u / 8; e._data[byteIndex] |= (byte)((i ? 1 : 0) << (7 - (u % 8))); u++; } } }
/// <summary> /// Adds an animation to the end of this one /// </summary> public void Append(VIS0Node external) { int origIntCount = FrameCount; FrameCount += external.FrameCount; foreach (VIS0EntryNode _extEntry in external.Children) { VIS0EntryNode _intEntry = null; if ((_intEntry = (VIS0EntryNode)FindChild(_extEntry.Name, false)) == null) { VIS0EntryNode newIntEntry = new VIS0EntryNode() { Name = _extEntry.Name }; newIntEntry._entryCount = -1; newIntEntry.EntryCount = _extEntry.EntryCount + origIntCount; newIntEntry._flags = 0; if (_extEntry.Constant) { if (_extEntry.Enabled) for (int i = origIntCount.Align(8) / 8; i < newIntEntry.EntryCount; i++) newIntEntry._data[i] = 0xFF; } else Array.Copy(_extEntry._data, 0, newIntEntry._data, origIntCount.Align(8) / 8, _extEntry.EntryCount.Align(8) / 8); AddChild(newIntEntry); } else { if (!_extEntry.Constant && !_intEntry.Constant) Array.Copy(_extEntry._data, 0, _intEntry._data, origIntCount.Align(8) / 8, _extEntry.EntryCount.Align(8) / 8); else { byte[] d = new byte[_extEntry._data.Length]; if (_intEntry.Constant) { if (_intEntry.Enabled) for (int i = 0; i < origIntCount.Align(8) / 8; i++) d[i] = 0xFF; } else Array.Copy(_extEntry._data, 0, _intEntry._data, origIntCount.Align(8) / 8, _extEntry.EntryCount.Align(8) / 8); _intEntry.Constant = false; if (_extEntry.Constant) { if (_extEntry.Enabled) for (int i = origIntCount.Align(8) / 8; i < _intEntry.EntryCount; i++) d[i] = 0xFF; } else Array.Copy(_extEntry._data, 0, d, origIntCount.Align(8) / 8, _extEntry.EntryCount.Align(8) / 8); _intEntry._data = d; } } } }
public unsafe VIS0EntryNode CreateEntry() { VIS0EntryNode entry = new VIS0EntryNode(); entry._entryCount = -1; entry.EntryCount = _frameCount + 1; entry.Name = this.FindName(null); AddChild(entry); return(entry); }
private void listBox1_SelectedIndexChanged(object sender, EventArgs e) { TargetVisEntry = listBox1.Items[listBox1.SelectedIndex] as VIS0EntryNode; //if (_mainWindow.CurrentFrame > 0 && _mainWindow.CurrentFrame < _mainWindow.KeyframePanel.visEditor.listBox1.Items.Count) // _mainWindow.KeyframePanel.visEditor.listBox1.SelectedIndex = _mainWindow.CurrentFrame - 1; }