private static void WriteConnectivityCustom2DField(this BinaryWriter writer, LEGOPrimitiveConnectivityCustom2DField custom2DField) { writer.Write(custom2DField.type); writer.Write(custom2DField.width); writer.Write(custom2DField.height); writer.Write(custom2DField.angle); writer.Write(custom2DField.ax); writer.Write(custom2DField.ay); writer.Write(custom2DField.az); writer.Write(custom2DField.tx); writer.Write(custom2DField.ty); writer.Write(custom2DField.tz); writer.Write(custom2DField.Value); }
/// <summary> /// 镜面取反 /// </summary> internal void Mirror() { float num = -this.GeometryBounding.AABB.maxZ; //取Z值最大值,取反,临时变量 this.GeometryBounding.AABB.maxZ = -this.GeometryBounding.AABB.minZ; //最大Z变最小Z this.GeometryBounding.AABB.minZ = num; //最小Z取 临时 //遍历碰撞数组中,储存的所有碰撞类型 foreach (object obj in this.Collision.Items) { if (obj is LEGOPrimitiveCollisionBox)//碰撞盒 { //强转Object,将数据取反 LEGOPrimitiveCollisionBox primitiveCollisionBox = obj as LEGOPrimitiveCollisionBox; primitiveCollisionBox.ax = -primitiveCollisionBox.ax; primitiveCollisionBox.ay = -primitiveCollisionBox.ay; primitiveCollisionBox.tz = -primitiveCollisionBox.tz; } if (obj is LEGOPrimitiveCollisionSphere)//碰撞圆 { LEGOPrimitiveCollisionSphere primitiveCollisionSphere = obj as LEGOPrimitiveCollisionSphere; primitiveCollisionSphere.ax = -primitiveCollisionSphere.ax; primitiveCollisionSphere.ay = -primitiveCollisionSphere.ay; primitiveCollisionSphere.tz = -primitiveCollisionSphere.tz; } } //遍历联通组所有项目 foreach (object obj in this.Connectivity.Items) { if (obj is LEGOPrimitiveConnectivityCustom2DField) { LEGOPrimitiveConnectivityCustom2DField connectivityCustom2Dfield = obj as LEGOPrimitiveConnectivityCustom2DField; connectivityCustom2Dfield.ax = -connectivityCustom2Dfield.ax; connectivityCustom2Dfield.ay = -connectivityCustom2Dfield.ay; connectivityCustom2Dfield.tz = -connectivityCustom2Dfield.tz; } if (obj is LEGOPrimitiveConnectivityAxel) { LEGOPrimitiveConnectivityAxel connectivityAxel = obj as LEGOPrimitiveConnectivityAxel; connectivityAxel.ax = -connectivityAxel.ax; connectivityAxel.ay = -connectivityAxel.ay; connectivityAxel.tz = -connectivityAxel.tz; } if (obj is LEGOPrimitiveConnectivityFixed) { LEGOPrimitiveConnectivityFixed connectivityFixed = obj as LEGOPrimitiveConnectivityFixed; connectivityFixed.ax = -connectivityFixed.ax; connectivityFixed.ay = -connectivityFixed.ay; connectivityFixed.tz = -connectivityFixed.tz; } if (obj is LEGOPrimitiveConnectivityHinge) { LEGOPrimitiveConnectivityHinge connectivityHinge = obj as LEGOPrimitiveConnectivityHinge; connectivityHinge.ax = -connectivityHinge.ax; connectivityHinge.ay = -connectivityHinge.ay; connectivityHinge.tz = -connectivityHinge.tz; } if (obj is LEGOPrimitiveConnectivitySlider) { LEGOPrimitiveConnectivitySlider connectivitySlider = obj as LEGOPrimitiveConnectivitySlider; connectivitySlider.ax = -connectivitySlider.ax; connectivitySlider.ay = -connectivitySlider.ay; connectivitySlider.tz = -connectivitySlider.tz; } if (obj is LEGOPrimitiveConnectivityBall) { LEGOPrimitiveConnectivityBall connectivityBall = obj as LEGOPrimitiveConnectivityBall; connectivityBall.ax = -connectivityBall.ax; connectivityBall.ay = -connectivityBall.ay; connectivityBall.tz = -connectivityBall.tz; } } }