Ejemplo n.º 1
0
 public static WeldJoint Weld(PhysicsEnt A, PhysicsEnt B)
 {
     return JointFactory.CreateWeldJoint(Engine.Space, A.Body, B.Body, A.Body.LocalCenter, B.Body.LocalCenter);
 }
Ejemplo n.º 2
0
 public static Fixture CreateBoxPhysics(float W, float H, Quantity Density, PhysicsEnt Ent)
 {
     return FixtureFactory.AttachRectangle(W.ToSimUnits(), H.ToSimUnits(), (float)Density.Convert(SI.ρ).Amount,
         new Vector2(), Ent.Body);
 }
Ejemplo n.º 3
0
        public override void OnMouseButton(MouseButtonEventArgs E, bool Pressed)
        {
            Vector2f Point = WorldRT.MapPixelToCoords(new Vector2i(E.X, E.Y), Engine.ActiveCamera);

            if (E.Button == Mouse.Button.Middle) {
                if (Pressed)
                    DraggedEnt = Phys.QueryPointEnt(Point.ToSimUnits());
                else
                    DraggedEnt = null;
                return;
            } else if (E.Button == Mouse.Button.Right && Pressed) {
                Entity Ent = Phys.QueryPointEnt(Point.ToSimUnits());

                if (Ent != null) {
                    Engine.RemoveEntity(Ent);
                } else {
                    PhysicsBox Box = new PhysicsBox();
                    Engine.SpawnEntity(Box);
                    Box.Position = Point;
                }
                return;
            }

            if (E.Button == Mouse.Button.Left && Pressed) {
                if (!HasA) {
                    HasA = true;
                    A = Point;
                } else if (!HasB) {
                    HasB = true;
                    B = Point;
                    if (VA == null) {
                        VA = new VertexArray(PrimType.Lines);
                        VB = new VertexArray(PrimType.Points);
                    }
                    VA.Clear();
                    VA.Append(new Vertex(A, Color.White));
                    VA.Append(new Vertex(B, Color.White));
                } else {
                    HasA = HasB = false;
                }
            }

            if (HasA && HasB && Pressed) {
                PhysicsBox EntA = Phys.QueryPointEnt(A.ToSimUnits()) as PhysicsBox;
                PhysicsBox EntB = Phys.QueryPointEnt(B.ToSimUnits()) as PhysicsBox;

                if (EntA != null && EntB != null && EntA != EntB) {
                    UpdatePhysics = false;
                    EntA.Rect.FillColor = EntB.Rect.FillColor = Color.Cyan;
                    Phys.Weld(EntA, EntB);
                }
            }
        }
Ejemplo n.º 4
0
 public static void CreateBoxPhysics(Quantity W, Quantity H, Quantity Density, PhysicsEnt Ent)
 {
     CreateBoxPhysics((float)W.Convert(SI.px).Amount, (float)H.Convert(SI.px).Amount, Density, Ent);
 }