private void BuildPatch(Quake3Face quake3Face, BspSubmeshStreams submesh) { var width = quake3Face.sizeX; var height = quake3Face.sizeY; if (width * height != quake3Face.numOfVerts) { throw new BspFormatException("wrong patch point count"); } for (int i = 0; i < width - 1; i += 1) { for (int j = 0; j < height - 1; j += 1) { AddVertexToMesh(quake3Face.vertexIndex + (i) + (j) * width, submesh); AddVertexToMesh(quake3Face.vertexIndex + (i + 1) + (j + 1) * width, submesh); AddVertexToMesh(quake3Face.vertexIndex + (i + 1) + (j) * width, submesh); AddVertexToMesh(quake3Face.vertexIndex + (i) + (j) * width, submesh); AddVertexToMesh(quake3Face.vertexIndex + (i) + (j + 1) * width, submesh); AddVertexToMesh(quake3Face.vertexIndex + (i + 1) + (j + 1) * width, submesh); } } }
protected virtual void ReadFace(ref Quake3Face quake3Face) { quake3Face.texinfo_id = this.Stream.ReadInt32(); quake3Face.effect = this.Stream.ReadInt32(); quake3Face.type = this.Stream.ReadInt32(); if (quake3Face.type > 4) { throw new BspFormatException("Unknown face type " + quake3Face.type); } quake3Face.vertexIndex = this.Stream.ReadInt32(); quake3Face.numOfVerts = this.Stream.ReadInt32(); quake3Face.meshVertIndex = this.Stream.ReadInt32(); quake3Face.numMeshVerts = this.Stream.ReadInt32(); quake3Face.lightmapID = this.Stream.ReadInt32(); quake3Face.lMapCornerX = this.Stream.ReadInt32(); quake3Face.lMapCornerY = this.Stream.ReadInt32(); quake3Face.lMapSizeX = this.Stream.ReadInt32(); quake3Face.lMapSizeY = this.Stream.ReadInt32(); quake3Face.lMapPos.X = this.Stream.ReadSingle(); quake3Face.lMapPos.Y = this.Stream.ReadSingle(); quake3Face.lMapPos.Z = this.Stream.ReadSingle(); quake3Face.lMapBitsetsS.X = this.Stream.ReadSingle(); quake3Face.lMapBitsetsS.Y = this.Stream.ReadSingle(); quake3Face.lMapBitsetsS.Z = this.Stream.ReadSingle(); quake3Face.lMapBitsetsT.X = this.Stream.ReadSingle(); quake3Face.lMapBitsetsT.Y = this.Stream.ReadSingle(); quake3Face.lMapBitsetsT.Z = this.Stream.ReadSingle(); quake3Face.vNormal.X = this.Stream.ReadSingle(); quake3Face.vNormal.Y = this.Stream.ReadSingle(); quake3Face.vNormal.Z = this.Stream.ReadSingle(); quake3Face.sizeX = this.Stream.ReadInt32(); quake3Face.sizeY = this.Stream.ReadInt32(); }