Inheritance: SceneComponent
        public override void Initialize()
        {
            FSWorld world = Entity.Scene.GetOrCreateSceneComponent <FSWorld>();

            // always sync position ASAP in case any joints are added without global constraints
            if (Body != null)
            {
                ((IUpdatable)this).Update();
            }
            else
            {
                Body = new Body(world, Transform.Position * FSConvert.DisplayToSim, Transform.Rotation);
            }
        }
示例#2
0
        private void CreateBody()
        {
            if (Body != null)
            {
                return;
            }

            FSWorld world = Entity.Scene.GetOrCreateSceneComponent <FSWorld>();

            Body = new Body(world, Transform.Position * FSConvert.DisplayToSim, Transform.Rotation, _bodyDef.BodyType,
                            this)
            {
                LinearVelocity  = _bodyDef.LinearVelocity,
                AngularVelocity = _bodyDef.AngularVelocity,
                LinearDamping   = _bodyDef.LinearDamping,
                AngularDamping  = _bodyDef.AngularDamping,

                IsBullet          = _bodyDef.IsBullet,
                IsSleepingAllowed = _bodyDef.IsSleepingAllowed,
                IsAwake           = _bodyDef.IsAwake,
                Enabled           = Enabled,
                FixedRotation     = _bodyDef.FixedRotation,
                IgnoreGravity     = _bodyDef.IgnoreGravity,
                Mass    = _bodyDef.Mass,
                Inertia = _bodyDef.Inertia
            };

            List <FSCollisionShape> collisionShapes = Entity.GetComponents <FSCollisionShape>();

            for (int i = 0; i < collisionShapes.Count; i++)
            {
                collisionShapes[i].CreateFixture();
            }

            ListPool <FSCollisionShape> .Free(collisionShapes);

            for (int i = 0; i < _joints.Count; i++)
            {
                _joints[i].CreateJoint();
            }
        }
        public override void Initialize()
        {
            FSWorld world = Entity.Scene.GetOrCreateSceneComponent <FSWorld>();

            Body = new Body(world, Transform.Position * FSConvert.DisplayToSim, Transform.Rotation);
        }