public virtual string Serialize(IntPtr dataBuffer, Serializer serializer)
		{
            return Marshal.PtrToStringAnsi(btCollisionShape_serialize(_native, dataBuffer, serializer._native));
            /*
            IntPtr name = serializer.FindNameForPointer(_native);
            IntPtr namePtr = serializer.GetUniquePointer(name);
            Marshal.WriteIntPtr(dataBuffer, namePtr);
            if (namePtr != IntPtr.Zero)
            {
                serializer.SerializeName(name);
            }
            Marshal.WriteInt32(dataBuffer, IntPtr.Size, (int)ShapeType);
            //Marshal.WriteInt32(dataBuffer, IntPtr.Size + sizeof(int), 0); //padding
            return "btCollisionShapeData";
            */
		}
        private unsafe void SerializeDynamicsWorldInfo(Serializer serializer)
        {
            int len = 88;
            Chunk chunk = serializer.Allocate((uint)len, 1);

            using (UnmanagedMemoryStream stream = new UnmanagedMemoryStream((byte*)chunk.OldPtr.ToPointer(), len, len, FileAccess.Write))
            {
                using (BinaryWriter writer = new BinaryWriter(stream))
                {
                    ContactSolverInfo solverInfo = SolverInfo;
                    writer.Write(solverInfo.Tau);
                    writer.Write(solverInfo.Damping);
                    writer.Write(solverInfo.Friction);
                    writer.Write(solverInfo.TimeStep);

                    writer.Write(solverInfo.Restitution);
                    writer.Write(solverInfo.MaxErrorReduction);
                    writer.Write(solverInfo.Sor);
                    writer.Write(solverInfo.Erp);

                    writer.Write(solverInfo.Erp2);
                    writer.Write(solverInfo.GlobalCfm);
                    writer.Write(solverInfo.SplitImpulsePenetrationThreshold);
                    writer.Write(solverInfo.SplitImpulseTurnErp);

                    writer.Write(solverInfo.LinearSlop);
                    writer.Write(solverInfo.WarmStartingFactor);
                    writer.Write(solverInfo.MaxGyroscopicForce);
                    writer.Write(solverInfo.SingleAxisRollingFrictionThreshold);

                    writer.Write(solverInfo.NumIterations);
                    writer.Write((int)solverInfo.SolverMode);
                    writer.Write(solverInfo.RestingContactRestitutionThreshold);
                    writer.Write(solverInfo.MinimumSolverBatchSize);

                    writer.Write(solverInfo.SplitImpulse);
                    writer.Write((int)0); // padding
                }
            }

            serializer.FinalizeChunk(chunk, "btDynamicsWorldFloatData", DnaID.DynamicsWorld, chunk.OldPtr);
        }
        void SerializeRigidBodies(Serializer serializer)
        {
            foreach (CollisionObject colObj in CollisionObjectArray)
            {
                if (colObj.InternalType == CollisionObjectTypes.RigidBody)
                {
                    int len = colObj.CalculateSerializeBufferSize();
                    Chunk chunk = serializer.Allocate((uint)len, 1);
                    string structType = colObj.Serialize(chunk.OldPtr, serializer);
                    serializer.FinalizeChunk(chunk, structType, DnaID.RigidBody, colObj._native);
                }
            }

            for (int i = 0; i < NumConstraints; i++)
            {
                TypedConstraint constraint = GetConstraint(i);
                int len = constraint.CalculateSerializeBufferSize();
                Chunk chunk = serializer.Allocate((uint)len, 1);
                string structType = constraint.Serialize(chunk.OldPtr, serializer);
                serializer.FinalizeChunk(chunk, structType, DnaID.Constraint, constraint._native);
            }
        }
 public void SerializeSingleObject(Serializer serializer)
 {
     btCollisionObject_serializeSingleObject(_native, serializer._native);
 }
 public string Serialize(IntPtr dataBuffer, Serializer serializer)
 {
     return Marshal.PtrToStringAnsi(btCollisionObject_serialize(_native, dataBuffer, serializer._native));
 }
 public void SerializeSingleShape(Serializer serializer)
 {
     int len = CalculateSerializeBufferSize();
     Chunk chunk = serializer.Allocate((uint)len, 1);
     string structType = Serialize(chunk.OldPtr, serializer);
     serializer.FinalizeChunk(chunk, structType, DnaID.Shape, _native);
 }
 public override void Serialize(Serializer serializer)
 {
     serializer.StartSerialization();
     SerializeDynamicsWorldInfo(serializer);
     SerializeCollisionObjects(serializer);
     SerializeRigidBodies(serializer);
     serializer.FinishSerialization();
 }
 public void SerializeSingleTriangleInfoMap(Serializer serializer)
 {
     btBvhTriangleMeshShape_serializeSingleTriangleInfoMap(_native, serializer._native);
 }
 public void SerializeSingleBvh(Serializer serializer)
 {
     btBvhTriangleMeshShape_serializeSingleBvh(_native, serializer._native);
 }
Beispiel #10
0
 public string Serialize(IntPtr dataBuffer, Serializer serializer)
 {
     return(Marshal.PtrToStringAnsi(btCollisionObject_serialize(Native, dataBuffer, serializer.Native)));
 }
 public string Serialize(IntPtr dataBuffer, Serializer serializer)
 {
     return Marshal.PtrToStringAnsi(btMultiBody_serialize(_native, dataBuffer, serializer._native));
 }
 /*
 public void DeSerialize(TriangleInfoMapData data)
 {
     btTriangleInfoMap_deSerialize(_native, data._native);
 }
 */
 public string Serialize(IntPtr dataBuffer, Serializer serializer)
 {
     return Marshal.PtrToStringAnsi(btTriangleInfoMap_serialize(_native, dataBuffer, serializer._native));
 }
		public virtual void Serialize(Serializer serializer)
		{
            serializer.StartSerialization();
            SerializeCollisionObjects(serializer);
            serializer.FinishSerialization();
		}
        protected void SerializeCollisionObjects(Serializer serializer)
        {
	        // keep track of shapes already serialized
            var serializedShapes = new Dictionary<CollisionShape, int>();

            foreach (var colObj in CollisionObjectArray)
            {
                var shape = colObj.CollisionShape;
                if (!serializedShapes.ContainsKey(shape))
                {
                    serializedShapes.Add(shape, 0);
                    shape.SerializeSingleShape(serializer);
                }
            }

            // serialize all collision objects
            foreach (var colObj in CollisionObjectArray)
            {
                if (colObj.InternalType == CollisionObjectTypes.CollisionObject)
                {
                    colObj.SerializeSingleObject(serializer);
                }
            }
        }
 public string Serialize(IntPtr dataBuffer, Serializer serializer)
 {
     return Marshal.PtrToStringAnsi(btStridingMeshInterface_serialize(_native, dataBuffer, serializer._native));
 }
 public string Serialize(IntPtr dataBuffer, Serializer serializer)
 {
     return Marshal.PtrToStringAnsi(btTypedConstraint_serialize(_native, dataBuffer, serializer._native));
 }
 public string Serialize(IntPtr dataBuffer, Serializer serializer)
 {
     return Marshal.PtrToStringAnsi(btQuantizedBvh_serialize2(_native, dataBuffer, serializer._native));
 }
Beispiel #18
0
 public void SerializeSingleObject(Serializer serializer)
 {
     btCollisionObject_serializeSingleObject(_native, serializer._native);
 }