Exemplo n.º 1
0
        //private readonly Force _torque2Sup = null!;

        public Hinge(float size, PhysicalObject object1, Vector2f object1RelPos,
                     PhysicalObject?object2 = null, Vector2f object2RelPos = default, ForceType?type = null)
            : base(1e8f, 0, size, object1, object1RelPos, object2, object2RelPos, type ?? ForceType.Hinge)
        {
            ShowInfos = false;

            type ??= ForceType.Hinge !;
            _torque1 = new Force(type, new Vector2f(0, 0), new Vector2f(1, 0))
            {
                Source = this
            };
            _torque2 = new Force(type, new Vector2f(0, 0), new Vector2f(-1, 0))
            {
                Source = this
            };
            object1 !.Forces.Add(_torque1);
            object1.Forces.Add(_torque2);
            object1.Hinge = this;

            Force1.OnlyTorque = true;
            if (Force2 != null)
            {
                Force2.OnlyTorque = true;
            }

            Size = size;
        }
Exemplo n.º 2
0
        public PinnedVirtualObject(PhysicalObject @object, Vector2f relPos)
        {
            Object = @object;
            RelPos = relPos;

            if (@object != null)
            {
                DependsOn(@object);
            }
        }
Exemplo n.º 3
0
        public Thruster(PhysicalObject @object, Vector2f relPos, float size, float force = 5, ForceType?type = null)
            : base(@object, relPos)
        {
            Size  = size;
            Force = force;

            _force.Source = this;
            if (type != null)
            {
                _force.Type = type;
            }
            Object.Forces.Add(_force);

            UpdatePhysics(0);
        }
Exemplo n.º 4
0
        public Spring(float constant, float targetLength, float size, PhysicalObject object1, Vector2f object1RelPos,
                      PhysicalObject?object2 = null, Vector2f object2RelPos = default, ForceType?type = null)
        {
            if (object1 == null)
            {
                throw new ArgumentNullException(nameof(object1));
            }

            Constant     = constant;
            TargetLength = targetLength;

            type ??= ForceType.Spring;

            Force1 = new Force(type, new Vector2f(0, 0), object1RelPos)
            {
                Source = this
            };
            End1 = new SpringEnd(object1, object1RelPos, size, this);
            End1.Object.Forces.Add(Force1);
            BothDepends(End1);

            End2 = new SpringEnd(object2, object2RelPos, size, this);

            if (object2 != null)
            {
                Force2 = new Force(type, new Vector2f(0, 0), object2RelPos)
                {
                    Source = this
                };
                End2.Object.Forces.Add(Force2);
            }

            BothDepends(End2);

            Color = Tools.RandomColor();

            UpdateForce();
        }
Exemplo n.º 5
0
 public Fixate(PhysicalObject @object, Vector2f relPos, float size)
     : base(@object, relPos)
 {
     Object.HasFixate = true;
     Size             = size;
 }