private void Write(BinaryWriterEx output) { output.WriteAscii("RTM_0101", 8); Displacement.Write(output); var nFrames = FrameTimes.Length; var nBones = BoneNames.Length; output.Write(nFrames); output.Write(nBones); for (int i = 0; i < nBones; i++) { output.WriteAscii(BoneNames[i], 32); } for (int frame = 0; frame < nFrames; frame++) { output.Write(FrameTimes[frame]); for (int b = 0; b < nBones; b++) { output.WriteAscii(BoneNames[b], 32); FrameTransforms[frame, b].Write(output); } } }
public void Write(BinaryWriterEx output) { var nPoints = Points.Length; var nNormals = Normals.Length; var nFaces = Faces.Length; output.WriteAscii("P3DM", 4); output.Write(28); //headerSize output.Write(Version); output.Write(nPoints); output.Write(nNormals); output.Write(nFaces); output.Write(Flags); for (int i = 0; i < nPoints; ++i) { Points[i].Write(output); } for (int index = 0; index < nNormals; ++index) { Normals[index].Write(output); } for (int index = 0; index < nFaces; ++index) { Faces[index].Write(output); } output.WriteAscii("TAGG", 4); foreach (Tagg tagg in Taggs) { tagg.Write(output); } output.Write(Resolution); }
private void Write(BinaryWriterEx output) { output.WriteAscii("MLOD", 4); output.Write(Version); output.Write(Lods.Length); for (int index = 0; index < Lods.Length; ++index) { Lods[index].Write(output); } }
public void Write(BinaryWriterEx output) { output.WriteAscii("8WVR", 4); output.Write(LandRangeX); output.Write(LandRangeY); output.Write(TerrainRangeX); output.Write(TerrainRangeY); output.Write(CellSize); output.WriteFloats(Elevation); output.WriteUshorts(MaterialIndex); output.Write(MatNames.Length); foreach (var mat in MatNames) { if (!string.IsNullOrEmpty(mat)) { output.WriteAscii32(mat); } output.WriteAscii32(""); } foreach (var obj in Objects) { obj.Write(output); } }
public override void Write(BinaryWriterEx output) { WriteHeader(output); output.WriteAscii(PropertyName, 64); output.WriteAscii(Value, 64); }
public static void WritePAA(BinaryWriterEx writer, ReadOnlyMemory2D <ColorRgba32> image, ColorRgba32 max, ColorRgba32 avg, PAAType type = PAAType.DXT5, PAAFlags flags = PAAFlags.InterpolatedAlpha) { if (type != PAAType.DXT5 && type != PAAType.DXT1) { throw new NotSupportedException(); } var enc = new BCnEncoder.Encoder.BcEncoder(type == PAAType.DXT5 ? CompressionFormat.Bc3 : CompressionFormat.Bc1); var mipmaps = new List <MipmapEncoder>(); var width = image.Width; var height = image.Width; var offset = type == PAAType.DXT5 ? 128 : 112; foreach (var mipmap in enc.EncodeToRawBytes(image)) { if (width > 2 || height > 2) { var menc = new MipmapEncoder(mipmap, width, height, offset); offset += menc.MipmapEntrySize; mipmaps.Add(menc); width = width / 2; height = height / 2; } } writer.Write(type == PAAType.DXT5 ? (ushort)0xff05 : (ushort)0xff01); writer.WriteAscii("GGATCGVA", 8); writer.Write((uint)4); writer.Write(avg.r); writer.Write(avg.g); writer.Write(avg.b); writer.Write(avg.a); writer.WriteAscii("GGATCXAM", 8); writer.Write((uint)4); writer.Write(max.r); writer.Write(max.g); writer.Write(max.b); writer.Write(max.a); if (type == PAAType.DXT5) { writer.WriteAscii("GGATGALF", 8); writer.Write((uint)4); writer.Write((uint)flags); } writer.WriteAscii("GGATSFFO", 8); writer.Write(16 * 4); for (int i = 0; i < 16; ++i) { if (i < mipmaps.Count) { writer.Write((uint)mipmaps[i].Offset); } else { writer.Write((uint)0); } } writer.Write((ushort)0x0000); int index = 0; foreach (var mipmap in mipmaps) { if (writer.Position != mipmap.Offset) { throw new Exception($"Wrong offset @{mipmap.Width} : {writer.Position} != { mipmap.Offset}"); } writer.Write(mipmap.WidthEncoded); writer.Write(mipmap.Height); writer.WriteUInt24((uint)mipmap.PaaData.Length); writer.Write(mipmap.PaaData); index++; width = width / 2; height = height / 2; } writer.Write((uint)0x0000); writer.Write((ushort)0x0000); }