OGRE Wiki
Support and community documentation for Ogre3D
Ogre Forums
ogre3d.org
Log in
Username:
Password:
CapsLock is on.
Remember me (for 1 year)
Log in
Home
Tutorials
Tutorials Home
Basic Tutorials
Intermediate Tutorials
Mad Marx Tutorials
In Depth Tutorials
Older Tutorials
External Tutorials
Cookbook
Cookbook Home
CodeBank
Snippets
Experiences
Ogre Articles
Libraries
Libraries Home
Alternative Languages
Assembling A Toolset
Development Tools
OGRE Libraries
List of Libraries
Tools
Tools Home
DCC Tools
DCC Tutorials
DCC Articles
DCC Resources
Assembling a production pipeline
Development
Development Home
Roadmap
Building Ogre
Installing the Ogre SDK
Setting Up An Application
Ogre Wiki Tutorial Framework
Frequently Asked Questions
Google Summer Of Code
Help Requested
Ogre Core Articles
Community
Community Home
Projects Using Ogre
Recommended Reading
Contractors
Wiki
Immediate Wiki Tasklist
Wiki Ideas
Wiki Guidelines
Article Writing Guidelines
Wiki Styles
Wiki Page Tracker
Ogre Wiki Help
Ogre Wiki Help Overview
Help - Basic Syntax
Help - Images
Help - Pages and Structures
Help - Wiki Plugins
Toolbox
Freetags
Categories
List Pages
Structures
Trackers
Statistics
Rankings
List Galleries
Ogre Lexicon
Comments
History: GeometricMesh
View page
Source of version: 9
(current)
The tutorial and the code are written by ((User:sphinkie)). You can also react to this article [http://www.ogre3d.org/phpBB2/viewtopic.php?t=19752&highlight=|in the forum] {maketoc} !!Credits Thanks to __Snowblind__ for the ((ManualSphereMeshes)) and its "shape to mesh" algorithm. Thanks to __Richard J. Bono__ for the geodesic algorithm (GNU licence) and the [http://mathforum.org/library/view/8321.html|winDome] utility. !!Download {ATTACH(name="geometrik.zip",id="140",icon="1")}{ATTACH} !!Presentation In this article, I will present a way to generate various geometric shapes. This article gives information about the library, the concept, and how to use it. The UV mapping applied on all shapes is a spherical mapping. The library can be upgraded for bugfix, optimization and adding new shapes. __All the sources can be found at the end of the article.__ !!How to use the library The API is quite simple, and you can built it using the utility doxygen (as the source files are doxygen compatible). When you create the object, you give the parameters needed: usually radius, and some others. It depend of the kind of shape you are creating. Then you call the ''createMesh'' method, giving the name of the mesh. You will use the same name when creating your Ogre entity. * Example 1: creating a cube with a halfside of 100 units: {CODE(wrap="1", colors="c++")} #include "Mesh_Cube.h" ... Mesh_Cube M(100); M.createMesh("myMesh"); mEntity = mSceneMgr->createEntity(mName, "myMesh"); mNode->attachObject(mEntity);{CODE} {img src="img/wiki_up/Geometrik_cube.jpg" alt="Geometrik_cube.jpg"} : A textured cube * Example 2: creating a geosphere with a radius of 800 units: {CODE(wrap="1", colors="c++")} #include "Mesh_geosphere.h" ... Mesh_Geosphere M(800); // radius 800 - default frequency - default class 1 // Mesh_Geosphere M(800, 4, true); // radius 800 - frequency 4 - class 2 M.createMesh("myMesh"); ... // extra functions available for geodesic shapes: M.dumpData(); // write data inthe log file M.createDXF("geosphere.dxf"); // create a DXF file M.createDXFwireframe("geosphere_WF.dxf"); // create a DXF file ... mEntity = mSceneMgr->createEntity(mName, "myMesh"); mNode->attachObject(mEntity); {CODE} For geodesic shapes, you have some more functions in the API that allow you to dump geometrical data in the log file, and to create a DXF file, so you can preview the shape in your favorite 3D modeler (ie: blender3D). {img src="img/wiki_up/Geometrik_planet.jpg" alt="Geometrik_planet.jpg"} : A textured geosphere * Example 3: creating a sphere with a radius of 800 units.: {CODE(wrap="1", colors="c++")} #include "Mesh_sphere.h" ... Mesh_Sphere M(800); M.createMesh("myMesh"); mEntity = mSceneMgr->createEntity(mName, "myMesh"); mNode->attachObject(mEntity);{CODE} {img src="img/wiki_up/Geometrik_sphere.jpg" alt="Geometrik_sphere.jpg"} : A wireframe sphere !!GeometricMesh The library is based on 2 generic classes : __GeometricMesh__ and __Geodesic__. __GeometricMesh__ allows you to create geometric meshes, when given a certain number of vertices and triangles. The GeometricMesh class itself cannot create any meshes. This class should be derived from, with a function ''fillMesh()'' defining the positions of all vertices. Existing derived class are: __Mesh_Cube__, __Mesh_Icosa__, __Mesh_Sphere__. New classes can be easily added (cylinder, etc). * In a Cube, or an Icosahedron, there is a small number of vertices (around 10 or 20), so the list of vertices can be manually defined. * In a Sphere, a simple function can be use to define all the vertex positions (thanks to the 'snowblind' equation). A function also allows you to create spheres with a parameterizable number of vertices. * But to create a geosphere, a more complex function is needed, and we will need another class (''Geodesic'') to generate the list of vertices for these shapes. !!Geodesic Geodesic shapes a large family of shapes, usually used in architecture for domes, honeycomb, etc. For us, we are only interrested a the subfamily based on assembly of triangles. (you can also have assembly of hexagons or pentagons). The __Geodesic__ class itself gives you no shape: it has to derived into classes that define the equation of the points of the shapes. Existing class are __Mesh_geosphere__ and __Mesh_geoellipse__. New classes can be added, but it is not so easy... __Geosphere__ is a good shape for planets, as is has less texture distortion at the pole (like the usual sphere has). __Geoellipse__ allow you to create Zeppelin shapes, flying saucers, eggs... {img src="img/wiki_up/Geometrik_geosphere_c1.jpg" alt="geometrik_geosphere_c1.jpg"} Class 1 geosphere {img src="img/wiki_up/Geometrik_geosphere_c2.jpg" alt="geometrik_geosphere_c2.jpg"} Class 2 geosphere {img src="img/wiki_up/Geometrik_geoellipse_c2.jpg" alt="geometrik_geoellipse_c2.jpg"} Class 2 geoellipse !!Bibliography * The main reference used in the creation of the geodesic code was "__Geodesic Math & How to Use It__" by Hugh Kenner, 1976, University of California Press. ISBN 0-520-02924-0 * [http://www.newciv.org/Synergetic_Geometry|Richard Hawkins digital archive] * [http://www.applied-synergetics.com/ashp/html/console_readme.html|Geodesic Dome Design] * [http://mathforum.org/library/view/8321.html|The Math Forum] * [http://www.nps.navy.mil/cs/sullivan/osgTutorials/osgGeometry.htm|Open Scene Graph Tutorials] * [http://gtulloue.free.fr/Cabri3D/polyedres/icosaedre.html|L'icosaedre] (french) * And Of course, [http://en.wikipedia.org/wiki/Geodesic_dome|Wikipedia] !!Source files __This is 1.1 version. All source files are in this zip file: __ {ATTACH(name="geometrik.zip",id="140",icon="1")}{ATTACH} The API can be found [http://www.sphinx-studio.fr/files/Geometrik/documentation/html/index.html|here] ~~#933:__Dead Link__~~ To compile you may need these lines in your __macros.h__. {CODE(wrap="1", colors="c++")} #define DEBUG_LOG(X) Ogre::LogManager::getSingleton().logMessage(X) #define TRACE(X) Ogre::LogManager::getSingleton().logMessage(X) {CODE} Or these lines, if you want to disable the debug log. {CODE(wrap="1", colors="c++")} #define DEBUG_LOG(X) #define TRACE(X) Ogre::LogManager::getSingleton().logMessage(X) {CODE} known bugs: * odd frequency with a class 2 geosphere give strange results. !!Todo list ''For the moment, if you want to add/modify the source code, please send me your files and I will update the zip file, or use the Discussion tab of this page.'' These functionnalities are not implemented yet in the library: * Une the new MeshFactory, available in the 'Dagon' version of Ogre3D. * Optimization of the vertex number. ''When the vertice list is defined by a function, it usually creates several vertices for the same point. ie: if a point belongs to 5 triangles, 5 vertices are usually generated for this point''. * New shape : A Cylinder * New shape : A Torus * In the geosphere, there are 2 points with X=0 and Z=0 (the poles). This makes the calculation of U coordinate difficult. ''The solution is maybe to pitch a bit the shape before transforming it into a mesh''. !! See also * ((Ogre Procedural Geometry Library)) * ((ManualObject))
Search by Tags
Search Wiki by Freetags
Latest Changes
Minimal Ogre Collision
Artifex Terra
OpenMB
Advanced Mogre Framework
MogreSocks
Critter AI
Mogre Add-ons
MOGRE
Mogre MyGUI wrapper
MOGRE Editable Terrain Manager
...more
Search
Find
Advanced
Search Help
Online Users
21 online users