private PhyObject SetUpPhyObject(BodyHandle bodyHandle, ObjectState state) { PhyObject phy = GetPhyClass(state.type); phy.Load(bodyHandle, connectionState, this, state); return(phy); }
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); }
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); }
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); }
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); }
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); }
public virtual void OnContact(PhyObject obj) { }
private void OnContact(PhyObject obj) { //phy.Agent.Unlock(); }
public Vehicle(PhyObject obj) { this.obj = obj; reference = obj.GetReference(); }
public PhyObject handleToPhyObject(BodyHandle handle) { PhyObject obj = objectsHandlers[handle]; return(obj); }
public override void OnContact(PhyObject obj) { base.OnContact(obj); ContactListeners?.Invoke(obj); }
public Agent(PhyObject phy) { this.phy = phy; }