private unsafe void btnOkay_Click(object sender, EventArgs e) { switch (comboBox3.SelectedIndex) { case 0: _parent.AddChild((ResourceNode)_baseInf); break; case 1: _parent.Parent.AddChild((ResourceNode)_baseInf); _parent.Remove(); break; case 2: MergeChildren(_parent, (MDL0BoneNode)_baseInf, _mergeModels ? (ResourceNode)_externalModel : (ResourceNode)node); break; } if (_mergeModels) { foreach (MDL0PolygonNode poly in _externalModel.FindChild("Objects", true).Children) { ImportObject(poly); } } else { ImportObject(node); } _internalModel.SignalPropertyChange(); DialogResult = DialogResult.OK; Close(); }
private unsafe void btnOkay_Click(object sender, EventArgs e) { switch (comboBox3.SelectedIndex) { case 0: foreach (MDL0BoneNode b in (_baseInf as MDL0BoneNode).Children) { MergeChildren(_parent, b, _mergeModels ? _externalModel : (ResourceNode)_node); } break; case 1: _parent.Parent.InsertChild((ResourceNode)_baseInf, true, _parent.Index); _parent.Remove(); break; case 2: _parent.AddChild((ResourceNode)_baseInf); break; } _internalModel.ApplyCHR(null, 0); if (_mergeModels) { _externalModel.ApplyCHR(null, 0); foreach (ResourceNode node in _externalModel?.FindChild("Objects", true)?.Children?.ToArray() ?? new ResourceNode[0]) { if (node is MDL0ObjectNode poly) { ImportObject(poly); } } } else { _node.Model.ApplyCHR(null, 0); ImportObject(_node); } _internalModel.SignalPropertyChange(); DialogResult = DialogResult.OK; Close(); }
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); } }
protected unsafe virtual void modelPanel1_MouseMove(object sender, MouseEventArgs e) { if (_playing) { return; } ModelPanel panel = sender as ModelPanel; ModelPanelViewport viewport = panel.CurrentViewport; bool moving = _scaling || _rotating || _translating; if (moving) { Vector3?point; if (SelectedBone != null) { Vector3 transform = GetLocalTransform(e, viewport, GetBoneWorldMtx(), GetBoneInvWorldMtx(), GetBoneParentTransformMtx(), out point); if (Alt && !_createdNewBone) { if (SelectedBone is MDL0BoneNode) { _createdNewBone = true; MDL0BoneNode b = SelectedBone as MDL0BoneNode; MDL0Node model = b.Model; MDL0BoneNode newBone = new MDL0BoneNode(); newBone.Scale = new Vector3(1.0f); newBone._bindMatrix = newBone._inverseBindMatrix = newBone._frameMatrix = newBone._inverseFrameMatrix = Matrix.Identity; if (model != null) { int id = 1; string name = "NewBone0"; Top: foreach (MDL0BoneNode x in model._linker.BoneCache) { if (x.Name == name) { name = "NewBone" + id++; goto Top; } } newBone.Name = name; newBone._entryIndex = model._linker.BoneCache.Length; b.AddChild(newBone); model._linker.RegenerateBoneCache(); } else { newBone.Name = "NewBone"; b.AddChild(newBone); } if (BonesPanel != null) { BonesPanel.Reset(); } SelectedBone = newBone; } } if (point != null) { for (int i = 0; i < 3; i++) { _boneTransform[(int)ControlType](i, transform[i]); } _lastPointLocal = GetBoneInvWorldMtx() * point.Value; } } else if (VertexLoc != null) { Vector3 center = VertexLoc.Value; Vector3 transform = GetLocalTransform(e, viewport, Matrix.TranslationMatrix(center), Matrix.TranslationMatrix(-center), Matrix.Identity, 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; _lastPointLocal = Matrix.TranslationMatrix(-VertexLoc.Value) * point.Value; } UpdateModel(); } } //if not dragging a point AND (highlighting is allowed, or not but selecting) if (!moving && (!DoNotHighlightOnMouseMove || (DoNotHighlightOnMouseMove && viewport.Selecting))) { HighlightStuff(e, panel); } }