public override void UserProcess(MogreNewt.ContactJoint contact, float timestep, int threadIndex) { //contact.Body0.AddForce(-contact.Body0.Velocity * new Mogre.Vector3(1, 0, 1) * 400 * contact.Body0.Mass); //contact.Body1.AddForce(-contact.Body1.Velocity * new Mogre.Vector3(1, 0, 1) * 400 * contact.Body1.Mass); return; }
public override bool UserCallback(MogreNewt.Body body, float distance, Vector3 normal, int collisionID) { ContactInfo contact = new ContactInfo(); contact.Distance = distance; contact.Body = body; contact.Normal = normal; Contacts.Add(contact); return true; }
public override void UserProcess(MogreNewt.ContactJoint contact, float timestep, int threadIndex) { if ( contact.Body0.Type == (int)PhysicsManager.BodyTypes.TRIGGER ) { Tachycardia.Objects.Actions.BaseAction action = (Tachycardia.Objects.Actions.BaseAction)contact.Body0.UserData; action.Go(); } else if ( contact.Body1.Type == (int)PhysicsManager.BodyTypes.TRIGGER ) { Tachycardia.Objects.Trigger _this = (Tachycardia.Objects.Trigger)contact.Body1.UserData; _this.m_action.Go(); } return; }
//position buffor /* public override void BodyTransformCallback(MogreNewt.Body sender, Mogre.Quaternion orientation, Mogre.Vector3 position, int threadIndex) {//calling each physics iteration //odczytywac ze stanu wysokosc kamery m_PlayerNode.Position = position + _position; //obracanie zgodnie z kierunkiem ruchu lub jezeli 0 to z kierunkiem goto if(m_MainBody.Velocity.Length < 0.1f) { m_State = CharacterState.IDLE; m_PlayerNode.Orientation = m_GoTo; } else { if (m_Pose == m_myPoses["normal"]) { if (m_MainBody.Velocity.Length > 3.5) m_State = CharacterState.RUN; else m_State = CharacterState.WALK; } else if (m_Pose == m_myPoses["fly"]) { m_State = CharacterState.JUMP; } Mogre.Vector3 xyVector = new Mogre.Vector3(0,0,1); Mogre.Vector3 velocityxy = m_MainBody.Velocity * new Mogre.Vector3(1,0,1); m_PlayerNode.Orientation = xyVector.GetRotationTo(velocityxy); } } */ public override void BodyForceCallback(MogreNewt.Body body, float timeStep, int threadIndex) { //calling each physics iteration //jezeli niedawno skoczyl to obniz //to zmiany bo jak zeskoczymy z czegos to nadal mozna bedzie podskoczycz lecac if (m_jumpLimit > 0) m_jumpLimit--; if (m_adrenaline > 1) m_adrenaline -= 0.01f * timeStep; else m_adrenaline = 1; Update(); }
public ForceBall(SceneManager sceneManager, MogreNewt.World physicsWorld, float tempSize, int own) { MogreNewt.ConvexCollision col; Mogre.Vector3 offset; Mogre.Vector3 inertia; unique++; // Create the visible mesh (no physics) ent = sceneManager.CreateEntity("forceball" + unique, "Sph.mesh"); sn = sceneManager.RootSceneNode.CreateChildSceneNode(); sn.AttachObject(ent); Console.WriteLine("end ball create"); size = tempSize; sn.SetScale(size, size, size); // Create the collision hull col = new MogreNewt.CollisionPrimitives.ConvexHull(physicsWorld, sn); col.calculateInertialMatrix(out inertia, out offset); // Create the physics body. This body is what you manipulate. The graphical Ogre scenenode is automatically synced with the physics body body = new MogreNewt.Body(physicsWorld, col); col.Dispose(); //body.setPositionOrientation(new Vector3(0, 10, 0), Quaternion.IDENTITY); body.attachToNode(sn); body.setContinuousCollisionMode(1); body.setMassMatrix(mass, mass * inertia); body.IsGravityEnabled = true; body.setUserData(this); trail = sceneManager.CreateParticleSystem("awesome" + StringConverter.ToString(unique), "Char/Smoke"); trail.CastShadows = true; trail.GetEmitter(0).EmissionRate = 100; sn.AttachObject(trail); Console.WriteLine("player stuff"); owner = own; Player tempP = (Player)Program.p1; colour = tempP.cv; }
public override void UserProcess(MogreNewt.ContactJoint contact, float timestep, int threadIndex) { if (contact.Body0.Type == (int)PhysicsManager.BodyTypes.PLAYER || contact.Body0.Type == (int)PhysicsManager.BodyTypes.NPC) { Tachycardia.PlayerController controler = (Tachycardia.PlayerController)contact.Body0.UserData; if (controler != null) { if (controler.m_Pose.m_name == "fly" && controler.m_jumpLimit < Core.m_FixedFPS / 2) { if (controler.m_MainBody.Velocity.y < -8) killtest( controler.m_MainBody.Position ); controler.ChangePoseTo("normal"); Console.WriteLine(controler.m_Pose.m_name); } controler.m_Onground = 0; } } else if (contact.Body1.Type == (int)PhysicsManager.BodyTypes.PLAYER || contact.Body1.Type == (int)PhysicsManager.BodyTypes.NPC) { Tachycardia.PlayerController controler = (Tachycardia.PlayerController)contact.Body1.UserData; if (controler != null) { if (controler.m_Pose.m_name == "fly" && controler.m_jumpLimit < Core.m_FixedFPS / 2) { if (controler.m_MainBody.Velocity.y < -8) killtest( controler.m_MainBody.Position ); controler.ChangePoseTo("normal"); Console.WriteLine(controler.m_Pose.m_name); } controler.m_Onground = 0; } } return; }
public override void UserProcess(MogreNewt.ContactJoint contact, float timestep, int threadIndex) { System.Console.WriteLine("metal metal kolizja: "); return; }
public void CallBack(MogreNewt.Body body, float tomeStep, int index) { ElevatorControl(); body.AddForce(new Vector3(0f, m_Direction * 3f, 0f) * body.Mass); }
//position buffor public virtual void BodyTransformCallback(MogreNewt.Body sender, Mogre.Quaternion orientation, Mogre.Vector3 position, int threadIndex) { //calling each physics iteration //odczytywac ze stanu wysokosc kamery m_PlayerNode.Position = position + m_Pose.m_HeadPosition; //obracanie zgodnie z kierunkiem ruchu lub jezeli 0 to z kierunkiem goto if (m_MainBody.Velocity.Length < 0.1f) { m_State = CharacterState.IDLE; } else { if (m_Pose.m_name == "normal") { if (m_MainBody.Velocity.Length > 3.5) m_State = CharacterState.RUN; else m_State = CharacterState.WALK; } else if (m_Pose.m_name == "fly") { m_State = CharacterState.JUMP; } if (!m_bBackward) {//dla wstecznego Mogre.Vector3 velocityxy = m_MainBody.Velocity * new Mogre.Vector3(1, 0, 1); m_PlayerNode.Orientation = Mogre.Vector3.UNIT_Z.GetRotationTo(velocityxy); } } }
public virtual void BodyForceCallback(MogreNewt.Body body, float timeStep, int threadIndex) { //calling each physics iteration //testuje jak dawno dotykal gruntu jezeli wartosc przekracza 5 lub 10 iteracji fiyzki //zmienia pozycje na lot if (m_Onground < 10) m_Onground++; else//jest w locie - zmieniamy mu stan ChangePoseTo("fly"); if (m_jumpLimit > 0) m_jumpLimit--; //obnizanie poziomu adrenaliny o staly czynnik if (m_adrenaline > 1) m_adrenaline -= 0.01f * timeStep; else m_adrenaline = 1; Update(); //trying to stop body in one position if (!m_bBackward && !m_bForward && !m_bLeft && !m_bRight) { if (!m_MainBody.Velocity.IsZeroLength) {//nie zatrzymal sie jeszcze to go zatrzymujemy //dla bardzo malych predksoci dac cos w stylu velocity 0 ... albo wprowadzic //punkt zatrzymania (x,y,z) dla velocity < 0.00001 Mogre.Vector3 xyVector = new Mogre.Vector3(0, 0, 1); Mogre.Vector3 velocityxy = m_MainBody.Velocity * new Mogre.Vector3(1, 0, 1); Mogre.Quaternion ForceDirection = xyVector.GetRotationTo(velocityxy); Mogre.Vector3 StoppingForce = -ForceDirection * Mogre.Vector3.UNIT_Z * m_MainBody.Mass * m_Pose.m_ForceStop; m_MainBody.AddForce(-StoppingForce); } } }
public override bool UserPreFilterCallback(MogreNewt.Body body) { return Predicate(body); }