public PhysicsManager(Main game, bool bEnableDebugDrawer)
            : base(game)
        {
            this.game = game;
            this.bEnableDebugDrawer = bEnableDebugDrawer;
            this.physicSystem = new PhysicsSystem();

            //add cd/cr system
            this.physicSystem.CollisionSystem = new CollisionSystemSAP();
            this.physicSystem.EnableFreezing = true;
            this.physicSystem.SolverType = PhysicsSystem.Solver.Normal;
            this.physicSystem.CollisionSystem.UseSweepTests = true;
            //affect accuracy and the overhead == time required
            this.physicSystem.NumCollisionIterations = 8; //8
            this.physicSystem.NumContactIterations = 8; //8
            this.physicSystem.NumPenetrationRelaxtionTimesteps = 12; //15

            #region SETTING_COLLISION_ACCURACY
            //affect accuracy of the collision detection
            this.physicSystem.AllowedPenetration = 0.000025f;
            this.physicSystem.CollisionTollerance = 0.00005f;
            #endregion

            this.physCont = new PhysicsController();
            this.physicSystem.AddController(physCont);

            if (bEnableDebugDrawer)
            {
                this.physicsDebugDrawer = new PhysicsDebugDrawer(game);
                game.Components.Add(this.physicsDebugDrawer);
            }
        }
        public override void Initialise()
        {
            m_PhysicsSystem = new PhysicsSystem();

            // Add Collision system
            m_PhysicsSystem.CollisionSystem = new CollisionSystemSAP();
        }
Beispiel #3
0
        public Physics()
        {
            PhysicsSystem = new PhysicsSystem
            {
                EnableFreezing = true,
                SolverType = PhysicsSystem.Solver.Normal,
                CollisionSystem = new CollisionSystemSAP()
            };

            UpdatePhysics = true;
        }
Beispiel #4
0
        protected override void Initialise()
        {
            //initialize the physic stuff!
            physics = new PhysicsSystem();
            physics.CollisionSystem = new CollisionSystemSAP();

            //all draw targets need a default camera.
            //create a 3D camera
            var camera = new Xen.Camera.FirstPersonControlledCamera3D(this.UpdateManager, Vector3.Zero, false);

            //don't allow the camera to move too fast
            camera.MovementSensitivity *= 0.1f;
            camera.LookAt(new Vector3(0.0f, 100.0f, 0.0f), new Vector3(640.0f, 300.0f, 640.0f), Vector3.Up);

            console = new Console(400, 200);

            //create the draw target.
            this.drawToScreen = new DrawTargetScreen(camera);

            //Set the screen clear colour to blue
            //(Draw targets have a built in ClearBuffer object)
            this.drawToScreen.ClearBuffer.ClearColour = Color.CornflowerBlue;

            //create new actor ("tiny")
            actor = new Actor(this.Content, "tiny_4anim", Vector3.Zero, 1f);

            skydome = new Skydome(Content, new Vector3(500,100,700), 1000f);

            //at runtime, pressing 'F12' will toggle the overlay (or holding both thumbsticks on x360)
            this.statisticsOverlay = new Xen.Ex.Graphics2D.Statistics.DrawStatisticsDisplay(this.UpdateManager);

            TerrainDrawer terrain = new TerrainDrawer(this.Content, Vector3.Zero);

            drawToScreen.Add(terrain);

            drawToScreen.Add(skydome);

            //add statistics to screen
            drawToScreen.Add(statisticsOverlay);

            //add console to screen
            drawToScreen.Add(console.getTextElementRect());

            //add actor to the screen
            drawToScreen.Add(actor);
        }
Beispiel #5
0
        public JiggleGame()
        {
            graphics = new GraphicsDeviceManager(this);
            content = new ContentManager(Services);

            graphics.SynchronizeWithVerticalRetrace = true;
            this.IsFixedTimeStep = true;

            physicSystem = new PhysicsSystem();

            graphics.SynchronizeWithVerticalRetrace = false;
            this.IsFixedTimeStep = false;
            //physicSystem.CollisionSystem = new CollisionSystemGrid(32, 32, 32, 30, 30, 30);
            //physicSystem.CollisionSystem = new CollisionSystemBrute();
            physicSystem.CollisionSystem = new CollisionSystemSAP();

            physicSystem.EnableFreezing = true;
            physicSystem.SolverType = PhysicsSystem.Solver.Normal;
            physicSystem.CollisionSystem.UseSweepTests = true;

            physicSystem.NumCollisionIterations = 8;
            physicSystem.NumContactIterations = 8;
            physicSystem.NumPenetrationRelaxtionTimesteps = 15;

            camera = new Camera(this);

            FrameRateCounter physStats = new FrameRateCounter(this, this.physicSystem);

            debugDrawer = new DebugDrawer(this);
            debugDrawer.Enabled = false;

            Components.Add(physStats);
            Components.Add(camera);
            Components.Add(debugDrawer);

            physStats.DrawOrder = 2;
            debugDrawer.DrawOrder = 3;

            this.IsMouseVisible = true;
            this.Window.Title = "JigLibX Physic Library " + System.Reflection.Assembly.GetAssembly(typeof(PhysicsSystem)).GetName().Version.ToString();
        }
Beispiel #6
0
        public Game1()
        {
            graphics = new GraphicsDeviceManager(this);
            Content.RootDirectory = "Content";

            //IsFixedTimeStep = false;
            //graphics.SynchronizeWithVerticalRetrace = false;

            graphics.PreferredBackBufferWidth = 1280;
            graphics.PreferredBackBufferHeight = 720;
            graphics.PreferMultiSampling = true;

            physics = new PhysicsSystem();
            physics.CollisionSystem = new CollisionSystemSAP();
            physics.EnableFreezing = true;
            physics.SolverType = PhysicsSystem.Solver.Fast;
            physics.CollisionSystem.UseSweepTests = true;
            physics.NumCollisionIterations = 10;
            physics.NumContactIterations = 10;
            physics.NumPenetrationRelaxtionTimesteps = 15;

            physics.Gravity = new Vector3(0, -50, 0);
            physics.Gravity = Vector3.Zero;
        }
Beispiel #7
0
        private void InitalizePhysics()
        {
            //Setting up the physics engine
            m_world = new PhysicsSystem();
            m_world.CollisionSystem = new CollisionSystemSAP();

            //Setting up gravity force and direction
            m_world.Gravity = new Vector3(0, -9.81f, 0);
        }
Beispiel #8
0
        /// <summary>
        /// Initializes a new instance of the XnaBasics class.
        /// </summary>
        public XnaBasics()
        {
            this.IsFixedTimeStep = false;
            this.IsMouseVisible = true;
            this.Window.Title = "Xna Basics";
            this.Window.AllowUserResizing = true;
            Width = System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width;
            Height = System.Windows.Forms.Screen.PrimaryScreen.Bounds.Height;
            // This sets the width to the desired width
            // It also forces a 4:3 ratio for height
            // Adds 110 for header/footer
            this.graphics = new GraphicsDeviceManager(this);
            this.graphics.PreferredBackBufferWidth = Width;
            //this.graphics.PreferredBackBufferHeight = ((Width / 4) * 3) + 110;
            this.graphics.PreferredBackBufferHeight = Height;
            this.graphics.PreparingDeviceSettings += this.GraphicsDevicePreparingDeviceSettings;
            this.graphics.SynchronizeWithVerticalRetrace = true;
            //this.viewPortRectangle = new Rectangle(10, 80, Width - 20, ((Width - 2) / 4) * 3);
            this.viewPortRectangle = new Rectangle(0, 0, Width, Height);
            this.graphics.IsFullScreen = false;
            this.IsMouseVisible = false;

            physicSystem = new PhysicsSystem();
            camera = new JiggleGame.Camera(this);

            Content.RootDirectory = "Content";

            // The Kinect sensor will use 640x480 for both streams
            // To make your app handle multiple Kinects and other scenarios,
            // it is recommended to use KinectSensorChooser provided in Microsoft.Kinect.Toolkit
            this.chooser = new KinectChooser(this, ColorImageFormat.RgbResolution640x480Fps30, DepthImageFormat.Resolution640x480Fps30);
            this.Services.AddService(typeof(KinectChooser), this.chooser);

            // Default size is the full viewport
            this.colorStream = new ColorStreamRenderer(this);

            // Calculate the minimized size and location
            this.depthStream = new DepthStreamRenderer(this);
            this.depthStream.Size = new Vector2(this.viewPortRectangle.Width / 4, this.viewPortRectangle.Height / 4);
            this.depthStream.Position = new Vector2(Width - this.depthStream.Size.X - 15, 10);

            // Store the values so we can animate them later
            this.minSize = this.depthStream.Size;
            this.depthSmallPosition = this.depthStream.Position;
            this.colorSmallPosition = new Vector2(15, 10);

            this.Components.Add(this.chooser);

            LeftHand = new Vector2();
            RightHand = new Vector2();

            this.clothRender = new ClothRender(this);
            this.Components.Add(this.clothRender);
        }
 public FrameRateCounter(Game game,PhysicsSystem physics)
     : base(game)
 {
     content = new ContentManager(game.Services);
     this.physics = physics;
 }
Beispiel #10
0
        void InitializePhysics()
        {
            world = new PhysicsSystem();

            //world.CollisionSystem = new CollisionSystemGrid(64, 64, 64, 5, 5, 5);
            //physicSystem.CollisionSystem = new CollisionSystemBrute();
            world.CollisionSystem = new CollisionSystemSAP();

            world.EnableFreezing = true;
            world.SolverType = PhysicsSystem.Solver.Combined;
            world.CollisionSystem.UseSweepTests = true;
            world.Gravity = new Vector3(0, -10, 0);//PhysicsHelper.GravityEarth, 0);

            world.NumCollisionIterations = 30;
            world.NumContactIterations = 30;
            world.NumPenetrationRelaxtionTimesteps = 30;
        }
Beispiel #11
0
        private void InitializePhysics(double updateInterval)
        {
            PhysicsSystem = new PhysicsSystem();
            PhysicsSystem.CollisionSystem = new CollisionSystemSAP();
            PhysicsSystem.EnableFreezing = true;
            PhysicsSystem.SolverType = PhysicsSystem.Solver.Normal;

            PhysicsSystem.CollisionSystem.UseSweepTests = true;
            PhysicsSystem.Gravity = new Vector3(0, -10, 0);
            // CollisionTOllerance and Allowed Penetration
            // changed because our objects were "too small"
            PhysicsSystem.CollisionTollerance = 0.01f;
            PhysicsSystem.AllowedPenetration = 0.001f;

            //PhysicsSystem.NumCollisionIterations = 8;
            //PhysicsSystem.NumContactIterations = 8;
            PhysicsSystem.NumPenetrationRelaxtionTimesteps = 15;

            tmrPhysicsElapsed = new Stopwatch();
            tmrPhysicsUpdate = new System.Timers.Timer();
            tmrPhysicsUpdate.AutoReset = false;
            tmrPhysicsUpdate.Enabled = false;
            tmrPhysicsUpdate.Interval = updateInterval;
            tmrPhysicsUpdate.Elapsed += new System.Timers.ElapsedEventHandler(tmrPhysicsUpdate_Elapsed);
            tmrPhysicsUpdate.Start();
            PhysicsEnabled = true;

            GeneralControllers = new List<Controller>();
        }
Beispiel #12
0
        private void InitializePhyics()
        {
            this.IsMouseVisible = true;

            PhysicsSystem world = new PhysicsSystem();
            world.CollisionSystem = new CollisionSystemSAP();

            testBox = new boxtest(this, "box");
            fallBox = new boxtest(this, "box", new Vector3(0,50,0));

            _camera = new Camera(this, testBox, new Vector3(5.0f, 5.0f, 5.0f), 6/8f, 0.1f, 10000.0f);

            testBox.Body.Immovable = true;
            fallBox.Body.Immovable = false;

            Components.Add(testBox);
            Components.Add(fallBox);
            Components.Add(_camera);
        }
 /// <summary>
 /// インスタンスを生成します。
 /// </summary>
 /// <param name="game">インスタンスを登録する Game。</param>
 /// <param name="physicsSystem">JigLibX の PhysicsSystem。</param>
 public JigLibXComponent(Game game, PhysicsSystem physicsSystem)
     : base(game)
 {
     this.physicsSystem = physicsSystem;
 }
        private void CreatePhysicsSystem()
        {
            physicSystem = new PhysicsSystem();
            physicSystem.CollisionSystem = new CollisionSystemSAP();

            physicSystem.EnableFreezing = true;
            physicSystem.SolverType = PhysicsSystem.Solver.Normal;
            physicSystem.CollisionSystem.UseSweepTests = true;

            physicSystem.NumCollisionIterations = 5;
            physicSystem.NumContactIterations = 5;
            physicSystem.NumPenetrationRelaxtionTimesteps = 15;
            physicSystem.Gravity = new Vector3(0, -9.8f, 0);
        }
Beispiel #15
0
        private void InitializePhysics()
        {
            PhysicsSystem world = new PhysicsSystem();
            world.CollisionSystem = new CollisionSystemSAP();
            world.SolverType = PhysicsSystem.Solver.Normal;

            //world.CollisionTollerance = 0.0001f;
            //world.AllowedPenetration = 0.001f;

            fallingBox = new BoxActor(this, new Vector3(85, 25, -65), new Vector3(3f, 2f, 4f));
            //immovableBox = new BoxActor(this, new Vector3(40, 15, -25), new Vector3(5f, 1f, 5f));
            //immovableBox.Body.Immovable = true;
            Components.Add(fallingBox);
            //Components.Add(immovableBox);

            fallBoxForce = new ForceControler(fallingBox.Body, new Vector3(0, 0, 0), false);
            //fallBoxForce.Force = new Vector3(0, 19, 0);
        }
Beispiel #16
0
 public void InitializePhysics()
 {
     world = new PhysicsSystem();
     world.CollisionSystem = new CollisionSystemSAP();
     world.SolverType = PhysicsSystem.Solver.Normal;
 }
Beispiel #17
0
 public JigLibWorld()
 {
     world = new PhysicsSystem();
     world.CollisionSystem = new CollisionSystemSAP();
 }
Beispiel #18
0
        protected override void Initialize()
        {
            #region IInputDeviceService

            inputDeviceService = new InputDeviceServiceComponent(this);
            inputDeviceService.UpdateOrder = 0;
            Components.Add(inputDeviceService);
            Services.AddService<IInputDeviceService>(inputDeviceService);

            #endregion

            #region IAudioService

            audioService = new AudioService(this, true);
            audioService.UpdateOrder = 10;
            Components.Add(audioService);
            Services.AddService<IAudioService>(audioService);

            #endregion

            #region IScreenService

            screenContainer = new ScreenContainer(this);
            screenContainer.BackgroundColor = Color.DimGray;
            screenContainer.UpdateOrder = 20;
            screenContainer.DrawOrder = 10;
            Components.Add(screenContainer);

            #endregion

            #region IPhysicsService

            // JigLibX ����������܂��B
            var physicsSystem = new PhysicsSystem();

            // Freezing ��L���ɂ��܂��B
            physicsSystem.EnableFreezing = true;

            // CollisionSystem ����������܂��B
            physicsSystem.CollisionSystem = new CollisionSystemSAP();

            // DetectFunctor ��o�^���܂��B
            physicsSystem.CollisionSystem.RegisterCollDetectFunctor(new CollDetectBoxCubicHeightmap());
            physicsSystem.CollisionSystem.RegisterCollDetectFunctor(new CollDetectCapsuleCubicHeightmap());

            // �񓯊� IPhysicsService ����������܂��B
            physicsService = new JigLibXAsyncPhysicsService(this, physicsSystem);

            // ICollisionShape ��o�^���܂��B
            physicsService.AddCollisionShape<IBoxCollisionShape, BoxCollisionShape>();
            physicsService.AddCollisionShape<IMeshCollisionShape, MeshCollisionShape>();
            physicsService.AddCollisionShape<ISlopeCollisionShape, SlopeCollisionShape>();
            physicsService.AddCollisionShape<IPlaneCollisionShape, PlaneCollisionShape>();
            physicsService.AddCollisionShape<ICubeHeightmapCollisionShape, CubeHeightmapCollisionShape>();

            // �e�X�g�p�� ICollisionTester ��o�^���܂��B
            //physicsService.CollisionTester = new SampleCollisionTester();

            // �񓯊� IPhysicsService ��T�[�r�X�o�^���܂��B
            Services.AddService<IPhysicsService>(physicsService);

            #endregion

            #region Debugs

            #if DEBUG
            InitializeDebugContent();
            #endif

            #endregion

            base.Initialize();

            audioService.SetVolume("Music", 0.1f);
        }
        public AsyncPhysicsSystem(Game game, PhysicsSystem physicsSystem)
        {
            this.physicsSystem = physicsSystem;

#if !XBOX && !USE_VOLATILE
			beginUpdateEvents = new WaitHandle[] { exitEvent, completedEvent };
			threadEvents = new WaitHandle[] { beginEvent, exitEvent };
#endif
            
            targetStepTime = game.IsFixedTimeStep ? (float) game.TargetElapsedTime.TotalSeconds : 1.0f / 60.0f;
        }
 public PhysicsManager(BlockSimulatorGame game)
     : base(game)
 {
     _physicsSystem = new PhysicsSystem();
     _physicsSystem.CollisionSystem = new CollisionSystemSAP();
 }