SetDebugDraw() public method

Register a routine for debug drawing. The debug draw functions are called inside the World.Step method, so make sure your renderer is ready to consume draw commands when you call Step().
public SetDebugDraw ( DebugDraw debugDraw ) : void
debugDraw DebugDraw
return void
Example #1
0
		public Test()
		{
			_worldAABB = new AABB();
			_worldAABB.LowerBound.Set(-200.0f, -100.0f);
			_worldAABB.UpperBound.Set(200.0f, 200.0f);
			Vec2 gravity = new Vec2();
			gravity.Set(0.0f, -10.0f);
			bool doSleep = true;
			_world = new World(_worldAABB, gravity, doSleep);
			_bomb = null;
			_textLine = 30;
			_mouseJoint = null;
			_pointCount = 0;

			_destructionListener.test = this;
			_boundaryListener.test = this;
			//_contactListener.test = this;
			_world.SetDestructionListener(_destructionListener);
			_world.SetBoundaryListener(_boundaryListener);
			//_world.SetContactListener(_contactListener);
			_world.SetDebugDraw(_debugDraw);
		}
Example #2
0
        /// <summary>
        /// Called to setup the arena boundaries and bind to all of the physics stuff.
        /// </summary>
        public virtual void Bind()
        {
            float width = dimensions.X, height = dimensions.Y;

            worldAABB = new AABB();
            worldAABB.LowerBound.Set(-width / 2 - edgeTolerance, -edgeTolerance);
            worldAABB.UpperBound.Set(width / 2 + edgeTolerance, height + edgeTolerance);

            Vec2 gravity = new Vec2(this.gravity.X, this.gravity.Y);
            bool doSleep = true;
            world = new World(worldAABB, gravity, doSleep);
            world.SetContactFilter(new ContactFilter());

            BodyDef groundBodyDef = new BodyDef();
            groundBodyDef.Position.Set(0.0f, 0.0f);

            Body groundBody = world.CreateBody(groundBodyDef);

            // Bottom
            AddBoundaryBlock(groundBody, 0, -(boundaryThickness / 2), width + boundaryThickness * 2, boundaryThickness);
            // Top
            AddBoundaryBlock(groundBody, 0, height + boundaryThickness / 2, width + boundaryThickness * 2, boundaryThickness);
            // Left
            AddBoundaryBlock(groundBody, -(width / 2) - boundaryThickness / 2, height / 2, boundaryThickness, height + boundaryThickness * 2);
            // Right
            AddBoundaryBlock(groundBody, +(width / 2) + boundaryThickness / 2, height / 2, boundaryThickness, height + boundaryThickness * 2);

            DebugDraw draw = new OpenTKDebugDraw();
            draw.Flags = DebugDraw.DrawFlags.Shape;
            if (Program.DebugDraw)
            {
                world.SetDebugDraw(draw);
            }

            world.SetContactListener(this);

            // Old code for reference

            /*
             *

             * _worldAABB = new AABB();
            _worldAABB.LowerBound.Set(-30.0f, -20.0f);
            _worldAABB.UpperBound.Set(30.0f, 40.0f);
            Vec2 gravity = new Vec2();
            gravity.Set(0.0f, -10.0f);
            bool doSleep = true;
            _world = new World(_worldAABB, gravity, doSleep);
            _world.SetContactFilter(new ContactFilter());

            BodyDef groundBodyDef = new BodyDef();
            groundBodyDef.Position.Set(0.0f, 0.0f);

            Body groundBody = _world.CreateBody(groundBodyDef);

            AddBlock(groundBody, 0, -5, 40, 10);
            AddBlock(groundBody, -20, 20, 1, 40);
            AddBlock(groundBody, 20, 20, 1, 40);
            AddBlock(groundBody, 0, 30, 40, 10);

            DebugDraw draw = new OpenTKDebugDraw();
            draw.Flags = DebugDraw.DrawFlags.Shape;
            if (Program.DebugDraw) {
                _world.SetDebugDraw(draw);
            }

            _world.SetContactListener(this);
             */
        }
Example #3
0
        public Test()
        {
            Vec2 gravity = new Vec2();
            gravity.Set(0.0f, -10.0f);
            bool doSleep = true;
            _world = new World(gravity, doSleep);
            _bomb = null;
            _textLine = 30;
            _mouseJoint = null;
            _pointCount = 0;

            _destructionListener.test = this;
            _world.SetDestructionListener(_destructionListener);
            _world.SetContactListener(this);
            _world.SetDebugDraw(_debugDraw);

            _bombSpawning = false;

            _stepCount = 0;

            BodyDef bodyDef = new BodyDef();
            _groundBody = _world.CreateBody(bodyDef);
        }