Ogre Wiki talk:Help        

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,

StaticGeometry* staticGeometry,
                       SceneNode* sceneNode )
{
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;

}

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 )

{
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;

}