Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaxime Curioni <maxime.curioni@gmail.com>2008-08-08 12:25:50 +0400
committerMaxime Curioni <maxime.curioni@gmail.com>2008-08-08 12:25:50 +0400
commit8bec6c559fef6e5838ddf165cd6f930eda0b03dd (patch)
tree628b8b9642a951c007f2dcff2131c5e8191ebb10 /source/blender/freestyle/intern/scene_graph
parent76a1363b0bf79c9fb02e45dd86efa0cbe2b8c8e4 (diff)
soc-2008-mxcurioni: finished removing lib3ds. Freestyle now runs correctly within Blender without using a 3ds import format. Most shapes tested work, the only exception being strands and halos.
Diffstat (limited to 'source/blender/freestyle/intern/scene_graph')
-rw-r--r--source/blender/freestyle/intern/scene_graph/BlenderFileLoader.cpp195
-rw-r--r--source/blender/freestyle/intern/scene_graph/BlenderFileLoader.h1
2 files changed, 123 insertions, 73 deletions
diff --git a/source/blender/freestyle/intern/scene_graph/BlenderFileLoader.cpp b/source/blender/freestyle/intern/scene_graph/BlenderFileLoader.cpp
index 3fc67a57329..bede99e4da3 100644
--- a/source/blender/freestyle/intern/scene_graph/BlenderFileLoader.cpp
+++ b/source/blender/freestyle/intern/scene_graph/BlenderFileLoader.cpp
@@ -18,13 +18,19 @@ NodeGroup* BlenderFileLoader::Load()
ObjectInstanceRen *obi;
ObjectRen *obr;
+ cout << "Shape loading" << endl;
+
// creation of the scene root node
_Scene = new NodeGroup;
int id = 0;
for(obi= (ObjectInstanceRen *) _re->instancetable.first; obi; obi=obi->next) {
obr= obi->obr;
- insertShapeNode(obr, ++id);
+
+ if( obr->totvlak > 0)
+ insertShapeNode(obr, ++id);
+ else
+ cout << " Sorry, only vlak-based shapes are supported." << endl;
}
//Returns the built scene.
@@ -175,13 +181,14 @@ void BlenderFileLoader::insertShapeNode(ObjectRen *obr, int id)
currentMIndex = meshFrsMaterials.size()-1;
}
}
-
+
+ unsigned j;
fv[0] = vlr->v1;
fv[1] = vlr->v2;
fv[2] = vlr->v3;
+ float *pv_ptr[3];
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++)
@@ -198,26 +205,44 @@ void BlenderFileLoader::insertShapeNode(ObjectRen *obr, int id)
vert[i][j] = pv[j];
}
-
- for(j=0; j<3; j++)
- pn[j] = fv[i]->n[j];
-
- MTC_Mat4MulVecfl( M, pn);
-
- //lib3ds_normal_transform(pn, M, normalL[3*p+i]); //fills the cells of the pv array
- //lib3ds_vector_normalize(pn);
-
+
+ pv_ptr[i] = pv;
*pvi = currentIndex;
- *pni = currentIndex;
*pmi = currentMIndex;
-
+
currentIndex +=3;
pv += 3;
- pn += 3;
+
pvi++;
- pni++;
pmi++;
-
+ }
+
+ currentIndex -= 9;
+
+ float vec01[3];
+ vec01[0] = pv_ptr[1][0] - pv_ptr[0][0];
+ vec01[1] = pv_ptr[1][1] - pv_ptr[0][1];
+ vec01[2] = pv_ptr[1][2] - pv_ptr[0][2];
+
+ float vec02[3];
+ vec02[0] = pv_ptr[2][0] - pv_ptr[0][0];
+ vec02[1] = pv_ptr[2][1] - pv_ptr[0][1];
+ vec02[2] = pv_ptr[2][2] - pv_ptr[0][2];
+
+ float n[3];
+ MTC_cross3Float(n, vec01, vec02);
+ MTC_normalize3DF(n);
+
+ for(i=0; i<3; ++i) {
+ for(j=0; j<3; ++j) {
+ pn[j] = n[j];
+ }
+ *pni = currentIndex;
+
+ pn += 3;
+ pni++;
+
+ currentIndex +=3;
}
for(i=0; i<3; i++)
@@ -233,65 +258,89 @@ void BlenderFileLoader::insertShapeNode(ObjectRen *obr, int id)
}
++_numFacesRead;
+
if(vlr->v4){
- fv[0] = vlr->v1;
- fv[1] = vlr->v3;
- fv[2] = vlr->v4;
- 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( 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( 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;
- }
+
+ unsigned j;
+ fv[0] = vlr->v1;
+ fv[1] = vlr->v3;
+ fv[2] = vlr->v4;
+ float *pv_ptr[3];
+ for(i=0; i<3; ++i) // we parse the vertices of the face f
+ {
+
+ //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( 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];
+ }
+
+ pv_ptr[i] = pv;
+ *pvi = currentIndex;
+ *pmi = currentMIndex;
+
+ currentIndex +=3;
+ pv += 3;
+
+ pvi++;
+ pmi++;
+ }
+
+ currentIndex -= 9;
+
+ float vec01[3];
+ vec01[0] = pv_ptr[1][0] - pv_ptr[0][0];
+ vec01[1] = pv_ptr[1][1] - pv_ptr[0][1];
+ vec01[2] = pv_ptr[1][2] - pv_ptr[0][2];
+
+ float vec02[3];
+ vec02[0] = pv_ptr[2][0] - pv_ptr[0][0];
+ vec02[1] = pv_ptr[2][1] - pv_ptr[0][1];
+ vec02[2] = pv_ptr[2][2] - pv_ptr[0][2];
+
+ float n[3];
+ MTC_cross3Float(n, vec01, vec02);
+ MTC_normalize3DF(n);
- ++_numFacesRead;
+ for(i=0; i<3; ++i) {
+ for(j=0; j<3; ++j) {
+ pn[j] = n[j];
+ }
+ *pni = currentIndex;
+
+ pn += 3;
+ pni++;
+
+ currentIndex +=3;
+ }
+
+ 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;
+ }
+
+ ++_numFacesRead;
+
+
+
}
}
diff --git a/source/blender/freestyle/intern/scene_graph/BlenderFileLoader.h b/source/blender/freestyle/intern/scene_graph/BlenderFileLoader.h
index 2b038e08b21..8202c0e4716 100644
--- a/source/blender/freestyle/intern/scene_graph/BlenderFileLoader.h
+++ b/source/blender/freestyle/intern/scene_graph/BlenderFileLoader.h
@@ -25,6 +25,7 @@ extern "C" {
#include "BKE_mesh.h"
#include "BKE_scene.h"
#include "MTC_matrixops.h"
+ #include "MTC_vectorops.h"
#ifdef __cplusplus
}