public static void AddPaddle(Entity boxObject, OpenTK.Vector3 position, double width, double height, double paddleAngle) { Box2DShape boxShape = new Box2DShape((float)(width / 2), (float)(height / 2), (0.0f)); RigidBodyConstructionInfo boxConstructionInfo = new RigidBodyConstructionInfo(10000f, new DefaultMotionState( Matrix.Translation(position.X, position.Y, 0) * Matrix.RotationZ((float)paddleAngle) ), boxShape); RigidBody box = new RigidBody(boxConstructionInfo); box.LinearFactor = new BulletSharp.Math.Vector3(1, 1, 0); box.AngularFactor = new BulletSharp.Math.Vector3(0, 0, 1); box.SetDamping(0, 0); box.Restitution = 1f; box.Friction = 0.0f; box.UserObject = boxObject; foreach (var box2 in boxes) { box.SetIgnoreCollisionCheck(box2.Box, true); } boxes.Add(new BoxInfo { BoxObject = boxObject, BoxShape = boxShape, BoxConstructionInfo = boxConstructionInfo, Box = box, DefaultPosition = position }); //Add box to the world colWorld.AddCollisionObject(box); }
private static Vector3[] CreateBox2DShape(Box2DShape box2DShape) { Vector3Array v = box2DShape.Vertices; return(new Vector3[12] { v[0], Vector3.UnitZ, v[1], Vector3.UnitZ, v[2], Vector3.UnitZ, v[0], Vector3.UnitZ, v[2], Vector3.UnitZ, v[3], Vector3.UnitZ, }); }
private static UnityEngine.Vector3[] CreateBox2DShape(Box2DShape box2DShape) { Vector3Array v = box2DShape.Vertices; return(new UnityEngine.Vector3[12] { v[0].ToUnity(), UnityEngine.Vector3.forward, v[1].ToUnity(), UnityEngine.Vector3.forward, v[2].ToUnity(), UnityEngine.Vector3.forward, v[0].ToUnity(), UnityEngine.Vector3.forward, v[2].ToUnity(), UnityEngine.Vector3.forward, v[3].ToUnity(), UnityEngine.Vector3.forward, }); }
public static void CreateBox2DShape(Box2DShape shape, Mesh mesh) { Vector3Array v = shape.Vertices; MakeUnityCubeMesh(v[0].ToUnity(), v[1].ToUnity(), v[2].ToUnity(), v[3].ToUnity(), v[4].ToUnity(), v[5].ToUnity(), v[6].ToUnity(), v[7].ToUnity(), mesh); }