TSOWeight-009とTSOWeitEd-001との差分です。

Format
Diff
Post date
2013-09-22 03:44
Publication Period
Unlimited
  1. diff -ur TSOWeight\Form1.cs TSOWeitEd\Form1.cs
  2. --- TSOWeight\Form1.cs Fri May 03 08:39:24 2013
  3. +++ TSOWeitEd\Form1.cs Tue Apr 09 18:49:58 2013
  4. @@ -250,6 +250,39 @@
  5. Invalidate(false);
  6. }
  7. + private void tbPower_ValueChanged(object sender, EventArgs e)
  8. + {
  9. + float power = (float)(tbPower.Value) * 0.050f;
  10. + edPower.TextChanged -= new EventHandler(edPower_TextChanged);
  11. + edPower.Text = string.Format("{0:F3}", power);
  12. + edPower.TextChanged += new EventHandler(edPower_TextChanged);
  13. + viewer.Power = power;
  14. + Invalidate(false);
  15. + }
  16. +
  17. + private void edPower_TextChanged(object sender, EventArgs e)
  18. + {
  19. + float power;
  20. + try
  21. + {
  22. + power = float.Parse(edPower.Text);
  23. + }
  24. + catch (FormatException)
  25. + {
  26. + power = 1.000f;
  27. + }
  28. + int value = (int)(power * 20.0f);
  29. + if (value < tbPower.Minimum)
  30. + value = tbPower.Minimum;
  31. + if (value > tbPower.Maximum)
  32. + value = tbPower.Maximum;
  33. + tbPower.ValueChanged -= new EventHandler(tbPower_ValueChanged);
  34. + tbPower.Value = value;
  35. + tbPower.ValueChanged += new EventHandler(tbPower_ValueChanged);
  36. + viewer.Power = power;
  37. + Invalidate(false);
  38. + }
  39. +
  40. private void btnGain_Click(object sender, EventArgs e)
  41. {
  42. viewer.GainSkinWeight();
  43. diff -ur TSOWeight\Form1.Designer.cs TSOWeitEd\Form1.Designer.cs
  44. --- TSOWeight\Form1.Designer.cs Fri May 03 08:39:24 2013
  45. +++ TSOWeitEd\Form1.Designer.cs Tue Apr 09 19:09:56 2013
  46. @@ -78,29 +78,33 @@
  47. this.helpVersionToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
  48. this.lbTSOFiles = new System.Windows.Forms.Label();
  49. this.lvTSOFiles = new System.Windows.Forms.ListView();
  50. - this.columnHeader6 = new System.Windows.Forms.ColumnHeader();
  51. + this.columnHeader6 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
  52. this.lbMeshes = new System.Windows.Forms.Label();
  53. this.lvMeshes = new System.Windows.Forms.ListView();
  54. - this.columnHeader1 = new System.Windows.Forms.ColumnHeader();
  55. + this.columnHeader1 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
  56. this.panel1 = new System.Windows.Forms.Panel();
  57. this.edRadius = new System.Windows.Forms.TextBox();
  58. this.edWeight = new System.Windows.Forms.TextBox();
  59. this.btnAssign = new System.Windows.Forms.Button();
  60. this.btnReduce = new System.Windows.Forms.Button();
  61. - this.lbWeightCaption = new System.Windows.Forms.Label();
  62. - this.lbRadiusCaption = new System.Windows.Forms.Label();
  63. + this.lbWeight = new System.Windows.Forms.Label();
  64. + this.lbRadius = new System.Windows.Forms.Label();
  65. this.lvSkinWeights = new System.Windows.Forms.ListView();
  66. - this.columnHeader4 = new System.Windows.Forms.ColumnHeader();
  67. - this.columnHeader5 = new System.Windows.Forms.ColumnHeader();
  68. + this.columnHeader4 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
  69. + this.columnHeader5 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
  70. this.lbSkinWeights = new System.Windows.Forms.Label();
  71. this.tbWeight = new System.Windows.Forms.TrackBar();
  72. this.btnGain = new System.Windows.Forms.Button();
  73. this.tbRadius = new System.Windows.Forms.TrackBar();
  74. this.statusStrip1 = new System.Windows.Forms.StatusStrip();
  75. + this.edPower = new System.Windows.Forms.TextBox();
  76. + this.lbPower = new System.Windows.Forms.Label();
  77. + this.tbPower = new System.Windows.Forms.TrackBar();
  78. this.menuStrip1.SuspendLayout();
  79. this.panel1.SuspendLayout();
  80. ((System.ComponentModel.ISupportInitialize)(this.tbWeight)).BeginInit();
  81. ((System.ComponentModel.ISupportInitialize)(this.tbRadius)).BeginInit();
  82. + ((System.ComponentModel.ISupportInitialize)(this.tbPower)).BeginInit();
  83. this.SuspendLayout();
  84. //
  85. // timer1
  86. @@ -512,18 +516,21 @@
  87. //
  88. // panel1
  89. //
  90. - this.panel1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top |
  91. System.Windows.Forms.AnchorStyles.Bottom)
  92. - | System.Windows.Forms.AnchorStyles.Right)));
  93. + this.panel1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top |
  94. System.Windows.Forms.AnchorStyles.Bottom)
  95. + | System.Windows.Forms.AnchorStyles.Right)));
  96. + this.panel1.Controls.Add(this.edPower);
  97. + this.panel1.Controls.Add(this.lbPower);
  98. + this.panel1.Controls.Add(this.tbPower);
  99. this.panel1.Controls.Add(this.edRadius);
  100. this.panel1.Controls.Add(this.edWeight);
  101. this.panel1.Controls.Add(this.btnAssign);
  102. this.panel1.Controls.Add(this.btnReduce);
  103. this.panel1.Controls.Add(this.lvTSOFiles);
  104. this.panel1.Controls.Add(this.lbTSOFiles);
  105. - this.panel1.Controls.Add(this.lbWeightCaption);
  106. + this.panel1.Controls.Add(this.lbWeight);
  107. this.panel1.Controls.Add(this.lbMeshes);
  108. this.panel1.Controls.Add(this.lvMeshes);
  109. - this.panel1.Controls.Add(this.lbRadiusCaption);
  110. + this.panel1.Controls.Add(this.lbRadius);
  111. this.panel1.Controls.Add(this.lvSkinWeights);
  112. this.panel1.Controls.Add(this.lbSkinWeights);
  113. this.panel1.Controls.Add(this.tbWeight);
  114. @@ -572,21 +579,21 @@
  115. this.btnReduce.UseVisualStyleBackColor = true;
  116. this.btnReduce.Click += new System.EventHandler(this.btnReduce_Click);
  117. //
  118. - // lbWeightCaption
  119. + // lbWeight
  120. //
  121. - this.lbWeightCaption.Location = new System.Drawing.Point(14, 421);
  122. - this.lbWeightCaption.Name = "lbWeightCaption";
  123. - this.lbWeightCaption.Size = new System.Drawing.Size(120, 12);
  124. - this.lbWeightCaption.TabIndex = 6;
  125. - this.lbWeightCaption.Text = "強度";
  126. - //
  127. - // lbRadiusCaption
  128. - //
  129. - this.lbRadiusCaption.Location = new System.Drawing.Point(14, 476);
  130. - this.lbRadiusCaption.Name = "lbRadiusCaption";
  131. - this.lbRadiusCaption.Size = new System.Drawing.Size(120, 12);
  132. - this.lbRadiusCaption.TabIndex = 9;
  133. - this.lbRadiusCaption.Text = "半径";
  134. + this.lbWeight.Location = new System.Drawing.Point(14, 421);
  135. + this.lbWeight.Name = "lbWeight";
  136. + this.lbWeight.Size = new System.Drawing.Size(84, 12);
  137. + this.lbWeight.TabIndex = 6;
  138. + this.lbWeight.Text = "強度";
  139. + //
  140. + // lbRadius
  141. + //
  142. + this.lbRadius.Location = new System.Drawing.Point(14, 476);
  143. + this.lbRadius.Name = "lbRadius";
  144. + this.lbRadius.Size = new System.Drawing.Size(84, 12);
  145. + this.lbRadius.TabIndex = 9;
  146. + this.lbRadius.Text = "半径";
  147. //
  148. // lvSkinWeights
  149. //
  150. @@ -663,6 +670,35 @@
  151. this.statusStrip1.TabIndex = 23;
  152. this.statusStrip1.Text = "statusStrip1";
  153. //
  154. + // edPower
  155. + //
  156. + this.edPower.Location = new System.Drawing.Point(104, 580);
  157. + this.edPower.Name = "edPower";
  158. + this.edPower.Size = new System.Drawing.Size(84, 19);
  159. + this.edPower.TabIndex = 16;
  160. + this.edPower.Text = "1.000";
  161. + this.edPower.TextChanged += new System.EventHandler(this.edPower_TextChanged);
  162. + //
  163. + // lbPower
  164. + //
  165. + this.lbPower.Location = new System.Drawing.Point(14, 583);
  166. + this.lbPower.Name = "lbPower";
  167. + this.lbPower.Size = new System.Drawing.Size(84, 12);
  168. + this.lbPower.TabIndex = 15;
  169. + this.lbPower.Text = "減衰";
  170. + //
  171. + // tbPower
  172. + //
  173. + this.tbPower.AutoSize = false;
  174. + this.tbPower.Location = new System.Drawing.Point(16, 605);
  175. + this.tbPower.Maximum = 40;
  176. + this.tbPower.Name = "tbPower";
  177. + this.tbPower.Size = new System.Drawing.Size(172, 24);
  178. + this.tbPower.TabIndex = 17;
  179. + this.tbPower.TickStyle = System.Windows.Forms.TickStyle.None;
  180. + this.tbPower.Value = 20;
  181. + this.tbPower.ValueChanged += new System.EventHandler(this.tbPower_ValueChanged);
  182. + //
  183. // Form1
  184. //
  185. this.AllowDrop = true;
  186. @@ -674,7 +710,7 @@
  187. this.Controls.Add(this.menuStrip1);
  188. this.MainMenuStrip = this.menuStrip1;
  189. this.Name = "Form1";
  190. - this.Text = "TSOWeight";
  191. + this.Text = "TSOWeitEd";
  192. this.DragDrop += new System.Windows.Forms.DragEventHandler(this.Form1_DragDrop);
  193. this.DragOver += new System.Windows.Forms.DragEventHandler(this.Form1_DragOver);
  194. this.menuStrip1.ResumeLayout(false);
  195. @@ -683,6 +719,7 @@
  196. this.panel1.PerformLayout();
  197. ((System.ComponentModel.ISupportInitialize)(this.tbWeight)).EndInit();
  198. ((System.ComponentModel.ISupportInitialize)(this.tbRadius)).EndInit();
  199. + ((System.ComponentModel.ISupportInitialize)(this.tbPower)).EndInit();
  200. this.ResumeLayout(false);
  201. this.PerformLayout();
  202. @@ -714,8 +751,8 @@
  203. private System.Windows.Forms.Label lbTSOFiles;
  204. private System.Windows.Forms.ListView lvTSOFiles;
  205. private System.Windows.Forms.ColumnHeader columnHeader6;
  206. - private System.Windows.Forms.Label lbWeightCaption;
  207. - private System.Windows.Forms.Label lbRadiusCaption;
  208. + private System.Windows.Forms.Label lbWeight;
  209. + private System.Windows.Forms.Label lbRadius;
  210. private System.Windows.Forms.Button btnGain;
  211. private System.Windows.Forms.TrackBar tbRadius;
  212. private System.Windows.Forms.TrackBar tbWeight;
  213. @@ -753,6 +790,9 @@
  214. private System.Windows.Forms.TextBox edWeight;
  215. private System.Windows.Forms.TextBox edRadius;
  216. private System.Windows.Forms.ToolStripMenuItem editResetPoseToolStripMenuItem;
  217. + private System.Windows.Forms.TextBox edPower;
  218. + private System.Windows.Forms.Label lbPower;
  219. + private System.Windows.Forms.TrackBar tbPower;
  220. }
  221. }
  222. diff -ur TSOWeight\TSOWeight.csproj TSOWeitEd\TSOWeight.csproj
  223. --- TSOWeight\TSOWeight.csproj Fri May 03 08:39:24 2013
  224. +++ TSOWeitEd\TSOWeight.csproj Mon Apr 08 03:26:42 2013
  225. @@ -112,6 +112,9 @@
  226. <Content Include="dot.bmp">
  227. <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
  228. </Content>
  229. + <Content Include="dotweit.bmp">
  230. + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
  231. + </Content>
  232. </ItemGroup>
  233. <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
  234. <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
  235. diff -ur TSOWeight\WeightViewer.cs TSOWeitEd\WeightViewer.cs
  236. --- TSOWeight\WeightViewer.cs Fri May 03 08:39:24 2013
  237. +++ TSOWeitEd\WeightViewer.cs Tue Apr 09 18:56:52 2013
  238. @@ -362,7 +362,7 @@
  239. if (v.selected)
  240. {
  241. - VertexCommand vertex_command = new VertexCommand(sub_mesh, selected_node, v, weight, weight_op);
  242. + VertexCommand vertex_command = new VertexCommand(sub_mesh, selected_node, v, weight * v.factor, weight_op);
  243. if (vertex_command.Execute())
  244. {
  245. @@ -450,6 +450,7 @@
  246. {
  247. internal Mesh sphere = null;
  248. internal Texture dot_texture = null;
  249. + internal Texture dotweit_texture = null;
  250. /// <summary>
  251. /// effect handle for LocalBoneSels
  252. @@ -476,6 +477,12 @@
  253. return Path.Combine(Application.StartupPath, @"dot.bmp");
  254. }
  255. + /// get path to dotweit.bmp
  256. + public static string GetDotWeitBitmapPath()
  257. + {
  258. + return Path.Combine(Application.StartupPath, @"dotweit.bmp");
  259. + }
  260. +
  261. /// <summary>
  262. /// deviceを作成します。
  263. /// </summary>
  264. @@ -499,6 +506,7 @@
  265. sphere = Mesh.Sphere(device, 0.25f, 8, 4);
  266. dot_texture = TextureLoader.FromFile(device, GetDotBitmapPath());
  267. + dotweit_texture = TextureLoader.FromFile(device, GetDotWeitBitmapPath());
  268. handle_LocalBoneSels = effect.GetParameter(null, "LocalBoneSels");
  269. return true;
  270. @@ -1003,14 +1011,28 @@
  271. for (int i = 0; i < sub_mesh.vertices.Length; i++)
  272. {
  273. - if (sub_mesh.vertices[i].selected)
  274. - rect = new Rectangle(8, 8, 7, 7);//yellow
  275. - else
  276. - rect = new Rectangle(0, 0, 7, 7);//red
  277. + Vertex v = sub_mesh.vertices[i];
  278. + int x = 0;
  279. + int y = 0;
  280. + if (v.selected)
  281. + {
  282. + if (v.factor == 1.0f)
  283. + {
  284. + x = 4;
  285. + y = 3;
  286. + }
  287. + else
  288. + {
  289. + int n = (int)(v.factor * 20.0f) % 20;
  290. + x = n % 5;
  291. + y = n / 5;
  292. + }
  293. + }
  294. + rect = new Rectangle(x*8, y*8, 7, 7);
  295. Vector3 p2 = screen_positions[i];
  296. p2.Z = 0.0f;
  297. - sprite.Draw(dot_texture, rect, rect_center, p2, Color.White);
  298. + sprite.Draw(dotweit_texture, rect, rect_center, p2, Color.White);
  299. }
  300. sprite.End();
  301. }
  302. @@ -1022,7 +1044,7 @@
  303. {
  304. Vector3 p2 = screen_positions[i];
  305. p2.Z = 0.0f;
  306. - sprite.Draw(dot_texture, rect, rect_center, p2, Color.White);
  307. + sprite.Draw(dotweit_texture, rect, rect_center, p2, Color.White);
  308. }
  309. sprite.End();
  310. }
  311. @@ -1041,14 +1063,28 @@
  312. if (!ccws[i])
  313. continue;
  314. - if (sub_mesh.vertices[i].selected)
  315. - rect = new Rectangle(8, 8, 7, 7);//yellow
  316. - else
  317. - rect = new Rectangle(0, 0, 7, 7);//red
  318. + Vertex v = sub_mesh.vertices[i];
  319. + int x = 0;
  320. + int y = 0;
  321. + if (v.selected)
  322. + {
  323. + if (v.factor == 1.0f)
  324. + {
  325. + x = 4;
  326. + y = 3;
  327. + }
  328. + else
  329. + {
  330. + int n = (int)(v.factor * 20.0f) % 20;
  331. + x = n % 5;
  332. + y = n / 5;
  333. + }
  334. + }
  335. + rect = new Rectangle(x*8, y*8, 7, 7);
  336. Vector3 p2 = screen_positions[i];
  337. p2.Z = 0.0f;
  338. - sprite.Draw(dot_texture, rect, rect_center, p2, Color.White);
  339. + sprite.Draw(dotweit_texture, rect, rect_center, p2, Color.White);
  340. }
  341. sprite.End();
  342. }
  343. @@ -1063,7 +1099,7 @@
  344. Vector3 p2 = screen_positions[i];
  345. p2.Z = 0.0f;
  346. - sprite.Draw(dot_texture, rect, rect_center, p2, Color.White);
  347. + sprite.Draw(dotweit_texture, rect, rect_center, p2, Color.White);
  348. }
  349. sprite.End();
  350. }
  351. @@ -1174,6 +1210,18 @@
  352. }
  353. }
  354. + float power = 1.000f;
  355. + /// 減衰
  356. + public float Power
  357. + {
  358. + get { return power; }
  359. + set
  360. + {
  361. + power = value;
  362. + SelectVertices();
  363. + }
  364. + }
  365. +
  366. float radius = 0.500f;
  367. /// 半径
  368. public float Radius
  369. @@ -1216,7 +1264,24 @@
  370. //頂点間距離が半径未満なら選択する。
  371. Vector3 p1 = v.CalcSkindeformPosition(clipped_boneMatrices);
  372. - v.selected = Vector3.LengthSq(p1 - center) - radius * radius < float.Epsilon;
  373. + float squared_length = Vector3.LengthSq(p1 - center);
  374. + float squared_radius = radius * radius;
  375. + v.selected = squared_length - squared_radius < float.Epsilon;
  376. + if (v.selected)
  377. + {
  378. + if (squared_radius < float.Epsilon)
  379. + {
  380. + v.factor = 1.0f;
  381. + }
  382. + else
  383. + {
  384. + //半径 1.0f とみなしたときの平方距離を得る
  385. + double len = 1.0 - squared_length / squared_radius;
  386. + //ウェイト乗数
  387. + //半径境界で 0.0f になる
  388. + v.factor = (float)Math.Pow(len, power);
  389. + }
  390. + }
  391. }
  392. }
  393. }
  394. @@ -1729,6 +1794,8 @@
  395. {
  396. if (dot_texture != null)
  397. dot_texture.Dispose();
  398. + if (dotweit_texture != null)
  399. + dotweit_texture.Dispose();
  400. if (sphere != null)
  401. sphere.Dispose();
  402. base.Dispose();
다운로드 Printable view

URL of this paste

Embed with JavaScript

Embed with iframe

Raw text