Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            var fact   = new ObjLoaderFactory();
            var loader = fact.Create();

            using (var fs = File.OpenRead(args[0]))
            {
                var res = loader.Load(fs);

                List <Vector3> verts   = new List <Vector3>();
                List <ushort>  indices = new List <ushort>();

                foreach (var vert in res.Vertices)
                {
                    verts.Add(new Vector3(vert.X, vert.Y, vert.Z));
                }
                foreach (var idx in res.Groups[0].Faces)
                {
                    indices.Add((ushort)(idx[0].VertexIndex - 1));
                    indices.Add((ushort)(idx[1].VertexIndex - 1));
                    indices.Add((ushort)(idx[2].VertexIndex - 1));
                }

                HKX2.Builders.hknpCollisionMeshBuilder colBuilder = new HKX2.Builders.hknpCollisionMeshBuilder();
                colBuilder.AddMesh(verts, indices);
                var root = colBuilder.CookCollision();

                using (FileStream s2 = File.Create(args[0] + ".hkx"))
                {
                    BinaryWriterEx bw = new BinaryWriterEx(false, s2);
                    var            s  = new HKX2.PackFileSerializer();
                    s.Serialize(root, bw);
                }
            }
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            var hkxpath = args[0];

            using (FileStream stream = File.OpenRead(hkxpath))
            {
                BinaryReaderEx br   = new BinaryReaderEx(false, stream);
                var            des  = new HKX2.PackFileDeserializer();
                var            root = (hkRootLevelContainer)des.Deserialize(br);

                // Strip some stuff

                /*var v = (hknpPhysicsSceneData)root.m_namedVariants[0].m_variant;
                 * foreach (fsnpCustomParamCompressedMeshShape s in v.m_systemDatas[0].m_referencedObjects)
                 * {
                 *  var bvh = s.m_data.getMeshBVH();
                 *  s.m_triangleIndexToShapeKey = null;
                 *  s.m_pParam = null;
                 *  s.m_edgeWeldingMap.m_primaryKeyToIndex = null;
                 *  s.m_edgeWeldingMap.m_secondaryKeyMask = 0;
                 *  s.m_edgeWeldingMap.m_sencondaryKeyBits = 0;
                 *  s.m_edgeWeldingMap.m_valueAndSecondaryKeys = null;
                 *  s.m_quadIsFlat.m_storage.m_numBits = 0;
                 *  s.m_quadIsFlat.m_storage.m_words = null;
                 *  s.m_triangleIsInterior.m_storage.m_numBits = 0;
                 *  s.m_triangleIsInterior.m_storage.m_words = null;
                 *  s.m_numShapeKeyBits = 0;
                 *  s.m_data.m_meshTree.m_bitsPerKey = 0;
                 *  s.m_data.m_meshTree.m_maxKeyValue = 0;
                 *  s.m_data.m_meshTree.m_bitsPerKey = 0;
                 *  s.m_data.m_meshTree.m_numPrimitiveKeys = 0;
                 *  s.m_data.m_meshTree.m_domain.m_min.W = 1.0f;
                 *  s.m_data.m_meshTree.m_domain.m_max.W = 1.0f;
                 *  s.m_data.m_simdTree.m_nodes = null;
                 *  foreach (var sec in s.m_data.m_meshTree.m_sections)
                 *  {
                 *      sec.m_leafIndex = 0;
                 *      sec.m_flags = 0;
                 *      var sbvh = sec.getSectionBVH();
                 *  }
                 * }*/

                using (FileStream s2 = File.Create(args[1]))
                {
                    BinaryWriterEx bw = new BinaryWriterEx(false, s2);
                    var            s  = new HKX2.PackFileSerializer();
                    s.Serialize(root, bw);
                }
            }
        }
Ejemplo n.º 3
0
 public virtual void Write(PackFileSerializer s, BinaryWriterEx bw)
 {
     m_value.Write(s, bw);
     bw.WriteByte(m_index);
     bw.WriteByte(m_count);
 }
Ejemplo n.º 4
0
 public override void Write(PackFileSerializer s, BinaryWriterEx bw)
 {
     base.Write(s, bw);
     s.WriteStringPointer(bw, m_name);
 }
 public override void Write(PackFileSerializer s, BinaryWriterEx bw)
 {
     base.Write(s, bw);
     s.WriteVector4(bw, m_a);
     s.WriteVector4(bw, m_b);
 }
 public override void Write(PackFileSerializer s, BinaryWriterEx bw)
 {
     base.Write(s, bw);
     s.WriteClassArray <hkpBreakableMultiMaterialInverseMappingDescriptor>(bw, m_descriptors);
     s.WriteUInt32Array(bw, m_subShapeIds);
 }
 public virtual void Write(PackFileSerializer s, BinaryWriterEx bw)
 {
     bw.WriteSingle(m_strength);
     bw.WriteSingle(m_dampingCompression);
     bw.WriteSingle(m_dampingRelaxation);
 }
 public virtual void Write(PackFileSerializer s, BinaryWriterEx bw)
 {
     s.WriteUInt32Array(bw, m_words);
     bw.WriteInt32(m_offset);
     bw.WriteUInt32(0);
 }
 public override void Write(PackFileSerializer s, BinaryWriterEx bw)
 {
     base.Write(s, bw);
     bw.WriteUInt64(0);
 }
 public virtual void Write(PackFileSerializer s, BinaryWriterEx bw)
 {
     bw.WriteSingle(m_restLengths_0);
     bw.WriteSingle(m_restLengths_1);
     bw.WriteSingle(m_restLengths_2);
     bw.WriteSingle(m_restLengths_3);
     bw.WriteSingle(m_restLengths_4);
     bw.WriteSingle(m_restLengths_5);
     bw.WriteSingle(m_restLengths_6);
     bw.WriteSingle(m_restLengths_7);
     bw.WriteSingle(m_restLengths_8);
     bw.WriteSingle(m_restLengths_9);
     bw.WriteSingle(m_restLengths_10);
     bw.WriteSingle(m_restLengths_11);
     bw.WriteSingle(m_restLengths_12);
     bw.WriteSingle(m_restLengths_13);
     bw.WriteSingle(m_restLengths_14);
     bw.WriteSingle(m_restLengths_15);
     bw.WriteSingle(m_stiffnesses_0);
     bw.WriteSingle(m_stiffnesses_1);
     bw.WriteSingle(m_stiffnesses_2);
     bw.WriteSingle(m_stiffnesses_3);
     bw.WriteSingle(m_stiffnesses_4);
     bw.WriteSingle(m_stiffnesses_5);
     bw.WriteSingle(m_stiffnesses_6);
     bw.WriteSingle(m_stiffnesses_7);
     bw.WriteSingle(m_stiffnesses_8);
     bw.WriteSingle(m_stiffnesses_9);
     bw.WriteSingle(m_stiffnesses_10);
     bw.WriteSingle(m_stiffnesses_11);
     bw.WriteSingle(m_stiffnesses_12);
     bw.WriteSingle(m_stiffnesses_13);
     bw.WriteSingle(m_stiffnesses_14);
     bw.WriteSingle(m_stiffnesses_15);
     bw.WriteUInt16(m_particlesA_0);
     bw.WriteUInt16(m_particlesA_1);
     bw.WriteUInt16(m_particlesA_2);
     bw.WriteUInt16(m_particlesA_3);
     bw.WriteUInt16(m_particlesA_4);
     bw.WriteUInt16(m_particlesA_5);
     bw.WriteUInt16(m_particlesA_6);
     bw.WriteUInt16(m_particlesA_7);
     bw.WriteUInt16(m_particlesA_8);
     bw.WriteUInt16(m_particlesA_9);
     bw.WriteUInt16(m_particlesA_10);
     bw.WriteUInt16(m_particlesA_11);
     bw.WriteUInt16(m_particlesA_12);
     bw.WriteUInt16(m_particlesA_13);
     bw.WriteUInt16(m_particlesA_14);
     bw.WriteUInt16(m_particlesA_15);
     bw.WriteUInt16(m_particlesB_0);
     bw.WriteUInt16(m_particlesB_1);
     bw.WriteUInt16(m_particlesB_2);
     bw.WriteUInt16(m_particlesB_3);
     bw.WriteUInt16(m_particlesB_4);
     bw.WriteUInt16(m_particlesB_5);
     bw.WriteUInt16(m_particlesB_6);
     bw.WriteUInt16(m_particlesB_7);
     bw.WriteUInt16(m_particlesB_8);
     bw.WriteUInt16(m_particlesB_9);
     bw.WriteUInt16(m_particlesB_10);
     bw.WriteUInt16(m_particlesB_11);
     bw.WriteUInt16(m_particlesB_12);
     bw.WriteUInt16(m_particlesB_13);
     bw.WriteUInt16(m_particlesB_14);
     bw.WriteUInt16(m_particlesB_15);
 }
Ejemplo n.º 11
0
 public override void Write(PackFileSerializer s, BinaryWriterEx bw)
 {
     base.Write(s, bw);
     s.WriteClassPointerArray <hkxMaterialShader>(bw, m_shaders);
 }
Ejemplo n.º 12
0
 public virtual void Write(PackFileSerializer s, BinaryWriterEx bw)
 {
     bw.WriteByte(0);
 }
 public override void Write(PackFileSerializer s, BinaryWriterEx bw)
 {
     base.Write(s, bw);
     s.WriteClassPointer <hkaSkeleton>(bw, m_skeleton);
 }
 public virtual void Write(PackFileSerializer s, BinaryWriterEx bw)
 {
     bw.WriteUInt32(m_data);
 }
Ejemplo n.º 15
0
 public override void Write(PackFileSerializer s, BinaryWriterEx bw)
 {
     base.Write(s, bw);
     s.WriteClassArray <hkbStateMachineTransitionInfo>(bw, m_transitions);
     bw.WriteUInt64(0);
 }
Ejemplo n.º 16
0
 public override void Write(PackFileSerializer s, BinaryWriterEx bw)
 {
     base.Write(s, bw);
     bw.WriteUInt32(m_bodyIdA);
     bw.WriteUInt32(m_bodyIdB);
 }
Ejemplo n.º 17
0
 public override void Write(PackFileSerializer s, BinaryWriterEx bw)
 {
     base.Write(s, bw);
     s.WriteClassArray <hclObjectSpaceDeformerLocalBlockPNTB>(bw, m_localPNTBs);
     s.WriteClassArray <hclObjectSpaceDeformerLocalBlockUnpackedPNTB>(bw, m_localUnpackedPNTBs);
 }
Ejemplo n.º 18
0
 public virtual void Write(PackFileSerializer s, BinaryWriterEx bw)
 {
     s.WriteVector4(bw, m_min);
     s.WriteVector4(bw, m_max);
 }
 public virtual void Write(PackFileSerializer s, BinaryWriterEx bw)
 {
     s.WriteVector4(bw, m_pivotInA);
     s.WriteVector4(bw, m_pivotInB);
 }
 public virtual void Write(PackFileSerializer s, BinaryWriterEx bw)
 {
     m_min.Write(s, bw);
     m_max.Write(s, bw);
 }
Ejemplo n.º 21
0
 public override void Write(PackFileSerializer s, BinaryWriterEx bw)
 {
     base.Write(s, bw);
     s.WriteClassArray <hkcdDynamicTreeCodecRawUlong>(bw, m_nodes);
     bw.WriteUInt64(m_firstFree);
 }
Ejemplo n.º 22
0
 public virtual void Write(PackFileSerializer s, BinaryWriterEx bw)
 {
     bw.WriteSByte((sbyte)m_type);
 }
 public virtual void Write(PackFileSerializer s, BinaryWriterEx bw)
 {
     bw.WriteUInt32(m_transformSetIndex);
     bw.WriteUInt32(0);
     m_transformSetUsage.Write(s, bw);
 }
Ejemplo n.º 24
0
 public virtual void Write(PackFileSerializer s, BinaryWriterEx bw)
 {
     s.WriteStringPointer(bw, m_name);
     bw.WriteUInt32((uint)m_type);
     bw.WriteUInt32(0);
 }
 public override void Write(PackFileSerializer s, BinaryWriterEx bw)
 {
     base.Write(s, bw);
     m_geometry.Write(s, bw);
     m_cuttingTriangles.Write(s, bw);
 }
 public override void Write(PackFileSerializer s, BinaryWriterEx bw)
 {
     base.Write(s, bw);
     s.WriteClassArray <hkaiAvoidancePairPropertiesPairData>(bw, m_avoidancePairDataMap);
 }
 public override void Write(PackFileSerializer s, BinaryWriterEx bw)
 {
     base.Write(s, bw);
     bw.WriteSingle(m_breakingImpulse);
     bw.WriteUInt32(0);
 }
 public virtual void Write(PackFileSerializer s, BinaryWriterEx bw)
 {
     s.WriteSingleArray(bw, m_data);
     s.WriteClassArray <hkaiIntervalPartitionLibraryPartitionRecord>(bw, m_partitionRecords);
 }
Ejemplo n.º 29
0
 public override void Write(PackFileSerializer s, BinaryWriterEx bw)
 {
     base.Write(s, bw);
     s.WriteVector4(bw, m_translationOut);
     s.WriteQuaternion(bw, m_rotationOut);
 }
Ejemplo n.º 30
0
 public override void Write(PackFileSerializer s, BinaryWriterEx bw)
 {
     base.Write(s, bw);
     s.WriteClassPointer <hkpShape>(bw, m_boundingVolumeShape);
     m_childShape.Write(s, bw);
 }