September 30, 2011

New GUI editor

A new GUI editor has just been added to the REVERT3D "toolkit". Now it is possible to design GUI pages using a (more or less ^^) comfortable WYSIWYG editor and save them to a file. The editor can also be configured to handle custom controls.
It has been a R3D feature since the very beginning (in fact, this was one of the first things we worked on), although we never really showed it, since there was only the "hardcoded" way to create them. The next demo versions will show this stuff and enable you to interact with GUIs using the scripting engine.

September 27, 2011

Tutorial: Resources and system configuration

This tutorial explains how to setup various system stuff, where to find resources like textures and objects within the filesystem and how to configure and import them

The configuration file
A single config file named "config.r3c" holds virtually all the information to setup the engine. It is located in the engine root directory (where "revert3d.exe" is stored). The file format is "r3c", which is a readable text format that is widely used by REVERT3D. You can open the file using a text editor like notepad to see its content. In version 0.8.1b, it should look something like this:

[PATHS]
COMMENTS = Path configuration (Relative to root directory)
TEXTURES = data\tex\
OBJECTS = data\obj\
MAPS = data\maps\
TEMP = data\temp\
USER = data\user\
SCRIPTS = data\scripts\

...

The structure should be quite easy to understand: "[PATHS]" is the name of the section, while the following keywords (no brackets) are the stuff to be configured:

[SECTION NAME]
KEYWORD = value

The combination of section/keyword has to be unique. Theres just one "TEXTURES" key in "PATHS" - On the other hand, there is a "COMMENTS" key in nearly every section. Also, be careful not to store information in the wrong section, since the engine will look for the keys in specific sections!
Most of the informations contained in this file will or should not be changed at all, but some can be useful to customize your project. Here comes a brief description:

Section/Key Description
    
[PATHS]Path configuration for all kinds of resources. These are alwaysrelative to the engines root directory! You should not do any changeshere afterwards. First set up the configuration, THEN start creatingmaps and stuff!
COMMENTS Just some comments about the content of this section
TEXTURESRelative path where to store and search for textures (Example: "data\textures") - These directories may have subdirectories to structurize your content
OBJECTS... same for objects
MAPS... maps
TEMP... temporary files / mainly used by the system as a cache
SCRIPTS... script sourcecode files
USER... "user files" (free for anything that doesn't fit to one of the other categories)
    
 [DEFAULT_TEXTURES]  Default textures which will be used by the editor when nothing else was selected
WALLSRelative path to default texture file for walls
FLOOR ... same for the floor
CEILING ... ceiling
    
[CAMERA] Camera configuration (which is more or less obsolete by now)
PLAYERHEIGHTHeight of the camera in units above the floor
[ENGINECORE]This configures the desired engine speed - Its a good idea not to change this ^^
TARGETLOGICRATEThe target rate of logic cycles
TARGETFRAMERATE... frame render cycles / fps
    
[SCRIPTING]  
BASESCRIPTRelative path to base script (into script directory). This will be executed each time a map is loaded and can be used to do init stuff
EDITORSCRIPTEditor script which will execute on specific editor events. This is where the editor creates the player and scene FX object when creating a map
EDITORCOLORSDefault color scheme for script editor. Values: BOW (black on white) or WOB (white on black)
    
[DEFAULT_FILTERS]This section defines the default texture filter used for each subdirectory into your textures folder. The system works hierachically, causing all subdirectories to inherit their parents texture filter if nothing other was defined. By default, all textures will use "TEXFILTER_MIPMAP". Possible values are TEXFILTER_MIPMAP (generates hardware mipmaps),TEXFILTER_LINEAR (linear filter), TEXFILTER_NEAREST(pixelize!)
%ROOT%Special constant defining the texture root directory
EDITORThis would be used for all textures inside the "Editor" subdir
GUI... same for the "gui" subdir
MAPS\OBJECTS... "objects" subdir inside "maps" subdir
......




The textures directory
This directory contains four subdirectories used by the system, which may not be renamed or moved. Here we go:
\editor (Icons and graphics used by the scene editor)
\fonts (Textures containing bitmap fontsets)
\gui (GUI graphics like button and window textures)
\sys (System graphics like markers and symbols)

There also has to be a texture named "dummy.bmp" right in the texture root directory. This is the "dummy texture" which will be used when no other texture has been selected, the selected texture is broken or not available anymore. This texture traditionally contains the REVERT3D logo.


Adding textures
This is pretty easy: Just put them somewhere in your textures directory and they will be available in the texture browser next time you start the editor. Currently supported formats are bmp and tga - More formats will be introduced in the future.

Adding objects
Same like adding textures: Just make sure to put them into the specified objects directory. The R3D object editor will automatically do this for you when creating new objects - But more on this soon in an upcoming tutorial!

Adding maps
Maps will be automatically saved to the specified maps directory when using the scene editor. However, you could also just put a map there manually. If the map contains textures which are not available, the dummy texture will be used instead. Missing objects can cause some trouble but it should at least load the map geometry without any problems.

General notes on adding resources
You should try to structurize your directories right from the start since it'll be hard to move them afterwards when there are objects,maps and textures referencing each other in specific locations! Creating subdirectories for specific stuff like objects and maps will help you to keep your resources "clean".

September 23, 2011

Tutorial: Fundamentals of scene editing

This tutorial will show you the basics of scene editing. We will show you how to effectively use the integrated scene editors to shape your own game environments.


The scene editor
The integrated scene editor works in two modes: 2D and 3D view. In 2D mode you draw the outline of your map by placing tiles on the grid. In 3D mode you model out the details of your map like: Texturing, setting floor/ceiling height, placing objects and so on. The 3D mode also gives a basic impression about what your map would look like in your actual game, as you can move through the scene using classic FPS controls (W/A/S/D/mouselook)


Starting the editor and creating a map
First of all, get the REVERT3D package from the download page if you haven't done yet. This tutorial was created using the Demo version 8.0.1b but it should also work with newer versions.

Start Revert3d.exe - Now you should see the scene editors main menu (Pic 1)









Click the "New map" button and the map property dialog will appear (Pic 2) Enter a map name, but keep the dimensions as they are (The standard size is 64 x 64 tiles) You might wonder about the size being 64 x 64 and not like 60 x 60 - This has something to do with REVERT3Ds map data management. To keep it simple for the moment: It divides the map into smaller subregions to boost performance. With the size being a power of 2, its easy to break down the subregions without producing fractional values (the next subregion size would be 32 x 32, then 16 x 16, 8 x 8 ...)



Now hit "Ok" and you will end up in the 2D editor view displaying an empty map (Pic 3) The 2D view is divided into a toolbar at the top of the window and the map view filling the rest of it. The toolbar contains buttons to select the tile type (P3/A), various tools to change pensize, toggle textures and lighting (P3/B), buttons to save/close or test the map (P3/C) and general informations about the cursor position inside the map space (P3/D). Right after creating the map, you will probably see an eye-like symbol and a "FX" icon in the middle of the screen. The "eye" is the current camera position that will be used when you switch to 3D mode. Don't worry about the meaning of that "FX" icon yet: Its the automatically created "player" object as well as another object at the same position which contains various informations about the scene - But more on that later.


Navigating in 2D view mode
The actual map is much larger than the portion you will see right after the start. You can use the mousewheel or +/- keys on your keyboard to zoom the view in or out. To scroll the map either use the arrow keys or right click and hold anywhere into the map to "drag" it around using the mouse. You can change the camera position by pointing the cursor to the desired location and pressing C - However, you should leave the cam where it is for now.


Your first room
In the case you played around with the navigation controls, first navigate back to the camera (the "eye"). Now click on the second / the white tile symbol in the toolbar (P4/A). The "active tile" info to the upper right should now read "Active tile: Open" (P4/C). You can now place open tiles on the grid using the mouse and left button. Holding the left button while moving the mouse will just "draw" the tiles like in a paint program. Draw a filled rectangle of open tiles around the camera, select the third/ solid tile from the toolbar (P4/B) and draw another rectangle around the open one, so it becomes a room looking like in Pic 4. Pretty easy. You can now switch between the 2D mode and the 3D/first person view by pressing Tab (Pic 5).


Navigating in 3D view mode
In 3D mode you can move around in a classic FPS manner using W/A/S/D keys and mouselook. If you move out of the room, you probably wouldn't see anything anymore because R3D would try to render void tiles what would make it hard to find your way back. So in the case you get lost: Press Tab to return to 2D mode and move the camera back into the room by pressing C.
Beside these controls there is Z(Y)/X to move up/down and C to toggle between fly- and clipmode. "Flymode" is the default mode in which the camera always follows the cursor in all directions, while "clipmode" will make the camera kind of stick to the floor, which helps to move through the scene more "game-like". By default the movement is quite fast and good to get around the map quickly. If you need more precise movement hold down Shift while moving.


Tile modeling
Beside showing you what the map would look like in an actual game, the main task of the 3D view mode is to model the map and add details like textures and objects. Now that you are familiar with moving around in 3D space, move to a tile of your choice, point the cursor to the floor and press PageUp a few times. As you will see, the floor moves up (Pic 6) PageDn would have an opposite effect, of course. This also works for the ceiling in the same way.




Try to move the ceiling down, to make it look like in Pic 7.
We now want to tilt the floor and ceiling to make it look sloped. To do this, point to the ceiling or floor again and press Ctrl + Up/Down/Left or Right a few times, depending on which side you want to tilt.







It works more or less view-dependent, so pressing Ctrl+Left should always tilt the tiles left side from your point of view. It works best, if you look at the tile from a straight ~90° angle (Pic 8)








Tiles can also be copy/pasted. To copy your "sloped-tile", point to one of its surfaces (it doesn't matter if its the ceiling, floor or a wall) and press Ctrl+C. A small symbol resembling the tile type will appear in the upper right (Pic 9/A), indicating that theres a tile on the clipboard. To paste it, point to the desired location (pointing to the floor when doing this, is a good idea) and press Ctrl+V.





We repeatedly paste the tile all along the wall to make it look like in Pic 10.









Texturing
You probably already wondered about that "REVERT3D" symbol in the upper right of the window (Pic 11/A) - It indicates the currently selected texture. This "REVERT3D" texture you see right at the start has some special function, since this is the "dummy texture" that will be used when no other texture has been selected or somethings wrong with it (file not found, wrong texture id, ... )





To get a list of all available textures hit B on your keyboard and the texture browser will open (Pic 12) It is divided into a row of buttons (P12/A) for each subdirectory into the texture folder and the texture list (P12/B). Click on a button to see which textures are inside that folder. You can scroll through the textures by using either arrow keys, PageUp/PageDown or the mousewheel. To select a texture, simply left-click on it and the browser will close, returning to the 3D view. The selected texture will now be indicated to the upper right. Apply the texture to any surface by pointing at it and pressing T.



You can change way the texture is mapped by adjusting its offset and scale (Pic 13). "Offset" shifts the starting position of the texture - You can use this to align a texture with the floor or ceiling (P13/A) Point to the surface and use the arrow keys to do this. "Scale" will stretch the texture. You can use this to make a texture "repeat" on a surface. Hold shift while using the arrow keys to perform this. (P13/B)




Objects
The placement of objects works pretty much like the texture assignment: Open the object browser by pressing Ctrl+B and select one by left-clicking on it. You will find yourself back in 3D view with the selected object visible to the upper right (Pic 14/A). The object can now be placed which works in two steps: Positioning and release. Lets select the "Spock" object from the object browser, then press O to insert the selected object. The object now follows your movement right in front of you in some distance from your position. Use the mousewheel to shorten the distance or extend it into your viewing direction. A 3D axis-cross will appear to help you make out the distance to surrounding objects or tiles (P14/C). The box around the object shows its physical boundaries which will be used for collision detection (P14/B). Just move around using the 3D controls until the object gets into the desired location. Place O or G again to release it. If the object has a mass and is affected by gravity it will fall to the ground if you release it in mid-air - But more on that later.
To change the position of an already placed object, point the cursor on it and press G. This will "grab" the object and return you into "positioning mode".
To rotate an object use Alt+Arrow keys while pointing at it. If you are in "positioning mode", you can also hold the right mouse button to rotate around the Y axis. To change the size of an object use Shift+Arrow keys. If you want to completely remove an object from the scene, point at it and press Del.


Lighting
Internally, lights are just regular objects with the difference that they "shade" surrounding tiles and other objects. They can be created by just pressing L or selecting a "light object" from the object browser (Ctrl+O). The positioning works the same like for a "normal" object. To see how the light actually affects the surrounding scene, press Ctrl+L to toggle the scene lighting on/off while in 3D view mode. Lights are set up with a color, lighting- and "fadeoff"-range. While the range value specifies the total radius in tiles which will be affected by the lightsource, the "fadeoff" range can be used to make a light look either "soft" or "hard".
It defines the range in tiles, at which the light will affect the scene in full intensity. The lower this value, the more "soft" the lighting. The difference is best noteable when you look at the scene in 2D mode, with lighting turned on (Pic 15 A/B).





Light properties can be edited by left clicking on the object while in 3D mode (Pic 16). Use the color values to define the color intensity for each channel (red/green/blue - P16/A). Be careful not to set the range and fadeoff-range values (P16/B/C) too high, because every affected tile must be recalculated, what can consume some computing time depending on your values :) For most situations, its better to place multiple lights with a short range < 10 tiles than one huge lightsource with long range. While editing a map, sometimes you will notice that the shading of tiles and objects looks weird when reworking the scene after inserting a lightsource. Thats because the lightsource will only calculate once, in the moment you create it. However, you can force recalculation by moving the lightsource a bit. These issues only occur while editing, since the engine recalculates all lightsources in a map right after loading it. So in an actual game, it would look right in any case.


Testing the map
Now that our scene has a room, some objects stuff and a lightsource, it's time to test it under real "gaming conditions". Before we enter the testmode, we switch back to 2D mode by pressing Tab, save the map using the button on the toolbar and ensure the camera to be inside the room. If not, point somewhere into the room and press C. The testmode will launch the map using the standard game implementation - Some kind of "game prototype" that can easily be transformed into your game using the scripting engine and/or the Visual C++ programming interface. In the default implementation, you can move through the map using classic W/A/S/D/mouselook controls and space to jump. Now, press the "Test map" button on the toolbar to launch the testmode. You can press ESC to return to the editors.

September 21, 2011

Tutorial: A brief introduction to REVERT3D

This is the first unit in our tutorial series thats going to show you the REVER3D fundamentals. We will start today by just giving you a brief overview about it. Since work is still in progress, some of the things described may change in the future. We will try the best to keep it up-to-date.


What is REVERT3D?
REVERT3D (or short "R3D"), is a graphics/game engine intended to create oldschool 3D games. The project was mainly inspired by the Ultima Underworld / System Shock engine (1994). R3D is an approach to create a modern tech engine featuring similiar capabilities. It is NOT going to become a System Shock rebuild neither a 100% rebuild of its engine.


Why one would focus on oldschool games
- We like the old stuff! In our own opinion, blocky graphics and simple effects leave more space for the players imagination. We feel that theres some kind of a special spirit to the 3D games of the 90s thats worth taking it to the future at the cost of heavy work.
- Creating a state-of-the-art 3D game is much more complicated than doing it the oldschool way - especially if you have modern tools to create them and especially if you're on your own.
- Its a good start to get into 3D graphics programming, since its not that hard to understand compared to modern graphics code.


Which additional tools are needed
For the most basic game implementation you would need rarely more than a program to create your graphics and sounds. REVERT3D contains most of the tools like map/object/script editors out of the box. It also features a standard game implementation. This enables you to create R3D games without the need of "hard" Visual C++ code. Of course, linking R3D to a C++ project offers much more possibilites, while the game implementation is limited to its standard set of functions and the scripting API.


Scene structure
A REVERT3D scene is made of three main elements:
- The map (The level geometry like the rooms, corridors or buildings your world is made of)
- Tiles (Block-like units the map is made of)
- Objects ("Things" with various properties which may be placed on your map)


The tile map
The R3D map structure looks like a two-dimensional floor plan, divided by a grid into blocks of the same size (Pic 1, Pic 2) / We often reference these blocks as "tiles".
Tiles can be of different type like solid (P1/B), open (P1/C), diagonal walls (P1/A) or simply empty space (P1/D). Imagine open tiles to be a solid cube split in half so you could move the upper half up and the lower part down, thus creating a space with a floor and ceiling between them. This is the way environments are created / thats where the player moves through and the action takes place. '


The "2D floor plan" architecture is easy to understand and quite easy to work with, compared to full 3D editing - But it also has its limitations:
- The smallest unit which can be modified is a tile, so there is no such thing like drawing the outline of your map by freehand. A map is assembled out of single tiles.
- Because of its "2D nature", the "floor plan" is flat! Tiles may have variable floor and ceiling height, which may generate a good three-dimensional feeling, but its never possible to build rooms over rooms or anything like that. However, there are some tricks to "simulate" environments like that!




Tiles
While solid tiles are just "walls" from the ceiling to the floor, open and diagonal tiles may have a variable floor and ceiling height for every corner, thus allowing to create slopes / ramps, stairs or just rooms at different height (Pic 3) Each face / side may also have a unique texture or be completely invisible to show a skybox instead.







Objects
Many variations of objects are available, like flat sprites, billboards and static 3d models (3DS). They can be animated, support directional textures and different object states (Pic 4) Directional textures can be used to make a 2D object look more three-dimensional (The texture changes depending on the cameras viewing angle). Object states become handy for defining a specific object state and changing its visuals at the same time. For example, you could create an enemy sprite with the states "moving", "attacking", "destroyed" featuring the corresponding animations and textures. This allows clear structuring of every object for any situation. Its also possible to assign user-defined properties to any object - This would allow to give your enemy sprite a "health" value which can be changed at runtime.





Bringing the scene to life
While the scene and object editors offer pretty much everything you need to design your environments and the engine handles most of the core tasks in the background (rendering, physics, objects/scene/memory management), everything that moves and changes within the scene / the stuff that makes a game, can be scripted using the integrated lightweight scripting interface. Scripts are tiny programs which run inside an own system environment of the engine. This Lua based system is divided into separate modules for graphics, scene/object management, system level operations, geo/mathematical/tool functions and sounds. The script functions are directly mapped to the REVERT3D API, which will be delivered as a static lib for use within Visual C++
While the C++ implementation is very much "open" in the way that it allows you to execute scripts virtually anytime/anywhere, the standard game implementation focuses on specific events and tasks. It also allows custom script calls with some additional work, anyway.


Game creation
The process to create interactive environments using REVERT3D should look like this:
Build your maps and objects using the integrated editor tools, implement the interactive components using the scripting interface. To test your environments, theres a feature to switch near seamless between the editing tools and the gamelogic, allowing rapid developement without the need to restart the whole engine each time. Design your worlds, test it, switch back and continue.

September 7, 2011

Demo v0.8.1

Hello again! The 0.8.1 demo features the newly implemented scripting engine. We translated all of the demo code into scripts to give you an impression about how it works. Don't expect any brand new stuff within the scene. It's more or less the original demo map with the "small" difference that 99% of the game logic runs as a script (Music is still hardcoded).
The available script functions are just a small bit of the whole functionality R3D will offer one day - Actually, it's just more or less everything that was necessary to implement the demo using scripts.
To access the script editor, press F5 while in 2D editor mode or open the properties page of a scripted object while in 3d mode (left click on object).
It is not necessary anymore to exit the editor and restart the demo to test a modified map. Just switch into 2D editor mode and press the "test map" button on the upper tool bar. Make sure to save any changes made to the map, since the engine will reload the map when starting the game logic. To return to the editor, press ESC.

We are sorry, that we cannot offer much documentation yet. You will find most of the commands in the help pages (F1). We'll try to explain how all this scripting / object properties stuff works together by giving you some examples within the next days. I guess some of you already figured stuff out by yourself but I'm sure there are lots of confusing things that need to be explained.

And: Please be patient - This is an in-developement version! Expect glitches and mysterious happenings :) We also had to remove some features which are currently under heavy reconstruction (such as the start-up/video mode dialog).
This demo was intended to show you how scripting could look like in REVERT3D.

DOWNLOAD: https://rapidshare.com/files/196290316/Demo_0_8_1b.zip

We would appreciate if you report any problems using our dev blog or email.