Physics Engine Woes Part 2
/
0 Comments
Well, we're back. and this time we have friends...not really. but anyway...*Cough*
and on with the useful info.
Today's post is a continuation of last weeks post...*cough!*...and it will be about how to implement the "Debug View" in your Farseer enabled XNA game.
First you need to copy the Debug View XNA folder into the main folder for your project. This can be found as part of the "Hello World" download from the farseer website. Be sure you are using Farseer 3.0 or better.
In your project right click on the title of your project in the solution explorer. select "Add" > Add an Existing Project. Navigate to where your copy of the Debug View is located and select the DebugView 3.0 XNA.csproj file. this will add the Debug data to your project. you will then need to add the following to your code:
public class Game1 : Microsoft.Xna.Framework.Game
{
private World world = new World(new Vector2(0, -60));
private DebugViewXNA debugView;
public Game1()
{
debugView = new DebugViewXNA(world);
}
protected override void LoadContent()
{
DebugViewXNA.LoadContent(graphics.GraphicsDevice, Content);
}
protected override void Draw(GameTime gameTime)
{
debugView.RenderDebugData(ref proj, ref view);
}
}
}
In the above code the lines you will need to add are listed in the methods they must be placed in. this is of course based on using the default XNA game setup.
one thing to mention is that the line:
private World world = new World(new Vector2(0, -60));
Is listed Because the farseer World variable is needed for the "DebugViewXNA(world);" call. you would need the world line even if you do not use the Debug View.
And if you do that you should then see all kinds of pretty shapes were all your Farseer Fixtures are.
I hope this helped. Next time I will go over some of the basics of how to use the Farseer Physics engine in your XNA game. until then, have fun tweaking.
CornDog
and on with the useful info.
Today's post is a continuation of last weeks post...*cough!*...and it will be about how to implement the "Debug View" in your Farseer enabled XNA game.
First you need to copy the Debug View XNA folder into the main folder for your project. This can be found as part of the "Hello World" download from the farseer website. Be sure you are using Farseer 3.0 or better.
In your project right click on the title of your project in the solution explorer. select "Add" > Add an Existing Project. Navigate to where your copy of the Debug View is located and select the DebugView 3.0 XNA.csproj file. this will add the Debug data to your project. you will then need to add the following to your code:
public class Game1 : Microsoft.Xna.Framework.Game
{
private World world = new World(new Vector2(0, -60));
private DebugViewXNA debugView;
public Game1()
{
debugView = new DebugViewXNA(world);
}
protected override void LoadContent()
{
DebugViewXNA.LoadContent(graphics.GraphicsDevice, Content);
}
protected override void Draw(GameTime gameTime)
{
debugView.RenderDebugData(ref proj, ref view);
}
}
}
In the above code the lines you will need to add are listed in the methods they must be placed in. this is of course based on using the default XNA game setup.
one thing to mention is that the line:
private World world = new World(new Vector2(0, -60));
Is listed Because the farseer World variable is needed for the "DebugViewXNA(world);" call. you would need the world line even if you do not use the Debug View.
And if you do that you should then see all kinds of pretty shapes were all your Farseer Fixtures are.
I hope this helped. Next time I will go over some of the basics of how to use the Farseer Physics engine in your XNA game. until then, have fun tweaking.
CornDog


