DeserializeNode() public method

public DeserializeNode ( GraphSerializationContext ctx ) : void
ctx Pathfinding.Serialization.GraphSerializationContext
return void
Example #1
0
        public override void DeserializeExtraInfo(GraphSerializationContext ctx)
        {
            uint graphIndex = (uint)ctx.graphIndex;

            TriangleMeshNode.SetNavmeshHolder((int)graphIndex, this);
            int num  = ctx.reader.ReadInt32();
            int num2 = ctx.reader.ReadInt32();

            if (num == -1)
            {
                this.nodes            = new TriangleMeshNode[0];
                this._vertices        = new Int3[0];
                this.originalVertices = new Vector3[0];
            }
            this.nodes            = new TriangleMeshNode[num];
            this._vertices        = new Int3[num2];
            this.originalVertices = new Vector3[num2];
            for (int i = 0; i < num2; i++)
            {
                this._vertices[i]        = new Int3(ctx.reader.ReadInt32(), ctx.reader.ReadInt32(), ctx.reader.ReadInt32());
                this.originalVertices[i] = new Vector3(ctx.reader.ReadSingle(), ctx.reader.ReadSingle(), ctx.reader.ReadSingle());
            }
            this.bbTree = new BBTree();
            for (int j = 0; j < num; j++)
            {
                this.nodes[j] = new TriangleMeshNode(this.active);
                TriangleMeshNode triangleMeshNode = this.nodes[j];
                triangleMeshNode.DeserializeNode(ctx);
                triangleMeshNode.UpdatePositionFromVertices();
            }
            this.bbTree.RebuildFrom(this.nodes);
        }
        public override void DeserializeExtraInfo(GraphSerializationContext ctx)
        {
            uint graphIndex = (uint)ctx.graphIndex;

            TriangleMeshNode.SetNavmeshHolder((int)graphIndex, this);

            int c1 = ctx.reader.ReadInt32();
            int c2 = ctx.reader.ReadInt32();

            if (c1 == -1)
            {
                nodes            = new TriangleMeshNode[0];
                _vertices        = new Int3[0];
                originalVertices = new Vector3[0];
            }

            nodes            = new TriangleMeshNode[c1];
            _vertices        = new Int3[c2];
            originalVertices = new Vector3[c2];

            for (int i = 0; i < c2; i++)
            {
                _vertices[i]        = new Int3(ctx.reader.ReadInt32(), ctx.reader.ReadInt32(), ctx.reader.ReadInt32());
                originalVertices[i] = new Vector3(ctx.reader.ReadSingle(), ctx.reader.ReadSingle(), ctx.reader.ReadSingle());
            }


            for (int i = 0; i < c1; i++)
            {
                nodes[i] = new TriangleMeshNode(active);
                TriangleMeshNode node = nodes[i];
                node.DeserializeNode(ctx);
                node.UpdatePositionFromVertices();
            }
        }
Example #3
0
        public override void DeserializeExtraInfo(GraphSerializationContext ctx)
        {
            uint graphIndex = (uint)base.active.astarData.GetGraphIndex(this);

            TriangleMeshNode.SetNavmeshHolder(0, (int)graphIndex, this);
            int num2 = ctx.reader.ReadInt32();
            int num3 = ctx.reader.ReadInt32();

            if (num2 == -1)
            {
                this.nodes            = new TriangleMeshNode[0];
                this._vertices        = new VInt3[0];
                this.originalVertices = new Vector3[0];
            }
            this.nodes            = new TriangleMeshNode[num2];
            this._vertices        = new VInt3[num3];
            this.originalVertices = new Vector3[num3];
            for (int i = 0; i < num3; i++)
            {
                this._vertices[i]        = new VInt3(ctx.reader.ReadInt32(), ctx.reader.ReadInt32(), ctx.reader.ReadInt32());
                this.originalVertices[i] = new Vector3(ctx.reader.ReadSingle(), ctx.reader.ReadSingle(), ctx.reader.ReadSingle());
            }
            this.bbTree = new BBTree(this);
            for (int j = 0; j < num2; j++)
            {
                this.nodes[j] = new TriangleMeshNode(base.active);
                TriangleMeshNode node = this.nodes[j];
                node.DeserializeNode(ctx);
                node.GraphIndex = graphIndex;
                node.UpdatePositionFromVertices();
                this.bbTree.Insert(node);
            }
        }
Example #4
0
        public override void DeserializeExtraInfo(GraphSerializationContext ctx)
        {
            uint graphIndex = ctx.graphIndex;

            TriangleMeshNode.SetNavmeshHolder((int)graphIndex, this);

            int nodeCount   = ctx.reader.ReadInt32();
            int vertexCount = ctx.reader.ReadInt32();

            if (nodeCount == -1)
            {
                nodes            = new TriangleMeshNode[0];
                _vertices        = new Int3[0];
                originalVertices = new Vector3[0];
                return;
            }

            nodes            = new TriangleMeshNode[nodeCount];
            _vertices        = new Int3[vertexCount];
            originalVertices = new Vector3[vertexCount];

            for (int i = 0; i < vertexCount; i++)
            {
                _vertices[i]        = ctx.DeserializeInt3();
                originalVertices[i] = ctx.DeserializeVector3();
            }

            bbTree = new BBTree();

            for (int i = 0; i < nodeCount; i++)
            {
                nodes[i] = new TriangleMeshNode(active);
                TriangleMeshNode node = nodes[i];
                node.DeserializeNode(ctx);
                node.UpdatePositionFromVertices();
            }

            bbTree.RebuildFrom(nodes);
        }
Example #5
0
		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);
					}
				}
			}
		}
Example #6
0
 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);
             }
         }
     }
 }