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-07 19:04:25 +0400
committerMaxime Curioni <maxime.curioni@gmail.com>2008-08-07 19:04:25 +0400
commit9a1217e55980f9b0a501fbe03ab2ea559638392d (patch)
tree28b4c5bcf547d2d9f63d7d687ff6f43064cc0dc5 /source/blender/freestyle/intern/scene_graph
parent1baf09110b2c3bd4a6eea128b61ca9a0017f81dd (diff)
soc-2008-mxcurioni: first version of lib3ds code. It does NOT work yet and has to be debugged. It can be activate in app_blender/api.cpp by replacing the FRS_scene_3ds_export call in FRS_prepare, by FRS_load_mesh.
All of the reference to the original Material class were renamed to FrsMaterial to resolve a name collision with Blender. To keep the window context necessary to draw the strokes after RE_Database_FromScene has been called, the display_clear function is used.
Diffstat (limited to 'source/blender/freestyle/intern/scene_graph')
-rw-r--r--source/blender/freestyle/intern/scene_graph/BlenderFileLoader.cpp360
-rw-r--r--source/blender/freestyle/intern/scene_graph/BlenderFileLoader.h62
-rwxr-xr-xsource/blender/freestyle/intern/scene_graph/FrsMaterial.h (renamed from source/blender/freestyle/intern/scene_graph/Material.h)46
-rwxr-xr-xsource/blender/freestyle/intern/scene_graph/IndexedFaceSet.cpp28
-rwxr-xr-xsource/blender/freestyle/intern/scene_graph/IndexedFaceSet.h8
-rwxr-xr-xsource/blender/freestyle/intern/scene_graph/MaxFileLoader.cpp28
-rwxr-xr-xsource/blender/freestyle/intern/scene_graph/NodeShape.cpp2
-rwxr-xr-xsource/blender/freestyle/intern/scene_graph/NodeShape.h8
-rwxr-xr-xsource/blender/freestyle/intern/scene_graph/OrientedLineRep.cpp2
-rwxr-xr-xsource/blender/freestyle/intern/scene_graph/Rep.h40
-rwxr-xr-xsource/blender/freestyle/intern/scene_graph/SceneVisitor.h4
11 files changed, 505 insertions, 83 deletions
diff --git a/source/blender/freestyle/intern/scene_graph/BlenderFileLoader.cpp b/source/blender/freestyle/intern/scene_graph/BlenderFileLoader.cpp
new file mode 100644
index 00000000000..f35f32a8bee
--- /dev/null
+++ b/source/blender/freestyle/intern/scene_graph/BlenderFileLoader.cpp
@@ -0,0 +1,360 @@
+#include "BlenderFileLoader.h"
+
+BlenderFileLoader::BlenderFileLoader(Render *re)
+{
+ _re = re;
+ _Scene = NULL;
+ _numFacesRead = 0;
+ _minEdgeSize = DBL_MAX;
+}
+
+BlenderFileLoader::~BlenderFileLoader()
+{
+ _Scene = NULL;
+}
+
+NodeGroup* BlenderFileLoader::Load()
+{
+ ObjectInstanceRen *obi;
+ ObjectRen *obr;
+
+ // 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);
+ }
+
+ //Returns the built scene.
+ return _Scene;
+}
+
+void BlenderFileLoader::insertShapeNode(ObjectRen *obr, int id)
+{
+ VlakRen *vlr;
+
+ float minBBox[3];
+ float maxBBox[3];
+
+ NodeTransform *currentMesh = new NodeTransform;
+ NodeShape * shape;
+
+ // Mesh *mesh = (Mesh *)ob->data;
+ //---------------------
+ // mesh => obr
+
+ // builds the shape:
+ shape = new NodeShape;
+
+ // We invert the matrix in order to be able to retrieve the shape's coordinates in its local coordinates system (origin is the iNode pivot)
+ // Lib3dsMatrix M;
+ // lib3ds_matrix_copy(M, mesh->matrix);
+ // lib3ds_matrix_inv(M);
+ //---------------------
+ // M => obr->ob->imat
+
+ // We compute a normal per vertex and manages the smoothing of the shape:
+ // Lib3dsVector *normalL=(Lib3dsVector*)malloc(3*sizeof(Lib3dsVector)*mesh->faces);
+ // lib3ds_mesh_calculate_normals(mesh, normalL);
+ // mesh_calc_normals(mesh->mvert, mesh->totvert, mesh->mface, mesh->totface, NULL);
+ //---------------------
+ // already calculated and availabe in vlak ?
+
+ // We build the rep:
+ IndexedFaceSet *rep;
+ unsigned numFaces = 0;
+ 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
+ numFaces++;
+ }
+
+ unsigned vSize = 3*3*numFaces;
+ float *vertices = new float[vSize];
+ unsigned nSize = vSize;
+ float *normals = new float[nSize];
+ unsigned *numVertexPerFaces = new unsigned[numFaces];
+ vector<FrsMaterial> meshFrsMaterials;
+
+ IndexedFaceSet::TRIANGLES_STYLE *faceStyle = new IndexedFaceSet::TRIANGLES_STYLE[numFaces];
+ unsigned i;
+ for (i = 0; i <numFaces; i++) {
+ faceStyle[i] = IndexedFaceSet::TRIANGLES;
+ numVertexPerFaces[i] = 3;
+ }
+
+ unsigned viSize = 3*numFaces;
+ unsigned *VIndices = new unsigned[viSize];
+ unsigned niSize = viSize;
+ unsigned *NIndices = new unsigned[niSize];
+ unsigned *MIndices = new unsigned[viSize]; // Material Indices
+
+
+ float *pv = vertices;
+ float *pn = normals;
+ unsigned *pvi = VIndices;
+ unsigned *pni = NIndices;
+ unsigned *pmi = MIndices;
+
+ unsigned currentIndex = 0;
+ unsigned currentMIndex = 0;
+
+ FrsMaterial tmpMat;
+
+ // we want to find the min and max coordinates as we build the rep.
+ // We initialize the min and max values whith the first vertex.
+ //lib3ds_vector_transform(pvtmp, M, mesh->pointL[mesh->faceL[0].points[0]].pos);
+ float pvtmp[3];
+ pvtmp[0] = obr->vertnodes[0].vert->co[0];
+ pvtmp[1] = obr->vertnodes[0].vert->co[1];
+ pvtmp[2] = obr->vertnodes[0].vert->co[2];
+
+ MTC_Mat4MulVecfl( obr->ob->imat, pvtmp);
+
+ minBBox[0] = pvtmp[0];
+ maxBBox[0] = pvtmp[0];
+ minBBox[1] = pvtmp[1];
+ maxBBox[1] = pvtmp[1];
+ minBBox[2] = pvtmp[2];
+ maxBBox[2] = pvtmp[2];
+
+ int p;
+ real vert[3][3];
+ real norm;
+ for(p=0; p < obr->totvlak; ++p) // we parse the faces of the mesh
+ {
+ VertRen * fv[3];
+
+ // Lib3dsFace *f=&mesh->faceL[p];
+ // Lib3dsMaterial *mat=0;
+ if((p & 255)==0) vlr = obr->vlaknodes[p>>8].vlak;
+ else vlr++;
+ Material *mat = vlr->mat;
+
+ if (mat)
+ {
+ tmpMat.setDiffuse( mat->r, mat->g, mat->b, mat->alpha );
+ tmpMat.setSpecular( mat->specr, mat->specg, mat->specb, mat->spectra);
+ float s = 1.0 * (mat->har + 1) / 4 ; // in Blender: [1;511] => in OpenGL: [0;128]
+ if(s > 128.f)
+ s = 128.f;
+ tmpMat.setShininess(s);
+ }
+
+ if(meshFrsMaterials.empty())
+ {
+ meshFrsMaterials.push_back(tmpMat);
+ shape->setFrsMaterial(tmpMat);
+ } else {
+ // find if the material is aleady in the list
+ unsigned i=0;
+ bool found = false;
+
+ for(vector<FrsMaterial>::iterator it=meshFrsMaterials.begin(), itend=meshFrsMaterials.end();
+ it!=itend;
+ ++it){
+ if(*it == tmpMat){
+ currentMIndex = i;
+ found = true;
+ break;
+ }
+ ++i;
+ }
+
+ if(!found){
+ meshFrsMaterials.push_back(tmpMat);
+ currentMIndex = meshFrsMaterials.size()-1;
+ }
+ }
+
+ fv[0] = vlr->v1;
+ fv[1] = vlr->v2;
+ fv[2] = vlr->v3;
+ 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);
+
+ 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);
+
+ //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;
+ }
+
+ ++_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( obr->ob->imat, 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);
+
+ //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;
+ }
+
+ ++_numFacesRead;
+ }
+
+ }
+
+ // We might have several times the same vertex. We want a clean
+ // shape with no real-vertex. Here, we are making a cleaning
+ // pass.
+ real *cleanVertices = NULL;
+ unsigned cvSize;
+ unsigned *cleanVIndices = NULL;
+
+ GeomCleaner::CleanIndexedVertexArray(
+ vertices, vSize,
+ VIndices, viSize,
+ &cleanVertices, &cvSize,
+ &cleanVIndices);
+
+ real *cleanNormals = NULL;
+ unsigned cnSize;
+ unsigned *cleanNIndices = NULL;
+
+ GeomCleaner::CleanIndexedVertexArray(
+ normals, nSize,
+ NIndices, niSize,
+ &cleanNormals, &cnSize,
+ &cleanNIndices);
+
+ // format materials array
+ FrsMaterial** marray = new FrsMaterial*[meshFrsMaterials.size()];
+ unsigned mindex=0;
+ for(vector<FrsMaterial>::iterator m=meshFrsMaterials.begin(), mend=meshFrsMaterials.end();
+ m!=mend;
+ ++m){
+ marray[mindex] = new FrsMaterial(*m);
+ ++mindex;
+ }
+ // deallocates memory:
+ delete [] vertices;
+ delete [] normals;
+ delete [] VIndices;
+ delete [] NIndices;
+
+ // Create the IndexedFaceSet with the retrieved attributes
+ rep = new IndexedFaceSet(cleanVertices, cvSize,
+ cleanNormals, cnSize,
+ marray, meshFrsMaterials.size(),
+ 0, 0,
+ numFaces, numVertexPerFaces, faceStyle,
+ cleanVIndices, viSize,
+ cleanNIndices, niSize,
+ MIndices, viSize,
+ 0,0,
+ 0);
+ // sets the id of the rep
+ rep->setId(Id(id, 0));
+
+ const BBox<Vec3r> bbox = BBox<Vec3r>(Vec3r(minBBox[0], minBBox[1], minBBox[2]),
+ Vec3r(maxBBox[0], maxBBox[1], maxBBox[2]));
+ rep->setBBox(bbox);
+ shape->AddRep(rep);
+
+ Matrix44r M = Matrix44r::identity();
+ currentMesh->setMatrix(M);
+ currentMesh->Translate(0,0,0);
+
+ currentMesh->AddChild(shape);
+ _Scene->AddChild(currentMesh);
+
+}
diff --git a/source/blender/freestyle/intern/scene_graph/BlenderFileLoader.h b/source/blender/freestyle/intern/scene_graph/BlenderFileLoader.h
new file mode 100644
index 00000000000..2b038e08b21
--- /dev/null
+++ b/source/blender/freestyle/intern/scene_graph/BlenderFileLoader.h
@@ -0,0 +1,62 @@
+#ifndef BLENDER_FILE_LOADER_H
+# define BLENDER_FILE_LOADER_H
+
+# include <string.h>
+# include <float.h>
+
+# include "../system/FreestyleConfig.h"
+# include "NodeGroup.h"
+# include "NodeTransform.h"
+# include "NodeShape.h"
+# include "IndexedFaceSet.h"
+# include "../geometry/BBox.h"
+# include "../geometry/Geom.h"
+# include "../geometry/GeomCleaner.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+ #include "DNA_material_types.h"
+ #include "DNA_scene_types.h"
+ #include "render_types.h"
+ #include "renderdatabase.h"
+
+ #include "BKE_mesh.h"
+ #include "BKE_scene.h"
+ #include "MTC_matrixops.h"
+
+#ifdef __cplusplus
+}
+#endif
+
+
+class NodeGroup;
+
+class LIB_SCENE_GRAPH_EXPORT BlenderFileLoader
+{
+public:
+ /*! Builds a MaxFileLoader */
+ BlenderFileLoader(Render *re);
+ virtual ~BlenderFileLoader();
+
+ /*! Loads the 3D scene and returns a pointer to the scene root node */
+ NodeGroup * Load();
+
+ /*! Gets the number of read faces */
+ inline unsigned int numFacesRead() {return _numFacesRead;}
+
+ /*! Gets the smallest edge size read */
+ inline real minEdgeSize() {return _minEdgeSize;}
+
+protected:
+ void insertShapeNode(ObjectRen *obr, int id);
+
+protected:
+ Render* _re;
+ NodeGroup* _Scene;
+ unsigned _numFacesRead;
+ real _minEdgeSize;
+};
+
+#endif // BLENDER_FILE_LOADER_H
diff --git a/source/blender/freestyle/intern/scene_graph/Material.h b/source/blender/freestyle/intern/scene_graph/FrsMaterial.h
index 64ae526ccb0..1cbadab2bd3 100755
--- a/source/blender/freestyle/intern/scene_graph/Material.h
+++ b/source/blender/freestyle/intern/scene_graph/FrsMaterial.h
@@ -1,5 +1,5 @@
//
-// Filename : Material.h
+// Filename : FrsMaterial.h
// Author(s) : Stephane Grabli
// Purpose : Class used to handle materials.
// Date of creation : 10/10/2002
@@ -27,17 +27,17 @@
//
///////////////////////////////////////////////////////////////////////////////
-#ifndef MATERIAL_H
-# define MATERIAL_H
+#ifndef FRS_MATERIAL_H
+# define FRS_MATERIAL_H
# include "../system/FreestyleConfig.h"
/*! Class defining a material */
-class Material
+class FrsMaterial
{
public:
/*! Default constructor */
- inline Material();
+ inline FrsMaterial();
/*! Builds a Material from its diffuse, ambiant, specular, emissive
* colors and a shininess coefficient.
* \param iDiffuse
@@ -51,16 +51,16 @@ public:
* \param iShininess
* The shininess coefficient.
*/
- inline Material(const float *iDiffuse,
+ inline FrsMaterial(const float *iDiffuse,
const float *iAmbiant,
const float *iSpecular,
const float *iEmission,
const float iShininess);
/*! Copy constructor */
- inline Material(const Material& m);
+ inline FrsMaterial(const FrsMaterial& m);
/*! Destructor */
- virtual ~Material() {}
+ virtual ~FrsMaterial() {}
/*! Returns the diffuse color as a 4 float array */
@@ -163,9 +163,9 @@ public:
inline void setShininess(const float s);
/* operators */
- inline Material& operator=(const Material& m);
- inline bool operator!=(const Material& m) const;
- inline bool operator==(const Material& m) const;
+ inline FrsMaterial& operator=(const FrsMaterial& m);
+ inline bool operator!=(const FrsMaterial& m) const;
+ inline bool operator==(const FrsMaterial& m) const;
private:
@@ -178,7 +178,7 @@ private:
};
-Material::Material()
+FrsMaterial::FrsMaterial()
{
Ambient[0] = Ambient[1] = Ambient[2] = 0.2f;
Ambient[3] = 1.f;
@@ -195,7 +195,7 @@ Material::Material()
Shininess = 0.f;
}
-Material::Material(const float *iDiffuse,
+FrsMaterial::FrsMaterial(const float *iDiffuse,
const float *iAmbiant,
const float *iSpecular,
const float *iEmission,
@@ -212,7 +212,7 @@ Material::Material(const float *iDiffuse,
Shininess = iShininess;
}
-Material::Material(const Material& m)
+FrsMaterial::FrsMaterial(const FrsMaterial& m)
{
for(int i=0; i<4; i++)
{
@@ -225,7 +225,7 @@ Material::Material(const Material& m)
Shininess = m.shininess();
}
-void Material::setDiffuse(const float r, const float g, const float b, const float a)
+void FrsMaterial::setDiffuse(const float r, const float g, const float b, const float a)
{
Diffuse[0] = r;
Diffuse[1] = g;
@@ -233,7 +233,7 @@ void Material::setDiffuse(const float r, const float g, const float b, const flo
Diffuse[3] = a;
}
-void Material::setSpecular(const float r, const float g, const float b, const float a)
+void FrsMaterial::setSpecular(const float r, const float g, const float b, const float a)
{
Specular[0] = r;
Specular[1] = g;
@@ -241,7 +241,7 @@ void Material::setSpecular(const float r, const float g, const float b, const fl
Specular[3] = a;
}
-void Material::setAmbient(const float r, const float g, const float b, const float a)
+void FrsMaterial::setAmbient(const float r, const float g, const float b, const float a)
{
Ambient[0] = r;
Ambient[1] = g;
@@ -249,7 +249,7 @@ void Material::setAmbient(const float r, const float g, const float b, const flo
Ambient[3] = a;
}
-void Material::setEmission(const float r, const float g, const float b, const float a)
+void FrsMaterial::setEmission(const float r, const float g, const float b, const float a)
{
Emission[0] = r;
Emission[1] = g;
@@ -257,12 +257,12 @@ void Material::setEmission(const float r, const float g, const float b, const fl
Emission[3] = a;
}
-void Material::setShininess(const float s)
+void FrsMaterial::setShininess(const float s)
{
Shininess = s;
}
-Material& Material::operator=(const Material& m)
+FrsMaterial& FrsMaterial::operator=(const FrsMaterial& m)
{
for(int i=0; i<4; i++)
{
@@ -277,7 +277,7 @@ Material& Material::operator=(const Material& m)
return *this;
}
-bool Material::operator!=(const Material& m) const
+bool FrsMaterial::operator!=(const FrsMaterial& m) const
{
if(Shininess != m.shininess())
return true;
@@ -296,9 +296,9 @@ bool Material::operator!=(const Material& m) const
return false;
}
-bool Material::operator==(const Material& m) const
+bool FrsMaterial::operator==(const FrsMaterial& m) const
{
return (!((*this)!=m));
}
-#endif // MATERIAL_H
+#endif // FRS_MATERIAL_H
diff --git a/source/blender/freestyle/intern/scene_graph/IndexedFaceSet.cpp b/source/blender/freestyle/intern/scene_graph/IndexedFaceSet.cpp
index 2604484ecd7..98872c6c8ea 100755
--- a/source/blender/freestyle/intern/scene_graph/IndexedFaceSet.cpp
+++ b/source/blender/freestyle/intern/scene_graph/IndexedFaceSet.cpp
@@ -26,7 +26,7 @@ IndexedFaceSet::IndexedFaceSet()
{
_Vertices = NULL;
_Normals = NULL;
- _Materials = 0;
+ _FrsMaterials = 0;
_TexCoords = 0;
_VSize = 0;
_NSize = 0;
@@ -48,7 +48,7 @@ IndexedFaceSet::IndexedFaceSet()
IndexedFaceSet::IndexedFaceSet( real *iVertices, unsigned iVSize,
real *iNormals, unsigned iNSize,
- Material **iMaterials, unsigned iMSize,
+ FrsMaterial **iMaterials, unsigned iMSize,
real *iTexCoords, unsigned iTSize,
unsigned iNumFaces, unsigned *iNumVertexPerFace, TRIANGLES_STYLE *iFaceStyle,
unsigned *iVIndices, unsigned iVISize,
@@ -69,11 +69,11 @@ IndexedFaceSet::IndexedFaceSet( real *iVertices, unsigned iVSize,
memcpy(_Normals, iNormals, iNSize*sizeof(real));
_MSize = iMSize;
- _Materials = 0;
+ _FrsMaterials = 0;
if(iMaterials){
- _Materials = new Material*[_MSize];
+ _FrsMaterials = new FrsMaterial*[_MSize];
for(unsigned i=0; i<_MSize; ++i)
- _Materials[i] = new Material(*(iMaterials[i]));
+ _FrsMaterials[i] = new FrsMaterial(*(iMaterials[i]));
}
_TSize = iTSize;
_TexCoords = 0;
@@ -119,9 +119,9 @@ IndexedFaceSet::IndexedFaceSet( real *iVertices, unsigned iVSize,
_Normals = iNormals;
_MSize = iMSize;
- _Materials = 0;
+ _FrsMaterials = 0;
if(iMaterials)
- _Materials = iMaterials;
+ _FrsMaterials = iMaterials;
_TSize = iTSize;
_TexCoords = iTexCoords;
@@ -161,12 +161,12 @@ IndexedFaceSet::IndexedFaceSet( const IndexedFaceSet& iBrother)
_MSize = iBrother.msize();
if(_MSize){
- _Materials = new Material*[_MSize];
+ _FrsMaterials = new FrsMaterial*[_MSize];
for(unsigned i=0; i<_MSize; ++i){
- _Materials[i] = new Material(*(iBrother._Materials[i]));
+ _FrsMaterials[i] = new FrsMaterial(*(iBrother._FrsMaterials[i]));
}
}else{
- _Materials = 0;
+ _FrsMaterials = 0;
}
_TSize = iBrother.tsize();
@@ -223,12 +223,12 @@ IndexedFaceSet::~IndexedFaceSet()
_Normals = NULL;
}
- if(NULL != _Materials)
+ if(NULL != _FrsMaterials)
{
for(unsigned i=0; i<_MSize; ++i)
- delete _Materials[i];
- delete [] _Materials;
- _Materials = NULL;
+ delete _FrsMaterials[i];
+ delete [] _FrsMaterials;
+ _FrsMaterials = NULL;
}
if(NULL != _TexCoords)
diff --git a/source/blender/freestyle/intern/scene_graph/IndexedFaceSet.h b/source/blender/freestyle/intern/scene_graph/IndexedFaceSet.h
index ce0afcd2fd6..41db4db4c42 100755
--- a/source/blender/freestyle/intern/scene_graph/IndexedFaceSet.h
+++ b/source/blender/freestyle/intern/scene_graph/IndexedFaceSet.h
@@ -106,7 +106,7 @@ public:
*/
IndexedFaceSet( real *iVertices, unsigned iVSize,
real *iNormals, unsigned iNSize,
- Material **iMaterials, unsigned iMSize,
+ FrsMaterial **iMaterials, unsigned iMSize,
real *iTexCoords, unsigned iTSize,
unsigned iNumFaces, unsigned *iNumVertexPerFace, TRIANGLES_STYLE *iFaceStyle,
unsigned *iVIndices, unsigned iVISize,
@@ -122,7 +122,7 @@ public:
void swap(IndexedFaceSet& ioOther){
std::swap(_Vertices, ioOther._Vertices);
std::swap(_Normals, ioOther._Normals);
- std::swap(_Materials, ioOther._Materials);
+ std::swap(_FrsMaterials, ioOther._FrsMaterials);
std::swap(_TexCoords, ioOther._TexCoords);
std::swap(_VSize, ioOther._VSize);
@@ -171,7 +171,7 @@ public:
/*! Accessors */
virtual const real * vertices() const {return _Vertices;}
virtual const real * normals() const {return _Normals;}
- virtual const Material*const* materials() const {return _Materials;}
+ virtual const FrsMaterial*const* frs_materials() const {return _FrsMaterials;}
virtual const real* texCoords() const {return _TexCoords;}
virtual const unsigned vsize() const {return _VSize;}
virtual const unsigned nsize() const {return _NSize;}
@@ -193,7 +193,7 @@ public:
protected:
real *_Vertices;
real *_Normals;
- Material** _Materials;
+ FrsMaterial** _FrsMaterials;
real *_TexCoords;
unsigned _VSize;
diff --git a/source/blender/freestyle/intern/scene_graph/MaxFileLoader.cpp b/source/blender/freestyle/intern/scene_graph/MaxFileLoader.cpp
index a6d3b8f8721..b32fb993c94 100755
--- a/source/blender/freestyle/intern/scene_graph/MaxFileLoader.cpp
+++ b/source/blender/freestyle/intern/scene_graph/MaxFileLoader.cpp
@@ -174,7 +174,7 @@ void MaxFileLoader::RenderNode(Lib3dsNode *iNode)
unsigned nSize = vSize;
float *normals = new float[nSize];
unsigned *numVertexPerFaces = new unsigned[numFaces];
- vector<Material> meshMaterials;
+ vector<FrsMaterial> meshFrsMaterials;
IndexedFaceSet::TRIANGLES_STYLE *faceStyle = new IndexedFaceSet::TRIANGLES_STYLE[numFaces];
unsigned i;
@@ -199,7 +199,7 @@ void MaxFileLoader::RenderNode(Lib3dsNode *iNode)
unsigned currentIndex = 0;
unsigned currentMIndex = 0;
- Material tmpMat;
+ FrsMaterial tmpMat;
// we want to find the min and max coordinates as we build the rep.
// We initialize the min and max values whith the first vertex.
@@ -232,14 +232,14 @@ void MaxFileLoader::RenderNode(Lib3dsNode *iNode)
tmpMat.setShininess(s);
}
- if(meshMaterials.empty()){
- meshMaterials.push_back(tmpMat);
- shape->setMaterial(tmpMat);
+ if(meshFrsMaterials.empty()){
+ meshFrsMaterials.push_back(tmpMat);
+ shape->setFrsMaterial(tmpMat);
}else{
// find if the material is aleady in the list
unsigned i=0;
bool found = false;
- for(vector<Material>::iterator it=meshMaterials.begin(), itend=meshMaterials.end();
+ for(vector<FrsMaterial>::iterator it=meshFrsMaterials.begin(), itend=meshFrsMaterials.end();
it!=itend;
++it){
if(*it == tmpMat){
@@ -250,8 +250,8 @@ void MaxFileLoader::RenderNode(Lib3dsNode *iNode)
++i;
}
if(!found){
- meshMaterials.push_back(tmpMat);
- currentMIndex = meshMaterials.size()-1;
+ meshFrsMaterials.push_back(tmpMat);
+ currentMIndex = meshFrsMaterials.size()-1;
}
}
@@ -271,8 +271,8 @@ void MaxFileLoader::RenderNode(Lib3dsNode *iNode)
vert[i][j] = pv[j];
}
- for(j=0; j<3; j++)
- pn[j] = f->normal[j];
+ // for(j=0; j<3; j++)
+ // pn[j] = f->normal[j];
lib3ds_normal_transform(pn, M, normalL[3*p+i]); //fills the cells of the pv array
//lib3ds_vector_normalize(pn);
@@ -331,12 +331,12 @@ void MaxFileLoader::RenderNode(Lib3dsNode *iNode)
&cleanNIndices);
// format materials array
- Material** marray = new Material*[meshMaterials.size()];
+ FrsMaterial** marray = new FrsMaterial*[meshFrsMaterials.size()];
unsigned mindex=0;
- for(vector<Material>::iterator m=meshMaterials.begin(), mend=meshMaterials.end();
+ for(vector<FrsMaterial>::iterator m=meshFrsMaterials.begin(), mend=meshFrsMaterials.end();
m!=mend;
++m){
- marray[mindex] = new Material(*m);
+ marray[mindex] = new FrsMaterial(*m);
++mindex;
}
// deallocates memory:
@@ -348,7 +348,7 @@ void MaxFileLoader::RenderNode(Lib3dsNode *iNode)
// Create the IndexedFaceSet with the retrieved attributes
rep = new IndexedFaceSet(cleanVertices, cvSize,
cleanNormals, cnSize,
- marray, meshMaterials.size(),
+ marray, meshFrsMaterials.size(),
0, 0,
numFaces, numVertexPerFaces, faceStyle,
cleanVIndices, viSize,
diff --git a/source/blender/freestyle/intern/scene_graph/NodeShape.cpp b/source/blender/freestyle/intern/scene_graph/NodeShape.cpp
index 2012ef83b9f..9083c852d36 100755
--- a/source/blender/freestyle/intern/scene_graph/NodeShape.cpp
+++ b/source/blender/freestyle/intern/scene_graph/NodeShape.cpp
@@ -41,7 +41,7 @@ NodeShape::~NodeShape()
void NodeShape::accept(SceneVisitor& v) {
v.visitNodeShape(*this);
- v.visitMaterial(_Material);
+ v.visitFrsMaterial(_FrsMaterial);
v.visitNodeShapeBefore(*this);
vector<Rep *>::iterator rep;
diff --git a/source/blender/freestyle/intern/scene_graph/NodeShape.h b/source/blender/freestyle/intern/scene_graph/NodeShape.h
index 34b049bfeb5..9849d4661b8 100755
--- a/source/blender/freestyle/intern/scene_graph/NodeShape.h
+++ b/source/blender/freestyle/intern/scene_graph/NodeShape.h
@@ -37,7 +37,7 @@
# include "Rep.h"
# include "../geometry/BBox.h"
# include "../geometry/Geom.h"
-# include "Material.h"
+# include "FrsMaterial.h"
using namespace std;
using namespace Geometry;
@@ -71,11 +71,11 @@ public:
virtual void accept(SceneVisitor& v);
/*! Sets the shape material */
- inline void setMaterial(const Material& iMaterial) { _Material = iMaterial; }
+ inline void setFrsMaterial(const FrsMaterial& iMaterial) { _FrsMaterial = iMaterial; }
/*! accessors */
/*! returns the shape's material */
- inline Material& material() { return _Material; }
+ inline FrsMaterial& frs_material() { return _FrsMaterial; }
inline const vector<Rep*>& shapes() {return _Shapes;}
private:
@@ -83,7 +83,7 @@ private:
vector<Rep*> _Shapes;
/*! Shape Material */
- Material _Material;
+ FrsMaterial _FrsMaterial;
};
#endif // NODESHAPE_H
diff --git a/source/blender/freestyle/intern/scene_graph/OrientedLineRep.cpp b/source/blender/freestyle/intern/scene_graph/OrientedLineRep.cpp
index 2d0205308b9..94068983596 100755
--- a/source/blender/freestyle/intern/scene_graph/OrientedLineRep.cpp
+++ b/source/blender/freestyle/intern/scene_graph/OrientedLineRep.cpp
@@ -24,7 +24,7 @@
void OrientedLineRep::accept(SceneVisitor& v) {
Rep::accept(v);
- if(!material())
+ if(!frs_material())
v.visitOrientedLineRep(*this);
else
v.visitLineRep(*this);
diff --git a/source/blender/freestyle/intern/scene_graph/Rep.h b/source/blender/freestyle/intern/scene_graph/Rep.h
index ee5f2942abf..6b213b01ba7 100755
--- a/source/blender/freestyle/intern/scene_graph/Rep.h
+++ b/source/blender/freestyle/intern/scene_graph/Rep.h
@@ -36,7 +36,7 @@
# include "../geometry/BBox.h"
# include "../geometry/Geom.h"
# include "../system/Precision.h"
-# include "Material.h"
+# include "FrsMaterial.h"
# include "../system/Id.h"
using namespace Geometry;
@@ -45,33 +45,33 @@ class LIB_SCENE_GRAPH_EXPORT Rep : public BaseObject
{
public:
- inline Rep() : BaseObject() {_Id = 0; _Material=0;}
+ inline Rep() : BaseObject() {_Id = 0; _FrsMaterial=0;}
inline Rep(const Rep& iBrother)
: BaseObject()
{
_Id = iBrother._Id;
- if(0 == iBrother._Material)
- _Material = 0;
+ if(0 == iBrother._FrsMaterial)
+ _FrsMaterial = 0;
else
- _Material = new Material(*(iBrother._Material));
+ _FrsMaterial = new FrsMaterial(*(iBrother._FrsMaterial));
_BBox = iBrother.bbox();
}
inline void swap(Rep& ioOther){
std::swap(_BBox,ioOther._BBox);
std::swap(_Id, ioOther._Id);
- std::swap(_Material,ioOther._Material);
+ std::swap(_FrsMaterial,ioOther._FrsMaterial);
}
Rep& operator=(const Rep& iBrother){
if(&iBrother != this){
_Id = iBrother._Id;
- if(0 == iBrother._Material)
- _Material = 0;
+ if(0 == iBrother._FrsMaterial)
+ _FrsMaterial = 0;
else{
- if(_Material == 0){
- _Material = new Material(*iBrother._Material);
+ if(_FrsMaterial == 0){
+ _FrsMaterial = new FrsMaterial(*iBrother._FrsMaterial);
}else{
- (*_Material)=(*(iBrother._Material));
+ (*_FrsMaterial)=(*(iBrother._FrsMaterial));
}
_BBox = iBrother.bbox();
}
@@ -80,10 +80,10 @@ public:
}
virtual ~Rep()
{
- if(0 != _Material)
+ if(0 != _FrsMaterial)
{
- delete _Material;
- _Material = 0;
+ delete _FrsMaterial;
+ _FrsMaterial = 0;
}
}
@@ -92,8 +92,8 @@ public:
* inherited classes
*/
virtual void accept(SceneVisitor& v) {
- if(_Material)
- v.visitMaterial(*_Material);
+ if(_FrsMaterial)
+ v.visitFrsMaterial(*_FrsMaterial);
v.visitRep(*this);
}
@@ -108,20 +108,20 @@ public:
/*! Returns the rep bounding box */
virtual const BBox<Vec3r>& bbox() const {return _BBox;}
inline Id getId() const {return _Id;}
- inline const Material * material() const {return _Material;}
+ inline const FrsMaterial * frs_material() const {return _FrsMaterial;}
/*! Sets the Rep bounding box */
virtual void setBBox(const BBox<Vec3r>& iBox) {_BBox = iBox;}
inline void setId(const Id& id) {_Id = id;}
- inline void setMaterial(const Material& iMaterial)
+ inline void setFrsMaterial(const FrsMaterial& iMaterial)
{
- _Material = new Material(iMaterial);
+ _FrsMaterial = new FrsMaterial(iMaterial);
}
private:
BBox<Vec3r> _BBox;
Id _Id;
- Material *_Material;
+ FrsMaterial *_FrsMaterial;
};
#endif // REP_H
diff --git a/source/blender/freestyle/intern/scene_graph/SceneVisitor.h b/source/blender/freestyle/intern/scene_graph/SceneVisitor.h
index c57bd2e0f6e..5f67b4b44aa 100755
--- a/source/blender/freestyle/intern/scene_graph/SceneVisitor.h
+++ b/source/blender/freestyle/intern/scene_graph/SceneVisitor.h
@@ -60,7 +60,7 @@ class TriangleRep;
class VertexRep;
class IndexedFaceSet;
class DrawingStyle;
-class Material;
+class FrsMaterial;
class LIB_SCENE_GRAPH_EXPORT SceneVisitor
{
@@ -92,7 +92,7 @@ public:
VISIT_COMPLETE_DEF(VertexRep)
VISIT_COMPLETE_DEF(IndexedFaceSet)
VISIT_COMPLETE_DEF(DrawingStyle)
- VISIT_COMPLETE_DEF(Material)
+ VISIT_COMPLETE_DEF(FrsMaterial)
};
#endif // SCENEVISITOR_H