public void Save(BinaryWriter writer, PSDLFile parent) { for (var i = 0; i < 4; i++) { writer.Write((ushort)parent.GetVertexIndex(Vertices[i])); } }
public void Save(BinaryWriter writer, PSDLFile parent) { writer.Write((ushort)parent.GetFloatIndex(Height)); writer.Write((ushort)parent.GetFloatIndex(TextureScale)); writer.Write((ushort)parent.GetVertexIndex(Vertices[0])); writer.Write((ushort)parent.GetVertexIndex(Vertices[1])); }
public void Read(BinaryReader reader, int subtype, PSDLFile parent) { for (var i = 0; i < 4; i++) { Vertices[i] = parent.Vertices[reader.ReadUInt16()]; } }
public void Read(BinaryReader reader, int subtype, PSDLFile parent) { var numSections = (ushort)subtype; if (numSections == 0) { numSections = reader.ReadUInt16(); } var flagType = reader.ReadByte(); DividerFlags = (DividerFlags)(flagType >> 2); DividerType = (DividerType)(flagType & 3); DividerTexture = reader.ReadByte(); //texture for divider what the f**k Angel!? DividerTextures = new[] { parent.GetTextureFromCache(DividerTexture - 1), parent.GetTextureFromCache(DividerTexture), parent.GetTextureFromCache(DividerTexture + 1), parent.GetTextureFromCache(DividerTexture + 2) }; Value = reader.ReadUInt16(); for (var i = 0; i < numSections * 6; i++) { var vertexIndex = reader.ReadUInt16(); Vertices.Add(parent.Vertices[vertexIndex]); } }
public void Save(BinaryWriter writer, PSDLFile parent) { if (IsJunctionTunnel) { writer.Write((ushort)((JunctionWalls.Count >> 4) + 4)); } writer.Write((ushort)Flags); writer.Write((ushort)(Height * 256f)); writer.Write(Unknown); if (IsJunctionTunnel) { writer.Write(JunctionCeilingBits); //hacky bit copying :( var ba = new BitArray(JunctionWalls.ToArray()); var ret = new byte[(ba.Length - 1) / 8 + 1]; ba.CopyTo(ret, 0); writer.Write(ret); //need padding? if (ret.Length % 2 > 0) { writer.Write((byte)0); } } }
public void Read(BinaryReader reader, int subtype, PSDLFile parent) { Height = parent.Floats[reader.ReadUInt16()]; TextureScale = parent.Floats[reader.ReadUInt16()]; Vertices[0] = parent.Vertices[reader.ReadUInt16()]; Vertices[1] = parent.Vertices[reader.ReadUInt16()]; }
public void Save(BinaryWriter writer, PSDLFile parent) { var subType = Subtype; if (subType == 0) { var bias = 0; if (IsStartCap || IsEndCap) { bias += 1; } bias += (Vertices.Count / 2); writer.Write((ushort)bias); } if (IsStartCap) { writer.Write((ushort)0); writer.Write((ushort)0); } else if (IsEndCap) { writer.Write((ushort)1); writer.Write((ushort)1); } for (var i = 0; i < Vertices.Count; i++) { writer.Write((ushort)parent.GetVertexIndex(Vertices[i])); } }
public void Read(BinaryReader reader, int subtype, PSDLFile parent) { ushort junctionShorts = 0; if (subtype == 0) { IsJunctionTunnel = true; junctionShorts = reader.ReadUInt16(); } Flags = (TunnelFlags)reader.ReadUInt16(); Height = reader.ReadUInt16() / 256f; //case for really old (beta1 and below) psdls //which don't have the other 2 bytes if (subtype != 2) { Unknown = reader.ReadUInt16(); } if (IsJunctionTunnel) { JunctionCeilingBits = reader.ReadUInt16(); var ba = new BitArray(reader.ReadBytes((junctionShorts - 4) * 2)); for (var i = 0; i < ba.Count; i++) { JunctionWalls.Add(ba.Get(i)); } } }
public void Save(BinaryWriter writer, PSDLFile parent) { writer.Write((ushort)parent.GetFloatIndex(BottomHeight)); writer.Write((ushort)parent.GetFloatIndex(TopHeight)); writer.Write(UTiling); writer.Write(VTiling); writer.Write((ushort)parent.GetVertexIndex(Vertices[0])); writer.Write((ushort)parent.GetVertexIndex(Vertices[1])); }
public void Read(BinaryReader reader, int subtype, PSDLFile parent) { BottomHeight = parent.Floats[reader.ReadUInt16()]; TopHeight = parent.Floats[reader.ReadUInt16()]; UTiling = reader.ReadInt16(); VTiling = reader.ReadInt16(); Vertices[0] = parent.Vertices[reader.ReadUInt16()]; Vertices[1] = parent.Vertices[reader.ReadUInt16()]; }
public void Read(BinaryReader reader, int subtype, PSDLFile parent) { var numSections = (ushort)subtype; if (numSections == 0) { numSections = reader.ReadUInt16(); } for (var i = 0; i < numSections * 4; i++) { var vertexIndex = reader.ReadUInt16(); Vertices.Add(parent.Vertices[vertexIndex]); } }
public void Save(BinaryWriter writer, PSDLFile parent) { //write count if applicable var subtype = Subtype; if (subtype == 0) { writer.Write((ushort)(Vertices.Count / 4)); } //write indices for (var i = 0; i < Vertices.Count; i++) { writer.Write((ushort)parent.GetVertexIndex(Vertices[i])); } }
public void Save(BinaryWriter writer, PSDLFile parent) { //write count if applicable var subtype = Subtype; if (subtype == 0) { writer.Write((ushort)(Vertices.Count / 6)); } writer.Write((byte)(((byte)DividerFlags << 2) | (byte)DividerType)); writer.Write(DividerTexture); writer.Write(Value); //write indices for (var i = 0; i < Vertices.Count; i++) { writer.Write((ushort)parent.GetVertexIndex(Vertices[i])); } }
public void Read(BinaryReader reader, int subtype, PSDLFile parent) { var refs = subtype; if (subtype == 0) { refs = reader.ReadUInt16(); } var refList = new ushort[refs * 2]; for (var i = 0; i < refs * 2; i++) { refList[i] = reader.ReadUInt16(); } //cap handling if (refList[0] == 0 && refList[1] == 0) { IsStartCap = true; } else if (refList[0] == 1 && refList[1] == 1) { IsEndCap = true; } //read in Vertices var vertexStart = 0; if (IsEndCap || IsStartCap) { vertexStart = 2; } for (var i = vertexStart; i < refList.Length; i++) { Vertices.Add(parent.Vertices[refList[i]]); } }