[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [16019] branches/soc-2008-mxcurioni/source /blender/freestyle/intern: soc-2008-mxcurioni: clean up
Maxime Curioni
maxime.curioni at gmail.com
Fri Aug 8 10:53:16 CEST 2008
Revision: 16019
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=16019
Author: mxcurioni
Date: 2008-08-08 10:53:13 +0200 (Fri, 08 Aug 2008)
Log Message:
-----------
soc-2008-mxcurioni: clean up
Modified Paths:
--------------
branches/soc-2008-mxcurioni/source/blender/freestyle/intern/app_blender/Controller.cpp
branches/soc-2008-mxcurioni/source/blender/freestyle/intern/app_blender/api.cpp
Removed Paths:
-------------
branches/soc-2008-mxcurioni/source/blender/freestyle/intern/scene_graph/MaxFileLoader.cpp
branches/soc-2008-mxcurioni/source/blender/freestyle/intern/scene_graph/MaxFileLoader.h
Modified: branches/soc-2008-mxcurioni/source/blender/freestyle/intern/app_blender/Controller.cpp
===================================================================
--- branches/soc-2008-mxcurioni/source/blender/freestyle/intern/app_blender/Controller.cpp 2008-08-08 08:42:00 UTC (rev 16018)
+++ branches/soc-2008-mxcurioni/source/blender/freestyle/intern/app_blender/Controller.cpp 2008-08-08 08:53:13 UTC (rev 16019)
@@ -32,7 +32,6 @@
#include "../system/StringUtils.h"
-#include "../scene_graph/MaxFileLoader.h"
#include "../scene_graph/NodeShape.h"
#include "../scene_graph/NodeTransform.h"
#include "../scene_graph/NodeDrawingStyle.h"
@@ -272,108 +271,6 @@
}
-int Controller::Load3DSFile(const char *iFileName)
-{
- if (_pView)
- _pView->setUpdateMode(false);
-
- MaxFileLoader loader3DS(iFileName);
- //_RootNode->AddChild(BuildSceneTest());
-
- _Chrono.start();
-
- NodeGroup *maxScene = loader3DS.Load();
-
- if (maxScene == NULL) {
- cout << "Cannot load scene" << endl;
- return 1;
- }
-
- cout << "Scene loaded\n" << endl;
-
- printf("Mesh cleaning : %lf\n", _Chrono.stop());
- _SceneNumFaces += loader3DS.numFacesRead();
-
- if(loader3DS.minEdgeSize() < _minEdgeSize)
- {
- _minEdgeSize = loader3DS.minEdgeSize();
- _EPSILON = _minEdgeSize*1e-6;
- if(_EPSILON < DBL_MIN)
- _EPSILON = 0.0;
- }
-
- cout << "Epsilon computed : " << _EPSILON << endl;
-
- // DEBUG
- // ScenePrettyPrinter spp;
- // maxScene->accept(spp);
-
- _RootNode->AddChild(maxScene);
- _RootNode->UpdateBBox(); // FIXME: Correct that by making a Renderer to compute the bbox
-
- _pView->setModel(_RootNode);
- //_pView->FitBBox();
-
-
- _Chrono.start();
-
-
- WXEdgeBuilder wx_builder;
- maxScene->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(basename);
-
- cout << "Triangles nb : " << _SceneNumFaces << endl;
- _bboxDiag = (_RootNode->bbox().getMax()-_RootNode->bbox().getMin()).norm();
- cout << "Bounding Box : " << _bboxDiag << endl;
- return 0;
-}
-
void Controller::CloseFile()
{
WShape::setCurrentId(0);
Modified: branches/soc-2008-mxcurioni/source/blender/freestyle/intern/app_blender/api.cpp
===================================================================
--- branches/soc-2008-mxcurioni/source/blender/freestyle/intern/app_blender/api.cpp 2008-08-08 08:42:00 UTC (rev 16018)
+++ branches/soc-2008-mxcurioni/source/blender/freestyle/intern/app_blender/api.cpp 2008-08-08 08:53:13 UTC (rev 16019)
@@ -82,28 +82,7 @@
view->_camera->setUpVector(camUp);
view->_camera->setViewDirection(camDirection);
}
-
- void FRS_scene_3ds_export(Render* re) {
- // export scene to 3ds format
- string script_3ds_export = pathconfig->getProjectDir() +
- Config::DIR_SEP + "python" +
- Config::DIR_SEP + "3ds_export.py";
- BPY_run_python_script( const_cast<char *>(script_3ds_export.c_str()) );
- // load 3ds scene
- char btempdir[255];
- BLI_where_is_temp(btempdir,1);
- string exported_3ds_file = btempdir;
- exported_3ds_file += Config::DIR_SEP + "tmp_scene_freestyle.3ds";
- if( BLI_exists( const_cast<char *>(exported_3ds_file.c_str()) ) ) {
- controller->Load3DSFile( exported_3ds_file.c_str() );
- }
- else {
- cout << "Cannot find" << exported_3ds_file << endl;
- return;
- }
- }
-
void FRS_load_mesh( Render *re ){
controller->LoadMesh(re);
}
@@ -113,8 +92,7 @@
FRS_init_view(re);
FRS_init_camera(re);
-
- //FRS_scene_3ds_export(re);
+
FRS_load_mesh(re);
}
Deleted: branches/soc-2008-mxcurioni/source/blender/freestyle/intern/scene_graph/MaxFileLoader.cpp
===================================================================
--- branches/soc-2008-mxcurioni/source/blender/freestyle/intern/scene_graph/MaxFileLoader.cpp 2008-08-08 08:42:00 UTC (rev 16018)
+++ branches/soc-2008-mxcurioni/source/blender/freestyle/intern/scene_graph/MaxFileLoader.cpp 2008-08-08 08:53:13 UTC (rev 16019)
@@ -1,388 +0,0 @@
-
-//
-// Copyright (C) : Please refer to the COPYRIGHT file distributed
-// with this source distribution.
-//
-// This program is free software; you can redistribute it and/or
-// modify it under the terms of the GNU General Public License
-// as published by the Free Software Foundation; either version 2
-// of the License, or (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-//
-///////////////////////////////////////////////////////////////////////////////
-
-#include "MaxFileLoader.h"
-
-MaxFileLoader::MaxFileLoader()
-{
- _FileName = NULL;
- _3dsFile = NULL;
- _Scene = NULL;
- _numFacesRead = 0;
- _minEdgeSize = DBL_MAX;
-}
-
-MaxFileLoader::MaxFileLoader(const char *iFileName)
-{
- _FileName = new char[strlen(iFileName)+1];
- strcpy(_FileName, iFileName);
-
- _3dsFile = NULL;
- _Scene = NULL;
- _numFacesRead = 0;
- _minEdgeSize = DBL_MAX;
-}
-
-MaxFileLoader::~MaxFileLoader()
-{
- if(NULL != _FileName)
- {
- delete [] _FileName;
- _FileName = NULL;
- }
-
- if(NULL != _3dsFile)
- {
- lib3ds_file_free(_3dsFile);
- _3dsFile = NULL;
- }
-
- _Scene = NULL;
-}
-
-void MaxFileLoader::setFileName(const char *iFileName)
-{
- if(NULL != _FileName)
- delete [] _FileName;
-
- _FileName = new char[strlen(iFileName)+1];
- strcpy(_FileName, iFileName);
-}
-
-NodeGroup* MaxFileLoader::Load()
-{
- _3dsFile=lib3ds_file_load(_FileName);
- if(NULL == _3dsFile)
- return NULL;
-
- /* No nodes? Fabricate nodes to display all the meshes. */
- if( !_3dsFile->nodes )
- {
- Lib3dsMesh *mesh;
- Lib3dsNode *node;
-
- for(mesh = _3dsFile->meshes; mesh != NULL; mesh = mesh->next)
- {
- node = lib3ds_node_new_object();
- strcpy(node->name, mesh->name);
- node->parent_id = LIB3DS_NO_PARENT;
- node->data.object.scl_track.keyL = lib3ds_lin3_key_new();
- node->data.object.scl_track.keyL->value[0] = 1.;
- node->data.object.scl_track.keyL->value[1] = 1.;
- node->data.object.scl_track.keyL->value[2] = 1.;
- lib3ds_file_insert_node(_3dsFile, node);
- }
- }
-
- lib3ds_file_eval(_3dsFile, 0);
-
- // creation of the scene root node
- _Scene = new NodeGroup;
-
- // converts the 3ds format to the scene format
- // the RenderNode method modifies _Scene.
- Lib3dsNode *p;
- for (p=_3dsFile->nodes; p!=0; p=p->next) {
- RenderNode(p);
- }
- //Returns the built scene.
- return _Scene;
-}
-
-void lib3ds_normal_transform(Lib3dsVector c, Lib3dsMatrix m, Lib3dsVector a)
-{
- c[0]= (m[0][0]*a[0] + m[1][0]*a[1] + m[2][0]*a[2]);
- c[1]= (m[0][1]*a[0] + m[1][1]*a[1] + m[2][1]*a[2]);
- c[2]= (m[0][2]*a[0] + m[1][2]*a[1] + m[2][2]*a[2]);
-
- // c[0]= (m[0][0]*a[0] + m[1][0]*a[1] + m[2][0]*a[2])/m[0][0];
- // c[1]= (m[0][1]*a[0] + m[1][1]*a[1] + m[2][1]*a[2])/m[1][1];
- // c[2]= (m[0][2]*a[0] + m[1][2]*a[1] + m[2][2]*a[2])/m[2][2];
-
- //lib3ds_vector_normalize(c);
-
- // c[0] = c[0]*m[0][0];
- // c[1] = c[1]*m[1][1];
- // c[2] = c[2]*m[2][2];
-
-}
-
-
-
-void MaxFileLoader::RenderNode(Lib3dsNode *iNode)
-{
- Lib3dsNode *p;
- for (p=iNode->childs; p!=0; p=p->next)
- RenderNode(p);
-
- float minBBox[3];
- float maxBBox[3];
- if (iNode->type==LIB3DS_OBJECT_NODE)
- {
- if (strcmp(iNode->name,"$$$DUMMY")==0)
- return;
-
- NodeTransform *currentMesh = new NodeTransform;
- NodeShape * shape;
-
- if (!iNode->user.d) // If the shape is not built yet, just do it !
- {
- Lib3dsMesh *mesh=lib3ds_file_mesh_by_name(_3dsFile, iNode->name);
- ASSERT(mesh);
- if (!mesh)
- return;
-
- // builds the shape:
- shape = new NodeShape;
- iNode->user.d=(unsigned long)shape; // We store as user data the NodeShape address
-
- // 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);
-
- // 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);
-
- // We build the rep:
- IndexedFaceSet *rep;
- unsigned numFaces = mesh->faces;
-
- 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;
- }
-
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list