public void MakeMorph(IPEConnector connector, MyPMX mypmx, VertexSelect vs, Form1 form) { float diff = form.Morphdiffernce; IPXPmx pmx = connector.Pmx.GetCurrentState(); if (mypmx.VertexArray.Count() != pmx.Vertex.Count) { MessageBox.Show("本体とプラグインのモデル頂点数が異なるのでこの操作はキャンセルされました。"); return; } basePos.Clear(); morphedPos.Clear(); for (int i = 0; i < pmx.Vertex.Count; i++) { Vector3 morphPosI = mypmx.VertexArray[i].Position; Vector3 basePosI = new Vector3(pmx.Vertex[i].UV.U, pmx.Vertex[i].UV.V, 0); if (Math.Abs(basePosI.X - morphPosI.X) > diff || Math.Abs(basePosI.Y - morphPosI.Y) > diff) { basePos.Add(i, basePosI); morphedPos.Add(i, morphPosI); } } form.SetMorphedCount(basePos.Count); vs.selectedVertexIndex = this.GetMorphTargetIndex(); }
private void EditMyPMXVertexes(MyPMX mypmx, UnDoRedoRecord record) { for (int i = 0; i < record._index.Length; i++) { mypmx.VertexArray[record._index[i]].Position = record._vec[i]; } }
public void MoveMorph(MyPMX mypmx, float ratio) { foreach (var i in basePos.Keys) { mypmx.VertexArray[i].Position = (1 - ratio) * basePos[i] + ratio * morphedPos[i]; } }
public UnDoRedoRecord(int[] index, MyPMX mypmx) { this._index = index; this._vec = new Vector3[index.Length]; for (int i = 0; i < index.Length; i++) { _vec[i] = mypmx.VertexArray[index[i]].Position; } }
public int GetNearSelected(MyPMX target, ICamera camera, Point p, float rad) { for (int i = 0; i < this.selectedVertexIndex.Length; i++) { if (camera.IsNear(p, target.VertexArray[this.selectedVertexIndex[i]].Position, rad)) { return(this.selectedVertexIndex[i]); } } return(-1); }
public void Redo(MyPMX mypmx) { if (redoStack.Count > 0) { UnDoRedoRecord poppedout = redoStack.Pop(); undoStack.Push(new UnDoRedoRecord(poppedout._index, mypmx)); if (redoStack.Count <= 0) { this.redoToolStripMenuItem.Enabled = false; } this._undoToolStripMenuItem.Enabled = true; this.EditMyPMXVertexes(mypmx, poppedout); } }
private bool LoadPMXMesh() { this.mesh = null; try { this.mypmx = new MyPMX(this.host, this.message); this.ConvertMyPMXtoMesh(); } catch (Direct3D9Exception ex) { MessageBox.Show("モデルが読み込まれてないのかも?"); this.Dispose(); throw ex; } this.SetTextures(); return(true); }
public int GetNearUsed(MyPMX target, ICamera camera, Point p, float rad) { try { for (int i = 0; i < target.VertexArray.Length; i++) { bool used = target.IsUsedinMat[this.SelectedMaterial, i]; if (used && camera.IsNear(p, target.VertexArray[i].Position, rad)) { this.nearUsedIndex = i; return(i); } } this.nearUsedIndex = -1; return(-1); } catch (SlimDXException ex) { Console.WriteLine(ex); return(-1); } }
public void ReadMorph(IPEConnector connector, MyPMX mypmx, VertexSelect vs, Form1 form) { IPXPmx pmx = connector.Pmx.GetCurrentState(); if (mypmx.VertexArray.Count() != pmx.Vertex.Count) { MessageBox.Show("本体とプラグインのモデル頂点数が異なるのでこの操作はキャンセルされました。"); return; } basePos.Clear(); morphedPos.Clear(); int morphindex = form.SelectedUVMorph(); if (morphindex < 0) { MessageBox.Show("UVモーフが選べません"); return; } var uvMorph = pmx.Morph[morphindex]; foreach (IPXUVMorphOffset offset in uvMorph.Offsets) { IPXVertex v = offset.Vertex; int index = pmx.Vertex.IndexOf(v); Vector3 baseI = new Vector3(v.UV.U, v.UV.V, 0); Vector3 morphI = baseI + new Vector3(offset.Offset.X, offset.Offset.Y, 0); try { this.basePos.Add(index, baseI); this.morphedPos.Add(index, morphI); } catch { MessageBox.Show(index.ToString()); throw; } } form.SetMorphedCount(basePos.Count); vs.selectedVertexIndex = this.GetMorphTargetIndex(); }