tag:blogger.com,1999:blog-8768285918186248163.post7688145324972774375..comments2008-02-24T17:48:58.701-08:00Comments on the xna machine: SceneCamera class nears completionemachine74noreply@blogger.comBlogger10125tag:blogger.com,1999:blog-8768285918186248163.post-53663232373856399942008-02-24T17:48:00.000-08:002008-02-24T17:48:00.000-08:002008-02-24T17:48:00.000-08:00Okay, I got it working, thanks to your example. Ge...Okay, I got it working, thanks to your example. Getting 140 FPS without any optimizations.Tomhttp://three.homeip.netnoreply@blogger.comtag:blogger.com,1999:blog-8768285918186248163.post-3058016749872012912008-02-24T01:36:00.000-08:002008-02-24T01:36:00.000-08:002008-02-24T01:36:00.000-08:00I calculate FPS in a pretty archaic fashion: fps c...I calculate FPS in a pretty archaic fashion: <A HREF="http://pastebin.com/f69622e00" REL="nofollow">fps component</A><BR/><BR/>As for the on-screen timer & calculating elapsed times, I'm struggling to visualize what may be going on there - how are you using the gameTime object? Can you give an example?emachine74http://www.blogger.com/profile/16131803862986581964noreply@blogger.comtag:blogger.com,1999:blog-8768285918186248163.post-47706061154837919382008-02-23T23:46:00.000-08:002008-02-23T23:46:00.000-08:002008-02-23T23:46:00.000-08:00No, I have the fixed time step disabled, along wit...No, I have the fixed time step disabled, along with anything else that would lock the frame rate. As I said, my on-screen timer runs faster than normal, but my frame rate is locked at 60, which leads me to believe I'm not calculating it correctly, but that doesn't make sense because I use the same interval to calculate elapsed time.<BR/><BR/>I want to know how fast the program is running under the hood so I know how much leeway I have to add more features, and what impact each feature has. I'll work it out somehow. I wanted to get around using temporary variables to hold previous times, since XNA seems to keep track of its own timing, but it looks like I'll have to resort to old-school methods. This would be a good opportunity to make a "game timer" class.Tomhttp://three.homeip.netnoreply@blogger.comtag:blogger.com,1999:blog-8768285918186248163.post-39466441720282105602008-02-22T14:39:00.000-08:002008-02-22T14:39:00.000-08:002008-02-22T14:39:00.000-08:00Is your Game.IsFixedTimestep property True? This ...Is your Game.IsFixedTimestep property True? This property of the XNA Game class works in conjunction with the TargetElapsedTime property to control the frequency of Updates. The idea is similar to how VSync works in conjunction with your monitor to control the frequency of Draws.<BR/><BR/><A HREF="http://blogs.msdn.com/shawnhar/archive/2007/11/23/game-timing-in-xna-game-studio-2-0.aspx" REL="nofollow">Game Timing in XNA Game Studio 2.0</A><BR/><BR/>Personally I found it easier to learn stuff in a predictable, consistent, "update-then-draw" environment, without XNA tossing in extra updates or draws (and I still haven't encountered a reason to turn it on).emachine74http://www.blogger.com/profile/16131803862986581964noreply@blogger.comtag:blogger.com,1999:blog-8768285918186248163.post-2682737019262774542008-02-22T13:17:00.000-08:002008-02-22T13:17:00.000-08:002008-02-22T13:17:00.000-08:00I was going to ask how you handled sprite rotation...I was going to ask how you handled sprite rotation, but you answered my question already. I wondered if you transformed each sprite by the camera's view matrix, which is obviously not nearly as efficient as transforming the render target. I'm becoming more and more eager to see your next installment.<BR/><BR/>I've been deviating a bit from your lessons. I split your DrawMatrix method to handle transformation propagation on a per-sprite basis (<A HREF="http://three.homeip.net/drawmatrix.htm" REL="nofollow">view code</A>). I did something similar in the DrawColor property method.<BR/><BR/>What I haven't gotten to work is a frame timer. I've disabled vsync for both the graphics device and game class, changed all the presentation parameters to the fastest settings, even set it to run full-screen just to be safe. It seems to be working because my cumulative timer is running faster, but when I use the frame interval to calculate FPS, I always end up with 60. Any chance you've experimented with this?Tomhttp://three.homeip.netnoreply@blogger.comtag:blogger.com,1999:blog-8768285918186248163.post-72540384329715744192008-02-21T18:35:00.000-08:002008-02-21T18:35:00.000-08:002008-02-21T18:35:00.000-08:00Yea - when multiple cameras see the same content, ...Yea - when multiple cameras see the same content, that content gets re-drawn by each camera.<BR/><BR/>The cameras function independently of each other; each one determines it's own "visible" content, and then draws that content to the screen with a unique matrix.<BR/><BR/>In the event two cameras overlap, some or all content ends up on the visibility lists of both cameras - those objects are subsequently drawn twice; once by the first camera using it's matrix, then again by second camera and <I>its</I> matrix.emachine74http://www.blogger.com/profile/16131803862986581964noreply@blogger.comtag:blogger.com,1999:blog-8768285918186248163.post-58975357868155468742008-02-21T07:15:00.000-08:002008-02-21T07:15:00.000-08:002008-02-21T07:15:00.000-08:00Okay ... another question ... Are you essentially ...Okay ... another question ... Are you essentially re-drawing each object for each camera? I can't see any way of getting around that.<BR/><BR/>-MattMatt Wordenhttp://www.blogger.com/profile/04067280616434945595noreply@blogger.comtag:blogger.com,1999:blog-8768285918186248163.post-66414606259015692552008-02-19T14:03:00.000-08:002008-02-19T14:03:00.000-08:002008-02-19T14:03:00.000-08:00Thanks ;) I was using targets initially, and then...Thanks ;) I was using targets initially, and then just to educate myself a bit I changed them to draw through viewports, which is what you see running in the video. Without the overhead of targets, drawing directly to the display buffer through a viewport performed considerably better. The big downside is that it's not really compatible with the "matrix cascade", since I don't think you can transform a viewport (I would love to be wrong about that though).<BR/><BR/>Viewports had such a significant difference in performance that I'm still motivated to use them when at all possible, and my guess is that 90-degree, 0 rotation 100% scale cameras might be the norm most of the time, in typical scenarios anyway. So I will probably implement both viewport- and renderTarget-based rendering methods on cameras, so that anytime the cam's tree node matrix changes the can can decide to use either viewport mode (if the resultant matrix rotation = 0 & scale = vector2.one), otherwise, renderTarget mode, so that its output can be rasterized & transformed prior to hitting the display buffer.<BR/><BR/>Tom, always glad to hear about someone getting something out of the blog. Once you get into the swing of .NET, you will hate the idea of going back to VB6! I will continue to try and brush up against the OOP/VB.NET logistics as I go along with the XNA stuff, hopefully without boring folks with too much "101" stuff. I've got an entire movement automation system which I <I>still</I> need to get around to showing you guys, which allows you to script sprite activities over time, such as changing tint, alpha, texture, moving around (linear, bezier curves), rotate, change origin etc. etc. There's a lot of class inheritance as well as interfaces and type predicates in that system, which should also provide some real-world examples of how those are neat ways to help organize, simplify and reuse code.<BR/><BR/>If I didn't have a day job taking up all my time and energy I might get more done around here :)emachine74http://www.blogger.com/profile/16131803862986581964noreply@blogger.comtag:blogger.com,1999:blog-8768285918186248163.post-28510930297814684162008-02-19T09:44:00.000-08:002008-02-19T09:44:00.000-08:002008-02-19T09:44:00.000-08:00Your cameras be slick! :-)It's interesting to see ...Your cameras be slick! :-)<BR/><BR/>It's interesting to see the direction you're taking, since I started about in the same place, conceptually, but have gone a different direction with the cameras in my project.<BR/><BR/>Looks like your approach makes multi-camera "split screen" type games easier to handle.<BR/><BR/>Do your cameras draw directly to the screen? Or do they draw to a texture (render target), which is then drawn to the screen?<BR/><BR/>-MattMatt Wordenhttp://www.blogger.com/profile/04067280616434945595noreply@blogger.comtag:blogger.com,1999:blog-8768285918186248163.post-31533246667226830972008-02-19T04:28:00.000-08:002008-02-19T04:28:00.000-08:002008-02-19T04:28:00.000-08:00I just discovered your series not too long ago and...I just discovered your series not too long ago and have been following it comprehensively since the weekend, adding to your samples where my explorative nature takes me. I can't really tell you how much I appreciate following your samples and videos as I learn the ropes of XNA and .NET development. I particularly appreciate your inheritance implementation, which, coming from VB6, I've had some bother pursuing myself. I'm very eager to see where your project goes. Rest assured, I'll be along for the ride.Tomhttp://three.homeip.netnoreply@blogger.com