public void AddMorph(IPEPluginHost host, Form1 form) { if (basePos.Count < 1) { MessageBox.Show("モデル形状に変化がありません"); return; } IPXMorph nmorph = host.Builder.Pmx.Morph(); nmorph.Kind = MorphKind.UV; nmorph.Name = form.MorphName; nmorph.Panel = form.MorphPanel; var pmx = host.Connector.Pmx.GetCurrentState(); foreach (var i in basePos.Keys) { IPXUVMorphOffset offset = host.Builder.Pmx.UVMorphOffset(); offset.Vertex = pmx.Vertex[i]; Vector3 offsetVec = morphedPos[i] - basePos[i]; offset.Offset = new V4(offsetVec, 0); nmorph.Offsets.Add(offset); } pmx.Morph.Add(nmorph); host.Connector.Pmx.Update(pmx); host.Connector.Form.UpdateList(PEPlugin.Pmd.UpdateObject.All); host.Connector.View.PMDView.UpdateModel(); host.Connector.View.PMDView.UpdateView(); ReSetUVList(host.Connector, form); MessageBox.Show(nmorph.Name + "を追加しました"); }
/// <summary> /// コンストラクタ /// </summary> /// <param name="host"></param> /// <param name="ver"></param> public MyGame(IPEPluginHost _host, string ver) { this.host = _host; this.form = new Form1(ver); this.subform = new DXView(); this.uvmorphes = new MakeUVMorph(_host.Connector, this.form); this.mmanage = new MaterialManager(); }
public override void Run(IPERunArgs args) { try { IPEPluginHost host = args.Host; IPEConnector connect = host.Connector; IPEViewConnector view = host.Connector.View; IPEFormConnector form = host.Connector.Form; IPXPmx pmx = connect.Pmx.GetCurrentState(); plugin_main(pmx, view, form); connect.View.PMDView.UpdateView(); } catch (Exception ex) { MessageBox.Show( ex.Message, "エラー", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } }
//************************************** private void InitializeValue() { try { this.host = this.args.Host;; this.connect = this.host.Connector; this.PMX = this.connect.Pmx.GetCurrentState(); this.PMDView = this.connect.View.PMDView; this.PMXView = this.connect.View.PmxView; this.builder = this.host.Builder; this.bd = this.host.Builder.SC; } catch { MessageBox.Show("值初始化失败"); } }
public override void Run(IPERunArgs args) { this.host = args.Host; this.builder = this.host.Builder; this.bd = this.host.Builder.SC; this.connect = this.host.Connector; this.pex = this.connect.Pmd.GetCurrentStateEx(); this.PMD = this.connect.Pmd.GetCurrentState(); this.PMX = this.connect.Pmx.GetCurrentState(); this.Form = this.connect.Form; this.PMDView = this.connect.View.PMDView; using (var saveFileDialog = new SaveFileDialog()) { saveFileDialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);; saveFileDialog.Filter = "Json files (*.json)|*.json|All files (*.*)|*.*"; saveFileDialog.FilterIndex = 1; saveFileDialog.RestoreDirectory = true; DialogResult result = saveFileDialog.ShowDialog(); if (result == DialogResult.OK) { var materials = PMX.Material; List <MaterialInfo> materialList = new List <MaterialInfo>(); foreach (var m in materials) { materialList.Add(new MaterialInfo() { Name = m.Name, Texture = m.Tex }); } SaveToFile(saveFileDialog.FileName, materialList); } } }
public override void Run(IPERunArgs args) { try { IPEPluginHost host = args.Host; IPEConnector connect = host.Connector; IPEViewConnector view = host.Connector.View; IPEFormConnector form = host.Connector.Form; IPXPmx pmx = connect.Pmx.GetCurrentState(); // 頂点辞書の使いまわしは出来ない様なので、作り直し v_dicted = -1; v_dict = new Dictionary <IPXVertex, int>(); // 頂点リストも更新しておく all_vertex_list = pmx.Vertex; plugin_main(pmx, view, form); connect.View.PMDView.UpdateView(); } catch (Exception ex) { MessageBox.Show( ex.Message, "エラー", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } }
public MainForm(IPEPluginHost host) { InitializeComponent(); Host = host; // 重心利用時カスタムボックス無効化 checkBoxCustomCentroidEnabled.CheckedChanged += (s, e) => customCentroidBox.Enabled = (s as CheckBox).Checked; buttonGetNormalVector.Click += (s, e) => { // 法線ベクトル取得 var model = Host.Connector.Pmd.GetCurrentState(); var view = Host.Connector.View.PMDView; var pos = view.GetSelectedVertexIndices() .Select(p => model.Vertex[p].Position) .Select(p => new Vector3(p.X, p.Y, p.Z)).ToList(); if (pos.Count != 3) { MessageBox.Show(this, "3頂点を選択してください。", "法線ベクトル取得", MessageBoxButtons.OK, MessageBoxIcon.Error); } DirectionVector = Vector3.Normalize(Vector3.Cross(pos[1] - pos[0], pos[2] - pos[0])); }; buttonExecute.Click += (s, e) => Execute(); this.FormClosing += (s, e) => { if (e.CloseReason == CloseReason.UserClosing) { e.Cancel = true; this.Visible = false; } }; IsCustomCentroidEnabled = true; IsCustomCentroidEnabled = false; }
// エントリポイント public override void Run(IPERunArgs args) { try { //PMD/PMXファイルを操作するためにおまじない。 this.host = args.Host; this.builder = this.host.Builder; this.bd = this.host.Builder.SC; this.connect = this.host.Connector; this.pex = this.connect.Pmd.GetCurrentStateEx(); this.PMD = this.connect.Pmd.GetCurrentState(); this.PMX = this.connect.Pmx.GetCurrentState(); this.Form = this.connect.Form; this.PMDView = this.connect.View.PMDView; //-----------------------------------------------------------ここから----------------------------------------------------------- //ここから処理開始 //-----------------------------------------------------------ここから----------------------------------------------------------- if (this.connect.Form.PmxFormActivate) { for (int i = 0; i < this.PMX.Vertex.Count; i++) { IPXVertex vertex = this.PMX.Vertex[i]; V3 vp = (V3)vertex.Position; int ind1, ind2; ind1 = ind2 = -1; float dis1, dis2; dis1 = dis2 = 10000000; for (int j = 0; j < this.PMX.Bone.Count; j++) { IPXBone bone = this.PMX.Bone[j]; V3 bp = (V3)bone.Position; float dis; if (bone.ToBone == null) continue; else dis = getDistanceBoneToVertex(bone, vertex); if (dis < dis1) { dis2 = dis1; ind2 = ind1; ind1 = j; dis1 = dis; } else if (dis < dis2) { dis2 = dis; ind2 = j; } } if (ind1 >= 0) { vertex.Bone1 = this.PMX.Bone[ind1]; vertex.Weight1 = 1.0f; } if (ind2 >= 0) { vertex.Bone2 = this.PMX.Bone[ind2]; #if MODE_EXCLUSIVE vertex.Weight2 = 0f; #else vertex.Weight2 = (1f * dis1 / (dis1 + dis2)); vertex.Weight1 = 1.0f - vertex.Weight2; #endif } } } else { for (int i = 0; i < this.PMD.Vertex.Count; i++) { IPEVertex vertex = this.PMD.Vertex[i]; V3 vp = (V3)vertex.Position; int ind1, ind2; ind1 = ind2 = -1; float dis1, dis2; dis1 = dis2 = 10000000; for (int j = 0; j < this.PMD.Bone.Count; j++) { IPEBone bone = this.PMD.Bone[j]; V3 bp = (V3)bone.Position; float dis; if (bone.To == -1 || bone.To == 0) continue; else dis = getDistanceBoneToVertex(bone, vertex); // float dis = (bp - vp).Length(); if (dis < dis1) { dis2 = dis1; ind2 = ind1; ind1 = j; dis1 = dis; } else if (dis < dis2) { dis2 = dis; ind2 = j; } } if (ind1 >= 0) vertex.Bone1 = ind1; if (ind2 >= 0) { vertex.Bone2 = ind2; #if MODE_EXCLUSIVE vertex.Weight = 100; #else vertex.Weight = (int)(100f * dis2 / (dis1 + dis2)); #endif } } } //-----------------------------------------------------------ここまで----------------------------------------------------------- //処理ここまで //-----------------------------------------------------------ここまで----------------------------------------------------------- //モデル・画面を更新します。 this.Update(); #if MODE_EXCLUSIVE MessageBox.Show(this.PMD.Vertex.Count.ToString() + "個の頂点のウェイトを最短排他形式で設定しました。", "ウェイト自動設定(排他的)", MessageBoxButtons.OK, MessageBoxIcon.Information); #else MessageBox.Show(this.PMX.Vertex.Count.ToString() + "個の頂点のウェイトを中間補完形式で設定しました。", "ウェイト自動設定(補完的)", MessageBoxButtons.OK, MessageBoxIcon.Information); #endif } catch (Exception ex) { MessageBox.Show(ex.Message, "エラー", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } }
// エントリポイント public override void Run(IPERunArgs args) { try { //PMD/PMXファイルを操作するためにおまじない。 this.host = args.Host; this.builder = this.host.Builder; this.bd = this.host.Builder.SC; this.connect = this.host.Connector; this.pex = this.connect.Pmd.GetCurrentStateEx(); this.PMD = this.connect.Pmd.GetCurrentState(); this.PMX = this.connect.Pmx.GetCurrentState(); this.Form = this.connect.Form; this.PMDView = this.connect.View.PMDView; //-----------------------------------------------------------ここから----------------------------------------------------------- //ここから処理開始 //-----------------------------------------------------------ここから----------------------------------------------------------- if (this.connect.Form.PmxFormActivate) { for (int i = 0; i < this.PMX.Vertex.Count; i++) { IPXVertex vertex = this.PMX.Vertex[i]; V3 vp = (V3)vertex.Position; int ind1, ind2; ind1 = ind2 = -1; float dis1, dis2; dis1 = dis2 = 10000000; for (int j = 0; j < this.PMX.Bone.Count; j++) { IPXBone bone = this.PMX.Bone[j]; V3 bp = (V3)bone.Position; float dis; if (bone.ToBone == null) { continue; } else { dis = getDistanceBoneToVertex(bone, vertex); } if (dis < dis1) { dis2 = dis1; ind2 = ind1; ind1 = j; dis1 = dis; } else if (dis < dis2) { dis2 = dis; ind2 = j; } } if (ind1 >= 0) { vertex.Bone1 = this.PMX.Bone[ind1]; vertex.Weight1 = 1.0f; } if (ind2 >= 0) { vertex.Bone2 = this.PMX.Bone[ind2]; #if MODE_EXCLUSIVE vertex.Weight2 = 0f; #else vertex.Weight2 = (1f * dis1 / (dis1 + dis2)); vertex.Weight1 = 1.0f - vertex.Weight2; #endif } } } else { for (int i = 0; i < this.PMD.Vertex.Count; i++) { IPEVertex vertex = this.PMD.Vertex[i]; V3 vp = (V3)vertex.Position; int ind1, ind2; ind1 = ind2 = -1; float dis1, dis2; dis1 = dis2 = 10000000; for (int j = 0; j < this.PMD.Bone.Count; j++) { IPEBone bone = this.PMD.Bone[j]; V3 bp = (V3)bone.Position; float dis; if (bone.To == -1 || bone.To == 0) { continue; } else { dis = getDistanceBoneToVertex(bone, vertex); } // float dis = (bp - vp).Length(); if (dis < dis1) { dis2 = dis1; ind2 = ind1; ind1 = j; dis1 = dis; } else if (dis < dis2) { dis2 = dis; ind2 = j; } } if (ind1 >= 0) { vertex.Bone1 = ind1; } if (ind2 >= 0) { vertex.Bone2 = ind2; #if MODE_EXCLUSIVE vertex.Weight = 100; #else vertex.Weight = (int)(100f * dis2 / (dis1 + dis2)); #endif } } } //-----------------------------------------------------------ここまで----------------------------------------------------------- //処理ここまで //-----------------------------------------------------------ここまで----------------------------------------------------------- //モデル・画面を更新します。 this.Update(); #if MODE_EXCLUSIVE MessageBox.Show(this.PMD.Vertex.Count.ToString() + "個の頂点のウェイトを最短排他形式で設定しました。", "ウェイト自動設定(排他的)", MessageBoxButtons.OK, MessageBoxIcon.Information); #else MessageBox.Show(this.PMX.Vertex.Count.ToString() + "個の頂点のウェイトを中間補完形式で設定しました。", "ウェイト自動設定(補完的)", MessageBoxButtons.OK, MessageBoxIcon.Information); #endif } catch (Exception ex) { MessageBox.Show(ex.Message, "エラー", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } }
public MyPMX(IPEPluginHost host, MessageForm _message) { this.message = _message; this.pmx = host.Connector.Pmx.GetCurrentState(); this.SetMyPmx(); }
public void InitVariables(IPERunArgs args) { // 常用接続変数一括登録 // ホスト配下 host = args.Host; builder = host.Builder; bd = builder.SC; // 短絡系ビルダ bdx = builder.Pmx; // PMXビルダ connect = host.Connector; view = connect.View.PMDView; // PMX関連 pmx = connect.Pmx.GetCurrentState(); // PMX取得 header = pmx.Header; // header :ヘッダ info = pmx.ModelInfo; // info :モデル情報 vertex = pmx.Vertex; // vertex :頂点 | リスト material = pmx.Material; // material :材質 | リスト bone = pmx.Bone; // bone :ボーン | リスト morph = pmx.Morph; // morph :モーフ | リスト node = pmx.Node; // node :表示枠 | リスト body = pmx.Body; // body :剛体 | リスト joint = pmx.Joint; // joint :Joint | リスト }
public MockRunArgs(IPEPluginHost host) { Host = host; }