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: Ogre Wiki talk:Help
View page
Source of version: 2
(current)
I used Blender3d for this technique, and it seemed to work fine. Let's say you want to create a map on your screen somewhere. Now, since you want portions of your map to be clickable/editable - say they're seperate provinces or something, they need to be created as seperate meshes. So how do you create a static border between the edges of your meshes? The answer is to use Line3d and getMeshInformation (both found on this wiki) along with the following method (outlineEntity). This method takes the vetex and index data from getMeshInformation and determines which edges are degenerate edges (this means an edge that does not border another triangle), then it draws a line (Line3d) between the two vertices. Here is the technique I used for displaying a border on the front-facing layer of a 3d mesh. First, in your modelling program, create your map as a 2d plane. You will use this only as a vertex query object. Then, convert this 2d map to a mesh. Next, extrude the vertices of your 2d mesh so that it becomes 3d. Convert this 3d map as a seperate mesh. Then, in your application code, add the 3d mesh as you normally would. Then, create an entity of the 2d mesh but instead of attaching it ot a SceneNode, call outLineEntity instead. Here is the outlineEntity code: void GameState::outlineEntity(Ogre::Entity* entity, {CODE(wrap="1", colors="c++")} StaticGeometry* staticGeometry, SceneNode* sceneNode ){CODE} {{CODE(wrap="1", colors="c++")} size_t vertex_count,index_count; Vector3* vertices; unsigned* indices; getMeshInformation(entity->getMesh(),vertex_count,vertices,index_count,indices); Vector3 *vertexArray = new Vector3[vertex_count]; vertexArray = vertices; Ogre::EdgeData* edgeData = entity->getMesh()->getEdgeList(0); Ogre::EdgeData::EdgeGroupList::iterator i, iend; Ogre::EdgeData::EdgeList::iterator ei, eiend; Line3D *myLine = new Line3D(); iend = edgeData->edgeGroups.end(); for (i = edgeData->edgeGroups.begin(); i != iend; ++i) { int num = 0; eiend = i->edges.end(); for (ei = i->edges.begin(); ei != eiend; ++ei, ++num) { Ogre::EdgeData::Edge& e = *ei; //If this edge is degenerate, then take the vertex index at 0 and 1, //Add both vertices to the Line3d dequeue.. if (e.degenerate) { Vector3 start = Vector3(vertexArray[e.vertIndex[0]]); Vector3 end = Vector3(vertexArray[e.vertIndex[1]]); myLine->addPoint(start); myLine->addPoint(end); } } } /*Here is the major optimization. Rather than draw each line and add it as a seperate SceneNode, I can use the inbred batching functionality of Line3d to draw all lines at the END of finding Silhouette Edges, and hence only have one Scene node as opposed to several hundred. Which improved the FPS on my laptop from ~7FPS to 79FPS. */ myLine->drawLines(); sceneNode->attachObject(myLine); staticGeometry->addSceneNode(sceneNode); delete[] vertices; delete[] indices; {CODE} } Note: If you don't want to attach it to a predefined SceneNode and StaticGeometry, the function is this: void GameState::outlineEntity(Ogre::Entity* entity ) {{CODE(wrap="1", colors="c++")} size_t vertex_count,index_count; Vector3* vertices; unsigned* indices; getMeshInformation(entity->getMesh(),vertex_count,vertices,index_count,indices); Vector3 *vertexArray = new Vector3[vertex_count]; vertexArray = vertices; SceneNode *myNode = State::gSceneMgr->getRootSceneNode()->createChildSceneNode(); Ogre::EdgeData* edgeData = entity->getMesh()->getEdgeList(0); Ogre::EdgeData::EdgeGroupList::iterator i, iend; Ogre::EdgeData::EdgeList::iterator ei, eiend; iend = edgeData->edgeGroups.end(); for (i = edgeData->edgeGroups.begin(); i != iend; ++i) { int num = 0; eiend = i->edges.end(); for (ei = i->edges.begin(); ei != eiend; ++ei, ++num) { Line3D *myLine = new Line3D(); Ogre::EdgeData::Edge& e = *ei; //If this edge is degenerate, then take the vertex index at 0 and 1, //do a lookup in the actual vertex array, and immediately //draw the line. if (e.degenerate) { Vector3 start = Vector3(vertexArray[e.vertIndex[0]]); //Lay slightly over the mesh. start.z += .01; Vector3 end = Vector3(vertexArray[e.vertIndex[1]]); end.z += .01; myLine->drawLine(start, end); myNode->attachObject(myLine); } } } delete[] vertices; delete[] indices;{CODE} }
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
17 online users