Commits

Anonymous committed 2e36d0f

added some logging

Comments (0)

Files changed (4)

Debug/resources.cfg

 FileSystem=../media/samples
 FileSystem=../media/celshading
 FileSystem=../media/stanford
-FileSystem=../media/npr
+FileSystem=../media/npr
+FileSystem=../media2/auralias
+FileSystem=../media/ulb_building

media/npr/gooch.material

 		{
 			vertex_program_ref Shading/PerVertex/GoochVP
 			{
-				param_named KCool float3	0.05  0.05  0.6
-				param_named KWarm float3 	0.5   0.4   0.05
+				param_named KCool float3	1.0   1.0   1.0
+				param_named KWarm float3 	0.0   0.0   0.5
 				param_named Ks 	  float3 	0.5   0.5   0.5
-	    			param_named ns 	  float 	50.0
+	    		param_named ns 	  float 	50.0
 			}
 			fragment_program_ref Shading/PerVertex/GoochFP
 			{
 			}
 			fragment_program_ref Shading/PerPixel/GoochFP
 			{
-				param_named KCool float3	0.05  0.05  0.6
-				param_named KWarm float3 	0.5   0.4   0.05
+				param_named KCool float3	1.0   1.0   1.0
+				param_named KWarm float3 	0.0   0.0   0.5
 				param_named Ks 	  float3 	0.0  0.0   0.0
 	    			param_named ns 	  float 	50.0
 			}

ogre-npr/NPRDemoApp.cpp

 
 #include <sstream>
 #include <boost/foreach.hpp>
+#include <boost/format.hpp>
 
 //#define ANIMATE_LIGHT
 
     ,mAnimState(NULL)
     ,mEdgesVisible(true)
 {
-
 }
 //-----------------------------------------------------------------------------
 void NPRDemoApp::createScene()
 {
+    mLog  = LogManager::getSingleton().createLog("NPR.log");
+
     const RenderSystemCapabilities* caps = Root::getSingleton().getRenderSystem()->getCapabilities();
     if (!caps->hasCapability(RSC_VERTEX_PROGRAM) || !(caps->hasCapability(RSC_FRAGMENT_PROGRAM)))
     {
 
 
     mLightNode->detachObject(mLight);
-    mCameraNode->attachObject(mLight);http://friendlyatheist.com/2010/01/20/stop-trampling-babies/
+    //mCameraNode->attachObject(mLight);
 
-    mLightNode->setVisible(false);
+    mLightNode->setVisible(true);
+
 
 }
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
 void NPRDemoApp::_populate()
 {
-    _loadMesh("TorusKnot01", Vector3(-50, 0, 0));
-    _loadMesh("Teapot01",    Vector3(50, 0, 0));
-    _loadMesh("Gengon01",   Vector3(-50, 0, 50));
-    _loadMesh("Cone01",     Vector3(50, 0, 50));
-    _loadMesh("Box01",      Vector3(-50, 0, -50));
-    _loadMesh("Cylinder01", Vector3(50, 0, -50));
-	
+    //_loadMesh("TorusKnot01", Vector3(-50, 0, 0));
+    //_loadMesh("Teapot01",    Vector3(50, 0, 0));
+    //_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("Rectangle01", Vector3(0, 0, 0));
+    //_loadMesh("Rectangle01", Vector3(0, 0, 0));
 
     // stanford models
 
 	//dragon->pitch(Degree(180));
 	//dragon->translate(0, 15, 0);
 
-
-	
-
+    //_loadMesh("math_back wall", Vector3(0, 0, 0));
+    //_loadMesh("math_front wall", Vector3(0, 0, 0));
+    //_loadMesh("math_left wall", Vector3(0, 0, 0));
+    //_loadMesh("math_right wall", Vector3(0, 0, 0));
+    //_loadMesh("math_roof", Vector3(0, 0, 0));
+    //_loadMesh("math_ground", Vector3(0, 0, 0));
+    //_loadMesh("math_chairs", Vector3(0, 0, 0));
 
     // loading a .scene scene
     //SceneNode *node = mSceneMgr->getRootSceneNode()->createChildSceneNode("titanic_root");
     //_loadScene("titanic", node);
 
-    ////node->translate(0, 0, 1000);
+
+
+
+    //_loadMesh("ulb_building_BATIMENTS_EST", Vector3(-1200, 0, 0));
+    //_loadMesh("ulb_building_BATIMENTS_TOUT", Vector3(-1200, 0, 0));
+    _loadMesh("ulb_building_bat_C", Vector3(-1200, 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_BAT_NEXT", Vector3(-1200, 0, 0));
+    //_loadMesh("ulb_building_BAT_PRINCIPAL", Vector3(-1200, 0, 0));
+    //_loadMesh("ulb_building_bat_projet broullion", Vector3(-1200, 0, 0));
+    //_loadMesh("ulb_building_bat_S_W", Vector3(-1200, 0, 0));
+    //_loadMesh("ulb_building_batiment_plus", Vector3(-1200, 0, 0));
+
+
+    //_loadMesh("ulb_building_BATIMENTS_PROJET", Vector3(-1200, 0, 0));
+    //_loadMesh("ulb_building_BATIMENTS_TOUT", Vector3(-1200, 0, 0));
+    //_loadMesh("ulb_building_Calque1", Vector3(-1200, 0, 0));
+    //_loadMesh("ulb_building_Calque2", Vector3(-1200, 0, 0));
+    //_loadMesh("ulb_building_COURBES", Vector3(-1200, 0, 0));
+
+    //_loadMesh("ulb_building_galleries", Vector3(-1200, 0, 0));
+    //_loadMesh("ulb_building_Layer0", Vector3(-1200, 0, 0));
+
+    //_loadMesh("ulb_building_Le_Batiment", Vector3(-1200, 0, 0));
+    //_loadMesh("ulb_building_route relief", Vector3(-1200, 0, 0));
+
+    //_loadMesh("ulb_building_tour", Vector3(-1200, 0, 0));
+    //_loadMesh("ulb_building_Z_LAYOUT", Vector3(-1200, 0, 0));
+
+    ////node->translate(0, 0, -1500);
     //node->scale(0.1, 0.1, 0.1);
 }
 //-----------------------------------------------------------------------------
     SceneNode *node = mSceneMgr->getRootSceneNode()->createChildSceneNode(_name+"Node", _pos);
 
 	ent->setMaterialName("Shading/PerPixel/Gooch");
-    //ent->setMaterialName("NPR/Face");
     node->attachObject(ent);
 
     ManualObject *edges = _createQuadFinGeometry(ent);
 //-----------------------------------------------------------------------------
 ManualObject* NPRDemoApp::_createQuadFinGeometry(Ogre::Entity *_ent)
 {
+    mLog->logMessage("Creating edges for entity : " + _ent->getName());
+
     MeshPtr mesh = _ent->getMesh();
+
+    {
+        boost::format fmt("Mesh has %d submeshes");
+        fmt % mesh->getNumSubMeshes();
+        mLog->logMessage(fmt.str());
+    }
+
+    // we want to generate edges for all submeshes
+    //Mesh::SubMeshIterator submeshIt = mesh->getSubMeshIterator();
+    //while (submeshIt.hasMoreElements())
+    //{
+    //    submeshIt.getNext()->setBuildEdgesEnabled(true);
+    //} 
+
+    mesh->getSubMesh(0)->setBuildEdgesEnabled(true);
+    mesh->getSubMesh(1)->setBuildEdgesEnabled(true);
+
     mesh->buildEdgeList();
-    
+                     
     EdgeData *edgeData = mesh->getEdgeList();
     
+
+    {
+        boost::format fmt("Generating %d edgegroups");
+        fmt % edgeData->edgeGroups.size();
+        mLog->logMessage(fmt.str());
+    }
+
+
     ManualObject *edgeGeometry = mSceneMgr->createManualObject(_ent->getName() + "edges");
 
     MeshData meshData;
     _getMeshInformation(mesh, meshData, Vector3::ZERO, Quaternion::IDENTITY, Vector3(1,1,1));
 
 
-    int edgeCount = edgeData->edgeGroups[0].edges.size();
-    int idx=0;
     edgeGeometry->begin("NPR/EdgeOutliner", RenderOperation::OT_TRIANGLE_LIST);
 
-    for(int i=0; i<edgeCount ; i++)
+    int idx=0;
+    for(int edgeGroupIdx = 0 ; edgeGroupIdx < edgeData->edgeGroups.size() ; edgeGroupIdx++)
     {
-        EdgeData::Edge e = edgeData->edgeGroups[0].edges[i];
-
-        Vector3 v0, v1;
-        Vector4 nA, nB ;
-        Real markedEdge;
-
-        if(e.degenerate)
         {
-            v0 =  meshData.vertices[e.vertIndex[0]];
-            v1 =  meshData.vertices[e.vertIndex[1]];
-
-            nA = edgeData->triangleFaceNormals[e.triIndex[0]];
-            nB = -nA;
-            markedEdge = 2.0f;
-        }
-        else
-        {
-            v0 =  meshData.vertices[e.vertIndex[0]];
-            v1 =  meshData.vertices[e.vertIndex[1]];
-
-            nA = edgeData->triangleFaceNormals[e.triIndex[0]];
-            nB = edgeData->triangleFaceNormals[e.triIndex[1]];
-            
-            Real ridgeThreshold = Degree(35.0f).valueRadians();
-            Real valleyThreshold = Degree(35.0f).valueRadians();
-
-
-            bool isRidge = _isEdgeARidge(Vector3(nA.x, nA.y, nA.z)
-                                        	,Vector3(nB.x, nB.y, nB.z)
-                                        ,ridgeThreshold);
-
-            bool isValley = _isEdgeAValley(Vector3(nA.x, nA.y, nA.z)
-                                          ,Vector3(nB.x, nB.y, nB.z)
-                                          ,valleyThreshold);
-
-            markedEdge = (isRidge || isValley) ? 1.0f : 0.0f;
+            boost::format fmt("Adding edges for edgegroup[%d]");
+            fmt % edgeGroupIdx ;
+            mLog->logMessage(fmt.str());
         }
 
-        _buildEdgeQuad(v0, v1, nA, nB, markedEdge, idx, edgeGeometry);
-        idx+=6;
+        int edgeCount = edgeData->edgeGroups[edgeGroupIdx].edges.size();
+
+
+        for(int i=0; i<edgeCount ; i++)
+        {
+            EdgeData::Edge e = edgeData->edgeGroups[0].edges[i];
+
+            Vector3 v0, v1;
+            Vector4 nA, nB ;
+            Real markedEdge;
+
+            if(e.degenerate)
+            {
+                v0 =  meshData.vertices[e.vertIndex[0]];
+                v1 =  meshData.vertices[e.vertIndex[1]];
+
+                nA = edgeData->triangleFaceNormals[e.triIndex[0]];
+                nB = -nA;
+                markedEdge = 2.0f;
+            }
+            else
+            {
+                v0 =  meshData.vertices[e.vertIndex[0]];
+                v1 =  meshData.vertices[e.vertIndex[1]];
+
+                nA = edgeData->triangleFaceNormals[e.triIndex[0]];
+                nB = edgeData->triangleFaceNormals[e.triIndex[1]];
+            
+                Real ridgeThreshold = Degree(10.0f).valueRadians();
+                Real valleyThreshold = Degree(10.0f).valueRadians();
+
+
+                bool isRidge = _isEdgeARidge(Vector3(nA.x, nA.y, nA.z)
+                    ,Vector3(nB.x, nB.y, nB.z)
+                    ,ridgeThreshold);
+
+                bool isValley = _isEdgeAValley(Vector3(nA.x, nA.y, nA.z)
+                    ,Vector3(nB.x, nB.y, nB.z)
+                    ,valleyThreshold);
+
+
+                markedEdge = (isRidge || isValley) ? 1.0f : 0.0f;
+            }
+
+            {
+                boost::format fmt("Adding new edge for position : (%.2f, %.2f, %.2f)  (%.2f, %.2f, %.2f)");
+                fmt % v0.x % v0.y % v0.z % v1.x % v1.y % v0.z; 
+                mLog->logMessage(fmt.str());
+            }
+
+            v0 += Vector3(0, edgeGroupIdx*100, 0);
+            v1 += Vector3(0, edgeGroupIdx*100, 0);
+
+            _buildEdgeQuad(v0, v1, nA, nB, markedEdge, idx, edgeGeometry);
+            idx+=6;
+        }
+
+        {
+            boost::format fmt("%s : Added %d edges (%d tris, %d vertices)");
+            fmt % edgeGeometry->getName() % (idx/6) % (idx/3) % (idx);
+            mLog->logMessage(fmt.str());
+        }
     }
-
     edgeGeometry->end();
     return edgeGeometry;
 }

ogre-npr/NPRDemoApp.h

     AnimationState *mAnimState;
     EdgeGeometryList mEdges;
     bool mEdgesVisible;
+
+    Log *mLog;
 };
 
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.