|  | 
 
Aarrgghh! (Why do all my posts start with that? Never mind....) Ignoring the external functions for the moment (which is why I wrote them as separate) there are two areas that need to be looked at: 1) UPDATEWORLD: What I didn't realise (despite all explanations) was that this is the work horse of tweening code and yet another example of Mark Sibly's brilliance. Suppose that I have created a little man whose movement frames are such that at 'Const FPS = 30' he will walk at a normal pace across the terrain. Suppose also that I have a dog-slow graphics card which (due to all the other clutter, village huts etc) is NEVER going to be actually able to render 30 frames per second to the screen. Mark's code effectively says 'I know your graphics card may be slow, but at least I can recalculate, on the fly, how much to change the little man's animations so that at least (a) the leg movements happen at the correct speed, and (b) he travels from point 1 to point 2 as you designed'. In other words the correct speed of animation does NOT depend on how fast the final images are flung at the screen by the graphics card. 2) RENDERWORLD: Of course all the frame counting code I was using was telling me that I was getting as low as 5 frames per second being rendered to the screen (the previously mentioned dog-slow graphics card) and I was saying 'Oh, no. My animation speeds are all over the place!' NOT SO. Internally Mark's code was still keeping all animations smooth and predictable, based on 'Const FPS = 30'. How fast the final images are flung at the screen is not Mark's problem, but the graphics card's problem. So I wrote the demo code above using two different counters, the UpdateWorldCounter to confirm that Mark's tweening style DOES work as designed, and then the RenderWorldCounter(s) to show me how often my graphics card is actually updating the screen. Sounds obvious when written down, but for a long time I was confusing the two concepts. SOME FINAL THOUGHTS: [1] A Big Mistake: Someone suggested that the variable 'ticks' might sometimes be zero, and that this would be a bad idea. So I added: If ticks<1 Then ticks = 1before For k=1 To ticksDo NOT do this! I think that this was the reason for my characters 'speed-walking' every so often. As soon as I removed it the problem went away. I guess it's a case of 'trust Mark's code'. [2] Other Methods: There are other methods of timing, notably Delta Timing (search in the forums for 'Tweening' or 'Delta') which may give a higher fps for Quake style games, but my understanding is that the above tweening method produces the kind of 'sublety' that I need for my slow walking animations, i.e. a village full of people and huts seen at very close quarters, and individual characters who talk to the camera. [3] Improving Speed (1): Several people have suggested that care should be taken to keep the number of entities visible to a minimum. In the case of furniture and houses (where you don't need to access separate child parts) the best way to do this is to merge (in your modeller) all the parts of an entity into one, as the final production model. And even, if possible, to merge all of THOSE entities into one final entity, which is your 'level'. It's my belief that this is why 'Morrowind' is so fast - the opening village is literally one entity - all the houses are really only external shells, and are merged with the terrain as one model. [4] Improving Speed (2): A nice tip I was given was the following: After UpdateWorld() do: For z = 1 To nNumObjsand just before RenderWorld tween# do: For z = 1 To nNumObjsThis DOES add quite a few frames to the final fps being rendered to the screen. [5] Improving Speed (3): If (like me) you want a huge terrain with many villages and people, then the ONLY way you are going to achieve this is by making different areas HIDE or SHOW when needed, otherwise the system just start to grind to a halt after you've added village number two. This was obviously quite a gut-wrenching rewrite to a system that I had been working on for nearly a year, but the difference it made was phenomenal. I had almost given up on the project, and suddenly it became viable again. There's no easy way to describe such a system (or give a code example) but if I just say that the essence is to keep a list of named rectangles [Areas] then other lists for objects and people, each of which contains a reference to an area which it it is linked to. [Man1] Then write a piece of code which detects the camera movement into and out of different areas, and run down your list of people and objects showing and hiding entities as appropriate. At first I thought that I'd end up with that horrible Morrowind-style message 'Loading area' with a blank screen for 5 seconds, but in actual fact Blitz can SHOW or HIDE a hundred entities literally in the blink of an eye, and the effect is virtually unnoticeable, Yay, Blitz! [6] Improving Speed (4): Change the VWAIT command to: VWaitThis change is still open to discussion and you should search the forums for 'Vwait' to read different people's opinions. FINALLY: Once again thanks to all the people who reacted to my cries for help, and helped out by providing fps counter code, HIDE and SHOW advice etc . Thanks to you all. This really is a GREAT community. Cheers, John For a printable copy of this article, please click HERE. 
 This site is Copyright© 2000-2004, BlitzCoder. All rights reserved.   |