diff options
Diffstat (limited to 'source/blender/freestyle/intern')
46 files changed, 827 insertions, 282 deletions
diff --git a/source/blender/freestyle/intern/app_blender/Controller.cpp b/source/blender/freestyle/intern/app_blender/Controller.cpp index ff6ca96e657..183695ec731 100755 --- a/source/blender/freestyle/intern/app_blender/Controller.cpp +++ b/source/blender/freestyle/intern/app_blender/Controller.cpp @@ -64,6 +64,8 @@ #include "../system/StringUtils.h" +#include "../scene_graph/BlenderFileLoader.h" + Controller::Controller() { @@ -168,6 +170,107 @@ void Controller::setView(AppGLWidget *iView) _Canvas->setViewer(_pView); } +int Controller::LoadMesh(Render *re) +{ + if (_pView) + _pView->setUpdateMode(false); + + BlenderFileLoader loader(re); + + _Chrono.start(); + + NodeGroup *blenderScene = loader.Load(); + + if (blenderScene == NULL) { + cout << "Cannot load scene" << endl; + return 1; + } + + cout << "Scene loaded\n" << endl; + + printf("Mesh cleaning : %lf\n", _Chrono.stop()); + _SceneNumFaces += loader.numFacesRead(); + + if(loader.minEdgeSize() < _minEdgeSize) + { + _minEdgeSize = loader.minEdgeSize(); + _EPSILON = _minEdgeSize*1e-6; + if(_EPSILON < DBL_MIN) + _EPSILON = 0.0; + } + + cout << "Epsilon computed : " << _EPSILON << endl; + + // DEBUG +// ScenePrettyPrinter spp; +// blenderScene->accept(spp); + + _RootNode->AddChild(blenderScene); + _RootNode->UpdateBBox(); // FIXME: Correct that by making a Renderer to compute the bbox + + _pView->setModel(_RootNode); + //_pView->FitBBox(); + + + _Chrono.start(); + + + WXEdgeBuilder wx_builder; + blenderScene->accept(wx_builder); + _winged_edge = wx_builder.getWingedEdge(); + + printf("WEdge building : %lf\n", _Chrono.stop()); + + _Chrono.start(); + + _Grid.clear(); + Vec3r size; + for(unsigned int i=0; i<3; i++) + { + size[i] = fabs(_RootNode->bbox().getMax()[i] - _RootNode->bbox().getMin()[i]); + size[i] += size[i]/10.0; // let make the grid 1/10 bigger to avoid numerical errors while computing triangles/cells intersections + if(size[i]==0){ + cout << "Warning: the bbox size is 0 in dimension "<<i<<endl; + } + } + _Grid.configure(Vec3r(_RootNode->bbox().getMin() - size / 20.0), size, + _SceneNumFaces); + + // Fill in the grid: + WFillGrid fillGridRenderer(&_Grid, _winged_edge); + fillGridRenderer.fillGrid(); + + printf("Grid building : %lf\n", _Chrono.stop()); + + // DEBUG +// _Grid.displayDebug(); + + _pView->setDebug(_DebugNode); + + //delete stuff + // if(0 != ws_builder) + // { + // delete ws_builder; + // ws_builder = 0; + // } + _pView->updateGL(); + + + //soc QFileInfo qfi(iFileName); + //soc string basename((const char*)qfi.fileName().toAscii().data()); + // char cleaned[FILE_MAX]; + // BLI_strncpy(cleaned, iFileName, FILE_MAX); + // BLI_cleanup_file(NULL, cleaned); + // string basename = StringUtils::toAscii( string(cleaned) ); + + _ListOfModels.push_back("Blender_models"); + + cout << "Triangles nb : " << _SceneNumFaces << endl; + _bboxDiag = (_RootNode->bbox().getMax()-_RootNode->bbox().getMin()).norm(); + cout << "Bounding Box : " << _bboxDiag << endl; + return 0; +} + int Controller::Load3DSFile(const char *iFileName) { @@ -649,6 +752,8 @@ void Controller::ComputeViewMap() _ViewMap = vmBuilder.BuildViewMap(*_winged_edge, _VisibilityAlgo, _EPSILON); _ViewMap->setScene3dBBox(_RootNode->bbox()); + printf("ViewMap edge count : %i\n", _ViewMap->viewedges_size() ); + //Tesselate the 3D edges: _SilhouetteNode = sTesselator3d.Tesselate(_ViewMap); _SilhouetteNode->addRef(); @@ -953,9 +1058,9 @@ NodeGroup * Controller::BuildRep(vector<ViewEdge*>::iterator vedges_begin, vector<ViewEdge*>::iterator vedges_end) { ViewMapTesselator2D tesselator2D; - Material mat; + FrsMaterial mat; mat.setDiffuse(1,1,0.3,1); - tesselator2D.setMaterial(mat); + tesselator2D.setFrsMaterial(mat); return (tesselator2D.Tesselate(vedges_begin, vedges_end)); } diff --git a/source/blender/freestyle/intern/app_blender/Controller.h b/source/blender/freestyle/intern/app_blender/Controller.h index 032e21a1ce5..7b982b7e9a2 100755 --- a/source/blender/freestyle/intern/app_blender/Controller.h +++ b/source/blender/freestyle/intern/app_blender/Controller.h @@ -51,6 +51,16 @@ class AppCanvas; class InteractiveShader; class Shader; +#ifdef __cplusplus +extern "C" { +#endif + + #include "render_types.h" + +#ifdef __cplusplus +} +#endif + class Controller { public: @@ -62,6 +72,7 @@ public: //soc void init_options(); + int LoadMesh( Render *re ); int Load3DSFile(const char *iFileName); void CloseFile(); void LoadViewMapFile(const char *iFileName, bool only_camera = false); diff --git a/source/blender/freestyle/intern/app_blender/api.cpp b/source/blender/freestyle/intern/app_blender/api.cpp index a6490324fbf..01c4cfb1460 100644 --- a/source/blender/freestyle/intern/app_blender/api.cpp +++ b/source/blender/freestyle/intern/app_blender/api.cpp @@ -14,6 +14,7 @@ extern "C" { #include "renderpipeline.h" #include "BLI_blenlib.h" +#include "BIF_renderwin.h" #include "BPY_extern.h" #ifdef __cplusplus @@ -103,6 +104,10 @@ extern "C" { } } + void FRS_load_mesh( Render *re ){ + controller->LoadMesh(re); + } + void FRS_prepare(Render* re) { FRS_initialize(); @@ -110,15 +115,12 @@ extern "C" { FRS_init_camera(re); FRS_scene_3ds_export(re); + //FRS_load_mesh(re); } void FRS_render(Render* re, int render_in_layer) { - if(render_in_layer) { - view->workingBuffer = GL_COLOR_ATTACHMENT1_EXT; - } else { - view->workingBuffer = GL_BACK; - } + view->workingBuffer = GL_BACK; // add style module cout << "Module: " << style_module << endl; @@ -185,8 +187,13 @@ extern "C" { } } else { - FRS_render(re, render_in_layer); + // used to reobtain ogl context after RE_Database_FromScene call + re->display_clear(re->result); + + // render strokes + FRS_render(re, render_in_layer); + // display result RenderResult rres; RE_GetResultImage(re, &rres); view->readPixels(0, 0, re->winx, re->winy, AppGLWidget::RGBA, rres.rectf ); diff --git a/source/blender/freestyle/intern/python/BPy_Convert.cpp b/source/blender/freestyle/intern/python/BPy_Convert.cpp index 5f4b7098f29..38eeced6958 100644 --- a/source/blender/freestyle/intern/python/BPy_Convert.cpp +++ b/source/blender/freestyle/intern/python/BPy_Convert.cpp @@ -190,9 +190,9 @@ PyObject * BPy_ViewShape_from_ViewShape( ViewShape& vs ) { return py_vs; } -PyObject * BPy_FrsMaterial_from_Material( Material& m ){ +PyObject * BPy_FrsMaterial_from_FrsMaterial( FrsMaterial& m ){ PyObject *py_m = FrsMaterial_Type.tp_new( &FrsMaterial_Type, 0, 0 ); - ((BPy_FrsMaterial*) py_m)->m = new Material( m ); + ((BPy_FrsMaterial*) py_m)->m = new FrsMaterial( m ); return py_m; } diff --git a/source/blender/freestyle/intern/python/BPy_Convert.h b/source/blender/freestyle/intern/python/BPy_Convert.h index 10efb2e5246..4ddfbe38d54 100644 --- a/source/blender/freestyle/intern/python/BPy_Convert.h +++ b/source/blender/freestyle/intern/python/BPy_Convert.h @@ -20,8 +20,8 @@ using namespace Geometry; // Interface1D #include "../view_map/Interface1D.h" -// Material -#include "../scene_graph/Material.h" +// FrsMaterial +#include "../scene_graph/FrsMaterial.h" // Nature::VertexNature, Nature::EdgeNature #include "../winged_edge/Nature.h" @@ -78,7 +78,7 @@ PyObject * BPy_Id_from_Id( Id& id ); PyObject * BPy_Interface0D_from_Interface0D( Interface0D& if0D ); PyObject * BPy_Interface1D_from_Interface1D( Interface1D& if1D ); PyObject * BPy_IntegrationType_from_IntegrationType( int i ); -PyObject * BPy_FrsMaterial_from_Material( Material& m ); +PyObject * BPy_FrsMaterial_from_FrsMaterial( FrsMaterial& m ); PyObject * BPy_Nature_from_Nature( unsigned short n ); PyObject * BPy_MediumType_from_MediumType( int n ); PyObject * BPy_SShape_from_SShape( SShape& ss ); diff --git a/source/blender/freestyle/intern/python/BPy_FrsMaterial.cpp b/source/blender/freestyle/intern/python/BPy_FrsMaterial.cpp index 052583e4621..6f7d4ba5015 100644 --- a/source/blender/freestyle/intern/python/BPy_FrsMaterial.cpp +++ b/source/blender/freestyle/intern/python/BPy_FrsMaterial.cpp @@ -180,17 +180,17 @@ int FrsMaterial___init__(BPy_FrsMaterial *self, PyObject *args, PyObject *kwds) return -1; if( !obj1 ){ - self->m = new Material(); + self->m = new FrsMaterial(); } else if( BPy_FrsMaterial_Check(obj1) ) { if( ((BPy_FrsMaterial *) obj1)->m ) - self->m = new Material(*( ((BPy_FrsMaterial *) obj1)->m )); + self->m = new FrsMaterial(*( ((BPy_FrsMaterial *) obj1)->m )); else return -1; } else if( PyFloat_Check(obj1) ) { f1 = PyFloat_AsDouble(obj1); - self->m = new Material(&f1, &f2, &f3, &f4, f5); + self->m = new FrsMaterial(&f1, &f2, &f3, &f4, f5); } else { return -1; diff --git a/source/blender/freestyle/intern/python/BPy_FrsMaterial.h b/source/blender/freestyle/intern/python/BPy_FrsMaterial.h index b25ddfc77bc..95264180f2f 100644 --- a/source/blender/freestyle/intern/python/BPy_FrsMaterial.h +++ b/source/blender/freestyle/intern/python/BPy_FrsMaterial.h @@ -1,7 +1,7 @@ #ifndef FREESTYLE_PYTHON_FRSMATERIAL_H #define FREESTYLE_PYTHON_FRSMATERIAL_H -#include "../scene_graph/Material.h" +#include "../scene_graph/FrsMaterial.h" #ifdef __cplusplus extern "C" { @@ -18,7 +18,7 @@ extern PyTypeObject FrsMaterial_Type; /*---------------------------Python BPy_FrsMaterial structure definition----------*/ typedef struct { PyObject_HEAD - Material *m; + FrsMaterial *m; } BPy_FrsMaterial; /*---------------------------Python BPy_FrsMaterial visible prototypes-----------*/ diff --git a/source/blender/freestyle/intern/python/Director.cpp b/source/blender/freestyle/intern/python/Director.cpp index 153ea79eabf..b56cd59e2f6 100644 --- a/source/blender/freestyle/intern/python/Director.cpp +++ b/source/blender/freestyle/intern/python/Director.cpp @@ -109,7 +109,7 @@ void Director_BPy_UnaryFunction0D___call__( void *uf0D, PyObject *obj, Interface ((UnaryFunction0D<Id> *) uf0D)->result = *( ((BPy_Id *) result)->id ); } else if ( BPy_UnaryFunction0DMaterial_Check(obj) ) { - ((UnaryFunction0D<Material> *) uf0D)->result = *( ((BPy_FrsMaterial *) result)->m ); + ((UnaryFunction0D<FrsMaterial> *) uf0D)->result = *( ((BPy_FrsMaterial *) result)->m ); } else if ( BPy_UnaryFunction0DUnsigned_Check(obj) ) { ((UnaryFunction0D<unsigned> *) uf0D)->result = PyInt_AsLong(result); diff --git a/source/blender/freestyle/intern/python/Interface1D/FEdge/BPy_FEdgeSharp.cpp b/source/blender/freestyle/intern/python/Interface1D/FEdge/BPy_FEdgeSharp.cpp index 22a4dbc378e..336331d92d5 100644 --- a/source/blender/freestyle/intern/python/Interface1D/FEdge/BPy_FEdgeSharp.cpp +++ b/source/blender/freestyle/intern/python/Interface1D/FEdge/BPy_FEdgeSharp.cpp @@ -166,21 +166,21 @@ PyObject * FEdgeSharp_normalB( BPy_FEdgeSharp *self ) { } PyObject * FEdgeSharp_aMaterialIndex( BPy_FEdgeSharp *self ) { - return PyInt_FromLong( self->fes->aMaterialIndex() ); + return PyInt_FromLong( self->fes->aFrsMaterialIndex() ); } PyObject * FEdgeSharp_bMaterialIndex( BPy_FEdgeSharp *self ) { - return PyInt_FromLong( self->fes->bMaterialIndex() ); + return PyInt_FromLong( self->fes->bFrsMaterialIndex() ); } PyObject * FEdgeSharp_aMaterial( BPy_FEdgeSharp *self ) { - Material m( self->fes->aMaterial() ); - return BPy_FrsMaterial_from_Material(m); + FrsMaterial m( self->fes->aFrsMaterial() ); + return BPy_FrsMaterial_from_FrsMaterial(m); } PyObject * FEdgeSharp_bMaterial( BPy_FEdgeSharp *self ) { - Material m( self->fes->aMaterial() ); - return BPy_FrsMaterial_from_Material(m); + FrsMaterial m( self->fes->aFrsMaterial() ); + return BPy_FrsMaterial_from_FrsMaterial(m); } PyObject * FEdgeSharp_setNormalA( BPy_FEdgeSharp *self, PyObject *args ) { @@ -225,7 +225,7 @@ PyObject * FEdgeSharp_setaMaterialIndex( BPy_FEdgeSharp *self, PyObject *args ) Py_RETURN_NONE; } - self->fes->setaMaterialIndex( i ); + self->fes->setaFrsMaterialIndex( i ); Py_RETURN_NONE; } @@ -238,7 +238,7 @@ PyObject * FEdgeSharp_setbMaterialIndex( BPy_FEdgeSharp *self, PyObject *args ) Py_RETURN_NONE; } - self->fes->setbMaterialIndex( i ); + self->fes->setbFrsMaterialIndex( i ); Py_RETURN_NONE; } diff --git a/source/blender/freestyle/intern/python/Interface1D/FEdge/BPy_FEdgeSmooth.cpp b/source/blender/freestyle/intern/python/Interface1D/FEdge/BPy_FEdgeSmooth.cpp index 6a11b6c1e98..0970e22a726 100644 --- a/source/blender/freestyle/intern/python/Interface1D/FEdge/BPy_FEdgeSmooth.cpp +++ b/source/blender/freestyle/intern/python/Interface1D/FEdge/BPy_FEdgeSmooth.cpp @@ -152,13 +152,13 @@ PyObject * FEdgeSmooth_normal( BPy_FEdgeSmooth *self ) { } PyObject * FEdgeSmooth_materialIndex( BPy_FEdgeSmooth *self ) { - return PyInt_FromLong( self->fes->materialIndex() ); + return PyInt_FromLong( self->fes->frs_materialIndex() ); } PyObject * FEdgeSmooth_material( BPy_FEdgeSmooth *self ) { - Material m( self->fes->material() ); - return BPy_FrsMaterial_from_Material(m); + FrsMaterial m( self->fes->frs_material() ); + return BPy_FrsMaterial_from_FrsMaterial(m); } PyObject * FEdgeSmooth_setNormal( BPy_FEdgeSmooth *self, PyObject *args ) { @@ -186,7 +186,7 @@ PyObject * FEdgeSmooth_setMaterialIndex( BPy_FEdgeSmooth *self, PyObject *args ) Py_RETURN_NONE; } - self->fes->setMaterialIndex( i ); + self->fes->setFrsMaterialIndex( i ); Py_RETURN_NONE; } diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DMaterial.cpp b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DMaterial.cpp index 2aef794617a..b719f6df71b 100644 --- a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DMaterial.cpp +++ b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DMaterial.cpp @@ -134,7 +134,7 @@ PyMODINIT_FUNC UnaryFunction0DMaterial_Init( PyObject *module ) { int UnaryFunction0DMaterial___init__(BPy_UnaryFunction0DMaterial* self) { - self->uf0D_material = new UnaryFunction0D<Material>(); + self->uf0D_material = new UnaryFunction0D<FrsMaterial>(); self->uf0D_material->py_uf0D = (PyObject *)self; return 0; } @@ -165,8 +165,8 @@ PyObject * UnaryFunction0DMaterial___call__( BPy_UnaryFunction0DMaterial *self, return NULL; } - Material m( self->uf0D_material->operator()(*( ((BPy_Interface0DIterator *) obj)->if0D_it )) ); - return BPy_FrsMaterial_from_Material( m ); + FrsMaterial m( self->uf0D_material->operator()(*( ((BPy_Interface0DIterator *) obj)->if0D_it )) ); + return BPy_FrsMaterial_from_FrsMaterial( m ); } diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DMaterial.h b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DMaterial.h index 5e932213128..ec4b3e1214d 100644 --- a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DMaterial.h +++ b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DMaterial.h @@ -3,7 +3,7 @@ #include "../BPy_UnaryFunction0D.h" -#include "../../scene_graph/Material.h" +#include "../../scene_graph/FrsMaterial.h" #ifdef __cplusplus extern "C" { @@ -20,7 +20,7 @@ extern PyTypeObject UnaryFunction0DMaterial_Type; /*---------------------------Python BPy_UnaryFunction0DMaterial structure definition----------*/ typedef struct { BPy_UnaryFunction0D py_uf0D; - UnaryFunction0D<Material> *uf0D_material; + UnaryFunction0D<FrsMaterial> *uf0D_material; } BPy_UnaryFunction0DMaterial; /*---------------------------Python BPy_UnaryFunction0DMaterial visible prototypes-----------*/ diff --git a/source/blender/freestyle/intern/rendering/GLDebugRenderer.cpp b/source/blender/freestyle/intern/rendering/GLDebugRenderer.cpp index 716db397e94..ed0cecbcfc8 100755 --- a/source/blender/freestyle/intern/rendering/GLDebugRenderer.cpp +++ b/source/blender/freestyle/intern/rendering/GLDebugRenderer.cpp @@ -40,7 +40,7 @@ void GLDebugRenderer::visitIndexedFaceSet(IndexedFaceSet& iFaceSet) const real * vertices = iFaceSet.vertices(); const real * normals = iFaceSet.normals(); - const Material *const* materials = (const Material**)iFaceSet.materials(); + const FrsMaterial *const* frs_materials = (const FrsMaterial**)iFaceSet.frs_materials(); const unsigned *vindices = iFaceSet.vindices(); const unsigned *nindices = iFaceSet.nindices(); const unsigned *mindices = iFaceSet.mindices(); @@ -57,13 +57,13 @@ void GLDebugRenderer::visitIndexedFaceSet(IndexedFaceSet& iFaceSet) switch(faceStyle[fIndex]) { case IndexedFaceSet::TRIANGLE_STRIP: - RenderTriangleStrip(vertices, normals, materials, pvi, pni, pmi, numVertexPerFace[fIndex]); + RenderTriangleStrip(vertices, normals, frs_materials, pvi, pni, pmi, numVertexPerFace[fIndex]); break; case IndexedFaceSet::TRIANGLE_FAN: - RenderTriangleFan(vertices, normals, materials, pvi, pni, pmi, numVertexPerFace[fIndex]); + RenderTriangleFan(vertices, normals, frs_materials, pvi, pni, pmi, numVertexPerFace[fIndex]); break; case IndexedFaceSet::TRIANGLES: - RenderTriangles(vertices, normals, materials, pvi, pni, pmi, numVertexPerFace[fIndex]); + RenderTriangles(vertices, normals, frs_materials, pvi, pni, pmi, numVertexPerFace[fIndex]); break; } pvi += numVertexPerFace[fIndex]; @@ -131,7 +131,7 @@ void GLDebugRenderer::renderBitmapString(real x, void GLDebugRenderer::RenderTriangleStrip(const real *iVertices, const real *iNormals, - const Material *const* iMaterials, + const FrsMaterial *const* iMaterials, const unsigned* iVIndices, const unsigned* iNIndices, const unsigned* iMIndices, @@ -153,7 +153,7 @@ void GLDebugRenderer::RenderTriangleStrip(const real *iVertices, void GLDebugRenderer::RenderTriangleFan(const real *iVertices, const real *iNormals, - const Material *const* iMaterials, + const FrsMaterial *const* iMaterials, const unsigned* iVIndices, const unsigned* iNIndices, const unsigned* iMIndices, @@ -175,7 +175,7 @@ void GLDebugRenderer::RenderTriangleFan(const real *iVertices, void GLDebugRenderer::RenderTriangles(const real *iVertices, const real *iNormals, - const Material *const* iMaterials, + const FrsMaterial *const* iMaterials, const unsigned* iVIndices, const unsigned* iNIndices, const unsigned* iMIndices, diff --git a/source/blender/freestyle/intern/rendering/GLDebugRenderer.h b/source/blender/freestyle/intern/rendering/GLDebugRenderer.h index e0f97249645..9111d5067bc 100755 --- a/source/blender/freestyle/intern/rendering/GLDebugRenderer.h +++ b/source/blender/freestyle/intern/rendering/GLDebugRenderer.h @@ -109,7 +109,7 @@ protected: */ virtual void RenderTriangleStrip(const real *iVertices, const real *iNormals, - const Material *const* iMaterials, + const FrsMaterial *const* iMaterials, const unsigned* iVIndices, const unsigned* iNIndices, const unsigned* iMIndices, @@ -133,7 +133,7 @@ protected: */ virtual void RenderTriangleFan(const real *iVertices, const real *iNormals, - const Material *const*iMaterials, + const FrsMaterial *const*iMaterials, const unsigned* iVIndices, const unsigned* iNIndices, const unsigned* iMIndices, @@ -157,7 +157,7 @@ protected: */ virtual void RenderTriangles(const real *iVertices, const real *iNormals, - const Material *const* iMaterials, + const FrsMaterial *const* iMaterials, const unsigned* iVIndices, const unsigned* iNIndices, const unsigned* iMIndices, diff --git a/source/blender/freestyle/intern/rendering/GLMonoColorRenderer.cpp b/source/blender/freestyle/intern/rendering/GLMonoColorRenderer.cpp index 792846fa020..ff893484fb5 100755 --- a/source/blender/freestyle/intern/rendering/GLMonoColorRenderer.cpp +++ b/source/blender/freestyle/intern/rendering/GLMonoColorRenderer.cpp @@ -21,7 +21,7 @@ #include "GLMonoColorRenderer.h" -void GLMonoColorRenderer::visitMaterial(Material&) { +void GLMonoColorRenderer::visitFrsMaterial(FrsMaterial&) { glColor3f(_r, _g, _b); } diff --git a/source/blender/freestyle/intern/rendering/GLMonoColorRenderer.h b/source/blender/freestyle/intern/rendering/GLMonoColorRenderer.h index d8e3cf536ec..9eb6c8134bb 100755 --- a/source/blender/freestyle/intern/rendering/GLMonoColorRenderer.h +++ b/source/blender/freestyle/intern/rendering/GLMonoColorRenderer.h @@ -45,7 +45,7 @@ class LIB_RENDERING_EXPORT GLMonoColorRenderer : public GLRenderer virtual ~GLMonoColorRenderer() {} VISIT_DECL(DrawingStyle) - VISIT_DECL(Material) + VISIT_DECL(FrsMaterial) void setColor(float r, float g, float b, float alpha = 1.f); diff --git a/source/blender/freestyle/intern/rendering/GLRenderer.cpp b/source/blender/freestyle/intern/rendering/GLRenderer.cpp index 45693413ace..678256f72bf 100755 --- a/source/blender/freestyle/intern/rendering/GLRenderer.cpp +++ b/source/blender/freestyle/intern/rendering/GLRenderer.cpp @@ -54,7 +54,7 @@ void GLRenderer::visitIndexedFaceSet(IndexedFaceSet& ifs) const real * vertices = ifs.vertices(); const real * normals = ifs.normals(); const real * texCoords = ifs.texCoords(); - const Material *const* materials = ifs.materials(); + const FrsMaterial *const* frs_materials = ifs.frs_materials(); const unsigned *vindices = ifs.vindices(); const unsigned *nindices = ifs.nindices(); const unsigned *mindices = ifs.mindices(); @@ -76,13 +76,13 @@ void GLRenderer::visitIndexedFaceSet(IndexedFaceSet& ifs) switch(faceStyle[fIndex]) { case IndexedFaceSet::TRIANGLE_STRIP: - RenderTriangleStrip(vertices, normals, materials, texCoords, pvi, pni, pmi, pti, numVertexPerFace[fIndex]); + RenderTriangleStrip(vertices, normals, frs_materials, texCoords, pvi, pni, pmi, pti, numVertexPerFace[fIndex]); break; case IndexedFaceSet::TRIANGLE_FAN: - RenderTriangleFan(vertices, normals, materials, texCoords, pvi, pni, pmi, pti, numVertexPerFace[fIndex]); + RenderTriangleFan(vertices, normals, frs_materials, texCoords, pvi, pni, pmi, pti, numVertexPerFace[fIndex]); break; case IndexedFaceSet::TRIANGLES: - RenderTriangles(vertices, normals, materials, texCoords, pvi, pni, pmi, pti, numVertexPerFace[fIndex]); + RenderTriangles(vertices, normals, frs_materials, texCoords, pvi, pni, pmi, pti, numVertexPerFace[fIndex]); break; } pvi += numVertexPerFace[fIndex]; @@ -153,7 +153,7 @@ void GLRenderer::visitNodeDrawingStyleAfter(NodeDrawingStyle&) { void GLRenderer::RenderTriangleStrip( const real *iVertices, const real *iNormals, - const Material *const* iMaterials, + const FrsMaterial *const* iMaterials, const real *iTexCoords, const unsigned* iVIndices, const unsigned* iNIndices, @@ -167,7 +167,7 @@ void GLRenderer::RenderTriangleStrip( const real *iVertices, { if(iMIndices){ if(iMIndices[i] != index){ - visitMaterial(*(iMaterials[iMIndices[i]])); + visitFrsMaterial(*(iMaterials[iMIndices[i]])); index = iMIndices[i]; } } @@ -190,7 +190,7 @@ void GLRenderer::RenderTriangleStrip( const real *iVertices, void GLRenderer::RenderTriangleFan( const real *iVertices, const real *iNormals, - const Material *const* iMaterials, + const FrsMaterial *const* iMaterials, const real *iTexCoords, const unsigned* iVIndices, const unsigned* iNIndices, @@ -204,7 +204,7 @@ void GLRenderer::RenderTriangleFan( const real *iVertices, { if(iMIndices){ if(iMIndices[i] != index){ - visitMaterial(*(iMaterials[iMIndices[i]])); + visitFrsMaterial(*(iMaterials[iMIndices[i]])); index = iMIndices[i]; } } @@ -226,7 +226,7 @@ void GLRenderer::RenderTriangleFan( const real *iVertices, void GLRenderer::RenderTriangles( const real *iVertices, const real *iNormals, - const Material *const* iMaterials, + const FrsMaterial *const* iMaterials, const real *iTexCoords, const unsigned* iVIndices, const unsigned* iNIndices, @@ -240,7 +240,7 @@ void GLRenderer::RenderTriangles( const real *iVertices, { if(iMIndices){ if(iMIndices[i] != index){ - visitMaterial(*(iMaterials[iMIndices[i]])); + visitFrsMaterial(*(iMaterials[iMIndices[i]])); index = iMIndices[i]; } } @@ -424,7 +424,7 @@ void GLRenderer::visitDrawingStyle(DrawingStyle& iDrawingStyle) glDisable(GL_LIGHTING); } -void GLRenderer::visitMaterial(Material& m) { +void GLRenderer::visitFrsMaterial(FrsMaterial& m) { const float* diff = m.diffuse(); const float* amb = m.ambient(); const float* spec = m.specular(); @@ -438,7 +438,7 @@ void GLRenderer::visitMaterial(Material& m) { glMaterialf(GL_FRONT, GL_SHININESS, m.shininess()); } -void GLRenderer::visitMaterial(const Material& m) { +void GLRenderer::visitFrsMaterial(const FrsMaterial& m) { const float* diff = m.diffuse(); const float* amb = m.ambient(); const float* spec = m.specular(); diff --git a/source/blender/freestyle/intern/rendering/GLRenderer.h b/source/blender/freestyle/intern/rendering/GLRenderer.h index ddbf082038b..3769aefb92b 100755 --- a/source/blender/freestyle/intern/rendering/GLRenderer.h +++ b/source/blender/freestyle/intern/rendering/GLRenderer.h @@ -67,9 +67,9 @@ class LIB_RENDERING_EXPORT GLRenderer : public SceneVisitor VISIT_DECL(VertexRep) VISIT_DECL(IndexedFaceSet) VISIT_DECL(DrawingStyle) - VISIT_DECL(Material) + VISIT_DECL(FrsMaterial) - virtual void visitMaterial(const Material&); + virtual void visitFrsMaterial(const FrsMaterial&); virtual void visitNodeTransformBefore(NodeTransform&); virtual void visitNodeTransformAfter(NodeTransform&); virtual void visitNodeDrawingStyleBefore(NodeDrawingStyle&); @@ -101,7 +101,7 @@ class LIB_RENDERING_EXPORT GLRenderer : public SceneVisitor */ virtual void RenderTriangleStrip(const real *iVertices, const real *iNormals, - const Material *const*iMaterials, + const FrsMaterial *const*iMaterials, const real *iTexCoords, const unsigned* iVIndices, const unsigned* iNIndices, @@ -133,7 +133,7 @@ class LIB_RENDERING_EXPORT GLRenderer : public SceneVisitor */ virtual void RenderTriangleFan(const real *iVertices, const real *iNormals, - const Material *const* iMaterials, + const FrsMaterial *const* iMaterials, const real *iTexCoords, const unsigned* iVIndices, const unsigned* iNIndices, @@ -165,7 +165,7 @@ class LIB_RENDERING_EXPORT GLRenderer : public SceneVisitor */ virtual void RenderTriangles(const real *iVertices, const real *iNormals, - const Material *const* iMaterials, + const FrsMaterial *const* iMaterials, const real *iTexCoords, const unsigned* iVIndices, const unsigned* iNIndices, diff --git a/source/blender/freestyle/intern/rendering/GLSelectRenderer.cpp b/source/blender/freestyle/intern/rendering/GLSelectRenderer.cpp index b4a2406c644..ca9199740f8 100755 --- a/source/blender/freestyle/intern/rendering/GLSelectRenderer.cpp +++ b/source/blender/freestyle/intern/rendering/GLSelectRenderer.cpp @@ -58,7 +58,7 @@ void GLSelectRenderer::visitNodeShape(NodeShape& sn) { _current_shape_active = false; } -void GLSelectRenderer::visitMaterial(Material& m) { +void GLSelectRenderer::visitFrsMaterial(FrsMaterial& m) { if (_gl_select_rendering) return; @@ -79,7 +79,7 @@ void GLSelectRenderer::visitMaterial(Material& m) { glMaterialf(GL_FRONT, GL_SHININESS, m.shininess()); } -void GLSelectRenderer::visitMaterial(const Material& m) { +void GLSelectRenderer::visitFrsMaterial(const FrsMaterial& m) { if (_gl_select_rendering) return; @@ -106,7 +106,7 @@ void GLSelectRenderer::visitIndexedFaceSet(IndexedFaceSet& ifs) const real * vertices = ifs.vertices(); const real * normals = ifs.normals(); - const Material *const* materials = ifs.materials(); + const FrsMaterial *const* frs_materials = ifs.frs_materials(); const real * texCoords= ifs.texCoords(); const unsigned *vindices = ifs.vindices(); const unsigned *nindices = ifs.nindices(); @@ -127,13 +127,13 @@ void GLSelectRenderer::visitIndexedFaceSet(IndexedFaceSet& ifs) switch(faceStyle[fIndex]) { case IndexedFaceSet::TRIANGLE_STRIP: - RenderTriangleStrip(vertices, normals, materials, texCoords, pvi, pni, pmi, pti, numVertexPerFace[fIndex]); + RenderTriangleStrip(vertices, normals, frs_materials, texCoords, pvi, pni, pmi, pti, numVertexPerFace[fIndex]); break; case IndexedFaceSet::TRIANGLE_FAN: - RenderTriangleFan(vertices, normals, materials, texCoords, pvi, pni, pmi, pti, numVertexPerFace[fIndex]); + RenderTriangleFan(vertices, normals, frs_materials, texCoords, pvi, pni, pmi, pti, numVertexPerFace[fIndex]); break; case IndexedFaceSet::TRIANGLES: - RenderTriangles(vertices, normals, materials, texCoords, pvi, pni, pmi, pti, numVertexPerFace[fIndex]); + RenderTriangles(vertices, normals, frs_materials, texCoords, pvi, pni, pmi, pti, numVertexPerFace[fIndex]); break; } pvi += numVertexPerFace[fIndex]; diff --git a/source/blender/freestyle/intern/rendering/GLSelectRenderer.h b/source/blender/freestyle/intern/rendering/GLSelectRenderer.h index bf8a334aebb..2ce8c3f62db 100755 --- a/source/blender/freestyle/intern/rendering/GLSelectRenderer.h +++ b/source/blender/freestyle/intern/rendering/GLSelectRenderer.h @@ -51,9 +51,9 @@ class LIB_RENDERING_EXPORT GLSelectRenderer : public GLRenderer VISIT_DECL(NodeShape) VISIT_DECL(IndexedFaceSet) - VISIT_DECL(Material) + VISIT_DECL(FrsMaterial) - virtual void visitMaterial(const Material&); + virtual void visitFrsMaterial(const FrsMaterial&); virtual void visitNodeShapeBefore(NodeShape&); virtual void visitNodeShapeAfter(NodeShape&); 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 diff --git a/source/blender/freestyle/intern/stroke/Curve.h b/source/blender/freestyle/intern/stroke/Curve.h index 7fbe7e701e9..ee27e92fa37 100755 --- a/source/blender/freestyle/intern/stroke/Curve.h +++ b/source/blender/freestyle/intern/stroke/Curve.h @@ -33,7 +33,7 @@ # include <deque> # include "../system/BaseIterator.h" # include "../geometry/Geom.h" -//# include "../scene_graph/Material.h" +//# include "../scene_graph/FrsMaterial.h" # include "../view_map/Silhouette.h" # include "../view_map/SilhouetteGeomEngine.h" # include "../view_map/Interface0D.h" @@ -234,7 +234,7 @@ public: inline const Vec3r& point2d() const {return _Point2d;} inline const Vec3r& point3d() const {return _Point3d;} Vec3r normal() const ; - //Material material() const ; + //FrsMaterial material() const ; // Id shape_id() const ; const SShape * shape() const ; // float shape_importance() const ; @@ -392,7 +392,7 @@ public: //Vec3r orientation3d(int iCombination = 0) const ; // real curvature2d(point_iterator it) const {return (*it)->curvature2d();} // real curvature2d(int iCombination = 0) const ; - //Material material() const ; + //FrsMaterial material() const ; //int qi() const ; // occluder_container::const_iterator occluders_begin() const ; // occluder_container::const_iterator occluders_end() const ; diff --git a/source/blender/freestyle/intern/stroke/StrokeTesselator.cpp b/source/blender/freestyle/intern/stroke/StrokeTesselator.cpp index 279655c22b7..465e5662774 100755 --- a/source/blender/freestyle/intern/stroke/StrokeTesselator.cpp +++ b/source/blender/freestyle/intern/stroke/StrokeTesselator.cpp @@ -48,8 +48,8 @@ LineRep* StrokeTesselator::Tesselate(Stroke *iStroke) } else { - if(_overloadMaterial) - line->setMaterial(_Material); + if(_overloadFrsMaterial) + line->setFrsMaterial(_FrsMaterial); line->setStyle(LineRep::LINE_STRIP); @@ -75,7 +75,7 @@ NodeGroup* StrokeTesselator::Tesselate(StrokeVertexIterator begin, StrokeVertexI NodeShape *tshape = new NodeShape; group->AddChild(tshape); //tshape->material().setDiffuse(0.f, 0.f, 0.f, 1.f); - tshape->setMaterial(_Material); + tshape->setFrsMaterial(_FrsMaterial); for(StrokeVertexIterator c=begin, cend=end; c!=cend; diff --git a/source/blender/freestyle/intern/stroke/StrokeTesselator.h b/source/blender/freestyle/intern/stroke/StrokeTesselator.h index eaeb73504c9..1de281734cd 100755 --- a/source/blender/freestyle/intern/stroke/StrokeTesselator.h +++ b/source/blender/freestyle/intern/stroke/StrokeTesselator.h @@ -38,7 +38,7 @@ class StrokeTesselator { public: - inline StrokeTesselator() {_Material.setDiffuse(0,0,0,1);_overloadMaterial=false;} + inline StrokeTesselator() {_FrsMaterial.setDiffuse(0,0,0,1);_overloadFrsMaterial=false;} virtual ~StrokeTesselator() {} /*! Builds a line rep contained from a Stroke @@ -54,13 +54,13 @@ public: - inline void setMaterial(const Material& iMaterial) {_Material=iMaterial;_overloadMaterial=true;} - inline const Material& material() const {return _Material;} + inline void setFrsMaterial(const FrsMaterial& iMaterial) {_FrsMaterial=iMaterial;_overloadFrsMaterial=true;} + inline const FrsMaterial& frs_material() const {return _FrsMaterial;} private: - Material _Material; - bool _overloadMaterial; + FrsMaterial _FrsMaterial; + bool _overloadFrsMaterial; }; #endif // STROKETESSELATOR_H diff --git a/source/blender/freestyle/intern/view_map/Functions0D.cpp b/source/blender/freestyle/intern/view_map/Functions0D.cpp index c868510624c..1bd6d6f46f1 100755 --- a/source/blender/freestyle/intern/view_map/Functions0D.cpp +++ b/source/blender/freestyle/intern/view_map/Functions0D.cpp @@ -288,17 +288,17 @@ namespace Functions0D { return n; } - Material MaterialF0D::operator()(Interface0DIterator& iter) { + FrsMaterial MaterialF0D::operator()(Interface0DIterator& iter) { FEdge *fe1, *fe2; getFEdges(iter,fe1,fe2); if(fe1 == 0) getFEdges(iter, fe1, fe2); - Material mat; + FrsMaterial mat; if(fe1->isSmooth()) - mat = ((FEdgeSmooth*)fe1)->material(); + mat = ((FEdgeSmooth*)fe1)->frs_material(); else - mat = ((FEdgeSharp*)fe1)->bMaterial(); + mat = ((FEdgeSharp*)fe1)->bFrsMaterial(); // const SShape * sshape = getShapeF0D(iter); // return sshape->material(); return mat; diff --git a/source/blender/freestyle/intern/view_map/Functions0D.h b/source/blender/freestyle/intern/view_map/Functions0D.h index 9543e8c34a6..24d2edac094 100755 --- a/source/blender/freestyle/intern/view_map/Functions0D.h +++ b/source/blender/freestyle/intern/view_map/Functions0D.h @@ -34,7 +34,7 @@ # include "Interface0D.h" # include "../geometry/Geom.h" # include "../system/Exception.h" -# include "../scene_graph/Material.h" +# include "../scene_graph/FrsMaterial.h" # include <set> # include <vector> class FEdge; @@ -350,7 +350,7 @@ namespace Functions0D { * to deal with this cases in a specific way should implement * its own getMaterial functor. */ - class LIB_VIEW_MAP_EXPORT MaterialF0D : public UnaryFunction0D<Material> + class LIB_VIEW_MAP_EXPORT MaterialF0D : public UnaryFunction0D<FrsMaterial> { public: /*! Returns the string "MaterialF0D"*/ @@ -358,7 +358,7 @@ namespace Functions0D { return "MaterialF0D"; } /*! the () operator.*/ - Material operator()(Interface0DIterator& iter); + FrsMaterial operator()(Interface0DIterator& iter); }; // ShapeIdF0D diff --git a/source/blender/freestyle/intern/view_map/Silhouette.cpp b/source/blender/freestyle/intern/view_map/Silhouette.cpp index db4f82d369e..7a7d0a51d4b 100755 --- a/source/blender/freestyle/intern/view_map/Silhouette.cpp +++ b/source/blender/freestyle/intern/view_map/Silhouette.cpp @@ -349,12 +349,12 @@ real FEdge::z_discontinuity() const //{ // return _VertexA->shape()->material(); //} -const Material& FEdgeSharp::aMaterial() const { - return _VertexA->shape()->material(_aMaterialIndex); +const FrsMaterial& FEdgeSharp::aFrsMaterial() const { + return _VertexA->shape()->frs_material(_aFrsMaterialIndex); } -const Material& FEdgeSharp::bMaterial() const { - return _VertexA->shape()->material(_bMaterialIndex); +const FrsMaterial& FEdgeSharp::bFrsMaterial() const { + return _VertexA->shape()->frs_material(_bFrsMaterialIndex); } /**********************************/ @@ -365,6 +365,6 @@ const Material& FEdgeSharp::bMaterial() const { /* */ /**********************************/ -const Material& FEdgeSmooth::material() const { - return _VertexA->shape()->material(_MaterialIndex); +const FrsMaterial& FEdgeSmooth::frs_material() const { + return _VertexA->shape()->frs_material(_FrsMaterialIndex); } diff --git a/source/blender/freestyle/intern/view_map/Silhouette.h b/source/blender/freestyle/intern/view_map/Silhouette.h index 14d934c6791..6b9ebde5707 100755 --- a/source/blender/freestyle/intern/view_map/Silhouette.h +++ b/source/blender/freestyle/intern/view_map/Silhouette.h @@ -38,7 +38,7 @@ # include "../system/FreestyleConfig.h" # include "../geometry/Geom.h" # include "../geometry/BBox.h" -# include "../scene_graph/Material.h" +# include "../scene_graph/FrsMaterial.h" # include "../geometry/Polygon.h" # include "../system/Exception.h" # include "Interface0D.h" @@ -785,24 +785,24 @@ class LIB_VIEW_MAP_EXPORT FEdgeSharp : public FEdge protected: Vec3r _aNormal; // When following the edge, normal of the right face Vec3r _bNormal; // When following the edge, normal of the left face - unsigned _aMaterialIndex; - unsigned _bMaterialIndex; + unsigned _aFrsMaterialIndex; + unsigned _bFrsMaterialIndex; public: /*! Default constructor. */ inline FEdgeSharp() : FEdge(){ - _aMaterialIndex = _bMaterialIndex = 0; + _aFrsMaterialIndex = _bFrsMaterialIndex = 0; } /*! Builds an FEdgeSharp going from vA to vB. */ inline FEdgeSharp(SVertex *vA, SVertex *vB) : FEdge(vA, vB){ - _aMaterialIndex = _bMaterialIndex = 0; + _aFrsMaterialIndex = _bFrsMaterialIndex = 0; } /*! Copy constructor. */ inline FEdgeSharp(FEdgeSharp& iBrother) : FEdge(iBrother){ _aNormal = iBrother._aNormal; _bNormal = iBrother._bNormal; - _aMaterialIndex = iBrother._aMaterialIndex; - _bMaterialIndex = iBrother._bMaterialIndex; + _aFrsMaterialIndex = iBrother._aFrsMaterialIndex; + _bFrsMaterialIndex = iBrother._bFrsMaterialIndex; } /*! Destructor. */ virtual ~FEdgeSharp() {} @@ -824,29 +824,29 @@ public: * right of the FEdge. If this FEdge is a border, * it has no Face on its right and therefore, no material. */ - inline unsigned aMaterialIndex() const {return _aMaterialIndex;} + inline unsigned aFrsMaterialIndex() const {return _aFrsMaterialIndex;} /*! Returns the material of the face lying on the * right of the FEdge. If this FEdge is a border, * it has no Face on its right and therefore, no material. */ - const Material& aMaterial() const ; + const FrsMaterial& aFrsMaterial() const ; /*! Returns the index of the material of the face lying on the * left of the FEdge. */ - inline unsigned bMaterialIndex() const {return _bMaterialIndex;} + inline unsigned bFrsMaterialIndex() const {return _bFrsMaterialIndex;} /*! Returns the material of the face lying on the * left of the FEdge. */ - const Material& bMaterial() const ; + const FrsMaterial& bFrsMaterial() const ; /*! Sets the normal to the face lying on the right of the FEdge. */ inline void setNormalA(const Vec3r& iNormal) {_aNormal = iNormal;} /*! Sets the normal to the face lying on the left of the FEdge. */ inline void setNormalB(const Vec3r& iNormal) {_bNormal = iNormal;} /*! Sets the index of the material lying on the right of the FEdge.*/ - inline void setaMaterialIndex(unsigned i) {_aMaterialIndex = i;} + inline void setaFrsMaterialIndex(unsigned i) {_aFrsMaterialIndex = i;} /*! Sets the index of the material lying on the left of the FEdge.*/ - inline void setbMaterialIndex(unsigned i) {_bMaterialIndex = i;} + inline void setbFrsMaterialIndex(unsigned i) {_bFrsMaterialIndex = i;} }; @@ -858,7 +858,7 @@ class LIB_VIEW_MAP_EXPORT FEdgeSmooth : public FEdge { protected: Vec3r _Normal; - unsigned _MaterialIndex; + unsigned _FrsMaterialIndex; // bool _hasVisibilityPoint; // Vec3r _VisibilityPointA; // The edge on which the visibility will be computed represented // Vec3r _VisibilityPointB; // using its 2 extremity points A and B @@ -868,13 +868,13 @@ public: /*! Default constructor. */ inline FEdgeSmooth() : FEdge(){ _Face=0; - _MaterialIndex = 0; + _FrsMaterialIndex = 0; _isSmooth = true; } /*! Builds an FEdgeSmooth going from vA to vB. */ inline FEdgeSmooth(SVertex *vA, SVertex *vB) : FEdge(vA, vB){ _Face=0; - _MaterialIndex = 0; + _FrsMaterialIndex = 0; _isSmooth = true; } @@ -882,7 +882,7 @@ public: inline FEdgeSmooth(FEdgeSmooth& iBrother) : FEdge(iBrother){ _Normal = iBrother._Normal; _Face = iBrother._Face; - _MaterialIndex = iBrother._MaterialIndex; + _FrsMaterialIndex = iBrother._FrsMaterialIndex; _isSmooth = true; } /*! Destructor. */ @@ -897,15 +897,15 @@ public: /*! Returns the normal to the Face it is running accross. */ inline const Vec3r& normal() {return _Normal;} /*! Returns the index of the material of the face it is running accross. */ - inline unsigned materialIndex() const {return _MaterialIndex;} + inline unsigned frs_materialIndex() const {return _FrsMaterialIndex;} /*! Returns the material of the face it is running accross. */ - const Material& material() const ; + const FrsMaterial& frs_material() const ; inline void setFace(void * iFace) {_Face = iFace;} /*! Sets the normal to the Face it is running accross. */ inline void setNormal(const Vec3r& iNormal) {_Normal = iNormal;} /*! Sets the index of the material of the face it is running accross. */ - inline void setMaterialIndex(unsigned i) {_MaterialIndex = i;} + inline void setFrsMaterialIndex(unsigned i) {_FrsMaterialIndex = i;} }; /**********************************/ /* */ @@ -927,7 +927,7 @@ private: vector<FEdge*> _edgesList; // list of all edges Id _Id; BBox<Vec3r> _BBox; - vector<Material> _Materials; + vector<FrsMaterial> _FrsMaterials; float _importance; @@ -952,7 +952,7 @@ public: userdata = 0; _Id = iBrother._Id; _BBox = iBrother.bbox(); - _Materials = iBrother._Materials; + _FrsMaterials = iBrother._FrsMaterials; _importance = iBrother._importance; @@ -1199,13 +1199,13 @@ public: newEdge = new FEdgeSmooth((*sv), svB); FEdgeSmooth * se = dynamic_cast<FEdgeSmooth*>(newEdge); FEdgeSmooth * fes = dynamic_cast<FEdgeSmooth*>(fe); - se->setMaterialIndex(fes->materialIndex()); + se->setFrsMaterialIndex(fes->frs_materialIndex()); }else{ newEdge = new FEdgeSharp((*sv), svB); FEdgeSharp * se = dynamic_cast<FEdgeSharp*>(newEdge); FEdgeSharp * fes = dynamic_cast<FEdgeSharp*>(fe); - se->setaMaterialIndex(fes->aMaterialIndex()); - se->setbMaterialIndex(fes->bMaterialIndex()); + se->setaFrsMaterialIndex(fes->aFrsMaterialIndex()); + se->setbFrsMaterialIndex(fes->bFrsMaterialIndex()); } newEdge->setNature((fe)->getNature()); @@ -1264,13 +1264,13 @@ public: newEdge = new FEdgeSmooth(ioNewVertex, B); FEdgeSmooth * se = dynamic_cast<FEdgeSmooth*>(newEdge); FEdgeSmooth * fes = dynamic_cast<FEdgeSmooth*>(ioEdge); - se->setMaterialIndex(fes->materialIndex()); + se->setFrsMaterialIndex(fes->frs_materialIndex()); }else{ newEdge = new FEdgeSharp(ioNewVertex, B); FEdgeSharp * se = dynamic_cast<FEdgeSharp*>(newEdge); FEdgeSharp * fes = dynamic_cast<FEdgeSharp*>(ioEdge); - se->setaMaterialIndex(fes->aMaterialIndex()); - se->setbMaterialIndex(fes->bMaterialIndex()); + se->setaFrsMaterialIndex(fes->aFrsMaterialIndex()); + se->setbFrsMaterialIndex(fes->bFrsMaterialIndex()); } newEdge->setNature(ioEdge->getNature()); @@ -1399,9 +1399,9 @@ public: /*! Returns the bounding box of the shape. */ inline const BBox<Vec3r>& bbox() {return _BBox;} /*! Returns the ith material of the shape. */ - inline const Material& material(unsigned i) const {return _Materials[i];} + inline const FrsMaterial& frs_material(unsigned i) const {return _FrsMaterials[i];} /*! Returns the list of materials of the Shape. */ - inline const vector<Material>& materials() const {return _Materials;} + inline const vector<FrsMaterial>& frs_materials() const {return _FrsMaterials;} inline ViewShape * viewShape() {return _ViewShape;} inline float importance() const {return _importance;} /*! Returns the Id of the Shape. */ @@ -1411,7 +1411,7 @@ public: /*! Sets the Id of the shape.*/ inline void setId(Id id) {_Id = id;} /*! Sets the list of materials for the shape */ - inline void setMaterials(const vector<Material>& iMaterials) {_Materials = iMaterials;} + inline void setFrsMaterials(const vector<FrsMaterial>& iMaterials) {_FrsMaterials = iMaterials;} inline void setViewShape(ViewShape *iShape) {_ViewShape = iShape;} inline void setImportance(float importance){_importance = importance;} }; diff --git a/source/blender/freestyle/intern/view_map/ViewEdgeXBuilder.cpp b/source/blender/freestyle/intern/view_map/ViewEdgeXBuilder.cpp index 42c39d5795e..5f7b313aaf6 100755 --- a/source/blender/freestyle/intern/view_map/ViewEdgeXBuilder.cpp +++ b/source/blender/freestyle/intern/view_map/ViewEdgeXBuilder.cpp @@ -470,7 +470,7 @@ FEdge * ViewEdgeXBuilder::BuildSmoothFEdge(FEdge *feprevious, const OWXFaceLayer fe = new FEdgeSmooth(va, vb); fe->setNature(ifl.fl->nature()); fe->setId(_currentFId); - fe->setMaterialIndex(ifl.fl->getFace()->materialIndex()); + fe->setFrsMaterialIndex(ifl.fl->getFace()->frs_materialIndex()); fe->setFace(ifl.fl->getFace()); fe->setNormal(normal); fe->setPreviousEdge(feprevious); @@ -587,17 +587,17 @@ FEdge * ViewEdgeXBuilder::BuildSharpFEdge(FEdge *feprevious, const OWXEdge& iwe) unsigned matA(0), matB(0); if(iwe.order){ normalB = (iwe.e->GetbFace()->GetNormal()); - matB = (iwe.e->GetbFace()->materialIndex()); + matB = (iwe.e->GetbFace()->frs_materialIndex()); if(!(iwe.e->nature() & Nature::BORDER)) { normalA = (iwe.e->GetaFace()->GetNormal()); - matA = (iwe.e->GetaFace()->materialIndex()); + matA = (iwe.e->GetaFace()->frs_materialIndex()); } }else{ normalA = (iwe.e->GetbFace()->GetNormal()); - matA = (iwe.e->GetbFace()->materialIndex()); + matA = (iwe.e->GetbFace()->frs_materialIndex()); if(!(iwe.e->nature() & Nature::BORDER)) { normalB = (iwe.e->GetaFace()->GetNormal()); - matB = (iwe.e->GetaFace()->materialIndex()); + matB = (iwe.e->GetaFace()->frs_materialIndex()); } } // Creates the corresponding feature edge @@ -605,8 +605,8 @@ FEdge * ViewEdgeXBuilder::BuildSharpFEdge(FEdge *feprevious, const OWXEdge& iwe) fe = new FEdgeSharp(va, vb); fe->setNature(iwe.e->nature()); fe->setId(_currentFId); - fe->setaMaterialIndex(matA); - fe->setbMaterialIndex(matB); + fe->setaFrsMaterialIndex(matA); + fe->setbFrsMaterialIndex(matB); fe->setNormalA(normalA); fe->setNormalB(normalB); fe->setPreviousEdge(feprevious); diff --git a/source/blender/freestyle/intern/view_map/ViewMapBuilder.cpp b/source/blender/freestyle/intern/view_map/ViewMapBuilder.cpp index 89e91e4f2c8..3a4d86ea16f 100755 --- a/source/blender/freestyle/intern/view_map/ViewMapBuilder.cpp +++ b/source/blender/freestyle/intern/view_map/ViewMapBuilder.cpp @@ -56,7 +56,7 @@ void ViewMapBuilder::computeInitialViewEdges(WingedEdge& we) // create the embedding psShape = new SShape; psShape->setId((*it)->GetId()); - psShape->setMaterials((*it)->materials()); // FIXME + psShape->setFrsMaterials((*it)->frs_materials()); // FIXME // create the view shape ViewShape * vshape = new ViewShape(psShape); diff --git a/source/blender/freestyle/intern/view_map/ViewMapIO.cpp b/source/blender/freestyle/intern/view_map/ViewMapIO.cpp index e42a0df0422..f99a574766b 100755 --- a/source/blender/freestyle/intern/view_map/ViewMapIO.cpp +++ b/source/blender/freestyle/intern/view_map/ViewMapIO.cpp @@ -91,7 +91,7 @@ namespace ViewMapIO { inline - int load(istream& in, Material& m) { + int load(istream& in, FrsMaterial& m) { float tmp_array[4]; int i; @@ -149,13 +149,13 @@ namespace ViewMapIO { // -> Material READ(size); - vector<Material> materials; - Material m; + vector<FrsMaterial> frs_materials; + FrsMaterial m; for(i=0; i<size; ++i){ load(in, m); - materials.push_back(m); + frs_materials.push_back(m); } - vs->sshape()->setMaterials(materials); + vs->sshape()->setFrsMaterials(frs_materials); @@ -252,7 +252,7 @@ namespace ViewMapIO { // Material READ(matindex); - fesmooth->setMaterialIndex(matindex); + fesmooth->setFrsMaterialIndex(matindex); }else{ // aNormal load(in, v); @@ -264,9 +264,9 @@ namespace ViewMapIO { // Materials READ(matindex); - fesharp->setaMaterialIndex(matindex); + fesharp->setaFrsMaterialIndex(matindex); READ(matindex); - fesharp->setbMaterialIndex(matindex); + fesharp->setbFrsMaterialIndex(matindex); } unsigned tmp; @@ -569,7 +569,7 @@ namespace ViewMapIO { inline - int save(ostream& out, const Material& m) { + int save(ostream& out, const FrsMaterial& m) { unsigned i; @@ -622,10 +622,10 @@ namespace ViewMapIO { // Not necessary (only used during view map computatiom) // -> Material - unsigned size = vs->sshape()->materials().size(); + unsigned size = vs->sshape()->frs_materials().size(); WRITE(size); for(unsigned i=0; i<size; ++i) - save(out, vs->sshape()->material(i)); + save(out, vs->sshape()->frs_material(i)); // -> VerticesList (List) tmp = vs->sshape()->getVertexList().size(); @@ -704,7 +704,7 @@ namespace ViewMapIO { // normal save(out, fesmooth->normal()); // material - index = fesmooth->materialIndex(); + index = fesmooth->frs_materialIndex(); WRITE(index); }else{ // aNormal @@ -712,10 +712,10 @@ namespace ViewMapIO { // bNormal save(out, fesharp->normalB()); // aMaterial - index = fesharp->aMaterialIndex(); + index = fesharp->aFrsMaterialIndex(); WRITE(index); // bMaterial - index = fesharp->bMaterialIndex(); + index = fesharp->bFrsMaterialIndex(); WRITE(index); } diff --git a/source/blender/freestyle/intern/view_map/ViewMapTesselator.h b/source/blender/freestyle/intern/view_map/ViewMapTesselator.h index 2d054d8a067..630bfa561f2 100755 --- a/source/blender/freestyle/intern/view_map/ViewMapTesselator.h +++ b/source/blender/freestyle/intern/view_map/ViewMapTesselator.h @@ -49,7 +49,7 @@ class LIB_VIEW_MAP_EXPORT ViewMapTesselator { public: - inline ViewMapTesselator() {_nature = Nature::SILHOUETTE | Nature::BORDER | Nature::CREASE;_Material.setDiffuse(0,0,0,1);_overloadMaterial=false;} + inline ViewMapTesselator() {_nature = Nature::SILHOUETTE | Nature::BORDER | Nature::CREASE;_FrsMaterial.setDiffuse(0,0,0,1);_overloadFrsMaterial=false;} virtual ~ViewMapTesselator() {} /*! Builds a set of lines rep contained under a @@ -71,17 +71,17 @@ public: inline void setNature(Nature::EdgeNature iNature) {_nature = iNature;} - inline void setMaterial(const Material& iMaterial) {_Material=iMaterial;_overloadMaterial=true;} + inline void setFrsMaterial(const FrsMaterial& iMaterial) {_FrsMaterial=iMaterial;_overloadFrsMaterial=true;} inline Nature::EdgeNature nature() {return _nature;} - inline const Material& material() const {return _Material;} + inline const FrsMaterial& frs_material() const {return _FrsMaterial;} protected: virtual void AddVertexToLine(LineRep *iLine, SVertex *v) = 0; private: Nature::EdgeNature _nature; - Material _Material; - bool _overloadMaterial; + FrsMaterial _FrsMaterial; + bool _overloadFrsMaterial; }; /*! Class to tesselate the 2D projected silhouette */ @@ -123,8 +123,8 @@ NodeGroup * ViewMapTesselator::Tesselate(ViewEdgesIterator begin, ViewEdgesItera NodeGroup *group = new NodeGroup; NodeShape *tshape = new NodeShape; group->AddChild(tshape); - //tshape->material().setDiffuse(0.f, 0.f, 0.f, 1.f); - tshape->setMaterial(_Material); + //tshape->frs_material().setDiffuse(0.f, 0.f, 0.f, 1.f); + tshape->setFrsMaterial(_FrsMaterial); LineRep* line; @@ -152,8 +152,8 @@ NodeGroup * ViewMapTesselator::Tesselate(ViewEdgesIterator begin, ViewEdgesItera // continue; line = new OrientedLineRep(); - if(_overloadMaterial) - line->setMaterial(_Material); + if(_overloadFrsMaterial) + line->setFrsMaterial(_FrsMaterial); // there might be chains containing a single element if(0 == (firstEdge)->nextEdge()) diff --git a/source/blender/freestyle/intern/winged_edge/WEdge.cpp b/source/blender/freestyle/intern/winged_edge/WEdge.cpp index b480b67b3d8..95be5f55794 100755 --- a/source/blender/freestyle/intern/winged_edge/WEdge.cpp +++ b/source/blender/freestyle/intern/winged_edge/WEdge.cpp @@ -254,7 +254,7 @@ WFace::WFace(WFace& iBrother) _VerticesNormals = iBrother._VerticesNormals; _VerticesTexCoords = iBrother._VerticesTexCoords; _Id = iBrother.GetId(); - _MaterialIndex = iBrother._MaterialIndex; + _FrsMaterialIndex = iBrother._FrsMaterialIndex; userdata = NULL; iBrother.userdata = new facedata; ((facedata*)(iBrother.userdata))->_copy = this; @@ -266,8 +266,8 @@ WFace * WFace::duplicate() return clone; } -const Material& WFace::material() { - return getShape()->material(_MaterialIndex); +const FrsMaterial& WFace::frs_material() { + return getShape()->frs_material(_FrsMaterialIndex); } WOEdge * WFace::MakeEdge(WVertex *v1, WVertex *v2) @@ -475,7 +475,7 @@ WShape * WShape::duplicate() WShape::WShape(WShape& iBrother) { _Id = iBrother.GetId(); - _Materials = iBrother._Materials; + _FrsMaterials = iBrother._FrsMaterials; _meanEdgeSize = iBrother._meanEdgeSize; iBrother.bbox(_min, _max); vector<WVertex*>& vertexList = iBrother.getVertexList(); @@ -650,7 +650,7 @@ WFace* WShape::MakeFace(vector<WVertex*>& iVertexList, unsigned iMaterial, WFace int id = _FaceList.size(); - face->setMaterialIndex(iMaterial); + face->setFrsMaterialIndex(iMaterial); // Check whether we have a degenerated face: diff --git a/source/blender/freestyle/intern/winged_edge/WEdge.h b/source/blender/freestyle/intern/winged_edge/WEdge.h index ea6c793bdfe..9b05b4577a9 100755 --- a/source/blender/freestyle/intern/winged_edge/WEdge.h +++ b/source/blender/freestyle/intern/winged_edge/WEdge.h @@ -34,7 +34,7 @@ # include <iterator> # include "../system/FreestyleConfig.h" # include "../geometry/Geom.h" -# include "../scene_graph/Material.h" +# include "../scene_graph/FrsMaterial.h" using namespace std; using namespace Geometry; @@ -495,11 +495,11 @@ protected: vector<Vec2r> _VerticesTexCoords; int _Id; - unsigned _MaterialIndex; + unsigned _FrsMaterialIndex; public: void *userdata; - inline WFace() {userdata = NULL;_MaterialIndex = 0;} + inline WFace() {userdata = NULL;_FrsMaterialIndex = 0;} /*! copy constructor */ WFace(WFace& iBrother); virtual WFace * duplicate(); @@ -510,8 +510,8 @@ public: inline WOEdge * GetOEdge(int i) {return _OEdgeList[i];} inline Vec3r& GetNormal() {return _Normal;} inline int GetId() {return _Id;} - inline unsigned materialIndex() const {return _MaterialIndex;} - const Material& material() ; + inline unsigned frs_materialIndex() const {return _FrsMaterialIndex;} + const FrsMaterial& frs_material() ; /*! The vertex of index i corresponds to the a vertex * of the edge of index i @@ -653,7 +653,7 @@ public: inline void setNormalList(const vector<Vec3r>& iNormalsList) {_VerticesNormals = iNormalsList;} inline void setTexCoordsList(const vector<Vec2r>& iTexCoordsList) {_VerticesTexCoords = iTexCoordsList;} inline void setId(int id) {_Id = id;} - inline void setMaterialIndex(unsigned iMaterialIndex) {_MaterialIndex = iMaterialIndex;} + inline void setFrsMaterialIndex(unsigned iMaterialIndex) {_FrsMaterialIndex = iMaterialIndex;} /*! designed to build a specialized WEdge * for use in MakeEdge @@ -702,7 +702,7 @@ protected: static unsigned _SceneCurrentId; Vec3r _min; Vec3r _max; - vector<Material> _Materials; + vector<FrsMaterial> _FrsMaterials; real _meanEdgeSize; public: @@ -749,8 +749,8 @@ public: inline vector<WFace*>& GetFaceList() {return _FaceList;} inline unsigned GetId() {return _Id;} inline void bbox(Vec3r& min, Vec3r& max) {min=_min; max=_max;} - inline const Material& material(unsigned i) const {return _Materials[i];} - inline const vector<Material>& materials() const {return _Materials;} + inline const FrsMaterial& frs_material(unsigned i) const {return _FrsMaterials[i];} + inline const vector<FrsMaterial>& frs_materials() const {return _FrsMaterials;} inline const real getMeanEdgeSize() const {return _meanEdgeSize;} /*! modifiers */ static inline void setCurrentId(const unsigned id) { _SceneCurrentId = id; } @@ -759,8 +759,8 @@ public: inline void setFaceList(const vector<WFace*>& iFaceList) {_FaceList = iFaceList;} inline void setId(int id) {_Id = id;} inline void setBBox(const Vec3r& min, const Vec3r& max) {_min = min; _max=max;} - inline void setMaterial(const Material& material, unsigned i) {_Materials[i]=material;} - inline void setMaterials(const vector<Material>& iMaterials) {_Materials = iMaterials;} + inline void setFrsMaterial(const FrsMaterial& frs_material, unsigned i) {_FrsMaterials[i]=frs_material;} + inline void setFrsMaterials(const vector<FrsMaterial>& iMaterials) {_FrsMaterials = iMaterials;} /*! designed to build a specialized WFace * for use in MakeFace diff --git a/source/blender/freestyle/intern/winged_edge/WingedEdgeBuilder.cpp b/source/blender/freestyle/intern/winged_edge/WingedEdgeBuilder.cpp index cccf876db8b..9f3da4707e3 100755 --- a/source/blender/freestyle/intern/winged_edge/WingedEdgeBuilder.cpp +++ b/source/blender/freestyle/intern/winged_edge/WingedEdgeBuilder.cpp @@ -34,7 +34,7 @@ void WingedEdgeBuilder::visitIndexedFaceSet(IndexedFaceSet& ifs) { void WingedEdgeBuilder::visitNodeShape(NodeShape& ns) { //Sets the current material to iShapeode->material: - _current_material = &(ns.material()); + _current_frs_material = &(ns.frs_material()); } void WingedEdgeBuilder::visitNodeTransform(NodeTransform& tn) { @@ -88,19 +88,19 @@ void WingedEdgeBuilder::buildWShape(WShape& shape, IndexedFaceSet& ifs) { const IndexedFaceSet::TRIANGLES_STYLE* faceStyle = ifs.trianglesStyle(); - vector<Material> materials; + vector<FrsMaterial> frs_materials; if(ifs.msize()){ - const Material*const* mats = ifs.materials(); + const FrsMaterial*const* mats = ifs.frs_materials(); for(unsigned i=0; i<ifs.msize(); ++i) - materials.push_back(*(mats[i])); - shape.setMaterials(materials); + frs_materials.push_back(*(mats[i])); + shape.setFrsMaterials(frs_materials); } - // const Material * mat = (ifs.material()); + // const FrsMaterial * mat = (ifs.frs_material()); // if (mat) - // shape.setMaterial(*mat); - // else if(_current_material) - // shape.setMaterial(*_current_material); + // shape.setFrsMaterial(*mat); + // else if(_current_frs_material) + // shape.setFrsMaterial(*_current_frs_material); // sets the current WShape to shape _current_wshape = &shape; @@ -126,7 +126,7 @@ void WingedEdgeBuilder::buildWShape(WShape& shape, IndexedFaceSet& ifs) { case IndexedFaceSet::TRIANGLE_STRIP: buildTriangleStrip(new_vertices, new_normals, - materials, + frs_materials, texCoords, vindices, nindices, @@ -137,7 +137,7 @@ void WingedEdgeBuilder::buildWShape(WShape& shape, IndexedFaceSet& ifs) { case IndexedFaceSet::TRIANGLE_FAN: buildTriangleFan(new_vertices, new_normals, - materials, + frs_materials, texCoords, vindices, nindices, @@ -148,7 +148,7 @@ void WingedEdgeBuilder::buildWShape(WShape& shape, IndexedFaceSet& ifs) { case IndexedFaceSet::TRIANGLES: buildTriangles(new_vertices, new_normals, - materials, + frs_materials, texCoords, vindices, nindices, @@ -215,7 +215,7 @@ void WingedEdgeBuilder::buildWVertices(WShape& shape, void WingedEdgeBuilder::buildTriangleStrip( const real *vertices, const real *normals, - vector<Material>& iMaterials, + vector<FrsMaterial>& iMaterials, const real *texCoords, const unsigned *vindices, const unsigned *nindices, @@ -279,7 +279,7 @@ void WingedEdgeBuilder::buildTriangleStrip( const real *vertices, void WingedEdgeBuilder::buildTriangleFan( const real *vertices, const real *normals, - vector<Material>& iMaterials, + vector<FrsMaterial>& iMaterials, const real *texCoords, const unsigned *vindices, const unsigned *nindices, @@ -291,7 +291,7 @@ void WingedEdgeBuilder::buildTriangleFan( const real *vertices, void WingedEdgeBuilder::buildTriangles(const real *vertices, const real *normals, - vector<Material>& iMaterials, + vector<FrsMaterial>& iMaterials, const real *texCoords, const unsigned *vindices, const unsigned *nindices, diff --git a/source/blender/freestyle/intern/winged_edge/WingedEdgeBuilder.h b/source/blender/freestyle/intern/winged_edge/WingedEdgeBuilder.h index fe033f2ea0b..6bd515aef0b 100755 --- a/source/blender/freestyle/intern/winged_edge/WingedEdgeBuilder.h +++ b/source/blender/freestyle/intern/winged_edge/WingedEdgeBuilder.h @@ -44,7 +44,7 @@ class LIB_WINGED_EDGE_EXPORT WingedEdgeBuilder : public SceneVisitor inline WingedEdgeBuilder() : SceneVisitor() { _current_wshape = NULL; - _current_material = NULL; + _current_frs_material = NULL; _current_matrix = NULL; _winged_edge = new WingedEdge; // Not deleted by the destructor } @@ -76,8 +76,8 @@ class LIB_WINGED_EDGE_EXPORT WingedEdgeBuilder : public SceneVisitor return _current_wshape; } - inline Material* getCurrentMaterial() { - return _current_material; + inline FrsMaterial* getCurrentFrsMaterial() { + return _current_frs_material; } inline Matrix44r* getCurrentMatrix() { @@ -93,8 +93,8 @@ class LIB_WINGED_EDGE_EXPORT WingedEdgeBuilder : public SceneVisitor _current_wshape = wshape; } - inline void setCurrentMaterial(Material* mat) { - _current_material = mat; + inline void setCurrentFrsMaterial(FrsMaterial* mat) { + _current_frs_material = mat; } // inline void setCurrentMatrix(Matrix44r* matrix) { @@ -112,7 +112,7 @@ class LIB_WINGED_EDGE_EXPORT WingedEdgeBuilder : public SceneVisitor void buildTriangleStrip(const real *vertices, const real *normals, - vector<Material>& iMaterials, + vector<FrsMaterial>& iMaterials, const real *texCoords, const unsigned *vindices, const unsigned *nindices, @@ -122,7 +122,7 @@ class LIB_WINGED_EDGE_EXPORT WingedEdgeBuilder : public SceneVisitor void buildTriangleFan(const real *vertices, const real *normals, - vector<Material>& iMaterials, + vector<FrsMaterial>& iMaterials, const real *texCoords, const unsigned *vindices, const unsigned *nindices, @@ -132,7 +132,7 @@ class LIB_WINGED_EDGE_EXPORT WingedEdgeBuilder : public SceneVisitor void buildTriangles(const real *vertices, const real *normals, - vector<Material>& iMaterials, + vector<FrsMaterial>& iMaterials, const real *texCoords, const unsigned *vindices, const unsigned *nindices, @@ -151,7 +151,7 @@ class LIB_WINGED_EDGE_EXPORT WingedEdgeBuilder : public SceneVisitor real *res); WShape* _current_wshape; - Material* _current_material; + FrsMaterial* _current_frs_material; WingedEdge* _winged_edge; Matrix44r* _current_matrix; vector<Matrix44r*> _matrices_stack; |