[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [16004] branches/soc-2008-mxcurioni/source /blender/freestyle/intern: soc-2008-mxcurioni: corrected matrix used to import meshes.

Maxime Curioni maxime.curioni at gmail.com
Thu Aug 7 18:15:13 CEST 2008


Revision: 16004
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=16004
Author:   mxcurioni
Date:     2008-08-07 18:15:10 +0200 (Thu, 07 Aug 2008)

Log Message:
-----------
soc-2008-mxcurioni: corrected matrix used to import meshes. Despite providing the exact same information (verified by the same bounding box and grid), the ViewMap does not have any view edge yet. The lib3ds-less iteration does NOT work yet.

Modified Paths:
--------------
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/app/Controller.cpp
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/app_blender/Controller.cpp
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/scene_graph/BlenderFileLoader.cpp

Modified: branches/soc-2008-mxcurioni/source/blender/freestyle/intern/app/Controller.cpp
===================================================================
--- branches/soc-2008-mxcurioni/source/blender/freestyle/intern/app/Controller.cpp	2008-08-07 15:18:47 UTC (rev 16003)
+++ branches/soc-2008-mxcurioni/source/blender/freestyle/intern/app/Controller.cpp	2008-08-07 16:15:10 UTC (rev 16004)
@@ -251,8 +251,8 @@
   _ProgressBar->setProgress(1);
 
   // DEBUG
-//   ScenePrettyPrinter spp;
-//   maxScene->accept(spp);
+  // ScenePrettyPrinter spp;
+  // maxScene->accept(spp);
 
   _RootNode->AddChild(maxScene);
   _RootNode->UpdateBBox(); // FIXME: Correct that by making a Renderer to compute the bbox

Modified: branches/soc-2008-mxcurioni/source/blender/freestyle/intern/app_blender/Controller.cpp
===================================================================
--- branches/soc-2008-mxcurioni/source/blender/freestyle/intern/app_blender/Controller.cpp	2008-08-07 15:18:47 UTC (rev 16003)
+++ branches/soc-2008-mxcurioni/source/blender/freestyle/intern/app_blender/Controller.cpp	2008-08-07 16:15:10 UTC (rev 16004)
@@ -202,8 +202,8 @@
   cout << "Epsilon computed : " << _EPSILON << endl;
 
   // DEBUG
-//   ScenePrettyPrinter spp;
-//   blenderScene->accept(spp);
+  // ScenePrettyPrinter spp;
+  // blenderScene->accept(spp);
 	
   _RootNode->AddChild(blenderScene);
   _RootNode->UpdateBBox(); // FIXME: Correct that by making a Renderer to compute the bbox
@@ -243,9 +243,9 @@
   printf("Grid building    : %lf\n", _Chrono.stop());
   
   // DEBUG
-//   _Grid.displayDebug();
-   
-  _pView->setDebug(_DebugNode);
+  _Grid.displayDebug();
+  //  
+  // _pView->setDebug(_DebugNode);
 
   //delete stuff
   //  if(0 != ws_builder)
@@ -305,8 +305,8 @@
   cout << "Epsilon computed : " << _EPSILON << endl;
 
   // DEBUG
-//   ScenePrettyPrinter spp;
-//   maxScene->accept(spp);
+  // ScenePrettyPrinter spp;
+  // maxScene->accept(spp);
 	
   _RootNode->AddChild(maxScene);
   _RootNode->UpdateBBox(); // FIXME: Correct that by making a Renderer to compute the bbox
@@ -346,7 +346,7 @@
   printf("Grid building    : %lf\n", _Chrono.stop());
   
   // DEBUG
-//   _Grid.displayDebug();
+  _Grid.displayDebug();
    
   _pView->setDebug(_DebugNode);
 

Modified: branches/soc-2008-mxcurioni/source/blender/freestyle/intern/scene_graph/BlenderFileLoader.cpp
===================================================================
--- branches/soc-2008-mxcurioni/source/blender/freestyle/intern/scene_graph/BlenderFileLoader.cpp	2008-08-07 15:18:47 UTC (rev 16003)
+++ branches/soc-2008-mxcurioni/source/blender/freestyle/intern/scene_graph/BlenderFileLoader.cpp	2008-08-07 16:15:10 UTC (rev 16004)
@@ -53,7 +53,10 @@
 	// lib3ds_matrix_copy(M, mesh->matrix);
 	// lib3ds_matrix_inv(M);
 	//---------------------
-	// M => obr->ob->imat
+	// M allows to recover world coordinates from camera coordinates
+	// M => obr->ob->imat * obr->obmat  (multiplication from left to right)
+	float M[4][4];
+	MTC_Mat4MulMat4(M, obr->ob->imat, obr->ob->obmat); 
 	
 	// We compute a normal per vertex and manages the smoothing of the shape:
 	// Lib3dsVector *normalL=(Lib3dsVector*)malloc(3*sizeof(Lib3dsVector)*mesh->faces);
@@ -68,7 +71,7 @@
 	for(int a=0; a < obr->totvlak; a++) {
 		if((a & 255)==0) vlr= obr->vlaknodes[a>>8].vlak;
 		else vlr++;
-
+	
 		if(vlr->v4)
 			numFaces += 2;
 		else
@@ -115,7 +118,7 @@
 	pvtmp[1] = obr->vertnodes[0].vert->co[1];
 	pvtmp[2] = obr->vertnodes[0].vert->co[2];
 	
-	MTC_Mat4MulVecfl( obr->ob->imat, pvtmp);
+	MTC_Mat4MulVecfl( M, pvtmp);
 	
 	minBBox[0] = pvtmp[0];
 	maxBBox[0] = pvtmp[0];
@@ -179,44 +182,44 @@
 			for(i=0; i<3; ++i) // we parse the vertices of the face f
 			{
 				unsigned j;
-
+	
 				//lib3ds_vector_transform(pv, M, mesh->pointL[f->points[i]].pos); //fills the cells of the pv array
 				for(j=0; j<3; j++)
 					pv[j] = fv[i]->co[j];
-				MTC_Mat4MulVecfl( obr->ob->imat, pv);
-
+				MTC_Mat4MulVecfl( M, pv);
+	
 				for(j=0; j<3; j++) // we parse the xyz coordinates of the vertex i
 				{
 			  		if(minBBox[j] > pv[j])
 			    		minBBox[j] = pv[j];
-
+	
 			  		if(maxBBox[j] < pv[j])
 			    		maxBBox[j] = pv[j];
-
+	
 			  		vert[i][j] = pv[j];
 				}
-
+	
 				for(j=0; j<3; j++)
 			  		pn[j] = fv[i]->n[j];
 			
-				MTC_Mat4MulVecfl( obr->ob->imat, pn);
-
+				MTC_Mat4MulVecfl( M, pn);
+	
 			//lib3ds_normal_transform(pn, M, normalL[3*p+i]); //fills the cells of the pv array
 			//lib3ds_vector_normalize(pn);
-
+	
 				*pvi = currentIndex;
 				*pni = currentIndex;
 				*pmi = currentMIndex;
-
+	
 				currentIndex +=3;
 				pv += 3;
 				pn += 3;
 				pvi++;
 				pni++;
 				pmi++;
-
+	
 			}
-
+	
 			for(i=0; i<3; i++)
 			{
 				norm = 0.0;
@@ -238,51 +241,51 @@
 						for(i=0; i<3; ++i) // we parse the vertices of the face f
 						{
 							unsigned j;
-
+	
 							//lib3ds_vector_transform(pv, M, mesh->pointL[f->points[i]].pos); //fills the cells of the pv array
 							for(j=0; j<3; j++)
 								pv[j] = fv[i]->co[j];
-							MTC_Mat4MulVecfl( obr->ob->imat, pv);
-
+							MTC_Mat4MulVecfl( M, pv);
+	
 							for(j=0; j<3; j++) // we parse the xyz coordinates of the vertex i
 							{
 						  		if(minBBox[j] > pv[j])
 						    		minBBox[j] = pv[j];
-
+	
 						  		if(maxBBox[j] < pv[j])
 						    		maxBBox[j] = pv[j];
-
+	
 						  		vert[i][j] = pv[j];
 							}
-
+	
 							for(j=0; j<3; j++)
 						  		pn[j] = fv[i]->n[j];
-
-							MTC_Mat4MulVecfl( obr->ob->imat, pn);
-
+	
+							MTC_Mat4MulVecfl( M, pn);
+	
 						//lib3ds_normal_transform(pn, M, normalL[3*p+i]); //fills the cells of the pv array
 						//lib3ds_vector_normalize(pn);
-
+	
 							*pvi = currentIndex;
 							*pni = currentIndex;
 							*pmi = currentMIndex;
-
+	
 							currentIndex +=3;
 							pv += 3;
 							pn += 3;
 							pvi++;
 							pni++;
 							pmi++;
-
+	
 						}
-
+	
 						for(i=0; i<3; i++)
 						{
 							norm = 0.0;
-
+	
 							for (unsigned j = 0; j < 3; j++)
 						  		norm += (vert[i][j] - vert[(i+1)%3][j])*(vert[i][j] - vert[(i+1)%3][j]);
-
+	
 							norm = sqrt(norm);
 							if(_minEdgeSize > norm)
 						  		_minEdgeSize = norm;
@@ -290,7 +293,7 @@
 				
 					++_numFacesRead;
 			}
-
+	
 	}
 	
 	// We might have several times the same vertex. We want a clean 
@@ -350,8 +353,8 @@
 	rep->setBBox(bbox);
 	shape->AddRep(rep);
 	
-	Matrix44r M = Matrix44r::identity();
-	currentMesh->setMatrix(M);
+	Matrix44r meshMat = Matrix44r::identity();
+	currentMesh->setMatrix(meshMat);
 	currentMesh->Translate(0,0,0);
 	
 	currentMesh->AddChild(shape);





More information about the Bf-blender-cvs mailing list