View OpenCity.info in GermanView OpenCity.info in FrenchView OpenCity.info in ItalianView OpenCity.info in English
OpenCity header image
NoPatent logoOpenSource logoOpenGL logoSourceForge.net logoValid CSS!Valid XHTML 1.0 Strict

Behind the scene

OpenCity 0.0.7 development plan


    Add Boolean datatype                            (done)
    Add String datatype                             (done)
    Add basic unit test framework                   (done)
    Add Boolean datatype unit tests                 (done)    
    Add String datatype unit tests                  (done)
    Add Forms basic classes                         (done)
    Add glew library for OpenGL extension handling

	

Design issue

The current UML class diagram is here. Everything in green is not implemented yet. All the yellow classes are more or less implemented and the pink rectangles are the interfaces. For the more complete, lastly updated UML design, download the file UML.xmi from the source repository. It is made with Umbrello, an Open Source UML design program that you can download here. I would like to notice you the UML design is not constantly accurate but it can improve the codes' understanding. Here is the collaboration diagram when the program starts up, and this one is when the city class displays a layer.

The UML is mainly for design purposes. And, you're right, there should be no "const", "&" or other language specific key-words in it. The reason is, at the beginning, I have used the built-in code generator of Umbrello. If I put some of those language specific key-words, I manage to get a functional codes directly from an UML class diagram. Besides, I'm very strict on using C++ key-words, that's why I decided to put them in the UML class diagram. They remind me how I should implement them later in the codes.

Usually, I work on the design of the classes before implementing them. In addition, I use the Standard Template Library (STL) as much as possible. However, in some cases, the STL is too slow for OpenCity. That's why I prefer the plain old C-style array instead of a vector of objects. In the near future, each class will be fully documented (er... I didn't do it for all of them yet ;-)). Since OpenCity is a 3d city simulator developed under Linux, it will run on most of Linux distributions. However, my program is coded in the way that makes it easy (I hope so) to port it to other OS. Currently, OpenCity can run on Win32 without any problem.

The following STL classes are used currently in the codes:

std::vector std::map std::pair std::deque

3D issue

I have a very limited experience with OpenGL and I learn it on the fly. More advanced functions will be used in the future as long as the development of OpenCity progresses in order to speed up rendering functions and to display better graphics. For the moment, the current version uses very basic OpenGL primitives such as:

GL_POLYGON GL_LINES GL_TRIANGLE_STRIP ...

The whole terrain is drawn as an unique GL_TRIANGLE_STRIP for speed optimization. The algorithm that I used is quick and dirty. For more information, you can read the comments in the code sources.

The old 0.0.3beta version uses the object coloring method for model picking. This method is described in the"OpenGL Programming Guide" or the "Red Book". When the player clicks in the window, it assigns a different RGB combination to each object in the back-buffer. Then it reads the RGB values of the pixel which is right under the cursor's position in order to determine which object is picked by the player. This method is quite easy to be implemented and it can process very fast. Furthermore, as it is used with depth checking, you don't even have to handle the depth of the objects because only the nearest object can be picked by the player. The limits of this method are the number of bits per pixel available and the double-buffering. OpenCity requires 32bpp and double-buffering because of this selection method.

In the new 0.0.3stable version, OpenCity uses GL_SELECT mode for object picking. That's why the 32bpp or 24bpp video modes are not required anymore.

Coding style

Sometimes, you can see "//TOKILL" in my codes. As you can guess its meaning easily, it's the opposite of "//TODO" :-D The codes which follow a "tokill" mark often work perfectly. However, they are no more used in the current version of OpenCity and will be "killed" in the near future. I left them there for reference purposes. Anyway, they won't slow down the game since they are all commented out.

Each variable is prefixed with its type, for example: "uiCityWidth". It's a variable of type "unsigned int". More details are given in the design document: "OpenCity_Design.sxw" and the "CodingStyle.*" files. You can download them from the SVN repository.

Other city simulators

I have searched on the Internet to find out about the other city simulators. There are of course, the so famous SimCity from 1 to 4 and Sim Societies. Under Linux, there're a lot of SimCity like too. However, in contrast of SimCity, they're free, and often abandoned projects... except three: LinCity, PocketCity, and Simutrans. If you are wondering what the other projects are, here is the list: TheCity, TransitExecutive, FreeReign, LCitySim and SimBlob.

I'd like to drop few lines to LinCity-NG which is an updated version of the old LinCity with new graphics. You can check it at Berlios Lincity-NG page.

All those projects are great and they make me dream of a huge ambition: integrate their best aspects into OpenCity.

SDL OpenGL Ogre3D STL Boost xhtmlCopyright (C) by Duong Khang NGUYEN - All rights reserved