Vincent's Ray Tracing

"... We slept on floors. We waded across rivers."

  :: 首页 :: 新随笔 :: 联系 :: 订阅 :: 管理 ::

如果没有任何人指引,就只看代码几乎如同瞎子摸象。打开sln可以看到botlib,cgame,game,q3_ui,quake3,renderer,splines,ui 8个project,但是它们各自的功能何如呢?

在gamespy找到一篇帖子稍微靠谱一些:

What's the difference between game and cgame? Most of the functions are very different. What's the role of them?


Game / cgame are the "gamecode", which defines the rules of the game, and the meaning of all "entities" (players, items, weapons, projectiles etc are all represented in the engine side as an entity_t). For example, the gamecode is where logic is that ties an entity that happens to have the model of a rocket into a thing that moves at 800ups in a straight line, and damages the entity it hits. The engine itself doesn't have a concept of a rocket, it just knows about the map, entities, and clients that it must send this data to / render.

CGame stands for Client Game, and is the code that runs on the client side, while "Game" only runs on the server. The server (game) is the thing that decides that the rocket is moving at 800ups in a straight line, and when a collision occurs, is the code that calls the damage function to hurt another entity. The client (cgame) simply knows it has a rocket entity, so it gives it the right model, sets up the right rendering effects, and plays the sounds at the right times.

You'll notice there are a few files in both projects with the prefix bg_* - these files are "both game" projects, because the code in them is shared between both client and server. This is mainly for things like movement, to allow the client to predict the path of the rocket so the client can guess where it is without waiting for the server to tell it, to avoid it feeling laggy.

In the released versions of q3, the game/cgame/ui/q3_ui projects aren't built as DLLs like they are in the VS project, they're built into the platform independent .QVM files by a custom version of the "lcc" compiler - the projects are set up as DLLs as well to make it much easier to debug them.

The q3_ui is I guess the user interface/menus, but there's also a ui project... again what's the role of both of them?


Originally, there was just q3_ui, and that is the userinterface used in Quake 3 itself. However the code they released includes the Team Arena missionpack too, which uses a re-written version of the user interface which you can find in the "ui" project. For game/cgame, the TA versions are actually merged into the project and are built by selecting a different configuration in VS (which just toggles the #define MISSIONPACK), but the UI was a major rewrite.

What are splines?


Funky maths (wikipedia link) for giving nice interpolated curves between points. IIRC the splines project is completely unused in Q3, it's just a hangover from something they were experimenting with.

Finally, what project/function links all this together, ie. whats the first script/header script to get executed when it's you've got the build and are running the release executable?


Well, like every Windows program, the very first place WinMain, which you can find at the bottom of win_main.c in the "quake3" project. That calls the Com_Init() which is the "common init" and will do all the real initialisation, and then sit in a loop calling Com_Frame() every frame, which does all processing for each frame of the game. Com_Frame will work out whether you're running a client, a server, or both, and call the appropriate bits.

posted:
Any info on this, or any resources you can point me to would be appreciated..


I don't know of any resources telling you this stuff - you might find something about the game / cgame split as this is the "mod" code, and so people were learning about it before the engine code was released.

posted on 2011-09-12 19:31  Vincent Pan  阅读(584)  评论(0)    收藏  举报