com.badlogic.gdx.physics.box2d.ContactImpulse Java Examples
The following examples show how to use
com.badlogic.gdx.physics.box2d.ContactImpulse.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CarImpactManager.java From uracer-kotd with Apache License 2.0 | 5 votes |
@Override public void process (Contact contact, ContactImpulse impulse) { Fixture a = contact.getFixtureA(); Fixture b = contact.getFixtureB(); ifCarThenCollide(contact, a, b, impulse); ifCarThenCollide(contact, b, a, impulse); }
Example #2
Source File: GameWorldContactListener.java From uracer-kotd with Apache License 2.0 | 4 votes |
@Override public void postSolve (Contact contact, ContactImpulse impulse) { impactManager.process(contact, impulse); }
Example #3
Source File: CarImpactManager.java From uracer-kotd with Apache License 2.0 | 4 votes |
private void ifCarThenCollide (Contact contact, Fixture f, Fixture other, ContactImpulse impulse) { Body body = f.getBody(); Object userData = f.getUserData(); if ((body != null) && (userData == CarType.PlayerCar || userData == CarType.ReplayCar)) { Car car = (Car)body.getUserData(); float[] impulses = impulse.getNormalImpulses(); tmpVec2.set(impulses[0], impulses[1]); // dbg Fixture fcar = null; if (contact.getFixtureA().getUserData() == CarType.PlayerCar) { fcar = contact.getFixtureA(); } else if (contact.getFixtureB().getUserData() == CarType.PlayerCar) { fcar = contact.getFixtureB(); } // assumes perfect side collision float front_ratio = 0.5f; // compute median front/rear ratio for collision points if (fcar != null) { front_ratio = 0; float ml = car.getCarModel().length; float half_ml = ml * 0.5f; Vector2[] pts = contact.getWorldManifold().getPoints(); int num_points = contact.getWorldManifold().getNumberOfContactPoints(); for (int i = 0; i < num_points; i++) { Vector2 lp = fcar.getBody().getLocalPoint(pts[i]); // examine front/rear ratio float r = MathUtils.clamp(lp.y + half_ml, 0, ml); r /= ml; front_ratio += r; } front_ratio /= (float)num_points; // Gdx.app.log("Cntct", "" + front_ratio); } // dbg car.onCollide(other, tmpVec2, front_ratio); } }
Example #4
Source File: Field.java From homescreenarcade with GNU General Public License v3.0 | 4 votes |
@Override public void postSolve(Contact arg0, ContactImpulse arg1) { // Not used. }
Example #5
Source File: WorldContactListener.java From Pacman_libGdx with MIT License | 4 votes |
@Override public void postSolve(Contact contact, ContactImpulse impulse) { }
Example #6
Source File: ContactListenerAdapter.java From tilt-game-android with MIT License | 4 votes |
@Override public void postSolve(Contact contact, ContactImpulse impulse) { }
Example #7
Source File: B2DWorldContactListener.java From Bomberman_libGdx with MIT License | 4 votes |
@Override public void postSolve(Contact contact, ContactImpulse impulse) { }
Example #8
Source File: NinjaRabbitPhysicsProcessor.java From ninja-rabbit with GNU General Public License v2.0 | 4 votes |
@Override public void postSolve(final Contact contact, final ContactImpulse impulse) { // TODO Auto-generated method stub }
Example #9
Source File: LevelPhysicsProcessor.java From ninja-rabbit with GNU General Public License v2.0 | 4 votes |
@Override public void postSolve(final Contact contact, final ContactImpulse impulse) { // TODO Auto-generated method stub }
Example #10
Source File: ContactListenerMultiplexer.java From ninja-rabbit with GNU General Public License v2.0 | 4 votes |
@Override public void postSolve(final Contact contact, final ContactImpulse impulse) { for (ContactListener listener : receivers) { listener.postSolve(contact, impulse); } }
Example #11
Source File: JumpingSample.java From Codelabs with MIT License | 2 votes |
@Override public void postSolve(Contact contact, ContactImpulse impulse) { }
Example #12
Source File: CollisionsSample.java From Codelabs with MIT License | 2 votes |
@Override public void postSolve(Contact contact, ContactImpulse impulse) { }
Example #13
Source File: BuoyancySample.java From Codelabs with MIT License | 2 votes |
@Override public void postSolve(Contact contact, ContactImpulse impulse) { }
Example #14
Source File: FluidSimulatorGeneric.java From fluid-simulator-v2 with Apache License 2.0 | 2 votes |
@Override public void postSolve(Contact contact, ContactImpulse impulse) { }
Example #15
Source File: CarrotPhysicsProcessor.java From ninja-rabbit with GNU General Public License v2.0 | 2 votes |
@Override public void postSolve(final Contact contact, final ContactImpulse impulse) { }
Example #16
Source File: ImpactManager.java From uracer-kotd with Apache License 2.0 | votes |
abstract void process (Contact contact, ContactImpulse impulse);