Example #1
0
            public override void Write(HKX hkx, HKXSection section, BinaryWriterEx bw, uint sectionBaseOffset, HKXVariation variation)
            {
                SectionOffset = (uint)bw.Position - sectionBaseOffset;
                bw.WriteInt64(0);
                bw.WriteInt64(0);
                bw.WriteByte(Unk10);
                bw.WriteByte(Unk11);
                bw.WriteByte(Unk12);
                bw.WriteByte(Unk13);
                bw.WriteInt32(Unk14);
                bw.WriteInt64(0);
                bw.WriteInt64(0);
                if (variation == HKXVariation.HKXDS3)
                {
                    bw.WriteInt64(0);
                }
                bw.WriteUInt32(0xFFFFFFFF);
                bw.WriteInt32(0);

                bw.WriteUInt64(0);
                bw.WriteUInt32(0);
                bw.WriteUInt32(0x80000000);

                bw.WriteUInt64(0);
                bw.WriteUInt32(0);
                bw.WriteUInt32(0x80000000);

                bw.WriteUInt32(0xFFFFFFFF);
                bw.WriteInt32(0);

                MeshShapeData.WritePlaceholder(bw, sectionBaseOffset);

                Unk68.Write(hkx, section, bw, sectionBaseOffset, variation);
                bw.WriteInt32(Unk78);
                bw.WriteInt32(0);

                Unk80.Write(hkx, section, bw, sectionBaseOffset, variation);
                bw.WriteInt32(Unk90);
                bw.WriteInt32(0);

                bw.WriteUInt64(0);

                CustomParam.WritePlaceholder(bw, sectionBaseOffset);

                UnkA8.Write(hkx, section, bw, sectionBaseOffset, variation);
                if (variation == HKXVariation.HKXDS3)
                {
                    bw.WriteInt64(0);
                }

                DataSize = (uint)bw.Position - sectionBaseOffset - SectionOffset;

                Unk68.WriteReferenceData(hkx, section, bw, sectionBaseOffset, variation);
                Unk80.WriteReferenceData(hkx, section, bw, sectionBaseOffset, variation);
                UnkA8.WriteReferenceData(hkx, section, bw, sectionBaseOffset, variation);
            }
Example #2
0
                internal void WriteValue(BinaryWriterEx bw, object value)
                {
                    switch (Type)
                    {
                    case ParamType.aob: bw.WriteBytes((byte[])value); break;

                    case ParamType.b: bw.WriteBoolean((bool)value); break;

                    case ParamType.u8:
                    case ParamType.x8: bw.WriteByte((byte)value); break;

                    case ParamType.s8: bw.WriteSByte((sbyte)value); break;

                    case ParamType.u16:
                    case ParamType.x16: bw.WriteUInt16((ushort)value); break;

                    case ParamType.s16: bw.WriteInt16((short)value); break;

                    case ParamType.u32:
                    case ParamType.x32: bw.WriteUInt32((uint)value); break;

                    case ParamType.s32: bw.WriteInt32((int)value); break;

                    case ParamType.u64:
                    case ParamType.x64: bw.WriteUInt64((ulong)value); break;

                    case ParamType.s64: bw.WriteInt64((long)value); break;

                    case ParamType.f32: bw.WriteSingle((float)value); break;

                    case ParamType.f64: bw.WriteDouble((double)value); break;

                    default: throw new Exception($"Invalid ParamTemplate ParamType: {Type.ToString()}");
                    }
                }
Example #3
0
            internal void WriteData(BinaryWriterEx bw, int i, int j, List<long> eventHeaderOffsets)
            {
                bw.FillInt64($"EventGroupTypeOffset{i}:{j}", bw.Position);
                bw.WriteUInt64((ulong)Type);
                bw.WriteInt64(0);

                bw.FillInt64($"EventGroupValuesOffset{i}:{j}", bw.Position);
                for (int k = 0; k < Indices.Count; k++)
                    bw.WriteInt32((int)eventHeaderOffsets[Indices[k]]);
                bw.Pad(0x10);
            }
Example #4
0
 // Writes an empty pointer taking into accound the HKX pointer size
 static private void WriteEmptyPointer(HKX hkx, BinaryWriterEx bw)
 {
     if (hkx.Header.PointerSize == 8)
     {
         bw.WriteUInt64(0);
     }
     else
     {
         bw.WriteUInt32(0);
     }
 }
Example #5
0
            public override void Write(HKX hkx, HKXSection section, BinaryWriterEx bw, uint sectionBaseOffset, HKXVariation variation)
            {
                SectionOffset = (uint)bw.Position - sectionBaseOffset;

                WriteEmptyPointer(hkx, bw);
                WriteEmptyPointer(hkx, bw);

                CompressedBVH.Write(hkx, section, bw, sectionBaseOffset, variation);
                bw.WriteVector4(BoundingBoxMin);
                bw.WriteVector4(BoundingBoxMax);

                bw.WriteUInt32(Unk40);
                bw.WriteUInt32(Unk44);
                bw.WriteUInt32(Unk48);
                bw.WriteUInt32(Unk4C);

                Chunks.Write(hkx, section, bw, sectionBaseOffset, variation);
                MeshIndices.Write(hkx, section, bw, sectionBaseOffset, variation);
                VertexIndices.Write(hkx, section, bw, sectionBaseOffset, variation);
                SmallVertices.Write(hkx, section, bw, sectionBaseOffset, variation);
                LargeVertices.Write(hkx, section, bw, sectionBaseOffset, variation);
                UnkA0.Write(hkx, section, bw, sectionBaseOffset, variation);
                bw.WriteUInt64(UnkB0);
                UnkB8.Write(hkx, section, bw, sectionBaseOffset, variation);
                bw.WriteUInt64(UnkC8);

                DataSize = (uint)bw.Position - sectionBaseOffset - SectionOffset;
                CompressedBVH.WriteReferenceData(hkx, section, bw, sectionBaseOffset, variation);
                Chunks.WriteReferenceData(hkx, section, bw, sectionBaseOffset, variation);
                MeshIndices.WriteReferenceData(hkx, section, bw, sectionBaseOffset, variation);
                VertexIndices.WriteReferenceData(hkx, section, bw, sectionBaseOffset, variation);
                SmallVertices.WriteReferenceData(hkx, section, bw, sectionBaseOffset, variation);
                LargeVertices.WriteReferenceData(hkx, section, bw, sectionBaseOffset, variation);
                UnkA0.WriteReferenceData(hkx, section, bw, sectionBaseOffset, variation);
                UnkB8.WriteReferenceData(hkx, section, bw, sectionBaseOffset, variation);
            }
Example #6
0
            public override void Write(HKX hkx, HKXSection section, BinaryWriterEx bw, uint sectionBaseOffset, HKXVariation variation)
            {
                SectionOffset = (uint)bw.Position - sectionBaseOffset;

                WriteEmptyPointer(hkx, bw);
                WriteEmptyPointer(hkx, bw);

                meshTree.Write(hkx, section, bw, sectionBaseOffset, variation);
                bw.WriteVector4(BoundingBoxMin);
                bw.WriteVector4(BoundingBoxMax);

                bw.WriteUInt32(numPrimitiveKeys);
                bw.WriteUInt32(bitsPerKey);
                bw.WriteUInt32(maxKeyValue);
                bw.WriteUInt32(Unk4C);

                sections.Write(hkx, section, bw, sectionBaseOffset, variation);
                primitives.Write(hkx, section, bw, sectionBaseOffset, variation);
                sharedVerticesIndex.Write(hkx, section, bw, sectionBaseOffset, variation);
                packedVertices.Write(hkx, section, bw, sectionBaseOffset, variation);
                sharedVertices.Write(hkx, section, bw, sectionBaseOffset, variation);
                primitiveDataRuns.Write(hkx, section, bw, sectionBaseOffset, variation);
                bw.WriteUInt64(UnkB0);
                simdTree.Write(hkx, section, bw, sectionBaseOffset, variation);
                bw.WriteUInt64(UnkC8);

                DataSize = (uint)bw.Position - sectionBaseOffset - SectionOffset;
                meshTree.WriteReferenceData(hkx, section, bw, sectionBaseOffset, variation);
                sections.WriteReferenceData(hkx, section, bw, sectionBaseOffset, variation);
                primitives.WriteReferenceData(hkx, section, bw, sectionBaseOffset, variation);
                sharedVerticesIndex.WriteReferenceData(hkx, section, bw, sectionBaseOffset, variation);
                packedVertices.WriteReferenceData(hkx, section, bw, sectionBaseOffset, variation);
                sharedVertices.WriteReferenceData(hkx, section, bw, sectionBaseOffset, variation);
                primitiveDataRuns.WriteReferenceData(hkx, section, bw, sectionBaseOffset, variation);
                simdTree.WriteReferenceData(hkx, section, bw, sectionBaseOffset, variation);
            }
Example #7
0
                internal void WriteValue(BinaryWriterEx bw, object value)
                {
                    switch (Type)
                    {
                    case ParamType.aob: bw.WriteBytes((byte[])value); break;

                    case ParamType.b: bw.WriteBoolean((bool)value); break;

                    case ParamType.u8:
                    case ParamType.x8:
                        bw.WriteByte(Convert.ToByte(value)); break;

                    case ParamType.s8:
                        bw.WriteSByte(Convert.ToSByte(value)); break;

                    case ParamType.u16:
                    case ParamType.x16:
                        bw.WriteUInt16(Convert.ToUInt16(value)); break;

                    case ParamType.s16:
                        bw.WriteInt16(Convert.ToInt16(value)); break;

                    case ParamType.u32:
                    case ParamType.x32:
                        bw.WriteUInt32(Convert.ToUInt32(value)); break;

                    case ParamType.s32:
                        bw.WriteInt32(Convert.ToInt32(value)); break;

                    case ParamType.u64:
                    case ParamType.x64:
                        bw.WriteUInt64(Convert.ToUInt64(value)); break;

                    case ParamType.s64:
                        bw.WriteInt64(Convert.ToInt64(value)); break;

                    case ParamType.f32:
                        bw.WriteSingle(Convert.ToSingle(value)); break;

                    case ParamType.f64:
                        bw.WriteDouble(Convert.ToDouble(value)); break;

                    default:
                        throw new Exception($"Invalid ParamTemplate ParamType: {Type.ToString()}");
                    }
                }
Example #8
0
 public override void Write(HKX hkx, HKXSection section, BinaryWriterEx bw, uint sectionBaseOffset, HKXVariation variation)
 {
     // Save new local position for local fixup
     if (Data != null)
     {
         Data.SourceLocalOffset = (uint)bw.Position - SourceObject.SectionOffset - sectionBaseOffset;
     }
     if (hkx.Header.PointerSize == 8)
     {
         bw.WriteUInt64(0); // Pointer placeholder
     }
     else
     {
         bw.WriteUInt32(0);
     }
     bw.WriteUInt32(Size);
     bw.WriteUInt32(Capacity | (((uint)Flags) << 24));
 }
Example #9
0
                internal void WriteDefaultValue(BinaryWriterEx bw)
                {
                    if (ValueToAssert != null)
                    {
                        WriteAssertValue(bw);
                    }
                    else if (DefaultValue == null)
                    {
                        switch (Type)
                        {
                        case ParamType.aob:
                            for (int i = 0; i < AobLength; i++)
                            {
                                bw.WriteByte(0);
                            }
                            break;

                        case ParamType.b:
                        case ParamType.u8:
                        case ParamType.x8: bw.WriteByte(0); break;

                        case ParamType.s8: bw.WriteSByte(0); break;

                        case ParamType.u16:
                        case ParamType.x16: bw.WriteUInt16(0); break;

                        case ParamType.s16: bw.WriteInt16(0); break;

                        case ParamType.u32:
                        case ParamType.x32: bw.WriteUInt32(0); break;

                        case ParamType.s32: bw.WriteInt32(0); break;

                        case ParamType.u64:
                        case ParamType.x64: bw.WriteUInt64(0); break;

                        case ParamType.s64: bw.WriteInt64(0); break;

                        case ParamType.f32: bw.WriteSingle(0); break;

                        case ParamType.f64: bw.WriteDouble(0); break;

                        default: throw new Exception($"Invalid ParamTemplate ParamType: {Type.ToString()}");
                        }
                    }
                    else
                    {
                        switch (Type)
                        {
                        case ParamType.aob:
                            var assertAob = (byte[])DefaultValue;
                            bw.WriteBytes(assertAob);
                            break;

                        case ParamType.b:
                        case ParamType.u8:
                        case ParamType.x8: bw.WriteByte((byte)DefaultValue); break;

                        case ParamType.s8: bw.WriteSByte((sbyte)DefaultValue); break;

                        case ParamType.u16:
                        case ParamType.x16: bw.WriteUInt16((ushort)DefaultValue); break;

                        case ParamType.s16: bw.WriteInt16((short)DefaultValue); break;

                        case ParamType.u32:
                        case ParamType.x32: bw.WriteUInt32((uint)DefaultValue); break;

                        case ParamType.s32: bw.WriteInt32((int)DefaultValue); break;

                        case ParamType.u64:
                        case ParamType.x64: bw.WriteUInt64((ulong)DefaultValue); break;

                        case ParamType.s64: bw.WriteInt64((long)DefaultValue); break;

                        case ParamType.f32: bw.WriteSingle((float)DefaultValue); break;

                        case ParamType.f64: bw.WriteDouble((double)DefaultValue); break;

                        default: throw new Exception($"Invalid ParamTemplate ParamType: {Type.ToString()}");
                        }
                    }
                }
Example #10
0
 public override void Write(HKX hkx, HKXSection section, BinaryWriterEx bw, uint sectionBaseOffset, HKXVariation variation)
 {
     bw.WriteUInt64(vertex);
 }