TSOWeight-009とTSOWeitEd-001との差分です。
- diff -ur TSOWeight\Form1.cs TSOWeitEd\Form1.cs
- --- TSOWeight\Form1.cs Fri May 03 08:39:24 2013
- +++ TSOWeitEd\Form1.cs Tue Apr 09 18:49:58 2013
- @@ -250,6 +250,39 @@
- Invalidate(false);
- }
- + private void tbPower_ValueChanged(object sender, EventArgs e)
- + {
- + float power = (float)(tbPower.Value) * 0.050f;
- + edPower.TextChanged -= new EventHandler(edPower_TextChanged);
- + edPower.Text = string.Format("{0:F3}", power);
- + edPower.TextChanged += new EventHandler(edPower_TextChanged);
- + viewer.Power = power;
- + Invalidate(false);
- + }
- +
- + private void edPower_TextChanged(object sender, EventArgs e)
- + {
- + float power;
- + try
- + {
- + power = float.Parse(edPower.Text);
- + }
- + catch (FormatException)
- + {
- + power = 1.000f;
- + }
- + int value = (int)(power * 20.0f);
- + if (value < tbPower.Minimum)
- + value = tbPower.Minimum;
- + if (value > tbPower.Maximum)
- + value = tbPower.Maximum;
- + tbPower.ValueChanged -= new EventHandler(tbPower_ValueChanged);
- + tbPower.Value = value;
- + tbPower.ValueChanged += new EventHandler(tbPower_ValueChanged);
- + viewer.Power = power;
- + Invalidate(false);
- + }
- +
- private void btnGain_Click(object sender, EventArgs e)
- {
- viewer.GainSkinWeight();
- diff -ur TSOWeight\Form1.Designer.cs TSOWeitEd\Form1.Designer.cs
- --- TSOWeight\Form1.Designer.cs Fri May 03 08:39:24 2013
- +++ TSOWeitEd\Form1.Designer.cs Tue Apr 09 19:09:56 2013
- @@ -78,29 +78,33 @@
- this.helpVersionToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
- this.lbTSOFiles = new System.Windows.Forms.Label();
- this.lvTSOFiles = new System.Windows.Forms.ListView();
- - this.columnHeader6 = new System.Windows.Forms.ColumnHeader();
- + this.columnHeader6 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
- this.lbMeshes = new System.Windows.Forms.Label();
- this.lvMeshes = new System.Windows.Forms.ListView();
- - this.columnHeader1 = new System.Windows.Forms.ColumnHeader();
- + this.columnHeader1 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
- this.panel1 = new System.Windows.Forms.Panel();
- this.edRadius = new System.Windows.Forms.TextBox();
- this.edWeight = new System.Windows.Forms.TextBox();
- this.btnAssign = new System.Windows.Forms.Button();
- this.btnReduce = new System.Windows.Forms.Button();
- - this.lbWeightCaption = new System.Windows.Forms.Label();
- - this.lbRadiusCaption = new System.Windows.Forms.Label();
- + this.lbWeight = new System.Windows.Forms.Label();
- + this.lbRadius = new System.Windows.Forms.Label();
- this.lvSkinWeights = new System.Windows.Forms.ListView();
- - this.columnHeader4 = new System.Windows.Forms.ColumnHeader();
- - this.columnHeader5 = new System.Windows.Forms.ColumnHeader();
- + this.columnHeader4 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
- + this.columnHeader5 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
- this.lbSkinWeights = new System.Windows.Forms.Label();
- this.tbWeight = new System.Windows.Forms.TrackBar();
- this.btnGain = new System.Windows.Forms.Button();
- this.tbRadius = new System.Windows.Forms.TrackBar();
- this.statusStrip1 = new System.Windows.Forms.StatusStrip();
- + this.edPower = new System.Windows.Forms.TextBox();
- + this.lbPower = new System.Windows.Forms.Label();
- + this.tbPower = new System.Windows.Forms.TrackBar();
- this.menuStrip1.SuspendLayout();
- this.panel1.SuspendLayout();
- ((System.ComponentModel.ISupportInitialize)(this.tbWeight)).BeginInit();
- ((System.ComponentModel.ISupportInitialize)(this.tbRadius)).BeginInit();
- + ((System.ComponentModel.ISupportInitialize)(this.tbPower)).BeginInit();
- this.SuspendLayout();
- //
- // timer1
- @@ -512,18 +516,21 @@
- //
- // panel1
- //
- - this.panel1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top |
- System.Windows.Forms.AnchorStyles.Bottom)
- - | System.Windows.Forms.AnchorStyles.Right)));
- + this.panel1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top |
- System.Windows.Forms.AnchorStyles.Bottom)
- + | System.Windows.Forms.AnchorStyles.Right)));
- + this.panel1.Controls.Add(this.edPower);
- + this.panel1.Controls.Add(this.lbPower);
- + this.panel1.Controls.Add(this.tbPower);
- this.panel1.Controls.Add(this.edRadius);
- this.panel1.Controls.Add(this.edWeight);
- this.panel1.Controls.Add(this.btnAssign);
- this.panel1.Controls.Add(this.btnReduce);
- this.panel1.Controls.Add(this.lvTSOFiles);
- this.panel1.Controls.Add(this.lbTSOFiles);
- - this.panel1.Controls.Add(this.lbWeightCaption);
- + this.panel1.Controls.Add(this.lbWeight);
- this.panel1.Controls.Add(this.lbMeshes);
- this.panel1.Controls.Add(this.lvMeshes);
- - this.panel1.Controls.Add(this.lbRadiusCaption);
- + this.panel1.Controls.Add(this.lbRadius);
- this.panel1.Controls.Add(this.lvSkinWeights);
- this.panel1.Controls.Add(this.lbSkinWeights);
- this.panel1.Controls.Add(this.tbWeight);
- @@ -572,21 +579,21 @@
- this.btnReduce.UseVisualStyleBackColor = true;
- this.btnReduce.Click += new System.EventHandler(this.btnReduce_Click);
- //
- - // lbWeightCaption
- + // lbWeight
- //
- - this.lbWeightCaption.Location = new System.Drawing.Point(14, 421);
- - this.lbWeightCaption.Name = "lbWeightCaption";
- - this.lbWeightCaption.Size = new System.Drawing.Size(120, 12);
- - this.lbWeightCaption.TabIndex = 6;
- - this.lbWeightCaption.Text = "強度";
- - //
- - // lbRadiusCaption
- - //
- - this.lbRadiusCaption.Location = new System.Drawing.Point(14, 476);
- - this.lbRadiusCaption.Name = "lbRadiusCaption";
- - this.lbRadiusCaption.Size = new System.Drawing.Size(120, 12);
- - this.lbRadiusCaption.TabIndex = 9;
- - this.lbRadiusCaption.Text = "半径";
- + this.lbWeight.Location = new System.Drawing.Point(14, 421);
- + this.lbWeight.Name = "lbWeight";
- + this.lbWeight.Size = new System.Drawing.Size(84, 12);
- + this.lbWeight.TabIndex = 6;
- + this.lbWeight.Text = "強度";
- + //
- + // lbRadius
- + //
- + this.lbRadius.Location = new System.Drawing.Point(14, 476);
- + this.lbRadius.Name = "lbRadius";
- + this.lbRadius.Size = new System.Drawing.Size(84, 12);
- + this.lbRadius.TabIndex = 9;
- + this.lbRadius.Text = "半径";
- //
- // lvSkinWeights
- //
- @@ -663,6 +670,35 @@
- this.statusStrip1.TabIndex = 23;
- this.statusStrip1.Text = "statusStrip1";
- //
- + // edPower
- + //
- + this.edPower.Location = new System.Drawing.Point(104, 580);
- + this.edPower.Name = "edPower";
- + this.edPower.Size = new System.Drawing.Size(84, 19);
- + this.edPower.TabIndex = 16;
- + this.edPower.Text = "1.000";
- + this.edPower.TextChanged += new System.EventHandler(this.edPower_TextChanged);
- + //
- + // lbPower
- + //
- + this.lbPower.Location = new System.Drawing.Point(14, 583);
- + this.lbPower.Name = "lbPower";
- + this.lbPower.Size = new System.Drawing.Size(84, 12);
- + this.lbPower.TabIndex = 15;
- + this.lbPower.Text = "減衰";
- + //
- + // tbPower
- + //
- + this.tbPower.AutoSize = false;
- + this.tbPower.Location = new System.Drawing.Point(16, 605);
- + this.tbPower.Maximum = 40;
- + this.tbPower.Name = "tbPower";
- + this.tbPower.Size = new System.Drawing.Size(172, 24);
- + this.tbPower.TabIndex = 17;
- + this.tbPower.TickStyle = System.Windows.Forms.TickStyle.None;
- + this.tbPower.Value = 20;
- + this.tbPower.ValueChanged += new System.EventHandler(this.tbPower_ValueChanged);
- + //
- // Form1
- //
- this.AllowDrop = true;
- @@ -674,7 +710,7 @@
- this.Controls.Add(this.menuStrip1);
- this.MainMenuStrip = this.menuStrip1;
- this.Name = "Form1";
- - this.Text = "TSOWeight";
- + this.Text = "TSOWeitEd";
- this.DragDrop += new System.Windows.Forms.DragEventHandler(this.Form1_DragDrop);
- this.DragOver += new System.Windows.Forms.DragEventHandler(this.Form1_DragOver);
- this.menuStrip1.ResumeLayout(false);
- @@ -683,6 +719,7 @@
- this.panel1.PerformLayout();
- ((System.ComponentModel.ISupportInitialize)(this.tbWeight)).EndInit();
- ((System.ComponentModel.ISupportInitialize)(this.tbRadius)).EndInit();
- + ((System.ComponentModel.ISupportInitialize)(this.tbPower)).EndInit();
- this.ResumeLayout(false);
- this.PerformLayout();
- @@ -714,8 +751,8 @@
- private System.Windows.Forms.Label lbTSOFiles;
- private System.Windows.Forms.ListView lvTSOFiles;
- private System.Windows.Forms.ColumnHeader columnHeader6;
- - private System.Windows.Forms.Label lbWeightCaption;
- - private System.Windows.Forms.Label lbRadiusCaption;
- + private System.Windows.Forms.Label lbWeight;
- + private System.Windows.Forms.Label lbRadius;
- private System.Windows.Forms.Button btnGain;
- private System.Windows.Forms.TrackBar tbRadius;
- private System.Windows.Forms.TrackBar tbWeight;
- @@ -753,6 +790,9 @@
- private System.Windows.Forms.TextBox edWeight;
- private System.Windows.Forms.TextBox edRadius;
- private System.Windows.Forms.ToolStripMenuItem editResetPoseToolStripMenuItem;
- + private System.Windows.Forms.TextBox edPower;
- + private System.Windows.Forms.Label lbPower;
- + private System.Windows.Forms.TrackBar tbPower;
- }
- }
- diff -ur TSOWeight\TSOWeight.csproj TSOWeitEd\TSOWeight.csproj
- --- TSOWeight\TSOWeight.csproj Fri May 03 08:39:24 2013
- +++ TSOWeitEd\TSOWeight.csproj Mon Apr 08 03:26:42 2013
- @@ -112,6 +112,9 @@
- <Content Include="dot.bmp">
- <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
- </Content>
- + <Content Include="dotweit.bmp">
- + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
- + </Content>
- </ItemGroup>
- <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
- <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
- diff -ur TSOWeight\WeightViewer.cs TSOWeitEd\WeightViewer.cs
- --- TSOWeight\WeightViewer.cs Fri May 03 08:39:24 2013
- +++ TSOWeitEd\WeightViewer.cs Tue Apr 09 18:56:52 2013
- @@ -362,7 +362,7 @@
- if (v.selected)
- {
- - VertexCommand vertex_command = new VertexCommand(sub_mesh, selected_node, v, weight, weight_op);
- + VertexCommand vertex_command = new VertexCommand(sub_mesh, selected_node, v, weight * v.factor, weight_op);
- if (vertex_command.Execute())
- {
- @@ -450,6 +450,7 @@
- {
- internal Mesh sphere = null;
- internal Texture dot_texture = null;
- + internal Texture dotweit_texture = null;
- /// <summary>
- /// effect handle for LocalBoneSels
- @@ -476,6 +477,12 @@
- return Path.Combine(Application.StartupPath, @"dot.bmp");
- }
- + /// get path to dotweit.bmp
- + public static string GetDotWeitBitmapPath()
- + {
- + return Path.Combine(Application.StartupPath, @"dotweit.bmp");
- + }
- +
- /// <summary>
- /// deviceを作成します。
- /// </summary>
- @@ -499,6 +506,7 @@
- sphere = Mesh.Sphere(device, 0.25f, 8, 4);
- dot_texture = TextureLoader.FromFile(device, GetDotBitmapPath());
- + dotweit_texture = TextureLoader.FromFile(device, GetDotWeitBitmapPath());
- handle_LocalBoneSels = effect.GetParameter(null, "LocalBoneSels");
- return true;
- @@ -1003,14 +1011,28 @@
- for (int i = 0; i < sub_mesh.vertices.Length; i++)
- {
- - if (sub_mesh.vertices[i].selected)
- - rect = new Rectangle(8, 8, 7, 7);//yellow
- - else
- - rect = new Rectangle(0, 0, 7, 7);//red
- + Vertex v = sub_mesh.vertices[i];
- + int x = 0;
- + int y = 0;
- + if (v.selected)
- + {
- + if (v.factor == 1.0f)
- + {
- + x = 4;
- + y = 3;
- + }
- + else
- + {
- + int n = (int)(v.factor * 20.0f) % 20;
- + x = n % 5;
- + y = n / 5;
- + }
- + }
- + rect = new Rectangle(x*8, y*8, 7, 7);
- Vector3 p2 = screen_positions[i];
- p2.Z = 0.0f;
- - sprite.Draw(dot_texture, rect, rect_center, p2, Color.White);
- + sprite.Draw(dotweit_texture, rect, rect_center, p2, Color.White);
- }
- sprite.End();
- }
- @@ -1022,7 +1044,7 @@
- {
- Vector3 p2 = screen_positions[i];
- p2.Z = 0.0f;
- - sprite.Draw(dot_texture, rect, rect_center, p2, Color.White);
- + sprite.Draw(dotweit_texture, rect, rect_center, p2, Color.White);
- }
- sprite.End();
- }
- @@ -1041,14 +1063,28 @@
- if (!ccws[i])
- continue;
- - if (sub_mesh.vertices[i].selected)
- - rect = new Rectangle(8, 8, 7, 7);//yellow
- - else
- - rect = new Rectangle(0, 0, 7, 7);//red
- + Vertex v = sub_mesh.vertices[i];
- + int x = 0;
- + int y = 0;
- + if (v.selected)
- + {
- + if (v.factor == 1.0f)
- + {
- + x = 4;
- + y = 3;
- + }
- + else
- + {
- + int n = (int)(v.factor * 20.0f) % 20;
- + x = n % 5;
- + y = n / 5;
- + }
- + }
- + rect = new Rectangle(x*8, y*8, 7, 7);
- Vector3 p2 = screen_positions[i];
- p2.Z = 0.0f;
- - sprite.Draw(dot_texture, rect, rect_center, p2, Color.White);
- + sprite.Draw(dotweit_texture, rect, rect_center, p2, Color.White);
- }
- sprite.End();
- }
- @@ -1063,7 +1099,7 @@
- Vector3 p2 = screen_positions[i];
- p2.Z = 0.0f;
- - sprite.Draw(dot_texture, rect, rect_center, p2, Color.White);
- + sprite.Draw(dotweit_texture, rect, rect_center, p2, Color.White);
- }
- sprite.End();
- }
- @@ -1174,6 +1210,18 @@
- }
- }
- + float power = 1.000f;
- + /// 減衰
- + public float Power
- + {
- + get { return power; }
- + set
- + {
- + power = value;
- + SelectVertices();
- + }
- + }
- +
- float radius = 0.500f;
- /// 半径
- public float Radius
- @@ -1216,7 +1264,24 @@
- //頂点間距離が半径未満なら選択する。
- Vector3 p1 = v.CalcSkindeformPosition(clipped_boneMatrices);
- - v.selected = Vector3.LengthSq(p1 - center) - radius * radius < float.Epsilon;
- + float squared_length = Vector3.LengthSq(p1 - center);
- + float squared_radius = radius * radius;
- + v.selected = squared_length - squared_radius < float.Epsilon;
- + if (v.selected)
- + {
- + if (squared_radius < float.Epsilon)
- + {
- + v.factor = 1.0f;
- + }
- + else
- + {
- + //半径 1.0f とみなしたときの平方距離を得る
- + double len = 1.0 - squared_length / squared_radius;
- + //ウェイト乗数
- + //半径境界で 0.0f になる
- + v.factor = (float)Math.Pow(len, power);
- + }
- + }
- }
- }
- }
- @@ -1729,6 +1794,8 @@
- {
- if (dot_texture != null)
- dot_texture.Dispose();
- + if (dotweit_texture != null)
- + dotweit_texture.Dispose();
- if (sphere != null)
- sphere.Dispose();
- base.Dispose();