protected override void OnInitializePhysics() { // collision configuration contains default setup for memory, collision setup CollisionConf = new DefaultCollisionConfiguration(); Dispatcher = new CollisionDispatcher(CollisionConf); Broadphase = new DbvtBroadphase(); Solver = new SequentialImpulseConstraintSolver(); World = new DiscreteDynamicsWorld(Dispatcher, Broadphase, Solver, CollisionConf); World.Gravity = Freelook.Up * -10.0f; var bspLoader = new BspLoader(); string[] args = Environment.GetCommandLineArgs(); if (args.Length == 1) { bspLoader.LoadBspFile(Path.Combine("data", "BspDemo.bsp")); } else { bspLoader.LoadBspFile(args[1]); } BspConverter bsp2Bullet = new BspToBulletConverter(this); bsp2Bullet.ConvertBsp(bspLoader, 0.1f); }
protected override void OnInitializePhysics() { // collision configuration contains default setup for memory, collision setup CollisionConf = new DefaultCollisionConfiguration(); Dispatcher = new CollisionDispatcher(CollisionConf); Broadphase = new DbvtBroadphase(); Solver = new SequentialImpulseConstraintSolver(); World = new DiscreteDynamicsWorld(Dispatcher, Broadphase, Solver, CollisionConf); World.Gravity = Freelook.Up * -10.0f; BspLoader bspLoader = new BspLoader(); //string[] args = Environment.GetCommandLineArgs(); //if (args.Length == 1) //{ UnityEngine.TextAsset bytes = (UnityEngine.TextAsset)UnityEngine.Resources.Load("BspDemo"); System.IO.Stream byteStream = new System.IO.MemoryStream(bytes.bytes); bspLoader.LoadBspFile(byteStream); //} //else //{ // bspLoader.LoadBspFile(args[1]); //} BspConverter bsp2Bullet = new BspToBulletConverter(this); bsp2Bullet.ConvertBsp(bspLoader, 0.1f); }
protected override void OnInitializePhysics() { // collision configuration contains default setup for memory, collision setup CollisionConf = new DefaultCollisionConfiguration(); Dispatcher = new CollisionDispatcher(CollisionConf); Broadphase = new DbvtBroadphase(); Solver = new SequentialImpulseConstraintSolver(); World = new DiscreteDynamicsWorld(Dispatcher, Broadphase, Solver, CollisionConf); World.Gravity = Freelook.Up * -10.0f; BspLoader bspLoader = new BspLoader(); string[] args = Environment.GetCommandLineArgs(); if (args.Length == 1) { bspLoader.LoadBspFile("data/BspDemo.bsp"); } else { bspLoader.LoadBspFile(args[1]); } BspConverter bsp2Bullet = new BspToBulletConverter(this); bsp2Bullet.ConvertBsp(bspLoader, 0.1f); }
public void ConvertBsp(BspLoader bspLoader, float scaling) { Vector3 playerStart = new Vector3(0, 0, 100); if (bspLoader.FindVectorByName("info_player_start", ref playerStart) == false) { bspLoader.FindVectorByName("info_player_deathmatch", ref playerStart); } playerStart[2] += 20.0f * scaling; //start a bit higher foreach (BspLeaf leaf in bspLoader.Leaves) { bool isValidBrush = false; for (int b = 0; b < leaf.NumLeafBrushes; b++) { AlignedVector3Array planeEquations = new AlignedVector3Array(); int brushID = bspLoader.LeafBrushes[leaf.FirstLeafBrush + b]; BspBrush brush = bspLoader.Brushes[brushID]; if (brush.ShaderNum != -1) { if ((bspLoader.Shaders[brush.ShaderNum].ContentFlags & ContentFlags.Solid) == ContentFlags.Solid) { brush.ShaderNum = -1; for (int p = 0; p < brush.NumSides; p++) { int sideid = brush.FirstSide + p; BspBrushSide brushside = bspLoader.BrushSides[sideid]; int planeid = brushside.PlaneNum; BspPlane plane = bspLoader.Planes[planeid]; Vector4 planeEq = new Vector4(plane.Normal, scaling * -plane.Distance); planeEquations.Add(planeEq); isValidBrush = true; } if (isValidBrush) { AlignedVector3Array vertices; GeometryUtil.GetVerticesFromPlaneEquations(planeEquations, out vertices); bool isEntity = false; Vector3 entityTarget = Vector3.Zero; AddConvexVerticesCollider(vertices, isEntity, entityTarget); } } } } } foreach (BspEntity entity in bspLoader.Entities) { if (entity.ClassName == "trigger_push") { } } }
public void ConvertBsp(BspLoader bspLoader, float scaling) { Vector3 playerStart = new Vector3(0, 0, 100); if (bspLoader.FindVectorByName("info_player_start", ref playerStart) == false) { bspLoader.FindVectorByName("info_player_deathmatch", ref playerStart); } playerStart[2] += 20.0f * scaling; //start a bit higher foreach (BspLeaf leaf in bspLoader.Leaves) { bool isValidBrush = false; for (int b = 0; b < leaf.NumLeafBrushes; b++) { AlignedVector3Array planeEquations = new AlignedVector3Array(); int brushID = bspLoader.LeafBrushes[leaf.FirstLeafBrush + b]; BspBrush brush = bspLoader.Brushes[brushID]; if (brush.ShaderNum != -1) { if ((bspLoader.Shaders[brush.ShaderNum].ContentFlags & ContentFlags.Solid) == ContentFlags.Solid) { brush.ShaderNum = -1; for (int p = 0; p < brush.NumSides; p++) { int sideid = brush.FirstSide + p; BspBrushSide brushside = bspLoader.BrushSides[sideid]; int planeid = brushside.PlaneNum; BspPlane plane = bspLoader.Planes[planeid]; Vector4 planeEq = new Vector4(plane.Normal, scaling*-plane.Distance); planeEquations.Add(planeEq); isValidBrush = true; } if (isValidBrush) { AlignedVector3Array vertices = new AlignedVector3Array(); GeometryUtil.GetVerticesFromPlaneEquations(planeEquations, vertices); bool isEntity = false; Vector3 entityTarget = Vector3.Zero; AddConvexVerticesCollider(vertices, isEntity, entityTarget); } } } } } foreach (BspEntity entity in bspLoader.Entities) { if (entity.ClassName == "trigger_push") { } } }
public Physics() { // collision configuration contains default setup for memory, collision setup CollisionConf = new DefaultCollisionConfiguration(); Dispatcher = new CollisionDispatcher(CollisionConf); Broadphase = new DbvtBroadphase(); Solver = new SequentialImpulseConstraintSolver(); World = new DiscreteDynamicsWorld(Dispatcher, Broadphase, Solver, CollisionConf); World.Gravity = new Vector3(0, 0, -10); BspLoader bspLoader = new BspLoader(); bspLoader.LoadBspFile("BspDemo.bsp"); BspConverter bsp2Bullet = new BspToBulletConverter(this); bsp2Bullet.ConvertBsp(bspLoader, 0.1f); }
private void LoadBspFile() { var bspLoader = new BspLoader(); string[] args = Environment.GetCommandLineArgs(); if (args.Length == 1) { bspLoader.LoadBspFile(Path.Combine("data", "BspDemo.bsp")); } else { bspLoader.LoadBspFile(args[1]); } var bsp2Bullet = new BspToBulletConverter(World); bsp2Bullet.ConvertBsp(bspLoader, 0.1f); }