private void CreateNode() { TreeView.BeginUpdate(); int id = 1; string name = "NewBone0"; MDL0Node model = ((MDL0BoneNode)_resource).Model; Top: foreach (MDL0BoneNode b in model._linker.BoneCache) { if (b.Name == name) { name = "NewBone" + id++; goto Top; } } MDL0BoneNode bone = new MDL0BoneNode { Name = name, _entryIndex = model._linker.BoneCache.Length }; bone.FrameState = bone.BindState = FrameState.Neutral; _resource.AddChild(bone, true); bone.RecalcFrameState(); bone.RecalcBindState(false, false, false); model._linker.RegenerateBoneCache(); TreeView.EndUpdate(); Nodes[Nodes.Count - 1].EnsureVisible(); //TreeView.SelectedNode = Nodes[Nodes.Count - 1]; }
protected unsafe virtual void modelPanel1_MouseMove(object sender, MouseEventArgs e) { if (_playing) { return; } ModelPanel panel = sender as ModelPanel; ModelPanelViewport viewport = panel.CurrentViewport; Vector3?point; if (_boneSelection.IsMoving() && SelectedBone != null) { Vector3 transform = GetLocalTransform(e, viewport, GetBoneWorldMtx(), GetBoneInvWorldMtx(), GetBoneParentTransformMtx(), _boneSelection, out point); if (Alt && !_createdNewBone) { if (SelectedBone is MDL0BoneNode) { _createdNewBone = true; MDL0BoneNode b = SelectedBone as MDL0BoneNode; MDL0Node model = b.Model; MDL0BoneNode newBone = new MDL0BoneNode(); string name = "NewBone"; if (model != null) { name += "0"; int id = 1; Top: foreach (MDL0BoneNode x in model._linker.BoneCache) { if (x.Name == name) { name = "NewBone" + id++; goto Top; } } newBone._entryIndex = model._linker.BoneCache.Length; } newBone.Name = name; newBone.FrameState = newBone.BindState = FrameState.Neutral; b.AddChild(newBone); newBone.RecalcFrameState(); newBone.RecalcBindState(false, false, false); model?._linker.RegenerateBoneCache(); BonesPanel?.Reset(); SelectedBone = newBone; } } if (point != null) { for (int i = 0; i < 3; i++) { _boneTransform[(int)ControlType](i, transform[i]); } _boneSelection._lastPointLocal = GetBoneInvWorldMtx() * point.Value; } } if (_vertexSelection.IsMoving() && VertexLoc != null) { Vector3 center = VertexLoc.Value; Vector3 transform = GetLocalTransform(e, viewport, Matrix.TranslationMatrix(center), Matrix.TranslationMatrix(-center), Matrix.Identity, _vertexSelection, out point); if (point != null) { switch (ControlType) { case TransformType.Scale: foreach (Vertex3 vertex in _selectedVertices) { vertex.WeightedPosition = Maths.ScaleAboutPoint(vertex.WeightedPosition, center, transform); } break; case TransformType.Rotation: foreach (Vertex3 vertex in _selectedVertices) { vertex.WeightedPosition = Maths.RotateAboutPoint(vertex.WeightedPosition, center, transform); } break; case TransformType.Translation: foreach (Vertex3 vertex in _selectedVertices) { vertex.WeightedPosition += transform; } break; } _vertexLoc = null; _vertexSelection._lastPointLocal = Matrix.TranslationMatrix(-VertexLoc.Value) * point.Value; } UpdateModel(); } bool allowHighlight = !DoNotHighlightOnMouseMove; bool draggingSelection = viewport.Selecting; //if not dragging a point AND (highlighting is allowed, or not but selecting) if (!_boneSelection.IsMoving() && !_vertexSelection.IsMoving() && (allowHighlight || (!allowHighlight && draggingSelection))) { HighlightStuff(e, panel); } }