Welcome to RenEvo Sign in | Join | Help
Home Wiisis Blogs Forums Photos Downloads About

3D Real-Time Strategy

File Details
Downloads: 1479 File Size: 2.6MB
Posted By: vloktboky Views: 2178
Date Added: Fri, Dec 07 2007

The 3D Raeal-Time Strategy engine is an accumulation of two months of research and development. It encorporates many techniques including an abstract rendering system, Lua scripting engine and entity management system, and the Intermediate Mode Graphical User Interface paradigm.

The engine is capable of loading an exported level and run-time entity creation and manipulation, including Picking control and Quad-tree Scene Management. Below is an extract from the documentation that covers some of its key features:

There are three major aspects that this engine illustrates:

  1. Entity Management system which operates through the Lua scripting language.  All entity behavior is externalized in special scripts attached to an entity based on its class type.
  2. Abstract rendering system with OpenGL and Direct3D 9 implementations.
  3. Intermediate-Mode Graphical User Interface controls for HUD updating/rendering.

The entity manager works in conjunction with a class definition table which is defined in a special Lua script.  Entity classes are given a unique ID and name, a type definition, and a behavior script.  The name and ID classify the entities and are used to create them.  The type definition is used by the engine when creating the C++ class object to represent the entity.  No type means a basic CEntity object is used; however, the type "Unit" means the CXUnit object is used.  This is important as the class object controls what member functions can be called on the entity in the scripts and what special behavior runs internally.  A basic entity cannot be selected, but a "Unit"-typed entity can.  The behavior script is also executed and a clone of the entity script object (the table that shares the same name as the class name) is connected to the entity.

When an entity is created, it is added to an internal list.  Special callbacks in the attached entity's behavior script are called at certain intervals, allowing the entity to externally initialize its behavior, update itself, and render special controls to the HUD.  Internal routines such as the quad tree management and collision detection are handled by the engine itself and are not apart of the behavior script.  However, such logic as position changes, 3d model representation, HUD information, and basic behavior are confined to the script and are operated by special functions exported to the script.  When the entity's C++ object is created, a special class called a ScriptObject class is also created and maintained during the entity's lifetime.  This ScriptObject class exposes special C++ functions and certain member variables of the entity to its Lua script object and allows it to change its position or load a model during runtime.  For an example of this, see the following C++ source files and Lua scripts: CXUnit.cpp, CScriptObjectUnit.cpp, TestEntity.lua.

The abstract rendering system is written in such a way that special concrete classes can be utilized for handling the physical rendering of the scenes, loading texture data, and controlling the camera.  OpenGL and Direct3D 9 concrete objects have already been coded and utilized in the system.  The abstract classes declare simple functions to handle everything from basic initialization and rendering processes to explicit sprite/line and texture loading operations.  The system also utilizes 3d object loading routines and scene management systems that incorporate a hierarchy of rendering nodes.  Such a list is constantly sorted for each scene in such a way that hardware switches are minimized during the rendering process.  Heavy use of instancing and frustum culling is also utilized to cut down on resource usage and minimizing the cost of collision detections and sending data to the graphics card.  The scene manager also manages a quad tree that splits up the terrain data and contains a list of entities used for such things as picking logic.

Finally, the IMGUI paradigm is heavily used for rendering the HUD of the game.  Basic routines such as drawing sprites, text, and lines are called from the HUD and entity scripts for rendering the physical HUD.  Everything from the console system to the green box around selected entities and on-screen text print out function from this very control.  The "Create Entity" button also works with this paradigm.  There is no physical C++ widget object in memory that represents this button.  It is instead contained entirely in the Lua engine and is merely just a table of data that holds its dimensions, color, and current behavior with special Update and Draw routines.  A white box (1x1 white pixel texture) is drawn with an appropriate color and scale to achieve the correct rectangular representation of the button and is drawn on the HUD each time it is redrawn.  Settle changes are made to reflect if the button is currently hot, has focus, or has been clicked based on its last update call.  You can see this for yourself in the following Lua scripts: HUD.lua, HUD_Button.lua.

Comments
No comments exist for this file.
Powered by Community Server, by Telligent Systems