예제 #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;
 }