Subdivide a map
From Gnoll's Wiki
Cette page est disponible en français.
Contents |
Introduction
When using Gnoll, you might have to divide your own maps into some squares called pages. This dividing is useful when dealing with wide spaces where the rendering process has to be optimized.
This subdividing task needs precision and it's not easy to do it by hand. If you are using Blender, you can use a script that can do it for you. Just read the following steps.
Using
Get the script
The script is available on Gnoll's repository : gnoll/tools/blender/scripts.
Copy the files named gnoll-export.py, gnollTools.py and knife.py to your Blender's script folder : on Windows it should be C:\Blender Foundation\Blender\scripts, on GNU/Linux it should be ~/.blender/scripts. Then launch Blender. You can launch the script by clicking on File -> Export -> Scene for Gnoll engine...
Use it
Main features
The script isn't fully stable (you should save your work first).
This script allows you to subdivide the ground object in squares and generate XML files which can be used with Gnoll to render your scene. The scene files generation cannot be separated of the cutting (you have to subdivide a mesh to generate scene files).
The script can only work with an object which is clean of any transformation. If your object has been displaced, sized or rotated, it will be centered again.
The only selected object must be your mesh.
Choose the size of the pages (edit Size of pages). This size is meant in BU (Blender Units). You can also use the 1/2, 1/3 and 1/4 buttons to define automatically the right size to get a particular number of pages. The maximum value is computed from the selected mesh's bounding box.
If you want to generate Gnoll's scene files directly during the cut, press Generate Gnoll files. You have to do this before doing the split. If you want to add an initial page (can be useful in some cases), press Add initial page.
Press Subdivide to get the mesh's page and the files.
You can change the file's format by setting Gnoll files version to another lower value. It can be useful in case of using an out-dated version of Gnoll, or older than the latest developpement version of XML syntax.
Version numbers meaning
- Version 1 : Page using static objects (everything written in page files);
- Version 2 : Page using game objects and game object components (everything written in page files).
Step-by-step tutorial
Requirements : You have modeled the entire scene you want to export in an unique Blend file. In this scene, you have an unique object for the ground, and many others for the various objects part of your scene (like buildings, trees, aso). The scene must have been created using the Z axis as the up axis. If not, select all and rotate so the scene is correctly oriented.
First, ensure the script is correctly installed (see first section). Launch Blender and load your Blend file. Before launching the script, you should create an area where the GUI will be displayed : right click on a border, split the area and select "Script Window" in the resulting area. Then launch the script : use File -> Export -> Scene for Gnoll engine....
Select the ground object. Now you have to define the size of the pages. This size depends on the geometry of your scene. When dealing with small spaces, a low number of pages is better. If you have a big and complex scene that needs strong optimizations, you should create more pages. You should try different values : you can delete the resulting meshes by pressing Ctrl-Z in the 3D view window.
Once you found the good size, just enable Gnoll files generation if you're interested in getting such files. If you want an initial page, toggle the corresponding button (in most of cases, you shouldn't need that). Edit the path where the files will be written (if you chose to do it). Then press Subdivide.
Now you got your meshes and your files. To use those results with Gnoll, you have to export every mesh which is part of the scene to the Ogre Mesh format (extension .mesh). You have to download the corresponding exporter from Ogre3D.org. With this exporter you'll get xml files. You have to convert those files to .mesh format : get the OgreXMLConverter, which is included in the main Ogre package.
The XML scene files have to be copied in the data directory of your project. The meshes should be placed in the data/models directory, and their textures and materials in data/materials/textures & data/material/scripts. Now edit the gSceneManager file, and edit the field named initialPage : put the name of one of your pages (ie Ground-Page-1).
Run Gnoll. It should work.
About the script
This script has been written by Antonin <Wetneb> Delpeuch. It's released under Blender Artistic Licence.
The algorithm is based on the Blender Knife Tool, by Stefano <S68> Selleri.
To Do list and known bugs
- Include Ogre files generation in the script -> easier to use;
- Make the algorithm support multi-texturing. It allows the user to create nice textures and use lightmapping;
- Make the algorithm automaticly remove doubles;
- Separate XML Files generation and cutting. It allows to generate files without creating meshes;
- Add a File browser widget instead of the editbox -> easier to use;
- Got an idea ? Found a bug ? Send a mail to ue.hcuepled@ninotna (reverse the letters :) )
Algorithm
The algorithm description is in the script's header. You can also read the source code (which is commented).
FIXME : add naming conventions