Running on Empty

The few things I know, I like to share.

XNA GameEngine Development Series

76 Comments »

  1. [...] XNA GameEngine Development Series [...]

    Pingback by XNA Framework GameEngine Development. (Part 1) « Running on Empty | January 28, 2008 | Reply

  2. Regarding your latest works you might consider using BulletX instead of Newton for your physics simulations the reason being that it is a fully managed system so it’s usable on the 360 and has quite a bit of support. Naturally if you’ve done some work with Newton already and would like to get your ideas out quicker then Newton’s your better option. Readers can simply gather the idea you’re conveying and substitute any system they need. Mostly I just wanted to let you know BulletX existed because I’m a fan of it, as far as 3D physics go.

    Comment by kt | February 22, 2008 | Reply

  3. kt,
    Thank you for your comment. I took a good long look at BulletX and you have convinced me. I will spend some time working on using it in the engine for some demos.

    I very much appreciate informed suggestions like these so please keep them coming.

    Comment by roecode | February 22, 2008 | Reply

  4. The physics puts the smaller boxes edge within thw large box top. This means the smaller boxes do not lay flat? Is this a issue with the engine?

    Comment by GRICES | March 3, 2008 | Reply

  5. GRICES, yes I have noticed the same thing. I need to do some more testing, it more than likely has to do with some setup of the BulletX engine that I have forgotten. Let me know if you find out what my problem could be.

    Comment by roecode | March 3, 2008 | Reply

  6. I noticed you switched to JigLibX, I grabbed the source from series 18. I was usually just copy/pasting your changes into my test engine to follow along, since I’m making changes as I go. It might be worth pointing this out as series 14, still shows your using BulletX.

    It is nice though, since I’ve been using JigLibX from the start anyways, haha.

    Comment by KaBaL | March 12, 2008 | Reply

  7. Yes, I made mention of this in a recent article. I am not fully convinced which physics engine I like best.

    Comment by roecode | March 13, 2008 | Reply

  8. Is Sound included in future articles ?

    Comment by Karim Kenawy | March 26, 2008 | Reply

  9. Kiram, wow man you have made a lot of comments, I am very happy to have struck a cord with you. Yes, I do plan on doing sound as well. I have a long way to go to finish this engine plus improvements along the way.

    This series will continue until I am finished, ie. will not be done any time soon.

    Comment by roecode | March 26, 2008 | Reply

  10. Sorry if I bothered you. My graduation project is a game, so I’m making my Engine by the help of your tutorials, so forgive my questions :) .

    Comment by Karim Kenawy | March 26, 2008 | Reply

  11. Kiram, no you are not bothering me. I am more than happy to answer any questions about the engine.

    Just have a long way to go until I am finished here. I would very much like to see your project when you are finished.

    Comment by roecode | March 26, 2008 | Reply

  12. I really like the series so far, great job! Any idea when the next article will come out?

    Comment by Eric | April 10, 2008 | Reply

  13. I have been working on a few other projects at the moment. But have an article nearly complete for next week.

    Comment by roecode | April 11, 2008 | Reply

  14. [...] April 12, 2008 Over at the “Running on Empty” blog, there is currently a nice series on game engine development with XNA in the making. It looks nice to actually watch someone doing such a major task and blogging about [...]

    Pingback by Series on XNA Game Engine Development: | April 12, 2008 | Reply

  15. Nice work. Looking forward to future articles. I have been trying to add normal mapped model rendering, but have a problem. The draw call in RoeSceneObject does a foreach Xna.Framework.Graphics.BasicEffect, but my Normal Mapped models use Xna.Framework.Content.EffectMaterial. Perhaps each Model should know how to draw itself instead of each Scene Object – and the Scene Object draw method would simply call the referenced model’s draw method instead? Any input on this?

    Comment by Litfu$e | April 19, 2008 | Reply

  16. Litfu$e, yes what you are referring to is batch drawing and yup I have recently been rewriting much of the engine to take advantage of it. I do intend to post some new articles soon, but want engine performance to improve drastically before I do.

    I also have been working on some new managers for shaders and materials so that I can take advantage of the content pipeline a little more.

    Comment by roecode | April 21, 2008 | Reply

  17. I got the normal mapping working by creating a new “Standard Object” that inherits from RoeSceneObject and overriding the Draw and DrawCulling methods (and using a custom processor to load the normal mapped models).

    I can’t wait to see you new stuff!

    Comment by Litfu$e | April 22, 2008 | Reply

  18. Is there perhaps any planned multiplayer or network code implementation for any of the future articles?

    Comment by Q | April 29, 2008 | Reply

  19. No I don’t have any planned articles on network or multiplayer functionality. That doesn’t mean it wont strike an interest with me and require a series though. Just has not been an interest of mine yet.

    Comment by roecode | April 29, 2008 | Reply

  20. Hi

    How can I add physics to your box object? Well all I want to do is a gravity to the static box, or standard box and disable world gravity. I already added an overide to the physics manager to handle environment gravity. But am not getting it right to add gravity to a boxes body.

    Thanks
    Hope u can help
    Q

    Comment by Q | May 17, 2008 | Reply

  21. I already have examples of using the Box object with physics. The static box is meant to be just that “static”, ie not effected by gravity.

    I dont understand your desire to turn off world gravity. I suppose you are looking for some localized gravitational object? In that case I suggest you look into the JigX tutorials on how to do localized gravity.

    Comment by roecode | May 19, 2008 | Reply

  22. I am trying to simulate gravity in space having one object drawn closer by another (the one with the gravitational field.

    I implemented a controler for the standard box, but am having some serious problem with calculating the physics to apply to it so it can be gradually acelerate torwards the other box with the gravity.

    Tried finding tutorials for Jiglib or JiglibX, not getting very far with that as I cant find any relative tutorials.

    Will post the controler code when/if I get it right.

    Comment by Q | May 21, 2008 | Reply

  23. Q,
    That sounds wonderful! Honestly, I have not set up a system like the one your are working on here. Personally, I do not think JigLibX is a good physics library for what you are trying to achieve.

    In the “next generation” of the RoeEngine, which I have been working on creating articles, I have gone over to the PhyX engine. It is a bit more flexible in the types of systems you can use, but doesn’t run on the XBox360.

    Comment by roecode | May 21, 2008 | Reply

  24. As promissed, here’s the code :]
    http://www.codeplex.com/JigLibX/Thread/View.aspx?ThreadId=27845

    I am sure this can be optimised and revised a bit. But it works good enough in my game (thus far) I only needed to apply the gravity on 2 of the dimensions, but adding it to the Z axis is as easy as copy paste…

    Looking forward to the next few articles!!! PhysX is a really good library, just not to happy about the no X360 support :[[ I really think they should make it supported on the 360 though, as I would like to have my games run on 360 too.

    Comment by Q | May 27, 2008 | Reply

  25. Q,
    Very nice, I will most likely have a good long look at this article when I get some free time. Thank you for posting your findings.

    Comment by roecode | May 27, 2008 | Reply

  26. Hi reo,
    i have a question which is not related to your engine ;-)
    Could you please tell me which code-plugin u’re using within this blog?
    ty

    Comment by J2T | June 10, 2008 | Reply

  27. So, I’ve finally downloaded your code to test it, rather than just reading your posts. I ported everything over for 360, and I’m only getting between 25-35 FPS in an empty scene. What gives? Is there some cycle-stealing method somewhere?

    BTW, I’m using an empty scene because the Kynskavion project hangs somewhere between GameplayScreen.LoadContent() and GamePlayScreen.Update(). If I remove all of the SceneObjects added during LoadContent it runs the CornflowerBlue screen just fine.

    Comment by JeBuS | June 10, 2008 | Reply

  28. Follow up:

    When running the same blank scene on my laptop (Intel integrated gfx) I actually get between 35-40FPS. There seems to be something mighty screwy going on here.

    Comment by JeBuS | June 10, 2008 | Reply

  29. J2T I am simply using the [sourcecode] flags that are standard with WordPress.

    Comment by roecode | June 11, 2008 | Reply

  30. JeBuS,
    Pretty much you ran into the same problem I did, that is the main reason why you have not seen many new articles in this series. I am completely reworking just about everything with performance in mind. Quite a few “mistakes” in my original implementation.

    Comment by roecode | June 11, 2008 | Reply

  31. I’m curious to hear more about that process as well. Reading how you find and correct / change things can be just as enlightening as the original articles.

    Something else I ran into. When I enabled the Ragdolls the Menu system displayed in WireFrame. I can see that you set the RenderState for that (somewhere, but I don’t remember where now), but you don’t have any handling for the MenuScreens to revert to Solid fill mode. I added that to all of the screen Draw methods I could find, but I couldn’t seem to fix the FPS stuff on the Gameplay Screen. Couldn’t find where it was being drawn at. (I admit I didn’t look to thoroughly for it, though.)

    And lastly. I did manage to tweak the engine to get the empty scene to render at about 1350FPS on the 360. I’m not sure how just yet, it happened amidst some other stuff I was doing, and I haven’t narrowed it down to any one thing. The scene with just the 25 Ragdolls (as no other objects work without hanging the game) runs at about 35FPS now. So, at least there was some small progress, but it’s still awful.

    Anyhow, I’m looking forward to your revisions, and I hope these comments help in some small way.

    Comment by JeBuS | June 11, 2008 | Reply

  32. OK, more comments from me! (I know, you must be getting sick of them by now!)

    I did some profiling to see what was eating up all the cpu cycles.

    55% System.Threading.ThreadHelper.ThreadStart
    41% Kynskavion.Program.Main

    This suggests to me (with my rather limited multi-threading knowledge) that the effort put into using all those threads is cutting the performance of the game in half. I thought I read somewhere that starting threads was costly in itself, so you should to it as little as possible. Is this a problem of starting new threads too frequently?

    Comment by JeBuS | June 12, 2008 | Reply

  33. More testing comments! (Sorry!)

    Removed all forms of ThreadStart from the game (all the managers and whatnot).

    On a blank scene, 1450FPS: +100FPS. On 25 Ragdolls, 37FPS: +2FPS.

    Threading does seem to be hurting performance, but not as much as would account for the generally low performance with so few objects.

    Also, it seems System.Threading.ThreadHelper.ThreadStart took about 49% of the cpu usage. The 6% less used corresponds almost exactly with the increase in FPS.

    Comment by JeBuS | June 12, 2008 | Reply

  34. JeBuS,
    You have been busy man, I do appreciate all of your help. First, you are correct, this model does rely heavily on helper threads, which is very bad. Also, the JigLibX physics library is slow. Also, I am not taking advantage of geometry batching as much as I should.

    So there are plenty of tweaks I can make and am making in the new version of the engine.

    Comment by roecode | June 12, 2008 | Reply

  35. Heh, I’ll just be quiet then, and let the pro deal with it. ;) Plenty of other things I can fiddle with in the meantime. Any ETA on your new version?

    Comment by JeBuS | June 12, 2008 | Reply

  36. JeBuS,
    I am hardly a pro at this stuff, so I definitly need peers to review the work I create. It is people like you that drive me to produce better work.

    The RoE3 engine is actually in the works, working on a better menu system currently and rethinking batching and multithreading. Also, highly considering other “managed” physics library for the XBox360 and the PhysX engine for PC implementations.

    I do wish I could give you a better ETA, writing these articles does seem to take me a lot of time.

    Comment by roecode | June 12, 2008 | Reply

  37. That reminds me… Is there a simple way to disable the PhysicsManager altogether if it’s not needed? Or any of the other Managers for that matter.

    Comment by JeBuS | June 12, 2008 | Reply

  38. Yes as a matter of fact, you can simply not add any manager to the Components of the RoeEngine. If a manager is not added it simply does not initialize.

    However, I have been toying around with the idea of making all managers plug-ins. That way you will be able to pick and chose via config file which managers get loaded.

    Comment by roecode | June 12, 2008 | Reply

  39. Hmm, not quite that simple, but almost. SceneGraphManager.Update still calls PhysicsManager.Update, but I just put a check:
    if(PhysicsManager.Initialized)
    PhysicsManager.Update(gameTime);

    And that did the trick for the Physics. Don’t know about the other Managers just yet, but that’s something you might want to remember to add for RoE3.

    Comment by JeBuS | June 12, 2008 | Reply

  40. So, any update on progress for the next release of the engine?

    Really looking forward to the next installment of engine tweaks and enhancements.

    Comment by Q | June 30, 2008 | Reply

  41. Why not use PhysX?

    Comment by sajmons | July 8, 2008 | Reply

  42. My understanding of PhysX is that it does not work on the XBox360. Honestly, I have not tried it.

    Comment by roecode | July 8, 2008 | Reply

  43. That’s true, it isn’t managed. I understand your dilema.
    There are two choices. Supporting XBOX and have poor physic on both platforms, or stick with yust one platform with outstanding full featured physic engine (http://code.google.com/p/physxdotnet/). Hmmm, but mybe there is third way with BEPU physic (http://bepu-games.com/BEPUphysics/index.html)?

    Comment by sajmons | July 9, 2008 | Reply

  44. My feature suggestions would be:
    - Particle system
    - Collada content pipeline
    - Some nice clouds system (with particle system rain and snow support, mybe some wind too :) )
    - Water with buoyancy and underwater shader
    - Vegetation generator (grass, procedural Trees – http://www.codeplex.com/XNATrees)
    - Endless terain – skydome (or something I’m not an expert) to support flight simulations

    I’m realy admiring your work and can’t wait for next article.

    Comment by sajmons | July 9, 2008 | Reply

  45. Sajmons,
    You hit upon my problem, do I support the Xbox360 and PC completely with a poor physics simulation or the PC with a great simulation? I flip flop almost on a daily basis between those decisions.

    Actually, I am seriously moving toward supporting one for the PC and another for the XBox. The “new” designs I am working on treats managers as plugable components. That way developers using the engine have better options for using the engine.

    My main goal with this series is to demonstrate reasonable techniques for creating a working engine. I never intended for anybody to actually use the engine as is.

    Comment by roecode | July 10, 2008 | Reply

  46. I have been following this EXCELLENT series and have to say that I am most impressed.

    Let me know if I can help with anything as I’m very keen to see RoE3 :-)

    Comment by Ardman | August 26, 2008 | Reply

  47. Can anyone help me with this tutorial via MSN? xsnip3rx@mythscape.org

    Comment by Xsnip3rX | August 26, 2008 | Reply

  48. Can you tell us roughly when we can expect the next part of this tutorial ?

    Comment by badwolfstudios | August 29, 2008 | Reply

  49. I am currently working on RoeEngine3. I will post as soon as possible, I am looking at starting the new article series early next year.

    Comment by roecode | August 29, 2008 | Reply

  50. Hi Roe,
    i have the same problem with running on laptops as another person wrote before!Not only on laptops also on my pc i can imagine to have more performace!
    Did you find something serious bugs/mistakes which you can post?
    ty

    Comment by J2T | September 26, 2008 | Reply

  51. Thank’s for your excellent work.

    I am very interested to see the new version of your engine!

    Comment by Kenshin | September 27, 2008 | Reply

  52. Hi Roe,
    Thanks for so great and useful series.
    I have some problem with viewing some component in 7 part.
    Does have any way to download last source code and content?

    Comment by Andrew | September 28, 2008 | Reply

  53. Oh, I saw in later parts.

    Comment by Andrew | September 29, 2008 | Reply

  54. [...] Verwendung einer Engine (RoE2) und deren Weiterentwicklung – Implementierung von Shadern und Physics (BEPU) – Aufsetzen eines [...]

    Pingback by Softwareprojekt » Michael Palmer | October 30, 2008 | Reply

  55. hey i was just wondering teh status of this if there is still work being done cause i like the tutorials alot and it seems that all of the free engines etc have stoped development. I noticed you said that you would be realsing stuff next year just wondering if thats still the plan

    Comment by Zach Aller | November 6, 2008 | Reply

  56. Yup, been working on the next iteration of tutorials for release early next year. Some NDA projects using this engine have taken much of my time recently. The good news is you get to see all of the new code I’ve written for that project. The bad news, you have to wait for it.

    Comment by roecode | November 6, 2008 | Reply

  57. I would just like to say thank you for the tutorials.

    Comment by Anthony | November 14, 2008 | Reply

  58. Thanks for the good job so far. I can’t wait to see the new stuff.

    Comment by Andreas | December 2, 2008 | Reply

  59. I would like to ask will be out early next year, when the update ah?

    Too look forward to the!

    Comment by TianYu | December 11, 2008 | Reply

  60. This is an awesome reference and learning tool for beginners to game engine design and structure. If I can get my xna engine going in the near future I’d like to contribute some examples on advanced terrain rendering/optimization techniques. Again thank you for your tutorials they are excellent!

    Comment by Dirtman | January 6, 2009 | Reply

    • Absolutely, I would very much enjoy seeing user contributions.

      Comment by roecode | January 7, 2009 | Reply

  61. Very nice series, I’m curious what exactly do you work with? Publish some info about yourself :D Seems like a pretty cool job if it’s related to this kind of stuff.

    Comment by Ajden Towfeek | January 7, 2009 | Reply

    • Thank you for your interest, I am not a game developer. Not sure I could get as much enjoyment out of XNA if I was. I am a business applications developer in the general aviation industry. I was hired specifically to design and develop a point of sales system for our front desk operations. Has been a great experience being on the cutting edge of WPF and WCF applications. Yup it is a cool job.

      I also do consulting work in my “free” time. I have been working with a local private school to develop scheduling applications and games for special needs students. I am nearing completion of a educational plateform based on my business partners thesis. Wish I could talk more about this project, but since it is under NDA, it would be wiser not to say more.

      My personal interests lean more toward design and system architecture. I am by no means a game development expert.

      Comment by roecode | January 7, 2009 | Reply

  62. Hi RoEcode, I’d like to say, Awesome job on a really in depth series here! I’m curious if you could suggest what pre-requisite knowledge someone needs to follow along with these articles? I ask because the more I attempt to understand what’s going on here the more I’m discovering huge gaps in my knowledge. I’ve never coded a game before , and I don’t have a programming background, but I’m eager to learn as much of the theory, math, and programming that goes behind designing a game engine like this. So as a complete begininer where would you suggest starting the path to knowledge?

    Thanks in advance! Keep up the great work!

    Comment by Kristafer Vale | February 3, 2009 | Reply

    • I am glad you enjoy the series. I do spend a lot of time with each article. As for prerequisite knowledge… well that is a bit difficult to answer. I want to suggest a college education, but there are obviously developers that write games without one. I read other game developers suggest to startups that they start with 2d games then move into 3d. However, I see enough differences in the thought process between 2d and 3d that it really isn’t a good arguement.

      So as a complete beginner, I would suggest you read as much as possible. Write code, every day! Writing code is like learning a foreign language, to become truely fluent you have to emmerse yourself on a daily basis. I’ve posted several blogs that I read on a daily basis in this site.

      Design as much as possible before you ever write a single line of code. Even as a beginner, you may have no clue what you should design. You have to force yourself to think like a designer. Anybody can be taught to write code. Only a rare few developers can design.

      Finally, figure out if you want to write games or write a game engine… you cant really do both. If you want to write games, start with a complete engine and write games. If you want to write a game engine, figure in your head that whatever project you are working on will take at least 3 years longer than you expected.

      Kristafer you are already ahead of the game though, you are able to look at your skillset and realize you have missing pieces. Read as much as you can, get a 4 year college education and write code every day.

      Comment by roecode | February 3, 2009 | Reply

  63. Cool thanks for the input and the awesome resources. :)

    Comment by winterkewl | February 3, 2009 | Reply

  64. Personally, I think the makes more sense to make focus on the pc version. Just about everybody has a PC that has SOME graphical ability. A lot of people have a 360, but out of them, only some subscribe to creators club. But for me at least, I would rather play a high(er) preforming game on my PC for free, than a low(er) preforming game on my 360 for $90 a year. I can barley convince my friends to install the XNA framework, let alone get them to pay for something. For physics though, have you considered Havok? I know it was made free due to something about Intel buying them, and there was an Xna wrapper being written for it by somebody else. It was called Xhk I think, I have no idea what happened with it, but it might be an option too if you don’t like JigLibX. I would not consider BEPU though, it does not have nearly as many features. JigLibX really could use some better documentation though.

    Comment by META_Cog | February 9, 2009 | Reply

  65. Is there a spot to get a final version of the code? It’s gotten a bit hard to follow the sequence of articles.

    Thanks. And what an awesome series!!!!

    Comment by dp | April 1, 2009 | Reply

    • Thank you for asking. Yup, in some of the later articles, I do provide code downloads.

      Comment by roecode | April 1, 2009 | Reply

  66. Awesome, thanks again for your work on this. So, the code available in #20 would be the latest?

    Comment by dp | April 1, 2009 | Reply

  67. I think 19 is the last time I posted code.

    Comment by roecode | April 1, 2009 | Reply

  68. Thanks for the excellent guide! XNA is fun but hard to break into.

    Comment by Nick Tantillo | April 10, 2009 | Reply

    • Thank you, glad you are enjoying the series.

      Comment by roecode | April 13, 2009 | Reply

  69. [...] e ho cercato “write a game engine XNA” e ho trovato un sito decisamente interessante: http://roecode.wordpress.com/xna-gameengine-development-series/. Ovviamente è in inglese e penso sia ottimamente [...]

    Pingback by Voglio scrivere un Game Engine! - Francesco Malatesta | June 20, 2009 | Reply

  70. Hi there! (sorry for my english)

    This is a fantastic tutorial series and i think i’m going to follow it really soon! I’ve also posted an article about this series on my blog, check it out!

    Awesome work!

    Francesco

    Comment by Francesco | June 20, 2009 | Reply

    • Glad you like the series, hope it is helpfu.

      Comment by roecode | June 22, 2009 | Reply


Leave a comment