예제 #1
0
        public static OSD ObjectPhysicsProperties(ISceneChildEntity[] entities)
        {
            ObjectPhysicsPropertiesMessage message = new ObjectPhysicsPropertiesMessage();
#if (!ISWIN)
            int i = 0;
            foreach (ISceneChildEntity entity in entities)
            {
                if (entity != null) i++;
            }
#else
            int i = entities.Count(entity => entity != null);
#endif

            message.ObjectPhysicsProperties = new Primitive.PhysicsProperties[i];
            i = 0;
#if (!ISWIN)
            foreach (ISceneChildEntity entity in entities)
            {
                if (entity != null)
                {
                    message.ObjectPhysicsProperties[i] = new Primitive.PhysicsProperties
                                                             {
                                                                 Density = entity.Density,
                                                                 Friction = entity.Friction,
                                                                 GravityMultiplier = entity.GravityMultiplier,
                                                                 LocalID = entity.LocalId,
                                                                 PhysicsShapeType =
                                                                     (PhysicsShapeType) entity.PhysicsType,
                                                                 Restitution = entity.Restitution
                                                             };
                    i++;
                }
            }
#else
            foreach (ISceneChildEntity entity in entities.Where(entity => entity != null))
            {
                message.ObjectPhysicsProperties[i] = new Primitive.PhysicsProperties
                                                         {
                                                             Density = entity.Density,
                                                             Friction = entity.Friction,
                                                             GravityMultiplier = entity.GravityMultiplier,
                                                             LocalID = entity.LocalId,
                                                             PhysicsShapeType = (PhysicsShapeType) entity.PhysicsType,
                                                             Restitution = entity.Restitution
                                                         };
                i++;
            }
#endif

            OSDMap m = new OSDMap {{"message", OSD.FromString("ObjectPhysicsProperties")}};
            OSD message_body = message.Serialize();
            m.Add("body", message_body);
            return m;
        }