Original Post
Hello people Ive been working on a game similar to SimCity 4. Here's how it looks uptil now:
Please download from here the sample exe of the game so you can help me out in the below queries. The game is built in Visual Basic 6, DirectX 8.1, using orthographic projection. Supports terrain rotation, zooming, grid lines. I am very new to graphics programming and therefore I am already facing the following problems in which Im totally lost; dont know what to do about them: 1. I think the frame rate is not good enough in respect of the current game position. Its only a terrain right now, still not enough frame rate. (well, thats what I think.. what do you think?) The whole terrain is built in TRIANGLELIST format. All the vertices are placed into a single vertex buffer and Index buffer. Is this a good idea? Because thats just it.. only a terrain and a single vertex buffer. Still the FPS is not adequate enough. What is the best way? I thought of using quadtrees but got stuck in the idea that how would I perform ray-picking on it.. because my terrain is not flat.. if I click a mountain which is in the 2nd quarter, using quadtrees it might detect it as if I clicked in the 1st quarter. 2. The FPS gets lower everytime a house is placed on the terrain. I cant understand.. everything is quite simple in my code, but the game performance shows signs of high inefficiency. 3. Ive gone through all ends to figure out how to detect which tile the mouse is over on the terrain. I finally found that out but its not working very well. Its toooo slow. I first obtain the mouse screen coordinates, normalize them, and do the necessary stuff (inverting camera matrix, determining the ray direction, etc). And just to see which tile I clicked, I go through a long loop in which I create a plane using each triangle's coordinates and check if ray intersects it or not. (two triangles make up one tile.. so in the default map the terrain is of 42x34 tiles.. makes it total 1428 tiles, ie. 2856 triangles are tested on each mousemove event.. yuck!) 4. Im also having trouble with lighting the terrain.. but thats not a big issue so I wont discuess it here right now. - Thats it.. the above are the problems Im facing about which I have no clue how to solve them. Im a newbie at graphics/directx programming so I may be wrong about what I said about quadtrees.. thats what I need help of this forum to straight out my concepts. I have turned off the Day/Night mode in the game.. actually I have turned off all the lighting effects and now Im using lit vertices. Also read the Readme.txt in the zip file to all the keyboard controls. I can also provide the source code.. please help me out especially in the ray-picking issue.. its really bugging me. I was told that visual basic 6 is not a good language to build directx apps and it is the major cause of low performance. Well I believe its true but only in respect of high/powerful games, not in my simple game engine. What do you say? Faraz Azhar