locked
Sample Framework

    Question

  • I've been looking over the sample framework (empty project) and I can see a lot of useful things in there that would be great if I didnt have to reinvent the wheel, mostly in terms of handling input and GUI code, but...

    Even though the sample framework code has a lot of comments, it's still very hard to follow and feels like it's all over the place. I realise we all have different coding styles but I was wondering if anyone has some kind of tutorial breakdown of the way it works so that we can learn from it.

    Sunday, March 12, 2006 7:16 AM

Answers

  • I'm not aware of a book by Tom on this subject, if I recall correctly this is actually a chapter/section in his book 'Beginning 3D Programming' (could anyone confirm this?). The information on the sample framework in this book unfortunately won't go much above and beyond what you'll find online, even though the rest of the book makes it well worth getting.

    Anyway, here's a bird's eye view of the topics you mentioned:

    Key handling

    The keys in the sample framework are handled either through the standard Windows Forms key events (as shown in the EmptyProject sample) for which many tutorials can be found, but they can also be handled by processing the windows messages directly. This is done in the OnMsgProc method in the sample's main class.

    How this works can be seen in the Camera and Dialog classes of the sample framework. Basically you'll have a switch on the Windows Message (which is just an int, 16bit IIRC) to determine what you have to do with the messages you're getting. This is generally useful for highly efficient input handling (mouse as well). The sample framework's classes should give you a basic idea on how this works and I think it shouldn't be too hard to find tutorials on this subject elsewhere online.

    Cameras

    The cameras (FirstPerson and ModelView) work with Quaternions, which can be quite a difficult subject at first. I won't even try to explain it, but point you to the book 'Game Programming Gems 1' which contains an excellent explaination if you want to learn more about these.

    By using these quaternions for the core math, the cameras process user input through the aforementioned Windows Messages and produce the view matrix which will be set on the device or the effect used for rendering each frame. Since most of the sample framework's camera math is abstracted into the quaternion/arcball classes, they're not that great to learn from. A better starting resource on cameras would be Toymaker's page on the subject.

    Mesh loading

    Again, you won't find much information on this subject in the sample framework itself. Both of Tom's books contain thorough information on this subject though and there are plenty of tutorials online on how to do this.

    Text helpers

    The text helpers employ DirectX Font helper classes to render text onto Sprite object (which also is a helper class for rendering textures onto your screen, not to be confused with generic game sprites). C-Unit has various tutorials on implementing Bitmap fonts and a completely custom GUI available, which should be a bit easier to learn from.

    *pfew* Well, I hope this helps you out some more than my reply above. And now, go have fun 

    Sunday, March 12, 2006 10:44 PM

All replies

  • Might be usefull to look at the empty project and see what methods are called from there, then go into the sample framework and look at the code in those methods.

    If u want to use the framework for creating your applications, u should find all the help u need in the help files, there are topic about it ... think they are under graphics

    Sunday, March 12, 2006 12:00 PM
  • The sample framework is also explained in the SDK's documentation, which can be found here on MSDN.

    Basically the items of most interest are the OnDeviceReset, OnDeviceLost, OnFrameMove and OnFrameRender methods that get created in your sample class when you install it. The Reset and Lost methods allow you to create and dispose of resources, while the Move and Render methods allow you to update your game world and render it.

    The rest of the framework can indeed be a bit murky to get through, but when you take it one piece at a time, it should become clear in time  I found the Visual Studio "Go to definition" function (right-click on a class/member/something in your code and select it in the popup menu) extremely useful in navigating the Sample Framework code.

    Good luck at any rate :)

    Sunday, March 12, 2006 2:46 PM
  •  Rim van Wersch wrote:

    The sample framework is also explained in the SDK's documentation, which can be found here on MSDN.

    Basically the items of most interest are the OnDeviceReset, OnDeviceLost, OnFrameMove and OnFrameRender methods that get created in your sample class when you install it. The Reset and Lost methods allow you to create and dispose of resources, while the Move and Render methods allow you to update your game world and render it.

    The rest of the framework can indeed be a bit murky to get through, but when you take it one piece at a time, it should become clear in time  I found the Visual Studio "Go to definition" function (right-click on a class/member/something in your code and select it in the popup menu) extremely useful in navigating the Sample Framework code.

    Good luck at any rate :)

    I hear what you're saying, and I have viewed that documentation in my local SDK. Those methods you speak of are interesting yes, but for me they are of least interest. I'm interested in using the other features provided, such as the key handling, cameras, mesh loading, text helpers and so forth.

    I actually found what I was looking for after a lot of looking, it's a book called something like "Understanding the sample framework" by Tom Miller, which is unavailble from anywhere that I can find.

    Needless to say, I'm just going to have to spend the next few weeks exploring the sample framework to see if I can figure out how it works.

    Sunday, March 12, 2006 10:20 PM
  • I'm not aware of a book by Tom on this subject, if I recall correctly this is actually a chapter/section in his book 'Beginning 3D Programming' (could anyone confirm this?). The information on the sample framework in this book unfortunately won't go much above and beyond what you'll find online, even though the rest of the book makes it well worth getting.

    Anyway, here's a bird's eye view of the topics you mentioned:

    Key handling

    The keys in the sample framework are handled either through the standard Windows Forms key events (as shown in the EmptyProject sample) for which many tutorials can be found, but they can also be handled by processing the windows messages directly. This is done in the OnMsgProc method in the sample's main class.

    How this works can be seen in the Camera and Dialog classes of the sample framework. Basically you'll have a switch on the Windows Message (which is just an int, 16bit IIRC) to determine what you have to do with the messages you're getting. This is generally useful for highly efficient input handling (mouse as well). The sample framework's classes should give you a basic idea on how this works and I think it shouldn't be too hard to find tutorials on this subject elsewhere online.

    Cameras

    The cameras (FirstPerson and ModelView) work with Quaternions, which can be quite a difficult subject at first. I won't even try to explain it, but point you to the book 'Game Programming Gems 1' which contains an excellent explaination if you want to learn more about these.

    By using these quaternions for the core math, the cameras process user input through the aforementioned Windows Messages and produce the view matrix which will be set on the device or the effect used for rendering each frame. Since most of the sample framework's camera math is abstracted into the quaternion/arcball classes, they're not that great to learn from. A better starting resource on cameras would be Toymaker's page on the subject.

    Mesh loading

    Again, you won't find much information on this subject in the sample framework itself. Both of Tom's books contain thorough information on this subject though and there are plenty of tutorials online on how to do this.

    Text helpers

    The text helpers employ DirectX Font helper classes to render text onto Sprite object (which also is a helper class for rendering textures onto your screen, not to be confused with generic game sprites). C-Unit has various tutorials on implementing Bitmap fonts and a completely custom GUI available, which should be a bit easier to learn from.

    *pfew* Well, I hope this helps you out some more than my reply above. And now, go have fun 

    Sunday, March 12, 2006 10:44 PM
  • Thanks for your input Rim, it has helped me sort out some of the issues I have with the way I am proceeding. I have previously read a lot of info on the toymaker site, and I do have Tom's kickstart book.

    I also had a look over the c-unit site, but his tutorials suffer the same problem as most books do: he writes his own library (one that I find very difficult to comprehend) and then works off that, so his GUI handling (which was what I was most interested in on his site) was useless to me.

    I know I sound like a n00b but that's just my communication skills. I am the only programmer of my experience that I know personally, and that makes it hard when you have noone to bounce ideas off. I've been playing with directx stuff on and off since DX2 with both pascal and c++.

    I had directinput working in my c++ version of the game, but I have issues with the workings of header files and Microsoft's tendency to use 57 macros to redefine __stdcall and char.

    So now, it looks like my plan is to go through the sample framework and pilfer the bits I want, such as the msg loop (which is so easy for me in c++ but I have no real clue about it in c#) and also the dialog and text handlers.

    Thanks again.

    Sunday, March 12, 2006 11:47 PM
  • Glad to see it was of some help. Sorry if I came across as condescending, such was not my intent

    Monday, March 13, 2006 1:13 AM
  •  Rim van Wersch wrote:

    Glad to see it was of some help. Sorry if I came across as condescending, such was not my intent

    Nothing like that at all. I write large professional database driven websites for a living, but I certainly don't know everything, and in a lot of cases, I am still missing basic skills, which are showing up in the questions I ask here. My posting style just doesn't show that I know much I guess!

    Monday, March 13, 2006 5:35 AM
  • http://www.tech-resource.gotdns.com/resources/resource.php?article=10

    Simple DirectX DXUT Framework Tutorial posted by Brian De Sousa on the DirectX newsgroups ;)

    Tuesday, March 14, 2006 7:41 AM
  • Thanks I'll check that one out shortly =)
    Tuesday, March 14, 2006 9:39 AM
  • ... if I recall correctly this is actually a chapter/section in his book 'Beginning 3D Programming' (could anyone confirm this?) ...


    Yes, 'Beginning 3D Game Programming': chapter 3: understanding the Sample Framework. Very good book, btw. I'm waiting for the next upcoming release on the subject.

    One question: is there an example of the sample framework for DX10 using c#? (the ones available now are only for c++)


    Friday, March 17, 2006 5:36 PM