{"id":754,"date":"2013-12-05T22:35:17","date_gmt":"2013-12-05T21:35:17","guid":{"rendered":"http:\/\/labalec.fr\/erwan\/?p=754"},"modified":"2013-12-05T22:47:06","modified_gmt":"2013-12-05T21:47:06","slug":"vb-net-and-xna-article-23-use-debugviewxna-in-farseer","status":"publish","type":"post","link":"https:\/\/labalec.fr\/erwan\/?p=754","title":{"rendered":"VB.Net and XNA : Article 23 &#8211; Use DebugViewXNA in Farseer"},"content":{"rendered":"<p>Farseer has one specific not always easy to deal with : your world is meant in KMS (kilo meter second) whereas your rendering is in pixel.<br \/>\nAdded to that, your world and rendering are two complete different things which does not make it easy to debug.<\/p>\n<p>This where the DebugViewXNA class kicks in : it will render your world \ud83d\ude42<br \/>\nThis and a few other things like stats, datas, etc.<\/p>\n<p>The how to use the DebugViewXNA class is rather easy :<\/p>\n<p>&#8211;<strong>add the project reference<\/strong> to debugview.xna.dll<br \/>\n&#8211;<strong>add an imports<\/strong> to FarseerPhysics.DebugView<br \/>\n&#8211;<strong>declare <\/strong>a _debugView As DebugViewXNA<br \/>\n&#8211;<strong>set it up<\/strong> in loadcontent (for instance) :<br \/>\n<code><br \/>\n_debugView = New DebugViewXNA(world)<br \/>\n        _debugView.AppendFlags(DebugViewFlags.DebugPanel)<br \/>\n        _debugView.DebugPanelPosition = New Vector2(15, 15)<br \/>\n        _debugView.DefaultShapeColor = Color.White<br \/>\n        _debugView.SleepingShapeColor = Color.LightGray<br \/>\n        _debugView.LoadContent(GraphicsDevice, Content)<br \/>\n<\/code><br \/>\n-use it in your draw method (after your spritebatch.end) :<br \/>\n<code><br \/>\nDim projection As Matrix = Matrix.CreateOrthographicOffCenter(0.0F, graphics.GraphicsDevice.Viewport.Width * DrawablePhysicsObject.pixelToUnit, graphics.GraphicsDevice.Viewport.Height * DrawablePhysicsObject.pixelToUnit, 0.0F, 0.0F, 1.0F)<br \/>\n_debugView.RenderDebugDataVB(projection)<br \/>\n<\/code><\/p>\n<p>A video to illustrate switching between rendering and debugging.<br \/>\n<div style=\"width: 695px;\" class=\"wp-video\"><video class=\"wp-video-shortcode\" id=\"video-754-1\" width=\"695\" height=\"493\" preload=\"metadata\" controls=\"controls\"><source type=\"video\/mp4\" src=\"https:\/\/labalec.fr\/erwan\/wp-content\/uploads\/2013\/12\/XNA_DEMO_23_.mp4?_=1\" \/><a href=\"https:\/\/labalec.fr\/erwan\/wp-content\/uploads\/2013\/12\/XNA_DEMO_23_.mp4\">https:\/\/labalec.fr\/erwan\/wp-content\/uploads\/2013\/12\/XNA_DEMO_23_.mp4<\/a><\/video><\/div><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Farseer has one specific not always easy to deal with : your world is meant in KMS (kilo meter second) whereas your rendering is in pixel. Added to that, your world and rendering are two complete different things which does not make it easy to debug. This where the DebugViewXNA class kicks in : it <a href='https:\/\/labalec.fr\/erwan\/?p=754' class='excerpt-more'>[&#8230;]<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[34,35],"tags":[],"class_list":["post-754","post","type-post","status-publish","format-standard","hentry","category-dotnet","category-xna","category-34-id","category-35-id","post-seq-1","post-parity-odd","meta-position-corners","fix"],"_links":{"self":[{"href":"https:\/\/labalec.fr\/erwan\/index.php?rest_route=\/wp\/v2\/posts\/754","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/labalec.fr\/erwan\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/labalec.fr\/erwan\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/labalec.fr\/erwan\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/labalec.fr\/erwan\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=754"}],"version-history":[{"count":2,"href":"https:\/\/labalec.fr\/erwan\/index.php?rest_route=\/wp\/v2\/posts\/754\/revisions"}],"predecessor-version":[{"id":757,"href":"https:\/\/labalec.fr\/erwan\/index.php?rest_route=\/wp\/v2\/posts\/754\/revisions\/757"}],"wp:attachment":[{"href":"https:\/\/labalec.fr\/erwan\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=754"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/labalec.fr\/erwan\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=754"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/labalec.fr\/erwan\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=754"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}