Beispiel #1
0
 public override void Serialize(System.IO.Stream stream, bool read)
 {
     if (read)
     {
         System.IO.BinaryReader r = new System.IO.BinaryReader(stream);
         SerializeOrient(stream, read);
         op_type = (TBoolOpType)r.ReadUInt32();
         int op_count = r.ReadInt32();
         for (int i = 0; i < op_count; i++)
         {
             TCSGObjectType type = (TCSGObjectType)r.ReadUInt32();
             TCSGObject     obj  = CreateObj(type);
             obj.Serialize(stream, true);
             AddOperand(obj);
         }
         need_update = true;
     }
     else
     {
         System.IO.BinaryWriter r = new System.IO.BinaryWriter(stream);
         r.Write((UInt32)TCSGObjectType.BOOL_OP);
         SerializeOrient(stream, read);
         r.Write((UInt32)op_type);
         r.Write(operand.Count);
         for (int i = 0; i < operand.Count; i++)
         {
             operand[i].Serialize(stream, false);
         }
     }
 }
Beispiel #2
0
        public TCSGObject CreateObj(TCSGObjectType type)
        {
            switch (type)
            {
            case TCSGObjectType.BOX:
                return(new CSGObjects.TCSGBox(1, 1, 1));

                break;

            case TCSGObjectType.SPHERE:
                return(new CSGObjects.TCSGSphere(1));

                break;

            case TCSGObjectType.CYLINDER:
                return(new CSGObjects.TCSGCylinder(1, 3, 30));

                break;

            case TCSGObjectType.BOOL_OP:
                return(new CSGObjects.TCSGBoolOp());

                break;
            }
            return(null);
        }