Commits

Frederic De Groef committed 15a7f8e

Corrected submesh bug : Not using stupid MeshData anymore (that does not handle submesh offsets). Copying positions from edgeGroup.vertexData instead.

  • Participants
  • Parent commits 92d6ee9

Comments (0)

Files changed (3)

Release/resources.cfg

 FileSystem=../media/samples
 FileSystem=../media/celshading
 FileSystem=../media/npr
-FileSystem=../media/titanic
+FileSystem=../media/titanic
+FileSystem=../media/ulb_building

ogre-npr/EdgeGeometryBuilder.cpp

     ,mIsBuilding(false)
     ,mIsVisible(false)
     ,mEdges(NULL)
-    ,mRidgeThreshold(10.0f)
+    ,mRidgeThreshold(40.0f)
 {
 }
 //-----------------------------------------------------------------------------
     }
 
     mEdges = mSceneMgr->createManualObject(_ent->getName() + "edges");
-    mMeshData = new MeshData(mesh,  Ogre::Vector3::ZERO, Ogre::Quaternion::IDENTITY, Ogre::Vector3::UNIT_SCALE);
+    //mMeshData = new MeshData(mesh,  Ogre::Vector3::ZERO, Ogre::Quaternion::IDENTITY, Ogre::Vector3::UNIT_SCALE);
 
+    
 
     mEdges->begin("NPR/EdgeOutliner", Ogre::RenderOperation::OT_TRIANGLE_LIST);
 
     }
     mEdges->end();
 
-    delete mMeshData;
-    mMeshData = NULL;
+    //delete mMeshData;
+    //mMeshData = NULL;
 }
 //-----------------------------------------------------------------------------
 void EdgeGeometryBuilder::_addEdgesForEdgeGroup(const Ogre::EdgeData::EdgeGroup &_edgeGroup, const Ogre::EdgeData &edgeData)
 {
+    std::vector<Ogre::Vector3> vertices;
+    vertices.resize(_edgeGroup.vertexData->vertexCount);
+
+    const Ogre::VertexElement* posElem =
+        _edgeGroup.vertexData->vertexDeclaration->findElementBySemantic(Ogre::VES_POSITION);
+
+    Ogre::HardwareVertexBufferSharedPtr vbuf =
+        _edgeGroup.vertexData->vertexBufferBinding->getBuffer(posElem->getSource());
+
+    unsigned char* vertex =
+        static_cast<unsigned char*>(vbuf->lock(Ogre::HardwareBuffer::HBL_READ_ONLY));
+
+    // There is _no_ baseVertexPointerToElement() which takes an Ogre::Real or a double
+    //  as second argument. So make it float, to avoid trouble when Ogre::Real will
+    //  be comiled/typedefed as double:
+    //      Ogre::Real* pReal;
+    float* pReal;
+
+    for( size_t j = 0; j < _edgeGroup.vertexData->vertexCount; ++j, vertex += vbuf->getVertexSize())
+    {
+        posElem->baseVertexPointerToElement(vertex, &pReal);
+
+        Ogre::Vector3 pt(pReal[0], pReal[1], pReal[2]);
+
+        vertices[j] = pt;
+    }
+    vbuf->unlock();
+
+
+
+
+
+
     int edgeCount = _edgeGroup.edges.size();
                                                             
     for(int i=0; i<edgeCount ; i++)
 
         if(e.degenerate)
         {
-            v0 =  mMeshData->getVertex(e.vertIndex[0]);
-            v1 =  mMeshData->getVertex(e.vertIndex[1]);
+            
+            v0 =  vertices[e.vertIndex[0]];
+            v1 =  vertices[e.vertIndex[1]];
 
             nA = edgeData.triangleFaceNormals[e.triIndex[0]];
             nB = -nA;
         }
         else
         {
-            v0 =  mMeshData->getVertex(e.vertIndex[0]);
-            v1 =  mMeshData->getVertex(e.vertIndex[1]);
+            v0 =  vertices[e.vertIndex[0]];
+            v1 =  vertices[e.vertIndex[1]];
 
             nA = edgeData.triangleFaceNormals[e.triIndex[0]];
             nB = edgeData.triangleFaceNormals[e.triIndex[1]];

ogre-npr/NPRDemoApp.cpp

     //_loadMesh("Gengon01",   Vector3(-50, 0, 50));
     //_loadMesh("Cone01",     Vector3(50, 0, 50));
     //_loadMesh("Box01",      Vector3(-50, 0, -50));
-    //_loadMesh("dummy", Vector3::ZERO);
 
 	//_loadMesh("sphere2", Vector3(500, 0, 0));
 	//
     //_loadMesh("ulb_building_bat_C_1", Vector3(-1200, 0, 0));
     //_loadMesh("ulb_building_bat_C_2", Vector3(-1200, 0, 0));
 
-    _loadMesh("ulb_building_ASCENCEUR", Vector3(-1200, 0, 0));
+    //_loadMesh("ulb_building_ASCENCEUR", Vector3(-1200, 0, 0));
 
  
     _loadMesh("ulb_building_BAT_NEXT", Vector3(-1200, 0, 0));