當前位置: 首頁>>代碼示例>>C#>>正文


C# TriangleMeshNode.DeserializeNode方法代碼示例

本文整理匯總了C#中Pathfinding.TriangleMeshNode.DeserializeNode方法的典型用法代碼示例。如果您正苦於以下問題:C# TriangleMeshNode.DeserializeNode方法的具體用法?C# TriangleMeshNode.DeserializeNode怎麽用?C# TriangleMeshNode.DeserializeNode使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Pathfinding.TriangleMeshNode的用法示例。


在下文中一共展示了TriangleMeshNode.DeserializeNode方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: DeserializeExtraInfo

		public override void DeserializeExtraInfo (GraphSerializationContext ctx) {
			//NavMeshGraph.DeserializeMeshNodes (this,nodes,bytes);
			
			System.IO.BinaryReader reader = ctx.reader;
			
			tileXCount = reader.ReadInt32();
			
			if (tileXCount < 0) return;
				
			tileZCount = reader.ReadInt32();
			
			tiles = new NavmeshTile[tileXCount * tileZCount];
			
			//Make sure mesh nodes can reference this graph
			TriangleMeshNode.SetNavmeshHolder (ctx.graphIndex, this);
			
			for (int z=0;z<tileZCount;z++) {
				for (int x=0;x<tileXCount;x++) {
					
					int tileIndex = x + z*tileXCount;
					int tx = reader.ReadInt32();
					if (tx < 0) throw new System.Exception ("Invalid tile coordinates (x < 0)");
					
					int tz = reader.ReadInt32();
					if (tz < 0) throw new System.Exception ("Invalid tile coordinates (z < 0)");
					
					// This is not the origin of a large tile. Refer back to that tile.
					if (tx != x || tz != z) {
						tiles[tileIndex] = tiles[tz*tileXCount + tx];
						continue;
					}
					
					NavmeshTile tile = new NavmeshTile ();
					
					tile.x = tx;
					tile.z = tz;
					tile.w = reader.ReadInt32();
					tile.d = reader.ReadInt32();
					tile.bbTree = new BBTree (tile);
					
					tiles[tileIndex] = tile;
					
					int trisCount = reader.ReadInt32 ();
					
					if (trisCount % 3 != 0) throw new System.Exception ("Corrupt data. Triangle indices count must be divisable by 3. Got " + trisCount);
					
					tile.tris = new int[trisCount];
					for (int i=0;i<tile.tris.Length;i++) tile.tris[i] = reader.ReadInt32();
					
					tile.verts = new Int3[reader.ReadInt32()];
					for (int i=0;i<tile.verts.Length;i++) {
						tile.verts[i] = new Int3 (reader.ReadInt32(), reader.ReadInt32(), reader.ReadInt32());
					}
					
					int nodeCount = reader.ReadInt32();
					tile.nodes = new TriangleMeshNode[nodeCount];
					
					//Prepare for storing in vertex indices
					tileIndex <<= TileIndexOffset;
					
					for (int i=0;i<tile.nodes.Length;i++) {
						TriangleMeshNode node = new TriangleMeshNode (active);
						tile.nodes[i] = node;
						node.GraphIndex = (uint)ctx.graphIndex;
						
						node.DeserializeNode (ctx);
						node.v0 = tile.tris[i*3+0] | tileIndex;
						node.v1 = tile.tris[i*3+1] | tileIndex;
						node.v2 = tile.tris[i*3+2] | tileIndex;
						node.UpdatePositionFromVertices();
						
						tile.bbTree.Insert (node);
					}
				}
			}
		}
開發者ID:JoseRego,項目名稱:summer-rush,代碼行數:76,代碼來源:RecastGenerator.cs

示例2: DeserializeExtraInfo

 public override void DeserializeExtraInfo(GraphSerializationContext ctx)
 {
     BinaryReader reader = ctx.reader;
     this.tileXCount = reader.ReadInt32();
     if (this.tileXCount < 0)
     {
         return;
     }
     this.tileZCount = reader.ReadInt32();
     this.tiles = new RecastGraph.NavmeshTile[this.tileXCount * this.tileZCount];
     TriangleMeshNode.SetNavmeshHolder(ctx.graphIndex, this);
     for (int i = 0; i < this.tileZCount; i++)
     {
         for (int j = 0; j < this.tileXCount; j++)
         {
             int num = j + i * this.tileXCount;
             int num2 = reader.ReadInt32();
             if (num2 < 0)
             {
                 throw new Exception("Invalid tile coordinates (x < 0)");
             }
             int num3 = reader.ReadInt32();
             if (num3 < 0)
             {
                 throw new Exception("Invalid tile coordinates (z < 0)");
             }
             if (num2 != j || num3 != i)
             {
                 this.tiles[num] = this.tiles[num3 * this.tileXCount + num2];
             }
             else
             {
                 RecastGraph.NavmeshTile navmeshTile = new RecastGraph.NavmeshTile();
                 navmeshTile.x = num2;
                 navmeshTile.z = num3;
                 navmeshTile.w = reader.ReadInt32();
                 navmeshTile.d = reader.ReadInt32();
                 navmeshTile.bbTree = new BBTree();
                 this.tiles[num] = navmeshTile;
                 int num4 = reader.ReadInt32();
                 if (num4 % 3 != 0)
                 {
                     throw new Exception("Corrupt data. Triangle indices count must be divisable by 3. Got " + num4);
                 }
                 navmeshTile.tris = new int[num4];
                 for (int k = 0; k < navmeshTile.tris.Length; k++)
                 {
                     navmeshTile.tris[k] = reader.ReadInt32();
                 }
                 navmeshTile.verts = new Int3[reader.ReadInt32()];
                 for (int l = 0; l < navmeshTile.verts.Length; l++)
                 {
                     navmeshTile.verts[l] = new Int3(reader.ReadInt32(), reader.ReadInt32(), reader.ReadInt32());
                 }
                 int num5 = reader.ReadInt32();
                 navmeshTile.nodes = new TriangleMeshNode[num5];
                 num <<= 12;
                 for (int m = 0; m < navmeshTile.nodes.Length; m++)
                 {
                     TriangleMeshNode triangleMeshNode = new TriangleMeshNode(this.active);
                     navmeshTile.nodes[m] = triangleMeshNode;
                     triangleMeshNode.DeserializeNode(ctx);
                     triangleMeshNode.v0 = (navmeshTile.tris[m * 3] | num);
                     triangleMeshNode.v1 = (navmeshTile.tris[m * 3 + 1] | num);
                     triangleMeshNode.v2 = (navmeshTile.tris[m * 3 + 2] | num);
                     triangleMeshNode.UpdatePositionFromVertices();
                 }
                 navmeshTile.bbTree.RebuildFrom(navmeshTile.nodes);
             }
         }
     }
 }
開發者ID:GameDiffs,項目名稱:TheForest,代碼行數:72,代碼來源:RecastGraph.cs


注:本文中的Pathfinding.TriangleMeshNode.DeserializeNode方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。