protected override void LoadContent() { // Create scene scene = new Scene(core); scene.Camera.Position = new Vector3(22, 27, -20); scene.Camera.Update(); core.ActiveScene = scene; // Create level entity DynamicEntity level = new DynamicEntity(core.ActiveScene); // Disable core input handling core.Input.ActiveDevices = Input.DeviceFlags.None; // Create player controller playerInput = new CharacterControllerInput(core.ActiveScene.Space, core.ActiveScene.Camera); playerInput.UseCameraSmoothing = true; playerInput.CharacterController.JumpSpeed = 9; playerInput.CharacterController.HorizontalMotionConstraint.Speed = 8; playerInput.StandingCameraOffset = 1.4f; playerInput.Activate(); // Initialise mouse state Game.IsMouseVisible = false; Mouse.SetPosition(GraphicsDevice.Viewport.Width / 2, GraphicsDevice.Viewport.Height / 2); startMouseState = mouseState = Mouse.GetState(); }
protected override void LoadContent(GraphicInfo GraphicInfo, GraphicFactory factory ,IContentManager contentManager) { base.LoadContent(GraphicInfo, factory, contentManager); { SimpleModel sm = new SimpleModel(factory, "..\\Content\\Model\\block"); sm.SetTexture(factory.CreateTexture2DColor(1, 1, Color.Blue), TextureType.DIFFUSE); DeferredNormalShader shader = new DeferredNormalShader(); IMaterial mat = new DeferredMaterial(shader); CharacterControllerInput character = new CharacterControllerInput(this, new Vector3(100, 150, 1), 1, 1, 50, Vector3.One * 10,0.5f); marine = new IObject(mat, sm, character.Characterobj); this.World.AddObject(marine); LightThrowBepu lt = new LightThrowBepu(this.World, factory); } { SimpleModel simpleModel = new SimpleModel(factory, "Model//cenario"); TriangleMeshObject tmesh = new TriangleMeshObject(simpleModel, Vector3.Zero, Matrix.Identity, Vector3.One, MaterialDescription.DefaultBepuMaterial()); DeferredNormalShader shader = new DeferredNormalShader(); DeferredMaterial fmaterial = new DeferredMaterial(shader); IObject obj = new IObject(fmaterial, simpleModel, tmesh); this.World.AddObject(obj); } #region NormalLight DirectionalLightPE ld1 = new DirectionalLightPE(Vector3.Left, Color.White); DirectionalLightPE ld2 = new DirectionalLightPE(Vector3.Right, Color.White); DirectionalLightPE ld3 = new DirectionalLightPE(Vector3.Backward, Color.White); DirectionalLightPE ld4 = new DirectionalLightPE(Vector3.Forward, Color.White); DirectionalLightPE ld5 = new DirectionalLightPE(Vector3.Down, Color.White); float li = 0.5f; ld1.LightIntensity = li; ld2.LightIntensity = li; ld3.LightIntensity = li; ld4.LightIntensity = li; ld5.LightIntensity = li; this.World.AddLight(ld1); this.World.AddLight(ld2); this.World.AddLight(ld3); this.World.AddLight(ld4); this.World.AddLight(ld5); #endregion CameraFirstPerson cam = new CameraFirstPerson(GraphicInfo); cam.MoveSpeed *= 5; this.World.CameraManager.AddCamera(cam); SkyBoxSetTextureCube stc = new SkyBoxSetTextureCube("Textures//grasscube"); CommandProcessor.getCommandProcessor().SendCommandAssyncronous(stc); }
protected override void LoadContent(GraphicInfo GraphicInfo, GraphicFactory factory ,IContentManager contentManager) { base.LoadContent(GraphicInfo, factory, contentManager); { SimpleModel simpleModel = new SimpleModel(factory, "Model//cenario"); TriangleMeshObject tmesh = new TriangleMeshObject(simpleModel, Vector3.Zero, Matrix.Identity, Vector3.One, MaterialDescription.DefaultBepuMaterial()); ForwardXNABasicShader shader = new ForwardXNABasicShader(ForwardXNABasicShaderDescription.Default()); ForwardMaterial fmaterial = new ForwardMaterial(shader); IObject obj = new IObject(fmaterial, simpleModel, tmesh); this.World.AddObject(obj); } { SimpleModel sm = new SimpleModel(factory, "..\\Content\\Model\\block"); sm.SetTexture(factory.CreateTexture2DColor(1, 1, Color.Blue), TextureType.DIFFUSE); ForwardXNABasicShader shader = new ForwardXNABasicShader(ForwardXNABasicShaderDescription.Default()); ForwardMaterial fmaterial = new ForwardMaterial(shader); CharacterControllerInput character = new CharacterControllerInput(this, new Vector3(100, 150, 1), 1, 1, 50, Vector3.One * 10, 0.5f); BaseObject marine = new BaseObject(fmaterial, character.Characterobj,sm); this.World.AddObject(marine); ///ever !!! marine.Behavior = new Repeater<BaseObject>( new Watch<BaseObject>( (a,b)=> { ///condition if(a.PhysicObject.Position.Length() < 100) { return TaskResult.Failure; } return TaskResult.Success; } , ///chnage its color =P new BehaviorTrees.Action<BaseObject>( (a,b)=> { a.Modelo.SetTexture(factory.CreateTexture2DColor(1,1,StaticRandom.RandomColor()),TextureType.DIFFUSE); return TaskResult.Success; } ) ) ); } this.World.CameraManager.AddCamera(new CameraFirstPerson(GraphicInfo)); }
public StandardDemo(DemosGame game) : base(game) { freeCameraControlScheme = new FreeCameraControlScheme(10, game.Camera, game); //Creates the player character (C). character = new CharacterControllerInput(Space, game.Camera, game); //Creates the drivable vehicle (V). var wheelModel = game.Content.Load <Model>("carWheel"); var wheelTexture = game.Content.Load <Texture2D>("wheel"); whitePixel = game.Content.Load <Texture2D>("whitePixel"); vehicle = new VehicleInput(new Vector3(10000, 0, 0), Space, game.Camera, game, game.ModelDrawer, wheelModel, wheelTexture); Space.ForceUpdater.Gravity = new Vector3(0, (Fix64)(-9.81m), 0); //If left unset, the default value is (0,0,0). //Create the tossable ball. kapow = new Sphere(new Vector3(11000, 0, 0), (Fix64).6m, 20); kapowMaker = new Explosion(Vector3.Zero, 400, 15, Space); //Create the right-click grab spring. grabber = new MotorizedGrabSpring(); grabberGraphic = game.ConstraintDrawer.Add(grabber); grabberGraphic.IsDrawing = false; Space.Add(grabber); Space.Add(kapow); //IMPORTANT PERFORMANCE NOTE: // BEPUphysics uses an iterative system to solve constraints. You can tell it to do more or less iterations. // Less iterations is faster; more iterations makes the result more accurate. // // The amount of iterations needed for a simulation varies. The "Wall" and "Pyramid" simulations are each fairly // solver intensive, but as few as 4 iterations can be used with acceptable results. // The "Jenga" simulation usually needs a few more iterations for stability; 7-9 is a good minimum. // // The Dogbot demo shows how accuracy can smoothly increase with more iterations. // With very few iterations (1-3), it has slightly jaggier movement, as if the parts used to construct it were a little cheap. // As you give it a few more iterations, the motors and constraints get more and more robust. // // Many simulations can work perfectly fine with very few iterations, // and using a low number of iterations can substantially improve performance. // // To change the number of iterations used, uncomment and change the following line (10 iterations is the default): //Space.Solver.IterationLimit = 10; rayCastFilter = RayCastFilter; }
public StandardDemo(DemosGame game) : base(game) { freeCameraControlScheme = new FreeCameraControlScheme(10, game.Camera, game); //Creates the player character (C). character = new CharacterControllerInput(Space, game.Camera, game); //Creates the drivable vehicle (V). var wheelModel = game.Content.Load<Model>("carWheel"); var wheelTexture = game.Content.Load<Texture2D>("wheel"); whitePixel = game.Content.Load<Texture2D>("whitePixel"); vehicle = new VehicleInput(new Vector3(10000, 0, 0), Space, game.Camera, game, game.ModelDrawer, wheelModel, wheelTexture); Space.ForceUpdater.Gravity = new Vector3(0, -9.81f, 0f); //If left unset, the default value is (0,0,0). //Create the tossable ball. kapow = new Sphere(new Vector3(11000, 0, 0), .6f, 20); kapowMaker = new Explosion(Vector3.Zero, 400, 15, Space); //Create the right-click grab spring. grabber = new MotorizedGrabSpring(); grabberGraphic = game.ConstraintDrawer.Add(grabber); grabberGraphic.IsDrawing = false; Space.Add(grabber); Space.Add(kapow); //IMPORTANT PERFORMANCE NOTE: // BEPUphysics uses an iterative system to solve constraints. You can tell it to do more or less iterations. // Less iterations is faster; more iterations makes the result more accurate. // // The amount of iterations needed for a simulation varies. The "Wall" and "Pyramid" simulations are each fairly // solver intensive, but as few as 4 iterations can be used with acceptable results. // The "Jenga" simulation usually needs a few more iterations for stability; 7-9 is a good minimum. // // The Dogbot demo shows how accuracy can smoothly increase with more iterations. // With very few iterations (1-3), it has slightly jaggier movement, as if the parts used to construct it were a little cheap. // As you give it a few more iterations, the motors and constraints get more and more robust. // // Many simulations can work perfectly fine with very few iterations, // and using a low number of iterations can substantially improve performance. // // To change the number of iterations used, uncomment and change the following line (10 iterations is the default): //Space.Solver.IterationLimit = 10; rayCastFilter = RayCastFilter; }
/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> public override void LoadContent() { InitialiseLevel(); // xEnvrio g = new xEnvrio(vxEngine, vxEngine.LoadModel("Models/tech demo/vrtc_techDemo"), Vector3.Zero); // g.World *= Matrix.CreateRotationZ(-MathHelper.PiOver2); // g.name = "tech demo"; // g.NormalMap = vxEngine.Game.Content.Load<Texture2D>("Models/tech demo/grass_nm"); int size = 100; Box baseBox = new Box(new Vector3(0, -5, 0), size, 10, size); BEPUPhyicsSpace.Add(baseBox); /////////////////////////////////////////////////////////////////////// //Initialise Camera Code /////////////////////////////////////////////////////////////////////// #region Set Up Camera base.LoadContent(); Camera.CameraType = CameraType.CharacterFPS; Camera.Position = new Vector3(0, 20, 0); character = new CharacterControllerInput(BEPUPhyicsSpace, Camera, vxEngine); //Since this is the character playground, turn on the character by default. character.Activate(); //Having the character body visible would be a bit distracting. character.CharacterController.Body.Tag = "noDisplayObject"; // //Grabbers // grabber = new MotorizedGrabSpring(); BEPUPhyicsSpace.Add(grabber); rayCastFilter = RayCastFilter; new IndexedPrimTest(vxEngine, new Vector3(0, 0, 0)); #endregion }
public Player() : base(null, null, 100) { character = new CharacterControllerInput(GameManager.Space, RenderingDevice.Camera as CharacterCamera, new Vector3(-1, -16, 5)); character.CharacterController.Body.Tag = this; character.CharacterController.HorizontalMotionConstraint.Speed = 10; character.CharacterController.HorizontalMotionConstraint.CrouchingSpeed = 5; PhysicsObject = character.CharacterController.Body; // for posterity PhysicsObject.CollisionInformation.CollisionRules.Group = dynamicObjects; // also for posterity rayCastFilter = RayCastFilter; sword = new BaseModel(delegate { return(Program.Game.Loader.SwordModel); }, false, true, new Vector3(0.5f, -15, 4.2f)); CollisionRules.AddRule(sword.Ent, PhysicsObject, CollisionRule.NoBroadPhase); sword.Ent.CollisionInformation.LocalPosition = new Vector3(0, -1, 0); sword.Ent.Orientation = Quaternion.CreateFromAxisAngle(Vector3.UnitX, -MathHelper.PiOver2); swordgrabber = new MotorizedGrabSpring(); swordgrabber.Setup(sword.Ent, sword.ModelPosition - Vector3.UnitX * 0.5f); sword.Ent.CollisionInformation.Events.PairTouching += onCollision; }
/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { // Create a new SpriteBatch, which can be used to draw textures. spriteBatch = new SpriteBatch(GraphicsDevice); // TODO: use this.Content to load your game content here // Load a sprite font font = Content.Load <SpriteFont>("SpriteFont1"); long startTime = stopwatch.ElapsedMilliseconds; // Load a test scene //LoadExteriorMapScene(); LoadBlockScene(); //LoadModelScene(); //LoadPhysicsScene(); // Load and play initial sound LoadSound(); PlaySound(); // Show or hide debug buffers core.Renderer.ShowDebugBuffers = false; lastLoadTime = stopwatch.ElapsedMilliseconds - startTime; playerInput = new CharacterControllerInput(core.ActiveScene.Space, core.ActiveScene.Camera); playerInput.UseCameraSmoothing = true; //playerInput.CharacterController.Body.Radius = 0.5f; playerInput.CharacterController.JumpSpeed = 10; playerInput.CharacterController.HorizontalMotionConstraint.Speed = 8; playerInput.StandingCameraOffset = 1.4f; playerInput.Activate(); }
public Player(BaseGame g) { character = new CharacterControllerInput(GameManager.Space, Renderer.Camera, g); character.CharacterController.Body.CollisionInformation.CollisionRules.Group = GameModel.NormalGroup; character.CharacterController.Body.Tag = this; dockTex = new Sprite(delegate { return(g.Loader.Dock); }, new Vector2(RenderingDevice.Width / 2, RenderingDevice.Height * 0.95f), null, Sprite.RenderPoint.Center); font = g.Loader.Font; underwaterTex = g.Loader.TabletopDotPNG; missileModel = g.Loader.Burst; crosshair = g.Loader.Crosshair; int add = 0; for (int i = 0; i < drawingRectangles.Length; i++) { add += 10; drawingRectangles[i] = new Rectangle((int)dockTex.UpperLeft.X + add, (int)dockTex.UpperLeft.Y - 140, 150, 150); add += 150; add += 10; } screenRect = new Rectangle(0, 0, (int)RenderingDevice.Width, (int)RenderingDevice.Height); }
public abstract void Init(CharacterControllerInput input);
public static unsafe void Move(CharacterControllerInput characterController, ref NativeList <float3> bounceNormals, in CollisionWorld collisionWorld, out CharacterControllerOutput output)
public override void Init(CharacterControllerInput input) { this.input = input; }
protected override void LoadContent() { // Load fonts consoleFont = Game.Content.Load <SpriteFont>("Fonts/MenuFont"); core.Renderer.ShowDebugBuffers = true; // Load fonts SpriteFont menuFont2 = Game.Content.Load <SpriteFont>("Fonts/MenuFont2"); // Create gui manager gui = new InterfaceManager(core); gui.SetMargins(Margins.All, 20); // Create status text physicsTextItem = new TextItemScreenComponent(core, menuFont2, string.Empty); physicsTextItem.EnableOutline = true; physicsTextItem.OutlineColor = Color.Gray; physicsTextItem.ShadowColor = Color.Black; physicsTextItem.ShadowVector = new Vector2(2, 2); physicsTextItem.HorizontalAlignment = HorizontalAlignment.Left; physicsTextItem.VerticalAlignment = VerticalAlignment.Top; // Add to gui gui.Components.Add(physicsTextItem); // Create scene scene = new Scene(core); scene.Camera.Position = new Vector3(22, 27, -20); scene.Camera.Update(); core.ActiveScene = scene; // Set day/night mode for window textures core.MaterialManager.Daytime = false; // Create level entity DynamicEntity level = new DynamicEntity(core.ActiveScene); // Create block component DaggerfallBlockComponent block = new DaggerfallBlockComponent(core); block.LoadBlock("S0000181.RDB", MapsFile.DefaultClimateSettings, core.ActiveScene, true); // Increase bounding sphere radius as block component does not current calculate properly block.BoundingSphere = new BoundingSphere(block.BoundingSphere.Center, block.BoundingSphere.Radius * 2); // Add block to level level.Components.Add(block); // Attach block flats AddBlockFlats(level, block); // Attach block lights AddBlockLights(level, block); // Add player point light playerLight = new LightComponent(core, Vector3.Zero, 7f, Color.White, 1f); level.Components.Add(playerLight); // Disable core input handling core.Input.ActiveDevices = Input.DeviceFlags.None; // Create player controller playerInput = new CharacterControllerInput(core.ActiveScene.Space, core.ActiveScene.Camera); playerInput.UseCameraSmoothing = true; playerInput.CharacterController.JumpSpeed = 9; playerInput.CharacterController.HorizontalMotionConstraint.Speed = 8; playerInput.StandingCameraOffset = 1.4f; playerInput.Activate(); // Initialise mouse state Game.IsMouseVisible = false; Mouse.SetPosition(GraphicsDevice.Viewport.Width / 2, GraphicsDevice.Viewport.Height / 2); startMouseState = mouseState = Mouse.GetState(); // Load songs MediaPlayer.Stop(); song = Game.Content.Load <Song>("Songs/DanGoodale_DF-D2"); MediaPlayer.Play(song); UpdatePhysicsObjectText(); }
protected override void LoadContent(GraphicInfo GraphicInfo, GraphicFactory factory ,IContentManager contentManager) { base.LoadContent(GraphicInfo, factory, contentManager); { ///carrega o Modelo AnimatedModel am = new AnimatedModel(factory, "..\\Content\\Model\\PlayerMarine", "..\\Content\\Textures\\PlayerMarineDiffuse"); ///Inicializa o Controlador (Idle eh o nome da animacao inicial) AnimatedController arobo = new AnimatedController(am, "Idle"); ///Cria o shader e o material animados DeferredSimpleAnimationShader sas = new DeferredSimpleAnimationShader(arobo); DeferredAnimatedMaterial amat = new DeferredAnimatedMaterial(arobo, sas); CharacterControllerInput gp = new CharacterControllerInput(this, new Vector3(100, 50, 1), 25, 10, 10, Vector3.One); IObject marine = new IObject(amat, am, gp.Characterobj); ///Adiciona no mundo this.World.AddObject(marine); LightThrowBepu lt = new LightThrowBepu(this.World, factory); } { SimpleModel simpleModel = new SimpleModel(factory, "Model//cenario"); TriangleMeshObject tmesh = new TriangleMeshObject(simpleModel, Vector3.Zero, Matrix.Identity, Vector3.One, MaterialDescription.DefaultBepuMaterial()); DeferredNormalShader shader = new DeferredNormalShader(); DeferredMaterial fmaterial = new DeferredMaterial(shader); IObject obj = new IObject(fmaterial, simpleModel, tmesh); this.World.AddObject(obj); } #region NormalLight DirectionalLightPE ld1 = new DirectionalLightPE(Vector3.Left, Color.White); DirectionalLightPE ld2 = new DirectionalLightPE(Vector3.Right, Color.White); DirectionalLightPE ld3 = new DirectionalLightPE(Vector3.Backward, Color.White); DirectionalLightPE ld4 = new DirectionalLightPE(Vector3.Forward, Color.White); DirectionalLightPE ld5 = new DirectionalLightPE(Vector3.Down, Color.White); float li = 0.5f; ld1.LightIntensity = li; ld2.LightIntensity = li; ld3.LightIntensity = li; ld4.LightIntensity = li; ld5.LightIntensity = li; this.World.AddLight(ld1); this.World.AddLight(ld2); this.World.AddLight(ld3); this.World.AddLight(ld4); this.World.AddLight(ld5); #endregion CameraFirstPerson cam = new CameraFirstPerson(GraphicInfo); cam.MoveSpeed *= 5; this.World.CameraManager.AddCamera(cam); SkyBoxSetTextureCube stc = new SkyBoxSetTextureCube("Textures//grasscube"); CommandProcessor.getCommandProcessor().SendCommandAssyncronous(stc); }
/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> public override void LoadContent() { InitialiseLevel(); /////////////////////////////////////////////////////////////////////// //Initialise Camera Code /////////////////////////////////////////////////////////////////////// #region Set Up Camera base.LoadContent(); Camera.CameraType = CameraType.CharacterFPS; character = new CharacterControllerInput(BEPUPhyicsSpace, Camera, vxEngine); //Since this is the character playground, turn on the character by default. character.Activate(); //Having the character body visible would be a bit distracting. character.CharacterController.Body.Tag = "noDisplayObject"; SimulationStart(); SimulationStop(); // //Grabbers // grabber = new MotorizedGrabSpring(); BEPUPhyicsSpace.Add(grabber); rayCastFilter = RayCastFilter; #endregion DoFog = true; FogNear = 20; FogFar = Camera.FarPlane / 4; Envrio envr = new Envrio(vxEngine, vxEngine.vxContentManager.LoadModel("Models/courtyard/td_courtyard"), Vector3.Zero); //Envrio envr = new Envrio(vxEngine, vxEngine.vxContentManager.LoadModel("Models/castle/mdl_castle"), new Vector3(0, 1, 0)); //waterItems.Add(new vxWaterEntity(vxEngine, Vector3.Up, new Vector3(50, 0.25f, 50))); envr.SpecularIntensity = 1; //envr.SpecularIntensity = 100; //envr.SpecularPower = 5f; //envr.DoFog = false; light = new vxLightEntity(vxEngine, new Vector3(0, 2, 0), LightType.Point, Color.Orange, 10, 1); //This is a little convenience method used to extract vertices and indices from a model. //It doesn't do anything special; any approach that gets valid vertices and indices will work. #if !TECHDEMO_PLTFRM_GL ModelDataExtractor.GetVerticesAndIndicesFromModel(envr.vxModel.ModelMain, out staticTriangleVertices, out staticTriangleIndices); //var staticMesh = new StaticMesh(staticTriangleVertices, staticTriangleIndices, new AffineTransform(Matrix3X3.CreateFromAxisAngle(Vector3.Up, MathHelper.Pi), new Vector3(0, -10, 0))); var staticMesh = new StaticMesh(staticTriangleVertices, staticTriangleIndices, new AffineTransform(new Vector3(1), Quaternion.CreateFromRotationMatrix(Matrix.CreateRotationX(-MathHelper.PiOver2) * Matrix.CreateRotationY(0)), new Vector3(0))); staticMesh.Sidedness = TriangleSidedness.Counterclockwise; BEPUPhyicsSpace.Add(staticMesh); BEPUDebugDrawer.Add(staticMesh); #endif int size = 100; BEPUPhyicsSpace.Add(new Box(new Vector3(0, -5, 0), size, 10, size)); vxTabPage Straights = new vxTabPage(vxEngine, tabControl, "Items"); tabControl.AddItem(Straights); vxScrollPanel ScrollPanel_GeneralItemsPage = new vxScrollPanel(new Vector2(0, 0), vxEngine.GraphicsDevice.Viewport.Width - 150, vxEngine.GraphicsDevice.Viewport.Height - 75); //Cubes ScrollPanel_GeneralItemsPage.AddItem(new vxScrollPanelSpliter(vxEngine, "Items")); ScrollPanel_GeneralItemsPage.AddItem(RegisterNewSandboxItem(WoodenCrate.EntityDescription)); //Add the scrollpanel to the slider tab page. Straights.AddItem(ScrollPanel_GeneralItemsPage); //IndexedCubeTest cube = new IndexedCubeTest(vxEngine, new Vector3(4, 4, 0)); Teapot t = new Teapot((GameEngine)vxEngine, new Vector3(4, 4, 0)); t.SetMesh(Matrix.CreateTranslation(new Vector3(4, 2, 0)), true, true); ConcreteCube cc = new ConcreteCube((GameEngine)vxEngine, new Vector3(0, 5, 0)); cc.SetMesh(Matrix.CreateTranslation(new Vector3(0, 2, 0)), true, true); ModelObjs mo = new ModelObjs((GameEngine)vxEngine, new Vector3(-4, 4, 0)); mo.SetMesh(Matrix.CreateTranslation(new Vector3(0, 2, 8)), true, true); vxEngine.InputManager.ShowCursor = true; }