• R/O
  • SSH
  • HTTPS

Commit

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

FreeTrainの進化系を目指す


Commit MetaInfo

Revision34 (tree)
Time2015-03-29 14:45:37
Authorc477

Log Message

調査ツールの地形ポリゴン表示の回転によるズレ修正

Change Summary

Incremental Difference

--- trunk/core/impl/view/SceneBuilder.cs (revision 33)
+++ trunk/core/impl/view/SceneBuilder.cs (revision 34)
@@ -208,15 +208,11 @@
208208 Debug.WriteLine(string.Format("time={0}ms", watch0.ElapsedMilliseconds));
209209 }
210210
211- public IEnumerable<I3DObject> GetTerrainsAt(int gridX, int gridY) {
211+ public IEnumerable<I3DObject> GetTerrainsAt(Location l) {
212212 // 概ね GetEnumerator() のループ内と同じだが、崖のチェックをしない(必ず描画)
213213 InterCardinalDirection dir = UpperDirection;
214214 TerrainMapImpl map = game.TerrainMap;
215215 Size3D sz = map.Size;
216- // terrain assembl loop
217-
218- Point3DV pv = new Point3DV(gridX * Geocon.UnitWidthPixel, gridY * Geocon.UnitWidthPixel, 0);
219- Location l = cdUtil.IsometricGridToLocation(gridX, gridY, 0);
220216 int x = l.X;
221217 int y = l.Y;
222218 if (x < 0 || y < 0 || x >= sz.sx || y >= sz.sy) {
@@ -227,6 +223,8 @@
227223 if (pair == null) {
228224 yield break;
229225 }
226+ //Point3DV pv = new Point3DV(gridX * Geocon.UnitWidthPixel, gridY * Geocon.UnitWidthPixel, 0);
227+ Point3DV pv = cdUtil.LocationToPoint3DV(l);
230228 TerrainPiecePair.ArrangedTerrainPieces atp = pair.GetTerrainPieces(UpperDirection);
231229 ITerrainPlate plate;
232230 int hgap = 0;
@@ -269,21 +267,22 @@
269267 plate.Location = new PointF3D(pv.VX, pv.VY, pv.VZ);
270268 yield return plate;
271269 }
272- // Process Diagonal Cliff
273- cp = atp.CliffDiagonal;
274- hgap = atp.BaseHeightDiagonal * Geocon.UnitHeightPixel;
275- pv.VZ = 0;
276- if (cp == null && hgap > 0) {
277- cp = CliffPolygon.DiagonalUnitCliff;
278- hgap -= Geocon.TerrainStepHeightInUnit;
279- pv.VZ -= Geocon.TerrainStepHeightInUnit;
270+ if (atp.PolygonSets[0].HorzSplitted) {
271+ // Process Diagonal Cliff
272+ cp = atp.CliffDiagonal;
273+ hgap = atp.BaseHeightDiagonal * Geocon.UnitHeightPixel;
274+ pv.VZ = 0;
275+ if (cp == null && hgap > 0) {
276+ cp = CliffPolygon.DiagonalUnitCliff;
277+ hgap -= Geocon.TerrainStepHeightInUnit;
278+ pv.VZ -= Geocon.TerrainStepHeightInUnit;
279+ }
280+ if (cp != null) {
281+ plate = apparents.DefaultCliffTexture.Get(cp, hgap, pv);
282+ plate.Location = new PointF3D(pv.VX, pv.VY, pv.VZ);
283+ yield return plate;
284+ }
280285 }
281- if (cp != null) {
282- plate = apparents.DefaultCliffTexture.Get(cp, hgap, pv);
283- plate.Location = new PointF3D(pv.VX, pv.VY, pv.VZ);
284- yield return plate;
285- }
286-
287286 }
288287
289288 System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() {
--- trunk/core/core/geometry/ViewGeoObjects.cs (revision 33)
+++ trunk/core/core/geometry/ViewGeoObjects.cs (revision 34)
@@ -37,6 +37,11 @@
3737 public int VY;
3838 public int VZ;
3939
40+ /// <summary>
41+ /// Do not called except from CoordinationUtil.
42+ /// ビューの回転が考慮されていないので、CoordinationUtil以外から使わないこと
43+ /// </summary>
44+ /// <param name="src"></param>
4045 internal Point3DV(Location src) {
4146 this.VX = src.X;
4247 this.VY = src.Y;
@@ -49,6 +54,12 @@
4954 this.VZ = src.VZ;
5055 }
5156
57+ public Point3DV(Point3D src) {
58+ this.VX = src.X;
59+ this.VY = src.Y;
60+ this.VZ = src.Z;
61+ }
62+
5263 public Point3DV(int vx, int vy, int vz) {
5364 this.VX = vx;
5465 this.VY = vy;
@@ -63,6 +74,24 @@
6374 /// 位置を持たないことを示す特殊な値
6475 /// </summary>
6576 public static readonly Point3DV UNPLACED = new Point3DV(short.MinValue, short.MinValue, short.MinValue);
77+
78+ #region cast operators for 'nft.framework.drawing' objects.
79+ public static implicit operator Point3DV(Point3D p) {
80+ return new Point3DV(p);
81+ }
82+
83+ public static implicit operator Point3D(Point3DV p) {
84+ return new Point3D(p.VX, p.VY, p.VZ);
85+ }
86+
87+ public static implicit operator PointF3D(Point3DV p) {
88+ return new PointF3D(p.VX, p.VY, p.VZ);
89+ }
90+
91+ public static explicit operator Point3DV(PointF3D p) {
92+ return new Point3DV((int)p.X, (int)p.Y, (int)p.Z);
93+ }
94+ #endregion
6695 }
6796
6897 public class Rect3DV {
@@ -81,6 +110,11 @@
81110 public int WidthY { get{ return size.VY; } }
82111 public int Height { get{ return size.VZ; } }
83112
113+ /// <summary>
114+ /// Do not called except from CoordinationUtil.
115+ /// ビューの回転が考慮されていないので、CoordinationUtil以外から使わないこと
116+ /// </summary>
117+ /// <param name="src"></param>
84118 internal Rect3DV(Rect3D src) {
85119 this.loc = new Point3DV(src.Location);
86120 this.size = new Size3DV(src.Size);
--- trunk/core/core/geometry/CoordinationUtil.cs (revision 33)
+++ trunk/core/core/geometry/CoordinationUtil.cs (revision 34)
@@ -57,6 +57,13 @@
5757 /// </summary>
5858 public abstract Location IsometricGridToLocation(int vx, int vy, int loc_z);
5959
60+ public Location Point3DVToLocation(Point3DV p) {
61+ int ux = p.VX / Geocon.UnitWidthPixel;
62+ int uy = p.VY / Geocon.UnitWidthPixel;
63+ int uz = p.VZ / Geocon.UnitHeightPixel;
64+ return IsometricGridToLocation(ux, uy, uz);
65+ }
66+
6067 /// <summary>
6168 /// Converts the quarter view coordinates(p) to world map location(X,Y,locZ).
6269 /// </summary>
@@ -82,6 +89,19 @@
8289 }
8390
8491 /// <summary>
92+ /// Converts the world map location(X,Y,Z) to 3D world coordination in pixel (not grid).
93+ /// </summary>
94+ /// <param name="loc"></param>
95+ /// <returns></returns>
96+ public Point3DV LocationToPoint3DV(Location loc) {
97+ Point3DV p = RotatedForViewAxis(loc);
98+ p.VX *= Geocon.UnitWidthPixel;
99+ p.VY *= Geocon.UnitWidthPixel;
100+ p.VZ *= Geocon.UnitHeightPixel;
101+ return p;
102+ }
103+
104+ /// <summary>
85105 /// Converts the rotated world map coordinates(X,Y,Z) to quarter view coordinates(X,Y).
86106 /// </summary>
87107 public Point LocationToQuarterXY(Point3DV pt) {
@@ -100,7 +120,7 @@
100120 public abstract PointF LocationToQuarterXY(LocationF loc);
101121
102122 /// <summary>
103- /// Rotate 3D Rectangle along the quarter view pseudo axis.
123+ /// Rotate 3D Rectangle along the quarter view pseudo axis. result is by grid unit.
104124 /// the vertex which point out the Location will re-selected to
105125 /// the one most nearest to the axis origin (0,0,0);
106126 /// Y Axis:Increase from bottom right to top left
@@ -111,7 +131,7 @@
111131 public abstract Rect3DV RotatedForViewAxis(Rect3D rect);
112132
113133 /// <summary>
114- /// Rotate 3D Location along the quarter view pseudo axis.
134+ /// Rotate 3D Location along the quarter view pseudo axis. result is by grid unit.
115135 /// coordination will recalced to be an offset from the front vertex of the world rectangle.
116136 /// Y Axis:Increase from bottom right to top left
117137 /// X Axis:Increase from bottom left to top right
--- trunk/ui_jp/ui/core/InspectorTool.cs (revision 33)
+++ trunk/ui_jp/ui/core/InspectorTool.cs (revision 34)
@@ -11,6 +11,7 @@
1111 using nft.framework.drawing;
1212 using nft.impl.game;
1313 using Geocon = nft.core.geometry.GeometricConstants;
14+using nft.core.geometry;
1415
1516 namespace nft.ui.core
1617 {
@@ -53,11 +54,21 @@
5354 Point pos = args.OriginalEventArgs.Location;
5455 SelectionInfo si = view.SceneBuilder.GetObjectAt(pos);
5556 if (si != null) {
56- if (si.Polygon != null) {
57- lbStatus.Text = String.Format("HT={0:X6},PID={1:X6}", si.HitTestValue, si.Polygon.ID);
57+ StringBuilder sb = new StringBuilder();
58+ sb.AppendLine(String.Format("Location({0},{1}), Height={2}", si.Location.X, si.Location.Y, si.Location.Z));
59+ sb.AppendLine(String.Format("ViewGrid({0:f1},{1:f1},{2:f1})", si.WorldPosition.X / Geocon.UnitWidthPixel, si.WorldPosition.Z / Geocon.UnitWidthPixel, si.WorldPosition.Y / Geocon.UnitHeightPixel));
60+ sb.Append(String.Format("HT={0:X6}", si.HitTestValue));
61+ if (si.TerrainPiece != null) {
62+ sb.Append(String.Format(",TID={0:X6}", si.TerrainPiece.Template.ID));
63+ if (si.Polygon != null) {
64+ sb.AppendLine(String.Format(",PID={0:X6}", si.Polygon.ID));
65+ } else {
66+ sb.AppendLine();
67+ }
5868 } else {
59- lbStatus.Text = String.Format("HT={0:X6},PID=N/A", si.HitTestValue);
69+ sb.AppendLine(",NoTerrain");
6070 }
71+ lbStatus.Text = sb.ToString();
6172 this.renderViewPanel.Surface.Objects = ToRenderObjects(si);
6273 } else {
6374 lbStatus.Text = "N/A";
@@ -66,20 +77,16 @@
6677
6778 protected IEnumerable<I3DObject> ToRenderObjects(SelectionInfo si) {
6879 if (si.TerrainPiece != null) {
69- int x = si.Location.X;
70- int y = si.Location.Y;
80+ Point3DV pv = (Point3DV)si.WorldPosition;
81+ IEnumerable<I3DObject> terrains = si.SceneBuilder.GetTerrainsAt(si.Location);
7182 int h = si.TerrainPiece.BaseHeight * Geocon.UnitHeightPixel;
72- IEnumerable<I3DObject> terrains = si.SceneBuilder.GetTerrainsAt(x, y);
73- x *= Geocon.UnitWidthPixel;
74- y *= Geocon.UnitWidthPixel;
75- PointF3D pt;
83+ PointF3D pt;
7684 foreach (I3DObject obj in terrains) {
7785 ITerrainPlate p = obj as ITerrainPlate;
7886 pt = p.Location;
79- p.Location = new PointF3D(pt.X - x, pt.Y - y, pt.Z - h);
87+ p.Location = new PointF3D(0, 0, pt.Z - h);
8088 yield return p;
8189 }
82-
8390 }
8491 yield break;
8592 }