Changeset 1251 for GTP/trunk/Lib/Vis
- Timestamp:
- 08/21/06 18:39:49 (18 years ago)
- Location:
- GTP/trunk/Lib/Vis
- Files:
-
- 22 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/GtpVisibility.sln
r1250 r1251 14 14 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Plugin_VisibilitySceneManager", "OnlineCullingCHC\OGRE\src\Plugin_VisibilitySceneManager.vcproj", "{80DECC17-BDDD-4412-8CF8-F7C1C17A7436}" 15 15 ProjectSection(ProjectDependencies) = postProject 16 {EABCE292-D598-4600-A1C9-2591E7D62FDA} = {EABCE292-D598-4600-A1C9-2591E7D62FDA} 16 17 {101A7691-74F3-48B4-96A3-CF35578F5900} = {101A7691-74F3-48B4-96A3-CF35578F5900} 17 {EABCE292-D598-4600-A1C9-2591E7D62FDA} = {EABCE292-D598-4600-A1C9-2591E7D62FDA}18 18 EndProjectSection 19 19 EndProject -
GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/include/OgreKdTreeSceneManager.h
r1221 r1251 228 228 // if transparents are skipped during rendering 229 229 bool mSkipTransparents; 230 231 230 // the item buffer pass (render items color-coded) 232 231 Pass *mItemBufferPass; … … 239 238 //KdRenderableList mVisibleNodes; 240 239 KdTree::NodeList mVisibleNodes; 240 241 bool mDeleteQueueAfterRendering; 241 242 242 243 /************************************************************************/ -
GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/include/OgreOcclusionCullingSceneManager.h
r1221 r1251 205 205 /// if the view cells are filtered 206 206 bool mUseVisibilityFilter; 207 208 bool mDeleteQueueAfterRendering; 207 209 }; 208 210 -
GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreKdTreeSceneManager.cpp
r1232 r1251 49 49 mRenderTransparentsForItemBuffer(true), 50 50 mExecuteVertexProgramForAllPasses(false), 51 mIsHierarchicalCulling(false) 51 mIsHierarchicalCulling(false), 52 mDeleteQueueAfterRendering(true) 52 53 { 53 54 // Replace root node with my node … … 731 732 732 733 // delete remaining renderables from queue: 733 // all which are not in mLeavePassesInQueue )734 // all which are not in mLeavePassesInQueue 734 735 #ifdef GTP_VISIBILITY_MODIFIED_OGRE 735 736 _deleteRenderedQueueGroups(mLeavePassesInQueue); … … 744 745 mLeavePassesInQueue = 0; 745 746 746 #if 1747 747 // add visible nodes found by the visibility culling algorithm 748 748 if (mUseDepthPass) 749 749 { 750 //KdRenderableList::const_iterator it, it_end = mVisibleNodes.end();751 752 ////getRenderQueue()->clear();753 //for (it = mVisibleNodes.begin(); it != it_end; ++ it)754 //{755 // (*it)->queueObjects(mCameraInProgress, getRenderQueue(), false);756 //}757 750 KdTree::NodeList::const_iterator it, end = mVisibleNodes.end(); 758 751 for (it = mVisibleNodes.begin(); it != end; it++) … … 762 755 } 763 756 } 764 #endif 757 765 758 //-- now we can render all remaining queue objects 766 759 //-- used for depth pass, transparents, overlay … … 774 767 setAmbientLight(savedAmbient); 775 768 776 getRenderQueue()->clear(); // finally clear render queue 777 if (1) OGRE_DELETE(mRenderQueue); // HACK: should rather only be cleared ... 769 if (!mDeleteQueueAfterRendering) 770 getRenderQueue()->clear(); // finally clear render queue 771 else 772 OGRE_DELETE(mRenderQueue); // HACK: should rather only be cleared ... 778 773 779 774 if (0) WriteLog(); // write out stats -
GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreOcclusionCullingSceneManager.cpp
r1232 r1251 53 53 mUseVisibilityFilter(false), 54 54 mCurrentViewCell(NULL), 55 mElementaryViewCell(NULL) 55 mElementaryViewCell(NULL), 56 mDeleteQueueAfterRendering(true) 56 57 { 57 58 mHierarchyInterface = new OctreeHierarchyInterface(this, mDestRenderSystem); … … 267 268 268 269 //-- set actual pass here 270 269 271 const Pass *result = SceneManager::_setPass(usedPass); 270 272 … … 360 362 else //-- the hierarchical culling algorithm 361 363 { 362 // this is also called in TerrainSceneManager: really 363 // nexessary? 364 // note matt: this is also called in TerrainSceneManager: really necessary? 364 365 mDestRenderSystem -> setLightingEnabled(false); 365 366 … … 417 418 #endif 418 419 419 //-- reset parameters 420 //-- reset parameters needed for special rendering 421 420 422 mIsDepthPassPhase = false; 421 423 mIsItemBufferPhase = false; … … 425 427 mLeavePassesInQueue = 0; 426 428 427 #if 1428 429 // add visible nodes found by the visibility culling algorithm 429 430 if (mUseDepthPass) … … 437 438 } 438 439 } 439 #endif440 440 //-- now we can render all remaining queue objects 441 441 //-- used for depth pass, transparents, overlay … … 443 443 444 444 TerrainSceneManager::_renderVisibleObjects(); 445 } // hierarchical culling445 } // end hierarchical culling 446 446 447 447 // HACK: set the new render level index, important to avoid cracks … … 452 452 setAmbientLight(savedAmbient); 453 453 454 getRenderQueue()->clear(); // finally clear render queue 455 if (1) OGRE_DELETE(mRenderQueue); // HACK: should rather only be cleared ... 454 if (!mDeleteQueueAfterRendering) 455 getRenderQueue()->clear(); // finally clear render queue 456 else 457 OGRE_DELETE(mRenderQueue); // HACK: should rather only be cleared ... 458 456 459 if (0) WriteLog(); // write out stats 457 460 } … … 519 522 return true; 520 523 } 521 522 524 if (key == "DepthWrite") 523 525 { -
GTP/trunk/Lib/Vis/OnlineCullingCHC/include/QueryManager.h
r897 r1251 83 83 */ 84 84 virtual bool 85 85 ShootRay(const Ray &ray, 86 86 std::vector<Mesh *> *visibleMeshes, 87 87 bool isGlobalLine = false -
GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.cpp
r1237 r1251 453 453 454 454 455 bool BvHierarchy::LocalTerminationCriteriaMet(const BvhTraversalData &data) const455 inline bool BvHierarchy::LocalTerminationCriteriaMet(const BvhTraversalData &data) const 456 456 { 457 457 // matt: TODO … … 464 464 465 465 466 bool BvHierarchy::GlobalTerminationCriteriaMet(const BvhTraversalData &data) const466 inline bool BvHierarchy::GlobalTerminationCriteriaMet(const BvhTraversalData &data) const 467 467 { 468 468 // matt: TODO -
GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.h
r1239 r1251 515 515 /** Returns true if tree can be terminated. 516 516 */ 517 inlinebool LocalTerminationCriteriaMet(const BvhTraversalData &data) const;517 bool LocalTerminationCriteriaMet(const BvhTraversalData &data) const; 518 518 519 519 /** Returns true if global tree can be terminated. 520 520 */ 521 inlinebool GlobalTerminationCriteriaMet(const BvhTraversalData &data) const;521 bool GlobalTerminationCriteriaMet(const BvhTraversalData &data) const; 522 522 523 523 // -------------------------------------------------------------- -
GTP/trunk/Lib/Vis/Preprocessing/src/OspTree.cpp
r1237 r1251 490 490 void OspTree::EvalSubdivisionCandidate(OspSubdivisionCandidate &splitCandidate) 491 491 { 492 float frontProb;493 float backProb;494 495 492 // compute locally best split plane 496 493 const float ratio = SelectSplitPlane(splitCandidate.mParentData, 497 splitCandidate.mSplitPlane, 498 frontProb, 499 backProb); 494 splitCandidate.mSplitPlane); 500 495 501 496 const bool success = ratio < mTermMaxCostRatio; … … 528 523 529 524 530 bool OspTree::LocalTerminationCriteriaMet(const OspTraversalData &data) const525 inline bool OspTree::LocalTerminationCriteriaMet(const OspTraversalData &data) const 531 526 { 532 527 // matt: TODO … … 539 534 540 535 541 bool OspTree::GlobalTerminationCriteriaMet(const OspTraversalData &data) const536 inline bool OspTree::GlobalTerminationCriteriaMet(const OspTraversalData &data) const 542 537 { 543 538 // matt: TODO … … 920 915 { 921 916 ViewCell *vc = *vit; 922 //Debug << "here30 vc mail " << vc->mMailbox - ViewCell::sMailId << endl; 923 917 924 918 // if obj not previously associated with this view cell => increase render cost 925 919 if (vc->Mailed(1) && !ViewCellHasMultipleReferences(obj, vc, false)) … … 944 938 { 945 939 ViewCell *vc = *vit; 946 947 //Debug << "here6 " << vc->mMailbox - ViewCell::sMailId << endl;948 940 949 941 // if obj was previously associated with this view cell but is not now … … 1084 1076 1085 1077 float OspTree::SelectSplitPlane(const OspTraversalData &tData, 1086 AxisAlignedPlane &plane, 1087 float &pFront, 1088 float &pBack) 1078 AxisAlignedPlane &plane) 1089 1079 { 1090 1080 float nPosition[3]; … … 1153 1143 // split plane position 1154 1144 plane.mPosition = nPosition[bestAxis]; 1155 1156 pFront = nProbFront[bestAxis];1157 pBack = nProbBack[bestAxis];1158 1145 1159 1146 Debug << "val: " << nCostRatio[bestAxis] << " axis: " << bestAxis << endl; -
GTP/trunk/Lib/Vis/Preprocessing/src/OspTree.h
r1239 r1251 568 568 /** Returns true if tree can be terminated. 569 569 */ 570 inlinebool LocalTerminationCriteriaMet(const OspTraversalData &data) const;570 bool LocalTerminationCriteriaMet(const OspTraversalData &data) const; 571 571 572 572 /** Returns true if global tree can be terminated. 573 573 */ 574 inlinebool GlobalTerminationCriteriaMet(const OspTraversalData &data) const;574 bool GlobalTerminationCriteriaMet(const OspTraversalData &data) const; 575 575 576 576 /** Selects an axis aligned for the next split. … … 579 579 float SelectSplitPlane( 580 580 const OspTraversalData &tData, 581 AxisAlignedPlane &plane, 582 float &pFront, 583 float &pBack); 581 AxisAlignedPlane &plane); 584 582 585 583 /** Propagates valid flag up the tree. -
GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp
r1233 r1251 16 16 #include "OspTree.h" 17 17 #include "ObjParser.h" 18 #ifdef INTEL_COMPILER18 #ifdef GTP_INTERNAL 19 19 #include "ArchModeler2MLRT.hxx" 20 20 #endif … … 123 123 mVspBspTree(NULL), 124 124 mViewCellsManager(NULL), 125 mRenderSimulator(NULL) 125 mRenderSimulator(NULL), 126 mPass(0) 126 127 { 127 128 Environment::GetSingleton()->GetBoolValue("Preprocessor.useGlRenderer", mUseGlRenderer); … … 757 758 { 758 759 case INTEL_RAYCASTER: 759 #ifdef INTEL_COMPILER760 #ifdef GTP_INTERNAL 760 761 return mlrtaLoadAS(externKdTree.c_str()); 761 762 #endif … … 768 769 } 769 770 770 } 771 772 int Preprocessor::CastIntelDoubleRay( 773 const Vector3 &viewPoint, 774 const Vector3 &direction, 775 const float probability, 776 VssRayContainer &vssRays, 777 const AxisAlignedBox3 &box 778 ) 779 { 780 VssRay *vssRay = NULL; 781 int hits = 0; 782 783 Vector3 pointA, pointB; 784 785 Intersectable *objectA = 786 CastIntelSingleRay(viewPoint, direction, pointA, box); 787 788 // cast ray into other direction 789 Intersectable *objectB = 790 CastIntelSingleRay(viewPoint, -direction, pointB, box); 791 792 const bool validSample = (objectA != objectB); 793 794 if (validSample) 795 { 796 if (objectA) 797 { 798 vssRay = new VssRay(pointB, 799 pointA, 800 objectB, 801 objectA, 802 probability, 803 mPass); 804 805 vssRays.push_back(vssRay); 806 hits ++; 807 } 808 809 if (objectB) 810 { 811 vssRay = new VssRay(pointA, 812 pointB, 813 objectA, 814 objectB, 815 probability, 816 mPass); 817 818 vssRays.push_back(vssRay); 819 hits ++; 820 } 821 //Debug << "intel ray: " << *vssRay << endl; 822 } 823 //cout << "a"; 824 return hits; 825 } 826 827 828 Intersectable *Preprocessor::CastIntelSingleRay(const Vector3 &viewPoint, 829 const Vector3 &direction, 830 //const float probability, 831 Vector3 &tPoint, 832 const AxisAlignedBox3 &box 833 ) 834 { 835 AxisAlignedBox3 sbox = box; 836 sbox.Enlarge(Vector3(-Limits::Small)); 837 838 if (!sbox.IsInside(viewPoint)) 839 return 0; 840 841 float pforg[3]; 842 float pfdir[3]; 843 double pfnorm[3]; 844 845 pforg[0] = viewPoint[0]; pforg[1] = viewPoint[1]; pforg[2] = viewPoint[2]; 846 pfdir[0] = direction[0]; pfdir[1] = direction[1]; pfdir[2] = direction[2]; 847 848 float dist = 0; 849 #ifdef GTP_INTERNAL 850 const int hittriangle = mlrtaIntersectAS(pforg, pfdir, pfnorm, dist); 851 #else 852 const int hittriangle = -1; 853 #endif 854 855 if (hittriangle == -1) 856 { 857 static Ray ray; 858 SetupRay(ray, viewPoint, direction); 859 860 float tmin = 0, tmax; 861 if (box.ComputeMinMaxT(ray, &tmin, &tmax) && tmin < tmax) 862 { 863 tPoint = ray.Extrap(tmax); 864 } 865 866 return NULL; 867 } 868 else 869 { 870 tPoint[0] = pforg[0] + pfdir[0] * dist; 871 tPoint[1] = pforg[1] + pfdir[1] * dist; 872 tPoint[2] = pforg[2] + pfdir[2] * dist; 873 874 return mFaceParents[hittriangle]; 875 } 876 } 877 878 879 int Preprocessor::CastInternalRay( 880 const Vector3 &viewPoint, 881 const Vector3 &direction, 882 const float probability, 883 VssRayContainer &vssRays, 884 const AxisAlignedBox3 &box 885 ) 886 { 887 int hits = 0; 888 static Ray ray; 889 890 AxisAlignedBox3 sbox = box; 891 sbox.Enlarge(Vector3(-Limits::Small)); 892 893 if (!sbox.IsInside(viewPoint)) 894 return 0; 895 896 SetupRay(ray, viewPoint, direction); 897 898 // cast ray to KD tree to find intersection with other objects 899 Intersectable *objectA, *objectB; 900 901 Vector3 pointA; 902 Vector3 pointB; 903 904 //float bsize = Magnitude(box.Size()); 905 if (!mDetectEmptyViewSpace) 906 ray.mFlags &= ~Ray::CULL_BACKFACES; 907 else 908 ray.mFlags |= Ray::CULL_BACKFACES; 909 910 if (mKdTree->CastRay(ray)) 911 { 912 objectA = ray.intersections[0].mObject; 913 pointA = ray.Extrap(ray.intersections[0].mT); 914 } 915 else 916 { 917 objectA = NULL; 918 // compute intersection with the scene bounding box 919 float tmin, tmax; 920 if (box.ComputeMinMaxT(ray, &tmin, &tmax) && tmin < tmax) 921 pointA = ray.Extrap(tmax); 922 else 923 return 0; 924 } 925 926 // matt: point A could be undefined? 927 928 // cast ray into opposite direction 929 if (1 && mDetectEmptyViewSpace) { 930 SetupRay(ray, pointA, -direction); 931 } else 932 SetupRay(ray, viewPoint, -direction); 933 934 if (!mDetectEmptyViewSpace) 935 ray.mFlags &= ~Ray::CULL_BACKFACES; 936 else 937 ray.mFlags |= Ray::CULL_BACKFACES; 938 939 if (mKdTree->CastRay(ray)) 940 { 941 objectB = ray.intersections[0].mObject; 942 pointB = ray.Extrap(ray.intersections[0].mT); 943 } 944 else 945 { 946 objectB = NULL; 947 float tmin, tmax; 948 949 if (box.ComputeMinMaxT(ray, &tmin, &tmax) && tmin < tmax) 950 pointB = ray.Extrap(tmax); 951 else 952 return 0; 953 } 954 955 //bool thesame = objectA && (objectA == objectB); 956 957 // if (objectA == NULL && objectB != NULL) { 958 if (1 && mDetectEmptyViewSpace) 959 { 960 // cast again to ensure that there is no objectA 961 SetupRay(ray, pointB, direction); 962 ray.mFlags |= Ray::CULL_BACKFACES; 963 964 if (mKdTree->CastRay(ray)) 965 { 966 objectA = ray.intersections[0].mObject; 967 pointA = ray.Extrap(ray.intersections[0].mT); 968 } 969 } 970 971 972 VssRay *vssRay = NULL; 973 974 bool validSample = (objectA != objectB); 975 976 //if (validSample && thesame) Debug << "warning!!" << endl; 977 978 if (0 && mDetectEmptyViewSpace) 979 { 980 // consider all samples valid 981 // check if the viewpoint lies on the line segment AB 982 if (Distance(pointA, pointB) < 983 Distance(viewPoint, pointA) + Distance(viewPoint, pointB) - Limits::Small) 984 { 985 validSample = false; 986 } 987 } 988 989 if (validSample) 990 { 991 if (objectA) 992 { 993 vssRay = new VssRay(pointB, 994 pointA, 995 objectB, 996 objectA, 997 probability, 998 mPass); 999 vssRays.push_back(vssRay); 1000 hits ++; 1001 } 1002 1003 if (objectB) 1004 { 1005 vssRay = new VssRay(pointA, 1006 pointB, 1007 objectA, 1008 objectB, 1009 probability, 1010 mPass); 1011 vssRays.push_back(vssRay); 1012 hits ++; 1013 } 1014 //Debug << "internal ray: " << *vssRay << endl << endl; 1015 } 1016 //cout << "b"; 1017 return hits; 1018 } 1019 1020 1021 int Preprocessor::CastRay( 1022 const Vector3 &viewPoint, 1023 const Vector3 &direction, 1024 const float probability, 1025 VssRayContainer &vssRays, 1026 const AxisAlignedBox3 &box 1027 ) 1028 { 1029 switch (mRayCastMethod) 1030 { 1031 case INTEL_RAYCASTER: 1032 return CastIntelDoubleRay(viewPoint, direction, probability, vssRays, box); 1033 case INTERNAL_RAYCASTER: 1034 default: 1035 return CastInternalRay(viewPoint, direction, probability, vssRays, box); 1036 } 1037 } 1038 1039 1040 void Preprocessor::SetupRay(Ray &ray, 1041 const Vector3 &point, 1042 const Vector3 &direction 1043 ) 1044 { 1045 ray.Clear(); 1046 // do not store anything else then intersections at the ray 1047 ray.Init(point, direction, Ray::LOCAL_RAY); 1048 } 1049 1050 } -
GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.h
r1221 r1251 150 150 */ 151 151 ViewCellsManager *CreateViewCellsManager(const char *name); 152 153 152 154 153 GlRendererBuffer *GetRenderer() { return renderer;} 155 154 156 155 bool InitRayCast(const string externKdTree); 156 157 int CastRay( 158 const Vector3 &viewPoint, 159 const Vector3 &direction, 160 const float probability, 161 VssRayContainer &vssRays, 162 const AxisAlignedBox3 &box 163 ); 157 164 158 165 //////////////////////////////////////////////// … … 209 216 void SetRayCastMethod(int rayCastMethod) { mRayCastMethod = rayCastMethod; } 210 217 218 int mPass; 219 211 220 protected: 221 222 void SetupRay(Ray &ray, const Vector3 &point, const Vector3 &direction); 223 224 int CastInternalRay( 225 const Vector3 &viewPoint, 226 const Vector3 &direction, 227 const float probability, 228 VssRayContainer &vssRays, 229 const AxisAlignedBox3 &box); 230 231 int CastIntelDoubleRay( 232 const Vector3 &viewPoint, 233 const Vector3 &direction, 234 const float probability, 235 VssRayContainer &vssRays, 236 const AxisAlignedBox3 &box); 237 238 Intersectable *CastIntelSingleRay( 239 const Vector3 &viewPoint, 240 const Vector3 &direction, 241 Vector3 &tPoint, 242 const AxisAlignedBox3 &box); 212 243 213 244 ///////////////////////// -
GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.vcproj
r1248 r1251 203 203 FavorSizeOrSpeed="0" 204 204 OptimizeForWindowsApplication="TRUE" 205 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;"$(BOOST_INCLUDE)";..\..\Preprocessing\MultiLevelRayTracing"206 PreprocessorDefinitions="WIN32;NDEBUG;_LIB "205 AdditionalIncludeDirectories="..\src;..\..\..\..\..\..\NonGTP\Devil\include;..\..\..\..\..\..\NonGTP\Zlib\include;..\..\..\..\..\..\NonGTP\Xerces;"$(BOOST_INCLUDE)";..\MultiLevelRayTracing" 206 PreprocessorDefinitions="WIN32;NDEBUG;_LIB;GTP_INTERNAL" 207 207 ExceptionHandling="TRUE" 208 208 RuntimeLibrary="2" … … 217 217 Name="VCCustomBuildTool"/> 218 218 <Tool 219 Name="VCLibrarianTool"/> 219 Name="VCLibrarianTool" 220 OutputFile="../lib/Release/$(ProjectName).lib"/> 220 221 <Tool 221 222 Name="VCMIDLTool"/> -
GTP/trunk/Lib/Vis/Preprocessing/src/RssPreprocessor.cpp
r1199 r1251 26 26 27 27 RssPreprocessor::RssPreprocessor(): 28 mPass(0),29 28 mVssRays() 30 29 { … … 87 86 { 88 87 for (int i=0; i < rays.size(); i++) { 89 CastRay(rays[i].mOrigin, rays[i].mDirection, rays[i].mPdf, vssRays );88 CastRay(rays[i].mOrigin, rays[i].mDirection, rays[i].mPdf, vssRays, mViewCellsManager->GetViewSpaceBox()); 90 89 if (i % 10000 == 0) 91 90 cout<<"."; … … 101 100 } 102 101 103 void 104 RssPreprocessor::SetupRay(Ray &ray, 105 const Vector3 &point, 106 const Vector3 &direction 107 ) 108 { 109 ray.intersections.clear(); 110 // do not store anything else then intersections at the ray 111 ray.Init(point, direction, Ray::LOCAL_RAY); 112 } 113 102 103 #if 0 //matt: this moved up to preprocessor 114 104 int 115 105 RssPreprocessor::CastRay( … … 212 202 return hits; 213 203 } 214 204 #endif 215 205 216 206 void -
GTP/trunk/Lib/Vis/Preprocessing/src/RssPreprocessor.h
r1112 r1251 15 15 16 16 17 /** Sampling based visibility preprocessing. The implementation is based on heuristical 18 sampling of view space */ 17 /** Sampling based visibility preprocessing. The implementation is 18 based on heuristical sampling of view space 19 */ 19 20 class RssPreprocessor : public Preprocessor { 20 21 21 22 public: 22 int mPass;23 23 int mSamplesPerPass; 24 24 int mRssSamplesPerPass; … … 56 56 virtual bool ComputeVisibility(); 57 57 58 59 void 60 SetupRay(Ray &ray, 61 const Vector3 &point, 62 const Vector3 &direction 63 ); 64 65 66 58 #if 0 // matt:: moved up into preprocessor 67 59 int 68 60 CastRay( … … 71 63 const float probability, 72 64 VssRayContainer &vssRays 73 74 65 ); 75 76 77 66 #endif 78 67 virtual bool BuildBspTree() { return false; } 79 68 -
GTP/trunk/Lib/Vis/Preprocessing/src/SamplingPreprocessor.cpp
r1221 r1251 36 36 ) 37 37 { 38 //float *pforg;39 //float *pfdir;40 //mlrtaStoreRayAS4(pforg, pfdir, 4);41 //////////////////////////////////42 38 static Ray ray; 43 39 AxisAlignedBox3 box = mViewCellsManager->GetViewSpaceBox(); -
GTP/trunk/Lib/Vis/Preprocessing/src/TestPreprocessor.vcproj
r1248 r1251 167 167 </Configuration> 168 168 <Configuration 169 Name="Release _Internal|Win32"170 OutputDirectory=" $(ConfigurationName)"171 IntermediateDirectory=" $(ConfigurationName)"172 ConfigurationType="1" 173 CharacterSet="2"> 174 <Tool 175 Name="VCCLCompilerTool" 176 Optimization="0" 177 AdditionalIncludeDirectories="..\include;"$(BOOST_INCLUDE)";"$(QTDIR)\include\QtOpenGl";..\src; "$(CG_INC_PATH)";..\..\..\..\..\..\NonGTP\Devil\include;..\..\..\..\..\..\NonGTP\Zlib\include;..\..\..\..\..\..\NonGTP\Xerces;..\..\MultiLevelRayTracing"169 Name="Release Internal|Win32" 170 OutputDirectory="bin\Release" 171 IntermediateDirectory="bin\Release" 172 ConfigurationType="1" 173 CharacterSet="2"> 174 <Tool 175 Name="VCCLCompilerTool" 176 Optimization="0" 177 AdditionalIncludeDirectories="..\include;"$(BOOST_INCLUDE)";"$(QTDIR)\include\QtOpenGl";..\src;..\..\..\..\..\..\NonGTP\Devil\include;..\..\..\..\..\..\NonGTP\Zlib\include;..\..\..\..\..\..\NonGTP\Xerces" 178 178 PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;GTP_INTERNAL" 179 179 RuntimeLibrary="2" … … 187 187 <Tool 188 188 Name="VCLinkerTool" 189 AdditionalDependencies="xerces-c_2.lib glew32.lib zdll.lib zziplib.lib devil.lib glut32.lib OpenGL32.Lib glu32.lib cg.lib cgGL.lib Preprocessor.lib"190 OutputFile=" $(OutDir)/Preprocessor.exe"189 AdditionalDependencies="xerces-c_2.lib glew32.lib zdll.lib zziplib.lib devil.lib glut32.lib OpenGL32.Lib glu32.lib Preprocessor.lib RTScene.lib RTWorld.lib" 190 OutputFile="../bin/release/Preprocessor.exe" 191 191 LinkIncremental="1" 192 AdditionalLibraryDirectories="..\support\xercesc\lib\;..\support\zlib\lib\;..\support\devil\lib;..\include;..\src\GL;"$(CG_LIB_PATH)";..\lib\release;..\..\Preprocessing\lib\release;"$(BOOST_LIB)";..\..\..\..\..\..\NonGTP\Xerces\xercesc\lib;..\..\..\..\..\..\NonGTP\Zlib\lib;..\..\..\..\..\..\NonGTP\Devil\lib;..\..\Preprocessing\MultiLevelRayTracing\RTScene\Release;..\..\Preprocessing\MultiLevelRayTracing\RTWorld\Release" 193 GenerateDebugInformation="FALSE" 194 SubSystem="1" 195 OptimizeReferences="2" 196 EnableCOMDATFolding="2" 197 TargetMachine="1" 198 FixedBaseAddress="1"/> 199 <Tool 200 Name="VCMIDLTool"/> 201 <Tool 202 Name="VCPostBuildEventTool"/> 203 <Tool 204 Name="VCPreBuildEventTool"/> 205 <Tool 206 Name="VCPreLinkEventTool"/> 207 <Tool 208 Name="VCResourceCompilerTool"/> 209 <Tool 210 Name="VCWebServiceProxyGeneratorTool"/> 211 <Tool 212 Name="VCXMLDataGeneratorTool"/> 213 <Tool 214 Name="VCWebDeploymentTool"/> 215 <Tool 216 Name="VCManagedWrapperGeneratorTool"/> 217 <Tool 218 Name="VCAuxiliaryManagedWrapperGeneratorTool"/> 219 </Configuration> 220 <Configuration 221 Name="Release Internal|Win32" 222 OutputDirectory="$(ConfigurationName)" 223 IntermediateDirectory="$(ConfigurationName)" 224 ConfigurationType="1" 225 CharacterSet="2"> 226 <Tool 227 Name="VCCLCompilerTool" 228 Optimization="0" 229 AdditionalIncludeDirectories="..\include;"$(BOOST_INCLUDE)";"$(QTDIR)\include\QtOpenGl";..\src;"$(CG_INC_PATH)";..\..\..\..\..\..\NonGTP\Devil\include;..\..\..\..\..\..\NonGTP\Zlib\include;..\..\..\..\..\..\NonGTP\Xerces;..\..\MultiLevelRayTracing" 230 PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;GTP_INTERNAL" 231 RuntimeLibrary="2" 232 RuntimeTypeInfo="TRUE" 233 UsePrecompiledHeader="0" 234 WarningLevel="3" 235 Detect64BitPortabilityProblems="TRUE" 236 DebugInformationFormat="3"/> 237 <Tool 238 Name="VCCustomBuildTool"/> 239 <Tool 240 Name="VCLinkerTool" 241 AdditionalDependencies="xerces-c_2.lib glew32.lib zdll.lib zziplib.lib devil.lib glut32.lib OpenGL32.Lib glu32.lib cg.lib cgGL.lib Preprocessor.lib" 242 OutputFile="$(OutDir)/Preprocessor.exe" 243 LinkIncremental="1" 244 AdditionalLibraryDirectories="..\support\xercesc\lib\;..\support\zlib\lib\;..\support\devil\lib;..\include;..\src\GL;"$(CG_LIB_PATH)";..\lib\release;..\..\Preprocessing\lib\release;"$(BOOST_LIB)";..\..\..\..\..\..\NonGTP\Xerces\xercesc\lib;..\..\..\..\..\..\NonGTP\Zlib\lib;..\..\..\..\..\..\NonGTP\Devil\lib;..\..\Preprocessing\MultiLevelRayTracing\RTScene\Release;..\..\Preprocessing\MultiLevelRayTracing\RTWorld\Release" 192 AdditionalLibraryDirectories="..\src\GL;..\lib\release;..\..\Preprocessing\lib\release;"$(BOOST_LIB)";..\..\..\..\..\..\NonGTP\Xerces\xercesc\lib;..\..\..\..\..\..\NonGTP\Zlib\lib;..\..\..\..\..\..\NonGTP\Devil\lib;..\MultiLevelRayTracing\RTScene\Release;..\MultiLevelRayTracing\RTWorld\Release" 245 193 GenerateDebugInformation="FALSE" 246 194 SubSystem="1" -
GTP/trunk/Lib/Vis/Preprocessing/src/VspBspTree.h
r1233 r1251 616 616 /** Returns true if tree can be terminated. 617 617 */ 618 inlinebool LocalTerminationCriteriaMet(const VspBspTraversalData &data) const;618 bool LocalTerminationCriteriaMet(const VspBspTraversalData &data) const; 619 619 620 620 /** Returns true if global tree can be terminated. 621 621 */ 622 inlinebool GlobalTerminationCriteriaMet(const VspBspTraversalData &data) const;622 bool GlobalTerminationCriteriaMet(const VspBspTraversalData &data) const; 623 623 624 624 /** Computes accumulated ray lenght of this rays. -
GTP/trunk/Lib/Vis/Preprocessing/src/VspTree.cpp
r1237 r1251 527 527 528 528 529 bool VspTree::LocalTerminationCriteriaMet(const VspTraversalData &data) const529 inline bool VspTree::LocalTerminationCriteriaMet(const VspTraversalData &data) const 530 530 { 531 531 const bool localTerminationCriteriaMet = ( … … 552 552 553 553 554 bool VspTree::GlobalTerminationCriteriaMet(const VspTraversalData &data) const554 inline bool VspTree::GlobalTerminationCriteriaMet(const VspTraversalData &data) const 555 555 { 556 556 const bool terminationCriteriaMet = ( -
GTP/trunk/Lib/Vis/Preprocessing/src/VspTree.h
r1239 r1251 843 843 /** Returns true if tree can be terminated. 844 844 */ 845 inlinebool LocalTerminationCriteriaMet(const VspTraversalData &data) const;845 bool LocalTerminationCriteriaMet(const VspTraversalData &data) const; 846 846 847 847 /** Returns true if global tree can be terminated. 848 848 */ 849 inlinebool GlobalTerminationCriteriaMet(const VspTraversalData &data) const;849 bool GlobalTerminationCriteriaMet(const VspTraversalData &data) const; 850 850 851 851 /** Adds ray sample contributions to the PVS. -
GTP/trunk/Lib/Vis/Preprocessing/src/VssPreprocessor.cpp
r1249 r1251 13 13 #include "Beam.h" 14 14 #include "GlRenderer.h" 15 //#include "ArchModeler2MLRT.hxx"16 15 #include "Intersectable.h" 17 16 #ifdef GTP_INTERNAL 17 #include "ArchModeler2MLRT.hxx" 18 #endif 18 19 19 20 namespace GtpVisibilityPreprocessor { … … 23 24 24 25 VssPreprocessor::VssPreprocessor(): 25 mPass(0),26 26 mVssRays(), 27 27 mViewSpaceBox(NULL) … … 61 61 62 62 void 63 VssPreprocessor::SetupRay(Ray &ray,64 const Vector3 &point,65 const Vector3 &direction66 )67 {68 ray.Clear();69 // do not store anything else then intersections at the ray70 ray.Init(point, direction, Ray::LOCAL_RAY);71 }72 73 74 void75 63 VssPreprocessor::CastRays( 76 64 SimpleRayContainer &rays, … … 78 66 ) 79 67 { 80 AxisAlignedBox3 &box = mViewSpaceBox ? *mViewSpaceBox : mKdTree->GetBox();68 const AxisAlignedBox3 box = mViewSpaceBox ? *mViewSpaceBox : mKdTree->GetBox(); 81 69 82 70 #if 1 83 for (int i=0; i < rays.size(); i++) 71 SimpleRayContainer::const_iterator rit, rit_end = rays.end(); 72 for (rit = rays.begin(); rit != rit_end; ++ rit) 84 73 { 85 CastRay( rays[i].mOrigin, rays[i].mDirection, vssRays, box);74 CastRay((*rit).mOrigin, (*rit).mDirection, 1, vssRays, box); 86 75 } 87 76 #else … … 99 88 const AxisAlignedBox3 &sbox) 100 89 { 90 #ifdef GTP_INTERNAL 101 91 /* 102 92 mlrtaStoreRayAS16(const float* pforg, const float* pfdir, int j); … … 118 108 119 109 mlrtaTraverseGroupAS16(const float* bbmin, const float* bbmax, int* hit_triangles, float* dist);*/ 120 } 121 122 123 int VssPreprocessor::CastIntelDoubleRay( 124 const Vector3 &viewPoint, 125 const Vector3 &direction, 126 VssRayContainer &vssRays, 127 const AxisAlignedBox3 &box) 128 { 129 VssRay *vssRay = NULL; 130 int hits = 0; 131 132 Vector3 pointA, pointB; 133 134 Intersectable *objectA = 135 CastIntelSingleRay(viewPoint, direction, pointA, box); 136 137 // cast ray into other direction 138 Intersectable *objectB = 139 CastIntelSingleRay(viewPoint, -direction, pointB, box); 140 141 const bool validSample = (objectA != objectB); 142 143 if (validSample) 144 { 145 if (objectA) 146 { 147 vssRay = new VssRay(pointB, 148 pointA, 149 objectB, 150 objectA, 151 mPass); 152 vssRays.push_back(vssRay); 153 hits ++; 154 } 155 156 if (objectB) 157 { 158 vssRay = new VssRay(pointA, 159 pointB, 160 objectA, 161 objectB, 162 mPass); 163 vssRays.push_back(vssRay); 164 hits ++; 165 } 166 //Debug << "intel ray: " << *vssRay << endl; 167 } 168 //cout << "a"; 169 return hits; 170 } 171 172 173 Intersectable *VssPreprocessor::CastIntelSingleRay(const Vector3 &viewPoint, 174 const Vector3 &direction, 175 Vector3 &tPoint, 176 const AxisAlignedBox3 &box 177 ) 178 { 179 AxisAlignedBox3 sbox = box; 180 sbox.Enlarge(Vector3(-Limits::Small)); 181 182 if (!sbox.IsInside(viewPoint)) 183 return 0; 184 185 float pforg[3]; 186 float pfdir[3]; 187 double pfnorm[3]; 188 189 pforg[0] = viewPoint[0]; pforg[1] = viewPoint[1]; pforg[2] = viewPoint[2]; 190 pfdir[0] = direction[0]; pfdir[1] = direction[1]; pfdir[2] = direction[2]; 191 192 float dist = 0; 193 const int hittriangle = -1;//mlrtaIntersectAS(pforg, pfdir, pfnorm, dist); 194 195 if (hittriangle == -1) 196 { 197 static Ray ray; 198 SetupRay(ray, viewPoint, direction); 199 200 float tmin = 0, tmax; 201 if (box.ComputeMinMaxT(ray, &tmin, &tmax) && tmin < tmax) 202 { 203 tPoint = ray.Extrap(tmax); 204 } 205 206 return NULL; 207 } 208 else 209 { 210 tPoint[0] = pforg[0] + pfdir[0] * dist; 211 tPoint[1] = pforg[1] + pfdir[1] * dist; 212 tPoint[2] = pforg[2] + pfdir[2] * dist; 213 214 return mFaceParents[hittriangle]; 215 } 216 } 217 218 219 int 220 VssPreprocessor::CastInternalRay( 221 const Vector3 &viewPoint, 222 const Vector3 &direction, 223 VssRayContainer &vssRays, 224 const AxisAlignedBox3 &box 225 ) 226 { 227 int hits = 0; 228 static Ray ray; 229 230 AxisAlignedBox3 sbox = box; 231 sbox.Enlarge(Vector3(-Limits::Small)); 232 233 if (!sbox.IsInside(viewPoint)) 234 return 0; 235 236 SetupRay(ray, viewPoint, direction); 237 238 // cast ray to KD tree to find intersection with other objects 239 Intersectable *objectA, *objectB; 240 241 Vector3 pointA; 242 Vector3 pointB; 243 244 //float bsize = Magnitude(box.Size()); 245 if (!mDetectEmptyViewSpace) 246 ray.mFlags &= ~Ray::CULL_BACKFACES; 247 else 248 ray.mFlags |= Ray::CULL_BACKFACES; 249 250 if (mKdTree->CastRay(ray)) 251 { 252 objectA = ray.intersections[0].mObject; 253 pointA = ray.Extrap(ray.intersections[0].mT); 254 } 255 else 256 { 257 objectA = NULL; 258 // compute intersection with the scene bounding box 259 float tmin, tmax; 260 if (box.ComputeMinMaxT(ray, &tmin, &tmax) && tmin < tmax) 261 pointA = ray.Extrap(tmax); 262 else 263 return 0; 264 } 265 266 // matt: point A could be undefined? 267 268 // cast ray into opposite direction 269 if (1 && mDetectEmptyViewSpace) { 270 SetupRay(ray, pointA, -direction); 271 } else 272 SetupRay(ray, viewPoint, -direction); 273 274 if (!mDetectEmptyViewSpace) 275 ray.mFlags &= ~Ray::CULL_BACKFACES; 276 else 277 ray.mFlags |= Ray::CULL_BACKFACES; 278 279 if (mKdTree->CastRay(ray)) 280 { 281 objectB = ray.intersections[0].mObject; 282 pointB = ray.Extrap(ray.intersections[0].mT); 283 } 284 else 285 { 286 objectB = NULL; 287 float tmin, tmax; 288 289 if (box.ComputeMinMaxT(ray, &tmin, &tmax) && tmin < tmax) 290 pointB = ray.Extrap(tmax); 291 else 292 return 0; 293 } 294 295 //bool thesame = objectA && (objectA == objectB); 296 297 // if (objectA == NULL && objectB != NULL) { 298 if (1 && mDetectEmptyViewSpace) 299 { 300 // cast again to ensure that there is no objectA 301 SetupRay(ray, pointB, direction); 302 ray.mFlags |= Ray::CULL_BACKFACES; 303 304 if (mKdTree->CastRay(ray)) 305 { 306 objectA = ray.intersections[0].mObject; 307 pointA = ray.Extrap(ray.intersections[0].mT); 308 } 309 } 310 311 312 VssRay *vssRay = NULL; 313 314 bool validSample = (objectA != objectB); 315 316 //if (validSample && thesame) Debug << "warning!!" << endl; 317 318 if (0 && mDetectEmptyViewSpace) 319 { 320 // consider all samples valid 321 // check if the viewpoint lies on the line segment AB 322 if (Distance(pointA, pointB) < 323 Distance(viewPoint, pointA) + Distance(viewPoint, pointB) - Limits::Small) 324 { 325 validSample = false; 326 } 327 } 328 329 if (validSample) 330 { 331 if (objectA) 332 { 333 vssRay = new VssRay(pointB, 334 pointA, 335 objectB, 336 objectA, 337 mPass); 338 vssRays.push_back(vssRay); 339 hits ++; 340 } 341 342 if (objectB) 343 { 344 vssRay = new VssRay(pointA, 345 pointB, 346 objectA, 347 objectB, 348 mPass); 349 vssRays.push_back(vssRay); 350 hits ++; 351 } 352 //Debug << "internal ray: " << *vssRay << endl << endl; 353 } 354 //cout << "b"; 355 return hits; 356 } 357 358 359 int 360 VssPreprocessor::CastRay( 361 const Vector3 &viewPoint, 362 const Vector3 &direction, 363 VssRayContainer &vssRays, 364 const AxisAlignedBox3 &box 365 ) 366 { 367 switch (mRayCastMethod) 368 { 369 case INTEL_RAYCASTER: 370 return CastIntelDoubleRay(viewPoint, direction, vssRays, box); 371 case INTERNAL_RAYCASTER: 372 default: 373 return CastInternalRay(viewPoint, direction, vssRays, box); 374 } 110 #endif 375 111 } 376 112 … … 828 564 Vector3 direction = GetDirection(viewpoint, mViewSpaceBox); 829 565 830 sampleContributions = CastRay(viewpoint, direction, mVssRays, vbox);566 sampleContributions = CastRay(viewpoint, direction, 1, mVssRays, vbox); 831 567 832 568 if (sampleContributions) { … … 959 695 960 696 for (int i=0; i < rays.size(); i++) 961 CastRay(rays[i].mOrigin, rays[i].mDirection, vssRays, vbox);697 CastRay(rays[i].mOrigin, rays[i].mDirection, 1, vssRays, vbox); 962 698 963 699 vssTree->AddRays(vssRays); -
GTP/trunk/Lib/Vis/Preprocessing/src/VssPreprocessor.h
r1221 r1251 19 19 class VssPreprocessor : public Preprocessor { 20 20 public: 21 int mPass;21 22 22 int mSamplesPerPass; 23 23 int mVssSamplesPerPass; … … 56 56 void CastRays(SimpleRayContainer &rays, VssRayContainer &vssRays); 57 57 58 void59 SetupRay(Ray &ray,60 const Vector3 &point,61 const Vector3 &direction62 );63 64 65 66 int67 CastRay(68 const Vector3 &viewPoint,69 const Vector3 &direction,70 VssRayContainer &vssRays,71 const AxisAlignedBox3 &box72 );73 74 75 58 bool 76 59 ExportRays(const char *filename, … … 107 90 ); 108 91 109 void CastRay(const BspTree &tree, const VssRay & vssRay);110 111 92 void TestBeamCasting(VssTree *tre, ViewCellsManager *vm, const ObjectContainer &objects); 112 93 … … 114 95 115 96 protected: 116 int CastInternalRay( 117 const Vector3 &viewPoint, 118 const Vector3 &direction, 119 VssRayContainer &vssRays, 120 const AxisAlignedBox3 &sbox); 121 122 int CastIntelDoubleRay( 123 const Vector3 &viewPoint, 124 const Vector3 &direction, 125 VssRayContainer &vssRays, 126 const AxisAlignedBox3 &sbox); 127 128 Intersectable *CastIntelSingleRay( 129 const Vector3 &viewPoint, 130 const Vector3 &direction, 131 Vector3 &tPoint, 132 const AxisAlignedBox3 &abox); 97 98 133 99 134 100 void CastRays16(SimpleRayContainer &rays,
Note: See TracChangeset
for help on using the changeset viewer.