Changeset 1002
- Timestamp:
- 06/07/06 10:59:55 (19 years ago)
- Location:
- GTP/trunk/Lib/Vis
- Files:
-
- 5 added
- 28 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/include/OgrePlatformOcclusionQuery.h
r160 r1002 20 20 virtual ~PlatformOcclusionQuery(); 21 21 22 virtual bool GetQueryResult(unsigned int &queryResult, 23 const bool waitForResult) const;22 virtual bool GetQueryResult(unsigned int &queryResult, 23 const bool waitForResult) const; 24 24 virtual void BeginQuery(); 25 25 virtual void EndQuery(); -
GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/scripts/Plugin_VisibilitySceneManager.vcproj
r1001 r1002 20 20 Name="VCCLCompilerTool" 21 21 Optimization="0" 22 AdditionalIncludeDirectories=""$(OGRE_PATH)\PlugIns\OctreeSceneManager\include";"$(OGRE_ ADDONS_PATH)\dotsceneoctree\PlugIns\DotSceneManager\include";"$(OGRE_PATH)\Samples\Common\include";"$(OGRE_PATH)\Dependencies\include\CEGUI";"$(OGRE_PATH)\Samples\Common\CEGUIRenderer\include";"$(OGRE_PATH)\OgreMain\include";"$(OGRE_PATH)\Dependencies\include";..\include;..\..\GtpVisibility\include;..\..\..\..\..\Lib\Vis\OnlineCullingCHC\OGRE\include;..\..\..\..\..\Lib\Vis\OnlineCullingCHC\include"22 AdditionalIncludeDirectories=""$(OGRE_PATH)\PlugIns\OctreeSceneManager\include";"$(OGRE_PATH)\Samples\Common\include";"$(OGRE_PATH)\Dependencies\include\CEGUI";"$(OGRE_PATH)\Samples\Common\CEGUIRenderer\include";"$(OGRE_PATH)\OgreMain\include";"$(OGRE_PATH)\Dependencies\include";..\include;..\..\..\OnlineCullingCHC\include;..\..\..\Preprocessing\src" 23 23 PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;PLUGIN_OCCLUSIONCULLINGSCENEMANAGER_EXPORTS;GTP_VISIBILITY_MODIFIED_OGRE" 24 24 MinimalRebuild="TRUE" … … 36 36 Name="VCLinkerTool" 37 37 IgnoreImportLibrary="TRUE" 38 AdditionalDependencies="OgreMain_d.lib CEGUIBase_d.lib OgreGUIRenderer_d.lib Plugin_OctreeSceneManager.lib GtpVisibility.lib "38 AdditionalDependencies="OgreMain_d.lib CEGUIBase_d.lib OgreGUIRenderer_d.lib Plugin_OctreeSceneManager.lib GtpVisibility.lib zdll.lib zziplibd.lib Preprocessor.lib devil.lib glut32.lib xerces-c_2.lib OpenGL32.Lib glu32.lib cg.lib cgGL.lib glew32.lib qtmain.lib QtOpenGLd4.lib QtCored4.lib QtGuid4.lib Qt3Supportd4.lib QAxContainer.lib" 39 39 OutputFile="$(OutDir)/Plugin_VisibilitySceneManager.dll" 40 40 Version="0.99" 41 41 LinkIncremental="1" 42 42 SuppressStartupBanner="TRUE" 43 AdditionalLibraryDirectories=""$(OGRE_PATH)\OgreMain\lib\$(ConfigurationName)";"$(OGRE_PATH)\Dependencies\lib\$(ConfigurationName)";"$(OGRE_PATH)\PlugIns\OctreeSceneManager\bin\$(ConfigurationName)";"$(OGRE_PATH)\Samples\Common\CEGUIRenderer\lib";" $(OGRE_ADDONS_PATH)\dotsceneoctree\PlugIns\DotSceneManager\bin\$(ConfigurationName)";"..\lib\$(ConfigurationName)";"..\..\lib\$(ConfigurationName)";"..\..\GtpVisibility\lib\$(ConfigurationName)""43 AdditionalLibraryDirectories=""$(OGRE_PATH)\OgreMain\lib\$(ConfigurationName)";"$(OGRE_PATH)\Dependencies\lib\$(ConfigurationName)";"$(OGRE_PATH)\PlugIns\OctreeSceneManager\bin\$(ConfigurationName)";"$(OGRE_PATH)\Samples\Common\CEGUIRenderer\lib";"..\lib\$(ConfigurationName)";"..\..\lib\$(ConfigurationName)";"..\..\..\Preprocessing\lib\$(ConfigurationName)";..\..\..\Preprocessing\src\GL;..\..\..\..\..\..\..\NonGTP\Xerces\xercesc\lib;"$(QTDIR)\lib";"$(CG_LIB_PATH)"" 44 44 ModuleDefinitionFile="..\misc\OgreVisibilitySceneManager.def" 45 45 GenerateDebugInformation="TRUE" … … 104 104 Name="VCLinkerTool" 105 105 IgnoreImportLibrary="TRUE" 106 AdditionalDependencies="OgreMain.lib CEGUIBase.lib OgreGUIRenderer.lib Plugin_OctreeSceneManager.lib GtpVisibility.lib zdll.lib zziplib d.lib Preprocessor.lib xerces-c_2.lib devil.lib qtmain.lib QtOpenGL4.lib QtCored4.lib QtGuid4.lib Qt3Support4.lib QAxContainer.lib glut32.lib OpenGL32.Lib glu32.lib cg.lib cgGL.lib glew32.lib glew32s.lib"106 AdditionalDependencies="OgreMain.lib CEGUIBase.lib OgreGUIRenderer.lib Plugin_OctreeSceneManager.lib GtpVisibility.lib zdll.lib zziplib.lib Preprocessor.lib xerces-c_2.lib devil.lib qtmain.lib QtOpenGL4.lib QtCore4.lib QtGui4.lib Qt3Support4.lib QAxContainer.lib glut32.lib OpenGL32.Lib glu32.lib cg.lib cgGL.lib glew32.lib glew32s.lib" 107 107 OutputFile="$(OutDir)/Plugin_VisibilitySceneManager.dll" 108 108 Version="0.99" -
GTP/trunk/Lib/Vis/OnlineCullingCHC/scripts/GtpVisibility.vcproj
r938 r1002 20 20 Name="VCCLCompilerTool" 21 21 Optimization="0" 22 AdditionalIncludeDirectories=""$(OGRE_PATH)\OgreMain\include";..\include "22 AdditionalIncludeDirectories=""$(OGRE_PATH)\OgreMain\include";..\include;..\..\Preprocessing\src" 23 23 PreprocessorDefinitions="WIN32;_DEBUG;_LIB;GTP_VISIBILITY_MODIFIED_OGRE" 24 24 MinimalRebuild="TRUE" -
GTP/trunk/Lib/Vis/Preprocessing/scripts/Preprocessor.vcproj
r1001 r1002 15 15 OutputDirectory="..\lib\$(ConfigurationName)" 16 16 IntermediateDirectory="..\obj\$(ConfigurationName)" 17 ConfigurationType=" 1"17 ConfigurationType="4" 18 18 CharacterSet="2"> 19 19 <Tool 20 20 Name="VCCLCompilerTool" 21 21 Optimization="0" 22 AdditionalIncludeDirectories="..\ support;..\support\devil\include;..\support\zlib\include;..\include..\support;"..\include ..\support";..\include;"$(QTDIR)\include\QtCore";"$(CG_INC_PATH)";"$(QTDIR)\include";"$(QTDIR)\include\QtOpenGl";"$(QTDIR)\include\QtGui";"$(GTPDIR)\NonGTP\Zlib\include";..\..\..\..\..\..\NonGTP\Xerces;..\..\..\..\..\..\NonGTP\Devil\include;..\src"23 PreprocessorDefinitions="WIN32;_DEBUG;_LIB "22 AdditionalIncludeDirectories="..\include;"$(QTDIR)\include\QtCore";"$(QTDIR)\include\QtGui";"$(QTDIR)\include";"$(QTDIR)\include\QtOpenGl";..\src;"$(CG_INC_PATH)";..\..\..\..\..\..\NonGTP\Devil\include;..\..\..\..\..\..\NonGTP\Zlib\include;..\..\..\..\..\..\NonGTP\Xerces" 23 PreprocessorDefinitions="WIN32;_DEBUG;_LIB;" 24 24 MinimalRebuild="TRUE" 25 25 BasicRuntimeChecks="3" … … 33 33 Name="VCCustomBuildTool"/> 34 34 <Tool 35 Name="VCLinkerTool" 36 AdditionalDependencies="xerces-c_2D.lib zdll.lib zziplibd.lib devil.lib qtmain.lib QtOpenGLd4.lib QtCored4.lib QtGuid4.lib Qt3Supportd4.lib QAxContainer.lib glut32.lib OpenGL32.Lib glu32.lib cg.lib cgGL.lib" 37 AdditionalLibraryDirectories="..\support\xercesc\lib\;..\support\zlib\lib\;..\support\devil\lib;"$(QTDIR)\lib";..\include;..\src\GL;"$(CG_LIB_PATH)";"$(GTPDIR)\NonGTP\Xerces";"$(GTPDIR)\NonGTP\Xerces\xercesc\lib";"$(GTPDIR)\NonGTP\zlib\lib";"$(GTPDIR)\NonGTP\Devil\lib""/> 35 Name="VCLibrarianTool"/> 38 36 <Tool 39 37 Name="VCMIDLTool"/> … … 50 48 <Tool 51 49 Name="VCXMLDataGeneratorTool"/> 52 <Tool53 Name="VCWebDeploymentTool"/>54 50 <Tool 55 51 Name="VCManagedWrapperGeneratorTool"/> … … 68 64 FavorSizeOrSpeed="0" 69 65 OptimizeForWindowsApplication="TRUE" 70 AdditionalIncludeDirectories="..\ support;..\support\devil\include;..\support\zlib\include;..\include;"$(QTDIR)\include\QtCore";"$(QTDIR)\include\QtGui";"$(QTDIR)\include";"$(QTDIR)\include\QtOpenGl";..\src;"$(CG_INC_PATH)";..\..\..\..\..\..\NonGTP\Devil\include;..\..\..\..\..\..\NonGTP\Zlib\include;..\..\..\..\..\..\NonGTP\Xerces"66 AdditionalIncludeDirectories="..\include;"$(QTDIR)\include\QtCore";"$(QTDIR)\include\QtGui";"$(QTDIR)\include";"$(QTDIR)\include\QtOpenGl";..\src;"$(CG_INC_PATH)";..\..\..\..\..\..\NonGTP\Devil\include;..\..\..\..\..\..\NonGTP\Zlib\include;..\..\..\..\..\..\NonGTP\Xerces" 71 67 PreprocessorDefinitions="WIN32;NDEBUG;_LIB;" 72 68 ExceptionHandling="TRUE" -
GTP/trunk/Lib/Vis/Preprocessing/scripts/TestPreprocessor.vcproj
r1001 r1002 13 13 <Configuration 14 14 Name="Debug|Win32" 15 OutputDirectory=" Debug"16 IntermediateDirectory=" Debug"15 OutputDirectory="..\bin\Debug" 16 IntermediateDirectory="..\obj\Debug" 17 17 ConfigurationType="1" 18 18 CharacterSet="2"> … … 20 20 Name="VCCLCompilerTool" 21 21 Optimization="0" 22 AdditionalIncludeDirectories="..\include;"$(QTDIR)\include\QtCore";"$(QTDIR)\include\QtGui";"$(QTDIR)\include";"$(QTDIR)\include\QtOpenGl";..\src;"$(CG_INC_PATH)";..\..\..\..\..\..\NonGTP\Devil\include;..\..\..\..\..\..\NonGTP\Zlib\include;..\..\..\..\..\..\NonGTP\Xerces" 22 23 PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE" 23 24 MinimalRebuild="TRUE" 24 25 BasicRuntimeChecks="3" 25 RuntimeLibrary=" 5"26 RuntimeLibrary="3" 26 27 UsePrecompiledHeader="0" 27 28 WarningLevel="3" … … 32 33 <Tool 33 34 Name="VCLinkerTool" 34 AdditionalDependencies="xerces-c_2D.lib zdll.lib zziplibd.lib devil.lib qtmain.lib QtOpenGLd4.lib QtCored4.lib QtGuid4.lib Qt3Supportd4.lib QAxContainer.lib glut32.lib OpenGL32.Lib glu32.lib cg.lib cgGL.lib "35 OutputFile="$(OutDir)/ TestPreprocessor.exe"35 AdditionalDependencies="xerces-c_2D.lib zdll.lib zziplibd.lib devil.lib qtmain.lib QtOpenGLd4.lib QtCored4.lib QtGuid4.lib Qt3Supportd4.lib QAxContainer.lib glut32.lib OpenGL32.Lib glu32.lib cg.lib cgGL.lib Preprocessor.lib glew32.lib" 36 OutputFile="$(OutDir)/Preprocessor.exe" 36 37 LinkIncremental="2" 37 AdditionalLibraryDirectories=" ..\support\xercesc\lib\;..\support\zlib\lib\;..\support\devil\lib;"$(QTDIR)\lib";..\include;..\src\GL;"$(CG_LIB_PATH)";"$(GTPDIR)\NonGTP\Xerces";"$(GTPDIR)\NonGTP\Xerces\xercesc\lib";"$(GTPDIR)\NonGTP\zlib\lib";"$(GTPDIR)\NonGTP\Devil\lib""38 AdditionalLibraryDirectories=""$(QTDIR)\lib";..\include;..\src\GL;"$(CG_LIB_PATH)";"$(GTPDIR)\NonGTP\Xerces";"$(GTPDIR)\NonGTP\Xerces\xercesc\lib";"$(GTPDIR)\NonGTP\zlib\lib";"$(GTPDIR)\NonGTP\Devil\lib";..\lib\debug" 38 39 GenerateDebugInformation="TRUE" 39 40 ProgramDatabaseFile="$(OutDir)/TestPreprocessor.pdb" … … 69 70 <Tool 70 71 Name="VCCLCompilerTool" 71 AdditionalIncludeDirectories="..\ support;..\support\devil\include;..\support\zlib\include;..\include;"$(QTDIR)\include\QtCore";"$(QTDIR)\include\QtGui";"$(QTDIR)\include";"$(QTDIR)\include\QtOpenGl";..\src;"$(CG_INC_PATH)";..\..\..\..\..\..\NonGTP\Devil\include;..\..\..\..\..\..\NonGTP\Zlib\include;..\..\..\..\..\..\NonGTP\Xerces"72 AdditionalIncludeDirectories="..\include;"$(QTDIR)\include\QtCore";"$(QTDIR)\include\QtGui";"$(QTDIR)\include";"$(QTDIR)\include\QtOpenGl";..\src;"$(CG_INC_PATH)";..\..\..\..\..\..\NonGTP\Devil\include;..\..\..\..\..\..\NonGTP\Zlib\include;..\..\..\..\..\..\NonGTP\Xerces" 72 73 PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE" 73 74 RuntimeLibrary="2" … … 83 84 OutputFile="$(OutDir)/Preprocessor.exe" 84 85 LinkIncremental="1" 85 AdditionalLibraryDirectories="..\support\xercesc\lib\;..\support\zlib\lib\;..\support\devil\lib;"$(QTDIR)\lib";..\include;..\src\GL;"$(CG_LIB_PATH)"; ..\..\..\..\..\..\NonGTP\Xerces;..\..\..\..\..\..\NonGTP\Xerces\xercesc\lib;..\..\..\..\..\..\NonGTP\zlib\lib;..\..\..\..\..\..\NonGTP\Devil\lib;"..\..\Preprocessing\lib\$(ConfigurationName)""86 AdditionalLibraryDirectories="..\support\xercesc\lib\;..\support\zlib\lib\;..\support\devil\lib;"$(QTDIR)\lib";..\include;..\src\GL;"$(CG_LIB_PATH)";"$(GTPDIR)\NonGTP\Xerces";"$(GTPDIR)\NonGTP\Xerces\xercesc\lib";"$(GTPDIR)\NonGTP\zlib\lib";"$(GTPDIR)\NonGTP\Devil\lib";..\lib\release" 86 87 GenerateDebugInformation="FALSE" 87 88 SubSystem="1" -
GTP/trunk/Lib/Vis/Preprocessing/src/Environment.cpp
r1001 r1002 245 245 void 246 246 Environment::RegisterOption(const char *name, 247 248 249 247 const EOptType type, 248 const char *abbrev, 249 const char *defValue) 250 250 { 251 251 int i; … … 2154 2154 RegisterOption("VspBspTree.Construction.renderCostWeight", 2155 2155 optFloat, 2156 " -vsp_bsp_post_process_render_cost_weight",2156 "vsp_bsp_post_process_render_cost_weight=", 2157 2157 "0.5"); 2158 2158 -
GTP/trunk/Lib/Vis/Preprocessing/src/FromPointVisibilityTree.cpp
r1001 r1002 304 304 dynamic_cast<TransformedMeshInstance *>(object); 305 305 306 if (!mi->GetMesh()) 306 if (!mi->GetMesh()) 307 307 break; 308 309 mesh = new Mesh(*mi->GetMesh()); 310 311 Matrix4x4 m; 312 mi->GetWorldTransform(m); 313 mesh->ApplyTransformation(m); 308 mesh = new Mesh(); 309 mi->GetTransformedMesh(*mesh); 314 310 315 311 break; … … 361 357 { 362 358 VssRay *ray = *rit; 359 Intersectable *obj = ray->mTerminationObject; 363 360 364 361 if ((mBox.IsInside(ray->mTermination) || !forcedBoundingBox) && 365 ray->mTerminationObject && 366 !ray->mTerminationObject->Mailed()) 367 { 368 ray->mTerminationObject->Mail(); 369 MeshInstance *obj = dynamic_cast<MeshInstance *>(ray->mTerminationObject); 370 AddMeshToPolygons(obj->GetMesh(), polys, obj); 371 ++ numObj; 362 obj && !obj->Mailed()) 363 { 364 obj->Mail(); 365 366 // transformed mesh instance and mesh instance handle mesh differently 367 if (obj->Type() == Intersectable::TRANSFORMED_MESH_INSTANCE) 368 { 369 Mesh mesh; 370 371 TransformedMeshInstance *tmobj = 372 dynamic_cast<TransformedMeshInstance *>(obj); 373 374 tmobj->GetTransformedMesh(mesh); 375 AddMeshToPolygons(&mesh, polys, tmobj); 376 } 377 else // MeshInstance 378 { 379 MeshInstance *mobj = dynamic_cast<MeshInstance *>(obj); 380 AddMeshToPolygons(mobj->GetMesh(), polys, mobj); 381 } 372 382 373 383 //-- compute bounding box … … 802 812 803 813 // update single pvs parameter 804 viewCell->mPvsSize = viewCell->GetPvs().GetSize(); 805 viewCell->mPvsSizeValid = true; 806 814 mViewCellsManager->SetScalarPvsSize(viewCell, viewCell->GetPvs().GetSize()); 815 807 816 808 817 mBspStats.contributingSamples += conSamp; … … 936 945 AddToPvs(leaf, *tData.mRays, sampCon, conSamp); 937 946 938 viewCell->mPvsSize = viewCell->GetPvs().GetSize(); 939 viewCell->mPvsSizeValid = true; 940 947 mViewCellsManager->SetScalarPvsSize(viewCell, viewCell->GetPvs().GetSize()); 948 941 949 mBspStats.contributingSamples += conSamp; 942 950 mBspStats.sampleContributions +=(int) sampCon; -
GTP/trunk/Lib/Vis/Preprocessing/src/FromPointVisibilityTree.h
r863 r1002 33 33 { 34 34 Vector3 mPosition; 35 35 36 /// from point visibility => visible objects, not potentially 36 37 ObjectPvs mVisibleObjects; … … 39 40 40 41 /** 41 This is a view space partitioning specialised BSPtree. 42 There are no polygon splits, but we split the sample rays. 43 The candidates for the next split plane are evaluated only 44 by checking the sampled visibility information. 45 The polygons are employed merely as candidates for the next split planes. 42 This is a tree which partitions from point queries in a greedy optimal fashion. 46 43 */ 47 44 class FromPointVisibilityTree … … 49 46 friend class ViewCellsParseHandlers; 50 47 friend class VspBspViewCellsManager; 48 51 49 public: 52 50 -
GTP/trunk/Lib/Vis/Preprocessing/src/GlRenderer.cpp
r1001 r1002 187 187 188 188 glPushMatrix(); 189 /* 190 cout << "\n*******" << endl; 191 for (int i = 0; i < 16; ++ i) 192 cout << (float *)(m.x)[i] << " "; 193 194 cout << "\n*******" << endl; 189 /* cout << "\n"; 195 190 for (int i = 0; i < 4; ++ i) 196 191 for (int j = 0; j < 4; ++ j) 197 cout << m.x[i][j] << " "; 198 199 cout << "\n==" << endl;*/ 192 cout << m.x[i][j] << " "; cout << "\n"*/ 200 193 201 194 glMultMatrixf((float *)m.x); 202 GLfloat dummy[16]; 203 204 /*glGetFloatv(GL_MODELVIEW_MATRIX, dummy); 205 195 196 /*GLfloat dummy[16]; 197 glGetFloatv(GL_MODELVIEW_MATRIX, dummy); 206 198 for (int i = 0; i < 16; ++ i) 207 199 cout << dummy[i] << " "; … … 631 623 sample.mVisibleObjects = 0; 632 624 633 int i, j;634 635 625 // reset object counters 636 626 ObjectContainer::const_iterator it, it_end = mObjects.end(); … … 649 639 650 640 // query all 6 directions for a full point sample 651 for (i = 0; i < 6; ++ i)641 for (int i = 0; i < 6; ++ i) 652 642 { 653 643 mViewDirection = directions[i]; … … 718 708 SetupProjection(GetHeight(), GetHeight(), 90.0f); 719 709 720 samples.resize(numSamples);710 //samples.resize(numSamples); 721 711 halton.Reset(); 722 712 723 713 // the number of queries queried in batch mode 724 714 const int numQ = 500; 715 725 716 //const int numQ = (int)mObjects.size(); 726 717 if (useOcclusionQueries) -
GTP/trunk/Lib/Vis/Preprocessing/src/KdTree.cpp
r904 r1002 21 21 mDepth = 0; 22 22 } 23 24 25 KdInterior::~KdInterior() 26 { 27 // recursivly destroy children 28 DEL_PTR(mFront); 29 DEL_PTR(mBack); 30 } 31 23 32 24 33 KdTree::KdTree() … … 54 63 splitCandidates = NULL; 55 64 } 65 66 67 KdTree::~KdTree() 68 { 69 DEL_PTR(mRoot); 70 } 71 56 72 57 73 bool -
GTP/trunk/Lib/Vis/Preprocessing/src/KdTree.h
r878 r1002 97 97 bool Mailed() const { return mailbox == mailID; } 98 98 99 99 virtual ~KdNode(){}; 100 100 KdNode(KdInterior *parent); 101 101 … … 124 124 125 125 KdInterior(KdInterior *parent):KdNode(parent), mBack(NULL), mFront(NULL) {} 126 127 ~KdInterior(); 126 128 127 129 /** \sa KdNode::IsLeaf() */ … … 170 172 } 171 173 174 ~KdLeaf() { DEL_PTR(mViewCell); } 172 175 173 176 void AddPassingRay2(const Ray &ray, … … 254 257 255 258 KdTree(); 256 259 260 ~KdTree(); 257 261 258 262 /** Insert view cell into the tree */ -
GTP/trunk/Lib/Vis/Preprocessing/src/Mesh.cpp
r1001 r1002 608 608 mFaces.reserve(rhs.mFaces.size()); 609 609 mId = rhs.mId; 610 mMaterial = rhs.mMaterial; 610 611 611 612 FaceContainer::const_iterator it, it_end = rhs.mFaces.end(); … … 628 629 mVertices = m.mVertices; 629 630 mFaces.reserve(m.mFaces.size()); 631 mMaterial = m.mMaterial; 632 // note: we don't copy id on purpose 630 633 //mId = m.mId; 631 634 632 635 FaceContainer::const_iterator it, it_end = m.mFaces.end(); 633 636 … … 695 698 696 699 /*************************************************************/ 697 /* TransformedMeshInstance implementation*/700 /* TransformedMeshInstance implementation */ 698 701 /*************************************************************/ 699 702 … … 747 750 } 748 751 749 750 } 752 void TransformedMeshInstance::GetTransformedMesh(Mesh &transformedMesh) 753 { 754 // copy mesh 755 transformedMesh = *mMesh; 756 transformedMesh.ApplyTransformation(mWorldTransform); 757 } 758 759 } -
GTP/trunk/Lib/Vis/Preprocessing/src/Mesh.h
r1001 r1002 329 329 void GetWorldTransform(Matrix4x4 &m); 330 330 331 /** Transforms mesh- 332 @param transformedMesh returns the tranformed mesh. 333 */ 334 void GetTransformedMesh(Mesh &transformedMesh); 335 331 336 protected: 332 337 -
GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp
r1001 r1002 115 115 mVspKdTree(NULL), 116 116 mVspBspTree(NULL), 117 mViewCellsManager(NULL) 117 mViewCellsManager(NULL), 118 mRenderSimulator(NULL) 118 119 { 119 120 environment->GetBoolValue("Preprocessor.useGlRenderer", mUseGlRenderer); … … 165 166 DEL_PTR(mVspBspTree); 166 167 cout << "done.\n"; 168 169 cout << "Deleting scene graph...\n"; 170 DEL_PTR(mSceneGraph); 171 cout << "done.\n"; 172 173 DEL_PTR(mRenderSimulator); 174 DEL_PTR(renderer); 167 175 } 168 176 … … 276 284 if (mApplyVisibilityFilter || mApplyVisibilitySpatialFilter) { 277 285 cout<<"Applying visibility filter ..."; 278 cout<<"filyter width = " << mVisibilityFilterWidth << endl; 279 286 cout<<"filter width = " << mVisibilityFilterWidth << endl; 287 288 if (!mViewCellsManager) 289 return false; 290 280 291 mViewCellsManager->ApplyFilter(mKdTree, 281 292 mApplyVisibilityFilter ? mVisibilityFilterWidth : -1.0f, … … 361 372 { 362 373 //-- parse type of view cell container 363 char viewCellsStr[64]; 364 environment->GetStringValue("ViewCells.type", viewCellsStr); 365 366 mViewCellsManager = CreateViewCellsManager(viewCellsStr); 374 environment->GetStringValue("ViewCells.type", buf); 375 mViewCellsManager = CreateViewCellsManager(buf); 367 376 } 368 377 -
GTP/trunk/Lib/Vis/Preprocessing/src/RenderSampler.cpp
r1001 r1002 33 33 cout << "starting sampling of render cost ... "; 34 34 35 vector<RenderCostSample> samples ;36 while (1){cout <<"q";}35 vector<RenderCostSample> samples(mSamples); 36 37 37 if (renderer) 38 38 { … … 57 57 histogram[i] = 0; 58 58 } 59 59 cout << "here3 "<< mSamples << endl; 60 cout << "here2 " << samples.size() << endl; 60 61 // store maximal pvs 61 62 for (int i = 0; i < mSamples; ++ i) -
GTP/trunk/Lib/Vis/Preprocessing/src/ResourceManager.h
r1001 r1002 114 114 for (mit = mEntries.begin(); mit != mEntries.end(); ++ mit) 115 115 { 116 cout << "mesh: " << (*mit).first << " " << (*mit).second << endl;116 //cout << "mesh: " << (*mit).first << " " << (*mit).second << endl; 117 117 DEL_PTR((*mit).second); 118 118 } -
GTP/trunk/Lib/Vis/Preprocessing/src/SceneGraph.cpp
r863 r1002 25 25 return false; 26 26 27 } 28 29 30 SceneGraph::~SceneGraph() 31 { 32 DEL_PTR(mRoot); 33 } 34 35 36 SceneGraphNode::~SceneGraphNode() 37 { 38 CLEAR_CONTAINER(mGeometry); 39 SceneGraphNodeContainer::iterator it, it_end = mChildren.end(); 40 41 // recursivly delete all children 42 CLEAR_CONTAINER(mChildren); 27 43 } 28 44 -
GTP/trunk/Lib/Vis/Preprocessing/src/SceneGraph.h
r860 r1002 11 11 12 12 /** Basic scene graph node, we are interested only in bounding boxes and topology 13 of the scene graph */ 13 of the scene graph 14 */ 14 15 class SceneGraphNode { 15 16 public: … … 17 18 SceneGraphNodeContainer mChildren; 18 19 AxisAlignedBox3 mBox; 20 ~SceneGraphNode(); 19 21 void UpdateBox(); 20 22 }; … … 25 27 26 28 public: 29 30 ~SceneGraph(); 31 27 32 SceneGraphNode *mRoot; 28 33 bool Export(const string filename); -
GTP/trunk/Lib/Vis/Preprocessing/src/UnigraphicsParser.cpp
r1001 r1002 161 161 if (ROTATE_SCENE) 162 162 RotateMesh(currentMesh); 163 currentMesh->Preprocess(); 164 // make an instance of this mesh 165 MeshInstance *mi = new MeshInstance(currentMesh); 166 root->mGeometry.push_back(mi); 167 currentMesh = new Mesh; 163 164 currentMesh->Preprocess(); 165 // make an instance of this mesh 166 MeshInstance *mi = new MeshInstance(currentMesh); 167 root->mGeometry.push_back(mi); 168 currentMesh = MeshManager::GetSingleton()->CreateResource(); 168 169 } 169 170 } -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCell.cpp
r997 r1002 55 55 } 56 56 57 57 /// Counts differences between pvss. 58 58 inline int CountDiffPvs(ViewCell *vc) 59 59 { … … 100 100 101 101 return pvs; 102 }103 104 // computet render cost of merge105 float ViewCellsTree::ComputeMergedPvsCost(const ObjectPvs &pvs1,106 const ObjectPvs &pvs2) const107 {108 float renderCost = 0;109 110 // compute new pvs size111 ObjectPvsMap::const_iterator it, it_end = pvs1.mEntries.end();112 113 Intersectable::NewMail();114 115 // first mail all objects in first pvs116 for (it = pvs1.mEntries.begin(); it != it_end; ++ it)117 {118 Intersectable *obj = (*it).first;119 120 obj->Mail();121 renderCost += mViewCellsManager->EvalRenderCost(obj);122 }123 124 it_end = pvs2.mEntries.end();125 126 127 for (it = pvs2.mEntries.begin(); it != it_end; ++ it)128 {129 Intersectable *obj = (*it).first;130 131 // test if object already considered132 if (!obj->Mailed())133 {134 renderCost += mViewCellsManager->EvalRenderCost(obj);135 }136 }137 138 return renderCost;139 102 } 140 103 … … 281 244 } 282 245 246 247 bool ViewCell::AddPvsSample(Intersectable *sample, 248 const float pdf, 249 float &contribution) 250 { 251 const bool result = mPvs.AddSample(sample, pdf, contribution); 252 253 // update pvs size 254 mPvsSize = mPvs.GetSize(); 255 mPvsSizeValid = true; 256 257 return result; 258 } 259 260 261 262 283 263 /************************************************************************/ 284 264 /* class ViewCellInterior implementation */ … … 315 295 { 316 296 mChildren.push_back(vc); 317 vc-> mParent = this;297 vc->SetParent(this); 318 298 } 319 299 … … 797 777 798 778 cout << "finished" << endl; 779 } 780 781 782 float ViewCellsTree::ComputeMergedPvsCost(const ObjectPvs &pvs1, 783 const ObjectPvs &pvs2) const 784 { 785 // computes render cost of merge 786 float renderCost = 0; 787 788 // compute new pvs size 789 ObjectPvsMap::const_iterator it, it_end = pvs1.mEntries.end(); 790 791 Intersectable::NewMail(); 792 793 // first mail all objects in first pvs 794 for (it = pvs1.mEntries.begin(); it != it_end; ++ it) 795 { 796 Intersectable *obj = (*it).first; 797 798 obj->Mail(); 799 renderCost += mViewCellsManager->EvalRenderCost(obj); 800 } 801 802 it_end = pvs2.mEntries.end(); 803 804 805 for (it = pvs2.mEntries.begin(); it != it_end; ++ it) 806 { 807 Intersectable *obj = (*it).first; 808 809 // test if object already considered 810 if (!obj->Mailed()) 811 { 812 renderCost += mViewCellsManager->EvalRenderCost(obj); 813 } 814 } 815 816 return renderCost; 799 817 } 800 818 … … 2146 2164 { 2147 2165 // if one has a parent, it was already merged 2148 return !(mLeftViewCell-> mParent || mRightViewCell->mParent);2166 return !(mLeftViewCell->GetParent() || mRightViewCell->GetParent()); 2149 2167 } 2150 2168 -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCell.h
r997 r1002 98 98 friend class ViewCellsTree; 99 99 friend class ViewCellsManager; 100 friend class VspBspViewCellsManager;101 friend class BspViewCellsManager;102 friend class VspBspTree;103 friend class FromPointVisibilityTree;104 friend class BspTree;100 //friend class VspBspViewCellsManager; 101 //friend class BspViewCellsManager; 102 //friend class VspBspTree; 103 //friend class FromPointVisibilityTree; 104 //friend class BspTree; 105 105 106 106 … … 120 120 const ObjectPvs &GetPvs() const; 121 121 122 /** Returns pvs. 123 */ 122 124 ObjectPvs &GetPvs(); 123 125 126 /** Completely substitutes the pvs. 127 */ 124 128 void SetPvs(const ObjectPvs &pvs); 125 129 … … 128 132 int Type() const; 129 133 134 135 /** Adds a passing ray to the passing ray container. 136 */ 137 void AddPassingRay(const Ray &ray, const int contributions); 138 139 /** Returns volume of the view cell. 140 */ 141 float GetVolume() const; 142 143 /** Returns area of the view cell. 144 */ 145 float GetArea() const; 146 147 /** Sets the volume of the view cell. 148 */ 149 void SetVolume(float volume); 150 151 /** Sets the area of the view cell. 152 */ 153 void SetArea(float area); 154 155 156 /** if this view cell is the root of a view cell hierarchy 157 */ 158 bool IsRoot() const; 159 160 /** Returns parent view cell. 161 */ 162 ViewCellInterior *GetParent() const; 163 164 /** Sets parent of this view cell. 165 */ 130 166 void SetParent(ViewCellInterior *parent); 131 167 132 /** Adds a passing ray to the passing ray container. 133 */ 134 void AddPassingRay(const Ray &ray, const int contributions); 135 136 /** Returns volume of the view cell. 137 */ 138 float GetVolume() const; 139 140 /** Returns area of the view cell. 141 */ 142 float GetArea() const; 143 144 /** Sets the volume of the view cell. 145 */ 146 void SetVolume(float volume); 147 148 /** Sets the area of the view cell. 149 */ 150 void SetArea(float area); 151 152 153 /** if this view cell is the root of a view cell hierarchy 154 */ 155 bool IsRoot() const; 156 157 /** Returns parent view cell. 158 */ 159 ViewCellInterior *GetParent() const; 160 161 168 162 169 /** Sets the mesh for this view cell. 163 170 */ 164 171 void SetMesh(Mesh *mesh); 165 172 173 /** Sets this view cell to be a valid view cell according to some criteria. 174 */ 166 175 void SetValid(const bool valid); 176 /** Returns true if this view cell is considered to be valid according to 177 some criteria. 178 */ 167 179 bool GetValid() const; 168 180 … … 179 191 RgbColor GetColor() const; 180 192 193 /** Adds a sample to the pvs. 194 @param sample the sample to be added 195 @param pdf a continuos measure of visibility 196 @param contribution returns the contribution of this sample to the pvs 197 */ 198 bool AddPvsSample(Intersectable *sample, const float pdf, float &contribution); 181 199 182 /// parent view cell in the view cell hierarchy 183 ViewCellInterior *mParent; 200 184 201 185 202 /// Rays piercing this view cell. … … 211 228 } 212 229 230 /** Sets merge cost used for merging this view cell from other cells. 231 @hack The function is available for leaves also to have a common interface, 232 but it should be less than zero for leaves. 233 */ 213 234 void SetMergeCost(const float mergeCost); 214 235 236 /** Returns merge cost needed to merge this leaf from other cells. 237 @hack The function is available for leaves also to have a common interface, 238 but it should be less than zero for leaves. 239 */ 215 240 float GetMergeCost() const; 241 242 243 244 //////////////////////////////////////////// 245 // mailing stuff 246 216 247 217 248 static void NewMail(const int reserve = 1) … … 228 259 229 260 int IncMail() { return ++mMailbox - sMailId; } 230 231 261 232 262 … … 239 269 protected: 240 270 271 /// parent view cell in the view cell hierarchy 272 ViewCellInterior *mParent; 273 241 274 /// the potentially visible objects 242 275 ObjectPvs mPvs; … … 253 286 254 287 255 /// pvs size, used for lazy pvs computation288 /// store pvs size, used for evaluation purpose when pvss are stored only in the leaves 256 289 int mPvsSize; 257 /// if the given pvs size isthe real pvs size290 /// if the pvs size scalar is up to date and corresponding to the real pvs size 258 291 bool mPvsSizeValid; 259 292 -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellBsp.cpp
r1001 r1002 661 661 case Intersectable::TRANSFORMED_MESH_INSTANCE: 662 662 { 663 TransformedMeshInstance *mi = 664 dynamic_cast<TransformedMeshInstance *>(object); 665 666 if (!mi->GetMesh()) 663 TransformedMeshInstance *mi = dynamic_cast<TransformedMeshInstance *>(object); 664 665 if (!mi->GetMesh()) 667 666 break; 668 669 mesh = new Mesh(*mi->GetMesh()); 670 671 Matrix4x4 m; 672 mi->GetWorldTransform(m); 673 mesh->ApplyTransformation(m); 667 mesh = new Mesh(); 668 mi->GetTransformedMesh(*mesh); 674 669 675 670 break; … … 773 768 } 774 769 } 770 771 CLEAR_CONTAINER(boxPolys); 775 772 } 776 773 … … 810 807 { 811 808 MeshInstance *obj = dynamic_cast<MeshInstance *>(ray->intersections[0].mObject); 812 Face *face = obj->GetMesh()->mFaces[ray->intersections[0].mFace]; 813 809 810 Mesh *mesh; 811 if (obj->Type() == Intersectable::TRANSFORMED_MESH_INSTANCE) 812 { 813 TransformedMeshInstance *tmobj = 814 dynamic_cast<TransformedMeshInstance *>(obj); 815 816 mesh = new Mesh(); 817 tmobj->GetTransformedMesh(*mesh); 818 } 819 else // MeshInstance 820 { 821 mesh = obj->GetMesh(); 822 } 823 824 Face *face = mesh->mFaces[ray->intersections[0].mFace]; 814 825 std::map<Face *, Polygon3 *>::iterator it = facePolyMap.find(face); 815 826 … … 821 832 } 822 833 else 823 { //store rays if needed for heuristics 824 Polygon3 *poly = new Polygon3(face, obj->GetMesh()); 834 { 835 //store rays if needed for heuristics 836 Polygon3 *poly = new Polygon3(face, mesh); 825 837 poly->mParent = obj; 826 838 polys->push_back(poly); … … 831 843 facePolyMap[face] = poly; 832 844 } 845 846 // cleanup 847 if (obj->Type() == Intersectable::TRANSFORMED_MESH_INSTANCE) 848 DEL_PTR(mesh); 833 849 } 834 850 } -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp
r1001 r1002 39 39 }; 40 40 41 //typedef priority_queue<ViewCell *, vector<ViewCell *>, myless<vector<ViewCell *>::value_type> > FilterQueue;42 43 44 41 45 42 ViewCellsManager::ViewCellsManager(Environment *env): … … 205 202 ViewCellsManager::~ViewCellsManager() 206 203 { 207 DEL_PTR(mRenderer);204 //DEL_PTR(mRenderer); 208 205 209 206 if (!ViewCellsTreeConstructed()) 210 207 CLEAR_CONTAINER(mViewCells); 211 else212 208 //else 209 DEL_PTR(mViewCellsTree); 213 210 } 214 211 … … 306 303 } 307 304 } 308 Debug << "\nSampled " << i << " new view cells (" << " of " << (int)mEmptyViewCells.size() << ")" << endl << endl; 305 Debug << "\nSampled " << i << " new view cells (" 306 << " of " << (int)mEmptyViewCells.size() << ")" << endl << endl; 309 307 } 310 308 … … 395 393 << TimeDiff(startTime, GetTime()) * 1e-3 << " secs" << endl; 396 394 397 395 return 0; 398 396 // take post processing time 399 397 startTime = GetTime(); 400 398 401 402 // testing the view cell filter functionality403 if (0) TestFilter(preprocessor->mObjects);404 405 399 // -- stats after contruction 406 400 ResetViewCells(); 407 408 401 Debug << "\nView cells after initial sampling:\n" << mCurrentViewCellsStats << endl; 402 409 403 410 404 if (1) // export initial view cells … … 473 467 474 468 475 476 469 //-- post processing 477 470 VssRayContainer postProcessSamples; … … 494 487 495 488 496 497 489 cout << "starting post processing and visualization" << endl; 498 490 … … 514 506 << TimeDiff(startTime, GetTime()) *1e-3 << " secs" << endl; 515 507 516 // only for debugging purpose517 if (TEST_EMPTY_VIEW_CELLS) 518 CollectEmptyViewCells();519 508 disposeRays(postProcessSamples, outRays); 509 510 511 //return 1; 520 512 // evaluation of the paritition, i.e., a number of new samples are cast 521 513 if (mEvaluateViewCells) … … 523 515 EvalViewCellPartition(preprocessor); 524 516 } 525 517 518 526 519 //-- visualization 527 520 if (mShowVisualization) … … 679 672 const ObjectContainer &objects) 680 673 { 681 if (!ViewCellsConstructed() )674 if (!ViewCellsConstructed() || !ViewCellsTreeConstructed()) 682 675 return false; 683 676 … … 764 757 sort(viewCells.begin(), viewCells.end(), ViewCell::SmallerPvs); 765 758 766 //Debug << "********************" << endl;767 //for (int i = 0; i < viewCells.size(); ++ i)768 // Debug << "pvs: " << mViewCellsTree->GetPvsSize(viewCells[i]) << " ";769 //Debug << "\n";770 759 maxPvs = mViewCellsTree->GetPvsSize(viewCells.back()); 771 760 minVal = 0; … … 844 833 845 834 835 bool ViewCellsManager::GetExportPvs() const 836 { 837 return mExportPvs; 838 } 839 840 846 841 void ViewCellsManager::EvalViewCellPartition(Preprocessor *preprocessor) 847 842 { … … 862 857 Debug << "view cell stats prefix: " << statsPrefix << endl; 863 858 864 //VssRayContainer outRays;859 865 860 // should directional sampling be used? 866 861 bool dirSamples = (mEvaluationSamplingType == Preprocessor::DIRECTION_BASED_DISTRIBUTION); … … 932 927 933 928 //-- histogram 934 935 929 936 930 bool useHisto; … … 1207 1201 bool ViewCellsManager::ViewCellsTreeConstructed() const 1208 1202 { 1209 return mViewCellsTree->GetRoot();1203 return (mViewCellsTree && mViewCellsTree->GetRoot()); 1210 1204 } 1211 1205 … … 1419 1413 1420 1414 1421 void ViewCellsManager::DeriveViewCells (const ObjectContainer &objects,1422 1423 1415 void ViewCellsManager::DeriveViewCellsFromObjects(const ObjectContainer &objects, 1416 ViewCellContainer &viewCells, 1417 const int maxViewCells) const 1424 1418 { 1425 1419 // maximal max viewcells … … 1444 1438 1445 1439 Mesh *mesh = MeshManager::GetSingleton()->CreateResource(); 1446 1447 // copy mesh 1448 *mesh = *mi->GetMesh(); 1449 1440 1450 1441 // transform mesh 1451 Matrix4x4 m; 1452 mi->GetWorldTransform(m); 1453 mesh->ApplyTransformation(m); 1442 mi->GetTransformedMesh(*mesh); 1454 1443 1455 1444 // create bb + kd tree … … 2168 2157 2169 2158 2159 void ViewCellsManager::SetScalarPvsSize(ViewCell *vc, const int pvsSize) const 2160 { 2161 vc->mPvsSize = pvsSize; 2162 vc->mPvsSizeValid = true; 2163 } 2164 2165 2170 2166 /**********************************************************************/ 2171 2167 /* BspViewCellsManager implementation */ … … 2964 2960 { 2965 2961 pvs = root->GetPvs(); 2966 2967 root->mPvsSize = pvs.GetSize(); 2968 root->mPvsSizeValid = true; 2969 2962 SetScalarPvsSize(root, pvs.GetSize()); 2963 2970 2964 return; 2971 2965 } … … 3018 3012 if (mViewCellsTree->ViewCellsStorage() == ViewCellsTree::PVS_IN_INTERIORS) 3019 3013 { 3020 interior-> mPvs = pvs;3014 interior->SetPvs(pvs); 3021 3015 } 3022 3016 3023 3017 // set new pvs size 3024 interior->mPvsSize = pvs.GetSize(); 3025 interior->mPvsSizeValid = true; 3018 SetScalarPvsSize(interior, pvs.GetSize()); 3026 3019 3027 3020 #else … … 3781 3774 Debug << "saved rays: " << (int)savedRays.size() << endl; 3782 3775 3783 3784 //TODO: remove 3776 long startTime; 3777 3785 3778 if (1) 3786 3779 mVspBspTree->Construct(constructionRays, &mViewSpaceBox); … … 3790 3783 // collapse invalid regions 3791 3784 cout << "collapsing invalid tree regions ... "; 3792 longstartTime = GetTime();3793 int collapsedLeaves = mVspBspTree->CollapseTree();3785 startTime = GetTime(); 3786 const int collapsedLeaves = mVspBspTree->CollapseTree(); 3794 3787 Debug << "collapsed in " << TimeDiff(startTime, GetTime()) * 1e-3 3795 3788 << " seconds" << endl; … … 3797 3790 cout << "finished" << endl; 3798 3791 3799 // 3792 //-- stats 3800 3793 Debug << mVspBspTree->GetStatistics() << endl; 3801 3794 … … 4211 4204 { 4212 4205 pvs = root->GetPvs(); 4213 4214 root->mPvsSize = root->GetPvs().GetSize(); 4215 root->mPvsSizeValid = true; 4216 4206 SetScalarPvsSize(root, root->GetPvs().GetSize()); 4207 4217 4208 return; 4218 4209 } … … 4266 4257 if (mViewCellsTree->ViewCellsStorage() == ViewCellsTree::PVS_IN_INTERIORS) 4267 4258 { 4268 interior-> mPvs = pvs;4259 interior->SetPvs(pvs); 4269 4260 } 4270 4261 4271 4262 // set new pvs size 4272 interior->mPvsSize = pvs.GetSize();4273 interior->mPvsSizeValid = true;4263 SetScalarPvsSize(interior, pvs.GetSize()); 4264 4274 4265 4275 4266 #else … … 4325 4316 GetRaySets(sampleRays, mVisualizationSamples, visRays); 4326 4317 4327 4328 if (1) // export view cells4318 //-- export view cells 4319 if (1) 4329 4320 { // hack pvs 4330 int savedColorCode = mColorCode;4321 const int savedColorCode = mColorCode; 4331 4322 mColorCode = 1; 4332 4323 … … 4367 4358 mColorCode = savedColorCode; 4368 4359 } 4360 4369 4361 4370 4362 if (0) … … 5035 5027 // AxisAlignedBox3 box(center - Vector3(viewSpaceFilterSize/2), 5036 5028 // center + Vector3(viewSpaceFilterSize/2)); 5037 5038 5029 if (!ViewCellsConstructed()) 5039 5030 return; 5040 5031 5041 if (viewSpaceFilterSize >=0.0f) {5032 if (viewSpaceFilterSize >= 0.0f) { 5042 5033 5043 5034 bool usePrVS = false; 5044 5035 5045 5046 5036 if (!usePrVS) { 5047 5037 AxisAlignedBox3 box = GetViewCellBox(viewCell); … … 5052 5042 5053 5043 // cout<<"box="<<box<<endl; 5054 ViewCellContainer::const_iterator it =viewCells.begin(), it_end = viewCells.end();5044 ViewCellContainer::const_iterator it = viewCells.begin(), it_end = viewCells.end(); 5055 5045 5056 5046 int i; 5057 for (i=0; it != it_end; ++ it, i++) {5058 //cout<<"v"<<i<<" pvs="<<(*it)->GetPvs().mEntries.size()<<endl;5047 for (i=0; it != it_end; ++ it, ++ i) { 5048 cout<<"v"<<i<<" pvs="<<(*it)->GetPvs().mEntries.size()<<endl; 5059 5049 pvs.Merge((*it)->GetPvs()); 5060 5050 } … … 5070 5060 } else 5071 5061 pvs = viewCell->GetPvs(); 5072 5062 5073 5063 if (spatialFilterSize >=0.0f) 5074 5064 ApplySpatialFilter(kdTree, spatialFilterSize, pvs); 5075 5065 5076 5066 } 5077 5067 … … 5097 5087 5098 5088 int i; 5099 for (i=0, it = mViewCells.begin(); it != it_end; ++ it, i++) {5089 for (i=0, it = mViewCells.begin(); it != it_end; ++ it, ++ i) { 5100 5090 ApplyFilter(*it, 5101 5091 kdTree, … … 5107 5097 5108 5098 // now replace all pvss 5109 for (i= 0, it = mViewCells.begin(); it != it_end; ++ it, i++) { 5099 for (i = 0, it = mViewCells.begin(); it != it_end; ++ it, ++ i) { 5100 5110 5101 ObjectPvs &pvs = (*it)->GetPvs(); 5111 5102 pvs.Clear(); … … 5114 5105 } 5115 5106 5116 delete newPvs;5107 delete [] newPvs; 5117 5108 } 5118 5109 … … 5180 5171 5181 5172 ////////////////////////////////// 5182 ViewCellsManager *ViewCellsManagerFactory::Create(const string mName)5173 /*ViewCellsManager *ViewCellsManagerFactory::Create(const string mName) 5183 5174 { 5184 5175 //TODO 5185 5176 return NULL;// new VspBspViewCellsManager(); 5186 } 5187 5188 5189 } 5177 }*/ 5178 5179 5180 } -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.h
r1001 r1002 170 170 void AddViewCell(ViewCell *viewCell); 171 171 172 /** Derive view cells from objects. The view ells are created by taking the object172 /** Derive view cells from scene objects. The view ells are created by taking the object 173 173 geometry into account. 174 174 */ 175 void DeriveViewCells (const ObjectContainer &objects,176 177 175 void DeriveViewCellsFromObjects(const ObjectContainer &objects, 176 ViewCellContainer &viewCells, 177 const int maxViewCells) const; 178 178 179 179 /** Sets maximal number of samples used for the … … 206 206 int GetPostProcessSamples() const; 207 207 208 /** Returns true if view cells weralready constructed.208 /** Returns true if view cells are already constructed. 209 209 */ 210 210 virtual bool ViewCellsConstructed() const = 0; … … 405 405 */ 406 406 float EvalRenderCost(Intersectable *obj) const; 407 408 407 409 408 /** Sets pvs size of view cell as a scalar. Used when storing pvs only in the leaves 409 of the hierarchy. 410 */ 411 inline void SetScalarPvsSize(ViewCell *vc, const int pvsSize) const; 412 413 410 414 /** Returns bounding box of a view cell. 411 415 */ … … 420 424 bool LoadBoundingBoxes(const string filename, IndexedBoundingBoxContainer &boxes) const; 421 425 422 bool GetExportPvs() const 423 { 424 return mExportPvs; 425 } 426 /** Returns true if pvs should be exported together with the view cells. 427 */ 428 bool GetExportPvs() const; 426 429 427 430 /** Loads view cells from file. The view cells manager is created with 428 431 respect to the loaded view cells. 429 432 433 @param filename the filename of the view cells 434 @param objects the scene objects 435 @param env an environment file containing more parameters 436 @param finalizeViewCells if the view cells should be post processed, i.e. 437 a mesh is created representing the geometry 438 @param bconverter a conversion routine working with the similarities of bounding 439 boxes: if there is a certain similarity of overlap between bounding boxes, two tested 440 candidate objects are considered to be the same objects 430 441 @returns the view cells manager if loading was successful, false otherwise 431 442 */ … … 522 533 virtual void ExportColor(Exporter *exporter, ViewCell *vc) const = 0; 523 534 524 535 /** Returns volume of the view space. 536 */ 525 537 virtual float GetViewSpaceVolume(); 526 538 … … 553 565 virtual void UpdatePvsForEvaluation(ViewCell *root, ObjectPvs &pvs) = 0; 554 566 555 567 556 568 //////////////////////////////////////////////// 557 569 … … 570 582 /// Loaded view cells 571 583 ViewCellContainer mViewCells; 572 584 /// the corresponding view cell tree holding the logical description of view cells 573 585 ViewCellsTree *mViewCellsTree; 574 586 /// if empty view cells should be pruned (i.e., invalidated) from this point on 575 587 bool mPruneEmptyViewCells; 576 588 589 /// if the pvss in the view cell leaves and the interiors are up to date 577 590 bool mViewCellPvsIsUpdated; 591 578 592 /// maximum number of samples taken for construction of the view cells 579 593 int mConstructionSamples; … … 595 609 bool mCompressViewCells; 596 610 611 /// holds the current view cell statistics 597 612 ViewCellsStatistics mCurrentViewCellsStats; 598 613 /// the scene bounding box … … 602 617 bool mExportViewCells; 603 618 604 // bool mMarchTree);619 // if only valid view cells should be considered for processing 605 620 bool mOnlyValidViewCells; 606 621 607 622 /// if rays should be used to collect merge candidates 608 623 bool mUseRaysForMerge; 609 /// merge the view cells?624 /// if there should be an additional merge step after the subdivision 610 625 bool mMergeViewCells; 611 626 … … 616 631 //-- visualization options 617 632 618 /// color code for view cells 633 /// color code for view cells visualization 619 634 int mColorCode; 620 635 bool mExportGeometry; … … 638 653 bool mExportPvs; 639 654 655 /// the pointer to the environment 640 656 Environment *mEnvironment; 641 657 }; 642 643 658 644 659 … … 729 744 void ExportBspPvs(const ObjectContainer &objects); 730 745 746 /** test if subdivision is valid in terms of volume / area. 747 */ 731 748 void TestSubdivision(); 732 749 }; … … 994 1011 const VssRayContainer &rays); 995 1012 1013 /** test if subdivision is valid in terms of volume / area. 1014 */ 996 1015 void TestSubdivision(); 997 1016 }; 998 1017 999 1018 1000 class ViewCellsManagerFactory1019 /*class ViewCellsManagerFactory 1001 1020 { 1002 1003 1021 public: 1004 1005 1022 ViewCellsManager *Create(const string mName); 1006 1007 }; 1023 };*/ 1008 1024 1009 1025 } -
GTP/trunk/Lib/Vis/Preprocessing/src/VspBspTree.cpp
r1001 r1002 317 317 TransformedMeshInstance *mi = dynamic_cast<TransformedMeshInstance *>(object); 318 318 319 if (!mi->GetMesh()) 319 if (!mi->GetMesh()) 320 320 break; 321 322 mesh = new Mesh(*mi->GetMesh()); 323 324 Matrix4x4 m; 325 mi->GetWorldTransform(m); 326 327 mesh->ApplyTransformation(m); 328 321 mesh = new Mesh(); 322 mi->GetTransformedMesh(*mesh); 323 329 324 break; 330 325 } … … 375 370 { 376 371 VssRay *ray = *rit; 372 Intersectable *obj = ray->mTerminationObject; 377 373 378 374 if ((mBox.IsInside(ray->mTermination) || !forcedBoundingBox) && 379 ray->mTerminationObject && 380 !ray->mTerminationObject->Mailed()) 381 { 382 ray->mTerminationObject->Mail(); 383 MeshInstance *obj = dynamic_cast<MeshInstance *>(ray->mTerminationObject); 384 AddMeshToPolygons(obj->GetMesh(), polys, obj); 375 obj && !obj->Mailed()) 376 { 377 obj->Mail(); 378 379 // transformed mesh instance and mesh instance handle mesh differently 380 if (obj->Type() == Intersectable::TRANSFORMED_MESH_INSTANCE) 381 { 382 Mesh mesh; 383 384 TransformedMeshInstance *tmobj = 385 dynamic_cast<TransformedMeshInstance *>(obj); 386 387 tmobj->GetTransformedMesh(mesh); 388 AddMeshToPolygons(&mesh, polys, tmobj); 389 } 390 else // MeshInstance 391 { 392 MeshInstance *mobj = dynamic_cast<MeshInstance *>(obj); 393 AddMeshToPolygons(mobj->GetMesh(), polys, mobj); 394 } 395 385 396 ++ numObj; 386 397 … … 815 826 AddToPvs(leaf, *tData.mRays, sampCon, conSamp); 816 827 817 // update single pvs parameter 818 viewCell->mPvsSize = viewCell->GetPvs().GetSize(); 819 viewCell->mPvsSizeValid = true; 820 828 // update scalar pvs size lookup 829 mViewCellsManager->SetScalarPvsSize(viewCell, viewCell->GetPvs().GetSize()); 830 821 831 822 832 mBspStats.contributingSamples += conSamp; … … 950 960 AddToPvs(leaf, *tData.mRays, sampCon, conSamp); 951 961 952 viewCell->mPvsSize = viewCell->GetPvs().GetSize();953 viewCell->mPvsSizeValid = true;962 // update scalar pvs size value 963 mViewCellsManager->SetScalarPvsSize(viewCell, viewCell->GetPvs().GetSize()); 954 964 955 965 mBspStats.contributingSamples += conSamp; … … 1161 1171 int &contributingSamples) 1162 1172 { 1163 1164 1173 sampleContributions = 0; 1174 contributingSamples = 0; 1165 1175 1166 1176 RayInfoContainer::const_iterator it, it_end = rays.end(); 1167 1177 1168 1178 ViewCellLeaf *vc = leaf->GetViewCell(); 1169 1179 1170 // add contributions from samples to the PVS 1171 for (it = rays.begin(); it != it_end; ++ it) 1172 { 1173 float sc = 0.0f; 1174 VssRay *ray = (*it).mRay; 1175 bool madeContrib = false; 1176 float contribution; 1177 if (ray->mTerminationObject) { 1178 if (vc->GetPvs().AddSample(ray->mTerminationObject, ray->mPdf, contribution)) 1179 madeContrib = true; 1180 sc += contribution; 1181 } 1180 // add contributions from samples to the PVS 1181 for (it = rays.begin(); it != it_end; ++ it) 1182 { 1183 float sc = 0.0f; 1184 VssRay *ray = (*it).mRay; 1185 1186 bool madeContrib = false; 1187 float contribution; 1188 1189 if (ray->mTerminationObject) 1190 { 1191 if (vc->AddPvsSample(ray->mTerminationObject, ray->mPdf, contribution)) 1192 madeContrib = true; 1193 sc += contribution; 1194 } 1182 1195 1183 if (ray->mOriginObject) { 1184 if (vc->GetPvs().AddSample(ray->mOriginObject, ray->mPdf, contribution)) 1185 madeContrib = true; 1186 sc += contribution; 1187 } 1196 if (ray->mOriginObject) 1197 { 1198 if (vc->AddPvsSample(ray->mOriginObject, ray->mPdf, contribution)) 1199 madeContrib = true; 1200 sc += contribution; 1201 } 1188 1202 1189 1203 sampleContributions += sc; 1204 1190 1205 if (madeContrib) 1191 1206 ++ contributingSamples; … … 2635 2650 // preprocess: throw out polygons coincident to the view space box (not needed) 2636 2651 PolygonContainer boxPolys; 2637 mBox.ExtractPolys(boxPolys);2652 /*mBox.ExtractPolys(boxPolys); 2638 2653 vector<Plane3> boxPlanes; 2639 2654 … … 2666 2681 } 2667 2682 2668 // remove deleted entries 2683 // remove deleted entries after swapping them to end of vector 2669 2684 for (int i = 0; i < (int)polys.size(); ++ i) 2670 2685 { … … 2674 2689 polys.pop_back(); 2675 2690 } 2676 } 2691 }*/ 2677 2692 } 2678 2693 -
GTP/trunk/Lib/Vis/Preprocessing/src/VssPreprocessor.cpp
r931 r1002 22 22 VssPreprocessor::VssPreprocessor(): 23 23 mPass(0), 24 mVssRays() 24 mVssRays(), 25 mViewSpaceBox(NULL) 25 26 { 26 27 // this should increase coherence of the samples … … 543 544 544 545 545 AxisAlignedBox3 *box = new AxisAlignedBox3(mKdTree->GetBox());546 AxisAlignedBox3 box(mKdTree->GetBox()); 546 547 547 548 if (!useViewspacePlane) { 548 549 float size = 0.05f; 549 550 float s = 0.5f - size; 550 float olds = Magnitude(box ->Size());551 box ->Enlarge(box->Size()*Vector3(-s));551 float olds = Magnitude(box.Size()); 552 box.Enlarge(box.Size()*Vector3(-s)); 552 553 Vector3 translation = Vector3(-olds*0.1f, 0, 0); 553 box ->SetMin(box->Min() + translation);554 box ->SetMax(box->Max() + translation);554 box.SetMin(box.Min() + translation); 555 box.SetMax(box.Max() + translation); 555 556 } else { 556 557 557 558 // sample city like heights 558 box ->SetMin(1, box->Min(1) + box->Size(1)*0.2f);559 box ->SetMax(1, box->Min(1) + box->Size(1)*0.3f);559 box.SetMin(1, box.Min(1) + box.Size(1)*0.2f); 560 box.SetMax(1, box.Min(1) + box.Size(1)*0.3f); 560 561 } 561 562 562 563 if (use2dSampling) 563 box ->SetMax(1, box->Min(1));564 box.SetMax(1, box.Min(1)); 564 565 565 566 cout<<"mUseViewSpaceBox="<<mUseViewSpaceBox<<endl; … … 570 571 if (!mEnlargeViewSpace) 571 572 { 572 mViewSpaceBox = box;573 mViewSpaceBox = new AxisAlignedBox3(box); 573 574 } 574 575 else … … 591 592 { 592 593 // $$ JB temporary 593 AxisAlignedBox3 box = *mViewSpaceBox;594 AxisAlignedBox3 tempbox = *mViewSpaceBox; 594 595 595 float s = box.Size(0);596 float s = tempbox.Size(0); 596 597 597 box.Scale(0.8f);598 box.SetMax(0, box.Max(0) + s*0.8f);599 box.SetMin(0, box.Min(0) + s*0.8f);600 *mViewSpaceBox = box;598 tempbox.Scale(0.8f); 599 tempbox.SetMax(0, box.Max(0) + s*0.8f); 600 tempbox.SetMin(0, box.Min(0) + s*0.8f); 601 *mViewSpaceBox = tempbox; 601 602 } 602 603 } -
GTP/trunk/Lib/Vis/Preprocessing/src/X3dParser.cpp
r1001 r1002 275 275 MeshInstance *mi; 276 276 277 if ( 0 &&!mUsingMeshDefinition)277 if (!mUsingMeshDefinition) 278 278 { 279 279 // make an instance of this mesh -
GTP/trunk/Lib/Vis/Preprocessing/src/main.cpp
r1001 r1002 10 10 #include "MeshKdTree.h" 11 11 #include "Exporter.h" 12 #include "X3dExporter.h" // delete later13 12 #include "ViewCell.h" 14 13 #include "SceneGraph.h" … … 49 48 environment->GetStringValue("Preprocessor.type", buff); 50 49 string preprocessorType(buff); 51 52 Preprocessor *p;53 50 51 Preprocessor *p = NULL; 52 53 54 54 if (preprocessorType == "vss") 55 55 { … … 57 57 } 58 58 else 59 { 59 60 if (preprocessorType == "rss") 60 p = new RssPreprocessor(); 61 { 62 p = new RssPreprocessor(); 63 } 61 64 else 65 { 62 66 if (preprocessorType == "exact") 67 { 63 68 p = new ExactPreprocessor(); 69 } 64 70 else 71 { 65 72 if (preprocessorType == "sampling") 73 { 66 74 p = new SamplingPreprocessor(); 75 } 67 76 else 77 { 68 78 if (preprocessorType == "render") 69 79 { 70 80 p = new RenderSampler(); 71 81 } 72 82 else { 73 cerr<<"Unknown preprocessor type"<<endl; 74 Debug<<"Unknown preprocessor type"<<endl; 75 exit(1); 83 DEL_PTR(environment); 84 cerr<<"Unknown preprocessor type"<<endl; 85 Debug<<"Unknown preprocessor type"<<endl; 86 exit(1); 76 87 } 88 } 89 } 90 } 91 } 77 92 78 93 79 94 QApplication *app = NULL; 80 95 … … 149 164 returnCode = app->exec(); 150 165 151 //clean up166 //-- clean up 152 167 DEL_PTR(p); 153 168 DEL_PTR(environment); 169 154 170 MeshManager::DelSingleton(); 155 171 MaterialManager::DelSingleton(); 156 172 173 DEL_PTR(pt); 157 174 158 175 return returnCode;
Note: See TracChangeset
for help on using the changeset viewer.