Пример #1
0
        private PhyObject SetUpPhyObject(BodyHandle bodyHandle, ObjectState state)
        {
            PhyObject phy = GetPhyClass(state.type);

            phy.Load(bodyHandle, connectionState, this, state);

            return(phy);
        }
Пример #2
0
        private void createFloor()
        {
            // Simulation.Statics.Add(new StaticDescription(new Vector3(0, -0.5f, 0), new CollidableDescription(Simulation.Shapes.Add(new Box(5000, 1, 5000)), 0.1f)));
            BoxState box = new BoxState();

            box.position   = new Vector3(0, 0, 0);
            box.uID        = PhyObject.createUID();
            box.mass       = 0;
            box.quaternion = Quaternion.Identity;
            box.type       = "QuixBox";
            box.halfSize   = new Vector3(5000, 1, 5000);

            // Create(box);
        }
Пример #3
0
        private void CreateNewt()
        {
            BoxState state = new BoxState();

            state.position    = new Vector3(0, 140, 160);
            state.halfSize    = new Vector3(10, 10, 10);
            state.quaternion  = Quaternion.Identity;
            state.mass        = 0;
            state.uID         = PhyObject.createUID();
            state.type        = "QuixBox";
            state.instantiate = true;
            state.mesh        = "Tiles/test";

            // CreateMesh(state);
        }
Пример #4
0
        private PhyObject GetPhyClass(string name)
        {
            System.Type t   = System.Type.GetType("QuixPhysics." + name + ", QuixPhysics");
            PhyObject   phy = null;

            if (t != null)
            {
                phy = (PhyObject)Activator.CreateInstance(t);
            }
            else
            {
                phy = new PhyObject();
            }
            return(phy);
        }
Пример #5
0
        public PhyObject Create(ObjectState state)
        {
            PhyObject phy = null;

            if (state.uID == null || objects.ContainsKey(state.uID))
            {
                state.uID = PhyObject.createUID();
            }
            if (state is BoxState)
            {
                if (state.isMesh)
                {
                    phy = CreateMesh((BoxState)state);
                }
                else
                {
                    phy = CreateBox((BoxState)state);
                }
            }
            if (state is SphereState)
            {
                phy = CreateSphere((SphereState)state);
            }

            if (phy.material == default(SimpleMaterial))
            {
                collidableMaterials.Allocate(phy.bodyHandle) = new SimpleMaterial
                {
                    FrictionCoefficient     = .1f,
                    MaximumRecoveryVelocity = float.MaxValue,
                    SpringSettings          = new SpringSettings(1f, 1.5f)
                };
            }

            if (!objects.ContainsKey(state.uID))
            {
                objects.Add(state.uID, phy);
            }
            else
            {
                QuixConsole.WriteLine("Objects already had that key");
            }
            return(phy);
        }
Пример #6
0
        internal void createObjects()
        {
            int width   = 10;
            int sizeObj = 60;

            for (int a = 0; a < boxToCreate; a++)
            {
                var box = new SphereState();
                box.uID  = PhyObject.createUID();
                box.uID += "" + a;
                box.mass = 10;
                box.type = "Bomb";
                // box.instantiate = false;

                int x = a % width;    // % is the "modulo operator", the remainder of i / width;
                int y = a / width;    // where "/" is an integer division
                box.position    = new Vector3(x * sizeObj, 1050 + (timesPressedCreateBoxes * sizeObj), y * sizeObj);
                box.radius      = 10;
                box.mesh        = "Board/Bomb";
                box.instantiate = true;
                box.quaternion  = Quaternion.Identity;
                var b = Create(box);

                /* int x = a % width;    // % is the "modulo operator", the remainder of i / width;
                 * int y = a / width;    // where "/" is an integer division
                 * var ringBoxShape = new Box(1, 1, 1);
                 * ringBoxShape.ComputeInertia(1, out var ringBoxInertia);
                 * var boxDescription = BodyDescription.CreateDynamic(new Vector3(), ringBoxInertia,
                 *                new CollidableDescription(Simulation.Shapes.Add(ringBoxShape), 0.1f),
                 *                new BodyActivityDescription(0.01f));
                 * new BodyActivityDescription(0.01f);
                 *
                 * boxDescription.Pose = new RigidPose(new Vector3(x,300,y), Quaternion.Identity);
                 * Simulation.Bodies.Add(boxDescription);*/
            }
            timesPressedCreateBoxes++;
            // Console.WriteLine("Statics size " + Simulation.Statics.Count);
        }
Пример #7
0
 public virtual void OnContact(PhyObject obj)
 {
 }
Пример #8
0
 private void OnContact(PhyObject obj)
 {
     //phy.Agent.Unlock();
 }
Пример #9
0
 public Vehicle(PhyObject obj)
 {
     this.obj  = obj;
     reference = obj.GetReference();
 }
Пример #10
0
        public PhyObject handleToPhyObject(BodyHandle handle)
        {
            PhyObject obj = objectsHandlers[handle];

            return(obj);
        }
Пример #11
0
 public override void OnContact(PhyObject obj)
 {
     base.OnContact(obj);
     ContactListeners?.Invoke(obj);
 }
Пример #12
0
 public Agent(PhyObject phy)
 {
     this.phy = phy;
 }