Changeset 1520 for GTP/trunk/Lib
- Timestamp:
- 09/27/06 16:24:39 (18 years ago)
- Location:
- GTP/trunk/Lib/Vis/Preprocessing/src
- Files:
-
- 6 added
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/src/Environment.cpp
r1500 r1520 1281 1281 1282 1282 1283 1283 1284 /***********************************************************************************/ 1284 1285 /* View cells related options */ -
GTP/trunk/Lib/Vis/Preprocessing/src/GvsPreprocessor.cpp
r1501 r1520 198 198 // establish visibility 199 199 VssRayContainer vssRays; 200 CastRays(simpleRays, vssRays );200 CastRays(simpleRays, vssRays, false); 201 201 // add to ray queue 202 202 EnqueueRays(vssRays); … … 273 273 // generate vss rays 274 274 VssRayContainer samples; 275 CastRays(simpleRays, samples );275 CastRays(simpleRays, samples, true); 276 276 277 277 // add to ray queue -
GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp
r1486 r1520 19 19 #include "HierarchyManager.h" 20 20 #include "VssRay.h" 21 22 23 #ifdef GTP_INTERNAL 24 #include "ArchModeler2MLRT.hxx" 25 #endif 21 #include "IntelRayCaster.h" 22 #include "InternalRayCaster.h" 23 24 26 25 27 26 #define DEBUG_RAYCAST 0 … … 31 30 32 31 const static bool ADDITIONAL_GEOMETRY_HACK = false; 33 34 //Preprocessor *preprocessor;35 32 36 33 … … 135 132 mRenderSimulator(NULL), 136 133 mPass(0), 137 m RayCastMethod(0),138 m SceneGraph(NULL)134 mSceneGraph(NULL), 135 mRayCaster(NULL) 139 136 { 140 137 Environment::GetSingleton()->GetBoolValue("Preprocessor.useGlRenderer", mUseGlRenderer); … … 149 146 Environment::GetSingleton()->GetBoolValue("Preprocessor.detectEmptyViewSpace", mDetectEmptyViewSpace); 150 147 Environment::GetSingleton()->GetBoolValue("Preprocessor.exportVisibility", mExportVisibility ); 151 Environment::GetSingleton()->GetIntValue("Preprocessor.rayCastMethod", mRayCastMethod); 152 148 153 149 char buffer[256]; 154 150 Environment::GetSingleton()->GetStringValue("Preprocessor.visibilityFile", buffer); … … 162 158 Debug << "detect empty view space=" << mDetectEmptyViewSpace << endl; 163 159 Debug << "load meshes: " << mLoadMeshes << endl; 164 165 if (mRayCastMethod == 0)166 cout << "ray cast method: internal" << endl;167 else168 cout << "ray cast method: intel" << endl;169 160 } 170 161 … … 237 228 238 229 // intel ray caster can only trace triangles 239 vector<FaceParentInfo> *fi = (mRayCastMethod == Preprocessor::INTEL_RAYCASTER) ? 230 int rayCastMethod; 231 Environment::GetSingleton()->GetIntValue("Preprocessor.rayCastMethod", rayCastMethod); 232 vector<FaceParentInfo> *fi = (rayCastMethod == RayCaster::INTEL_RAYCASTER) ? 240 233 &mFaceParents : NULL; 241 234 … … 759 752 switch (strategyId) 760 753 { 761 case OBJECT_BASED_DISTRIBUTION:754 case SamplingStrategy::OBJECT_BASED_DISTRIBUTION: 762 755 return new ObjectBasedDistribution(*this); 763 case OBJECT_DIRECTION_BASED_DISTRIBUTION:756 case SamplingStrategy::OBJECT_DIRECTION_BASED_DISTRIBUTION: 764 757 return new ObjectDirectionBasedDistribution(*this); 765 case DIRECTION_BASED_DISTRIBUTION:758 case SamplingStrategy::DIRECTION_BASED_DISTRIBUTION: 766 759 return new DirectionBasedDistribution(*this); 767 case DIRECTION_BOX_BASED_DISTRIBUTION:760 case SamplingStrategy::DIRECTION_BOX_BASED_DISTRIBUTION: 768 761 return new DirectionBoxBasedDistribution(*this); 769 case S PATIAL_BOX_BASED_DISTRIBUTION:762 case SamplingStrategy::SPATIAL_BOX_BASED_DISTRIBUTION: 770 763 return new SpatialBoxBasedDistribution(*this); 771 764 //case OBJECTS_INTERIOR_DISTRIBUTION: … … 819 812 } 820 813 821 switch (mRayCastMethod) // use intel ray tracing 822 { 823 case INTEL_RAYCASTER: 824 #ifdef GTP_INTERNAL 825 cout<<"Ray Cast file: " << externKdTree << endl; 826 return mlrtaLoadAS(externKdTree.c_str()); 827 #endif 828 case INTERNAL_RAYCASTER: 829 default: 830 break; 814 int rayCastMethod; 815 Environment::GetSingleton()->GetIntValue("Preprocessor.rayCastMethod", rayCastMethod); 816 817 if (rayCastMethod == 0) 818 { 819 mRayCaster = new InternalRayCaster(*this, mKdTree); 820 cout << "ray cast method: internal" << endl; 821 } 822 else 823 { 824 mRayCaster = new IntelRayCaster(*this, externKdTree); 825 cout << "ray cast method: intel" << endl; 831 826 } 832 827 … … 834 829 } 835 830 836 837 int Preprocessor::CastIntelDoubleRay(838 const Vector3 &viewPoint,839 const Vector3 &direction,840 const float probability,841 VssRayContainer &vssRays,842 const AxisAlignedBox3 &box843 )844 {845 #ifdef GTP_INTERNAL846 //cout << "intel ray" << endl;847 VssRay *vssRay = NULL;848 int hits = 0;849 int hittriangle;850 Vector3 pointA, pointB;851 Vector3 normalA, normalB;852 Intersectable *objectA = NULL, *objectB = NULL;853 float dist;854 double normal[3];855 856 hittriangle = mlrtaIntersectAS(&viewPoint.x,857 &direction.x,858 normal,859 dist);860 861 if (hittriangle != -1 ) {862 if (hittriangle >= mFaceParents.size())863 cerr<<"Warning: triangle index out of range! "<<hittriangle<<endl;864 else {865 objectA = mFaceParents[hittriangle].mObject;866 normalA = Vector3(normal[0], normal[1], normal[2]);867 // Get the normal of that face868 // Mesh *mesh = ((MeshInstance *)objectA)->GetMesh();869 // normalA = mesh->GetFacePlane(mFaceParents[forward_hit_triangles[i]].mFaceIndex).mNormal;870 //-rays[index+i].mDirection; // $$ temporary871 pointA = viewPoint + direction*dist;872 }873 }874 875 876 Vector3 dir = -direction;877 hittriangle = mlrtaIntersectAS(&viewPoint.x,878 &dir.x,879 normal,880 dist);881 882 if (hittriangle != -1 ) {883 if (hittriangle >= mFaceParents.size())884 cerr<<"Warning: triangle index out of range! "<<hittriangle<<endl;885 else {886 objectB = mFaceParents[hittriangle].mObject;887 normalB = Vector3(normal[0], normal[1], normal[2]);888 // Get the normal of that face889 // Mesh *mesh = ((MeshInstance *)objectB)->GetMesh();890 // normalA = mesh->GetFacePlane(mFaceParents[forward_hit_triangles[i]].mFaceIndex).mNormal;891 //-rays[index+i].mDirection; // $$ temporary892 pointB = viewPoint + dir * dist;893 }894 }895 896 return ProcessRay(viewPoint,897 direction,898 objectA, pointA, normalA,899 objectB, pointB, normalB,900 probability,901 vssRays,902 box903 );904 #else905 return -1;906 #endif907 }908 909 910 Intersectable *Preprocessor::CastIntelSingleRay(const Vector3 &viewPoint,911 const Vector3 &direction,912 //const float probability,913 Vector3 &tPoint,914 const AxisAlignedBox3 &box915 )916 {917 AxisAlignedBox3 sbox = box;918 sbox.Enlarge(Vector3(-Limits::Small));919 920 if (!sbox.IsInside(viewPoint))921 return 0;922 923 #ifdef GTP_INTERNAL924 float pforg[3];925 float pfdir[3];926 double pfnorm[3];927 928 pforg[0] = viewPoint[0]; pforg[1] = viewPoint[1]; pforg[2] = viewPoint[2];929 pfdir[0] = direction[0]; pfdir[1] = direction[1]; pfdir[2] = direction[2];930 931 float dist;932 const int hittriangle = mlrtaIntersectAS(pforg, pfdir, pfnorm, dist);933 934 if (hittriangle == -1)935 {936 static Ray ray;937 SetupRay(ray, viewPoint, direction);938 939 float tmin = 0, tmax;940 if (box.ComputeMinMaxT(ray, &tmin, &tmax) && tmin < tmax)941 {942 tPoint = ray.Extrap(tmax);943 }944 945 return NULL;946 }947 else {948 if (hittriangle >= mFaceParents.size()) {949 cerr<<"Warning: triangle index out of range! "<<hittriangle<<endl;950 return NULL;951 }952 else {953 954 tPoint[0] = pforg[0] + pfdir[0] * dist;955 tPoint[1] = pforg[1] + pfdir[1] * dist;956 tPoint[2] = pforg[2] + pfdir[2] * dist;957 958 return mFaceParents[hittriangle].mObject;959 }960 }961 962 #else963 const int hittriangle = -1;964 return NULL;965 #endif966 967 }968 969 970 int Preprocessor::CastInternalRay(971 const Vector3 &viewPoint,972 const Vector3 &direction,973 const float probability,974 VssRayContainer &vssRays,975 const AxisAlignedBox3 &box976 )977 {978 //cout << "internal ray" << endl;979 int hits = 0;980 static Ray ray;981 Intersectable *objectA, *objectB;982 Vector3 pointA, pointB;983 984 // AxisAlignedBox3 box = Union(mKdTree->GetBox(), mViewCellsManager->GetViewSpaceBox());985 AxisAlignedBox3 sbox = box;986 sbox.Enlarge(Vector3(-Limits::Small));987 if (!sbox.IsInside(viewPoint))988 return 0;989 990 SetupRay(ray, viewPoint, direction);991 ray.mFlags &= ~Ray::CULL_BACKFACES;992 993 // cast ray to KD tree to find intersection with other objects994 float bsize = Magnitude(box.Size());995 996 997 if (mKdTree->CastRay(ray)) {998 objectA = ray.intersections[0].mObject;999 pointA = ray.Extrap(ray.intersections[0].mT);1000 if (mDetectEmptyViewSpace)1001 if (DotProd(ray.intersections[0].mNormal, direction) >= 0) {1002 // discard the sample1003 return 0;1004 }1005 1006 } else {1007 objectA = NULL;1008 // compute intersection with the scene bounding box1009 float tmin, tmax;1010 if (box.ComputeMinMaxT(ray, &tmin, &tmax) && tmin < tmax)1011 pointA = ray.Extrap(tmax);1012 else1013 return 0;1014 }1015 1016 SetupRay(ray, viewPoint, -direction);1017 ray.mFlags &= ~Ray::CULL_BACKFACES;1018 1019 if (mKdTree->CastRay(ray)) {1020 objectB = ray.intersections[0].mObject;1021 pointB = ray.Extrap(ray.intersections[0].mT);1022 if (mDetectEmptyViewSpace)1023 if (DotProd(ray.intersections[0].mNormal, direction) <= 0) {1024 // discard the sample1025 return 0;1026 }1027 } else {1028 objectB = NULL;1029 float tmin, tmax;1030 if (box.ComputeMinMaxT(ray, &tmin, &tmax) && tmin < tmax)1031 pointB = ray.Extrap(tmax);1032 else1033 return 0;1034 }1035 1036 1037 VssRay *vssRay = NULL;1038 bool validSample = (objectA != objectB);1039 if (validSample) {1040 if (objectA) {1041 vssRay = new VssRay(pointB,1042 pointA,1043 objectB,1044 objectA,1045 mPass,1046 probability1047 );1048 vssRays.push_back(vssRay);1049 //cout << "ray: " << *vssRay << endl;1050 hits ++;1051 }1052 1053 if (objectB) {1054 vssRay = new VssRay(pointA,1055 pointB,1056 objectA,1057 objectB,1058 mPass,1059 probability1060 );1061 vssRays.push_back(vssRay);1062 //cout << "ray: " << *vssRay << endl;1063 hits ++;1064 }1065 }1066 1067 return hits;1068 }1069 1070 1071 int1072 Preprocessor::ProcessRay(1073 const Vector3 &viewPoint,1074 const Vector3 &direction,1075 Intersectable *objectA,1076 Vector3 &pointA,1077 const Vector3 &normalA,1078 Intersectable *objectB,1079 Vector3 &pointB,1080 const Vector3 &normalB,1081 const float probability,1082 VssRayContainer &vssRays,1083 const AxisAlignedBox3 &box1084 )1085 {1086 int hits=0;1087 #if DEBUG_RAYCAST1088 Debug<<"PR ";1089 #endif1090 if (objectA == NULL && objectB == NULL)1091 return 0;1092 1093 AxisAlignedBox3 sbox = box;1094 sbox.Enlarge(Vector3(-Limits::Small));1095 1096 if (!sbox.IsInside(viewPoint))1097 return 0;1098 1099 if (objectA == NULL) {1100 // compute intersection with the scene bounding box1101 static Ray ray;1102 SetupRay(ray, viewPoint, direction);1103 1104 float tmin, tmax;1105 if (box.ComputeMinMaxT(ray, &tmin, &tmax) && tmin < tmax)1106 pointA = ray.Extrap(tmax);1107 else1108 return 0;1109 } else {1110 if (mDetectEmptyViewSpace)1111 if (DotProd(normalA, direction) >= 0) {1112 // discard the sample1113 return 0;1114 }1115 }1116 1117 if (objectB == NULL) {1118 // compute intersection with the scene bounding box1119 static Ray ray;1120 SetupRay(ray, viewPoint, -direction);1121 1122 float tmin, tmax;1123 if (box.ComputeMinMaxT(ray, &tmin, &tmax) && tmin < tmax)1124 pointB = ray.Extrap(tmax);1125 else1126 return 0;1127 } else {1128 if (mDetectEmptyViewSpace)1129 if (DotProd(normalB, direction) <= 0) {1130 // discard the sample1131 return 0;1132 }1133 }1134 1135 VssRay *vssRay = NULL;1136 bool validSample = (objectA != objectB);1137 if (validSample) {1138 if (objectA) {1139 vssRay = new VssRay(pointB,1140 pointA,1141 objectB,1142 objectA,1143 mPass,1144 probability1145 );1146 vssRays.push_back(vssRay);1147 //cout << "ray: " << *vssRay << endl;1148 hits ++;1149 }1150 1151 if (objectB) {1152 vssRay = new VssRay(pointA,1153 pointB,1154 objectA,1155 objectB,1156 mPass,1157 probability1158 );1159 vssRays.push_back(vssRay);1160 //cout << "ray: " << *vssRay << endl;1161 hits ++;1162 }1163 }1164 1165 1166 return hits;1167 }1168 1169 void1170 Preprocessor::CastRays16(const int index,1171 SimpleRayContainer &rays,1172 VssRayContainer &vssRays,1173 const AxisAlignedBox3 &sbox)1174 {1175 int i;1176 const int num = 16;1177 1178 #if DEBUG_RAYCAST1179 Debug<<"C16 "<<flush;1180 #endif1181 if (mRayCastMethod == INTEL_RAYCASTER) {1182 #ifdef GTP_INTERNAL1183 1184 int forward_hit_triangles[16];1185 float forward_dist[16];1186 1187 int backward_hit_triangles[16];1188 float backward_dist[16];1189 1190 1191 Vector3 min = sbox.Min();1192 Vector3 max = sbox.Max();1193 1194 for (i=0; i < num; i++) {1195 mlrtaStoreRayAS16(&rays[index + i].mOrigin.x,1196 &rays[index + i].mDirection.x,1197 i);1198 }1199 1200 mlrtaTraverseGroupAS16(&min.x,1201 &max.x,1202 forward_hit_triangles,1203 forward_dist);1204 1205 for (i=0; i < num; i++) {1206 Vector3 dir = -rays[index + i].mDirection;1207 mlrtaStoreRayAS16(&rays[index+i].mOrigin.x,1208 &dir.x,1209 i);1210 }1211 1212 mlrtaTraverseGroupAS16(&min.x,1213 &max.x,1214 backward_hit_triangles,1215 backward_dist);1216 1217 1218 for (i=0; i < num; i++) {1219 Intersectable *objectA = NULL, *objectB = NULL;1220 Vector3 pointA, pointB;1221 Vector3 normalA, normalB;1222 1223 if (forward_hit_triangles[i] != -1 ) {1224 if (forward_hit_triangles[i] >= mFaceParents.size())1225 cerr<<"Warning: triangle index out of range! "<<forward_hit_triangles[i]<<endl;1226 else {1227 objectA = mFaceParents[forward_hit_triangles[i]].mObject;1228 // Get the normal of that face1229 normalA = objectA->GetNormal(mFaceParents[forward_hit_triangles[i]].mFaceIndex);1230 //-rays[index+i].mDirection; // $$ temporary1231 pointA = rays[index+i].Extrap(forward_dist[i]);1232 }1233 }1234 1235 if (backward_hit_triangles[i]!=-1) {1236 if (backward_hit_triangles[i] >= mFaceParents.size())1237 cerr<<"Warning: triangle index out of range! "<<backward_hit_triangles[i]<<endl;1238 else {1239 objectB = mFaceParents[backward_hit_triangles[i]].mObject;1240 normalB = objectB->GetNormal(mFaceParents[forward_hit_triangles[i]].mFaceIndex);1241 1242 // normalB = rays[index+i].mDirection; // $$ temporary1243 pointB = rays[index+i].Extrap(-backward_dist[i]);1244 }1245 }1246 1247 ProcessRay(rays[index+i].mOrigin,1248 rays[index+i].mDirection,1249 objectA, pointA, normalA,1250 objectB, pointB, normalB,1251 rays[index+i].mPdf,1252 vssRays,1253 sbox1254 );1255 }1256 1257 #endif1258 1259 } else {1260 1261 for (i=index; i < index + num; i++) {1262 CastRay(rays[i].mOrigin,1263 rays[i].mDirection,1264 rays[i].mPdf,1265 vssRays,1266 sbox);1267 }1268 }1269 #if DEBUG_RAYCAST1270 Debug<<"C16F\n"<<flush;1271 #endif1272 }1273 831 1274 832 void 1275 833 Preprocessor::CastRays( 1276 834 SimpleRayContainer &rays, 1277 VssRayContainer &vssRays 835 VssRayContainer &vssRays, 836 const bool castDoubleRays 1278 837 ) 1279 838 { 1280 long t1 = GetTime(); 1281 1282 for (int i = 0; i < (int)rays.size(); ) { 1283 // method only available for intel raycaster yet 1284 if (i + 16 < (int)rays.size()) { 1285 1286 CastRays16( 1287 i, 1288 rays, 1289 vssRays, 1290 mViewCellsManager->GetViewSpaceBox()); 1291 i += 16; 1292 } else { 1293 CastRay(rays[i].mOrigin, 1294 rays[i].mDirection, 1295 rays[i].mPdf, 1296 vssRays, 1297 mViewCellsManager->GetViewSpaceBox()); 1298 i++; 1299 } 1300 if (i % 10000 == 0) 1301 cout<<"."; 1302 } 1303 1304 long t2 = GetTime(); 1305 cout<<2*rays.size()/(1e3*TimeDiff(t1, t2))<<"M rays/s"<<endl; 1306 } 1307 1308 Intersectable * 1309 Preprocessor::CastSimpleRay( 1310 const Vector3 &viewPoint, 1311 const Vector3 &direction, 1312 const AxisAlignedBox3 &box, 1313 Vector3 &point, 1314 Vector3 &normal 1315 ) 1316 { 1317 Intersectable *result = NULL; 1318 switch (mRayCastMethod) 1319 { 1320 case INTEL_RAYCASTER: { 1321 1322 int hittriangle; 1323 1324 #ifdef GTP_INTERNAL 1325 float dist; 1326 double n[3]; 1327 1328 hittriangle = mlrtaIntersectAS(&viewPoint.x, 1329 &direction.x, 1330 n, 1331 dist); 1332 1333 if (hittriangle !=-1 ) { 1334 if (hittriangle >= mFaceParents.size()) 1335 cerr<<"Warning: triangle index out of range! "<<hittriangle<<endl; 1336 else { 1337 result = mFaceParents[hittriangle].mObject; 1338 normal = Vector3(n[0], n[1], n[2]); 1339 point = viewPoint + direction*dist; 1340 } 1341 } 1342 #else 1343 hittriangle = -1; 1344 #endif 1345 1346 break; 1347 } 1348 case INTERNAL_RAYCASTER: 1349 default: { 1350 static Ray ray; 1351 1352 ray.intersections.clear(); 1353 // do not store anything else then intersections at the ray 1354 ray.Init(viewPoint, direction, Ray::LOCAL_RAY); 1355 1356 ray.mFlags &= ~Ray::CULL_BACKFACES; 1357 1358 if (mKdTree->CastRay(ray)) { 1359 result = ray.intersections[0].mObject; 1360 point = ray.Extrap(ray.intersections[0].mT); 1361 normal = ray.intersections[0].mNormal; 1362 } 1363 break; 1364 } 1365 } 1366 return result; 1367 } 1368 1369 int 1370 Preprocessor::CastRay( 1371 const Vector3 &viewPoint, 1372 const Vector3 &direction, 1373 const float probability, 1374 VssRayContainer &vssRays, 1375 const AxisAlignedBox3 &box 1376 ) 1377 { 1378 #if DEBUG_RAYCAST 1379 Debug<<"CR "<<flush; 1380 #endif 1381 switch (mRayCastMethod) 1382 { 1383 case INTEL_RAYCASTER: 1384 return CastIntelDoubleRay(viewPoint, direction, probability, vssRays, box); 1385 case INTERNAL_RAYCASTER: 1386 default: 1387 return CastInternalRay(viewPoint, direction, probability, vssRays, box); 1388 } 1389 #if DEBUG_RAYCAST 1390 Debug<<"CRF "<<flush; 1391 #endif 839 long t1 = GetTime(); 840 841 if (castDoubleRays) 842 { 843 for (int i = 0; i < (int)rays.size(); ) 844 { 845 if (i + 16 < (int)rays.size()) 846 { 847 mRayCaster->CastRays16( 848 i, 849 rays, 850 vssRays, 851 mViewCellsManager->GetViewSpaceBox(), 852 castDoubleRays); 853 i += 16; 854 } 855 else 856 { 857 mRayCaster->CastRay( 858 rays[i].mOrigin, 859 rays[i].mDirection, 860 rays[i].mPdf, 861 vssRays, 862 mViewCellsManager->GetViewSpaceBox(), 863 castDoubleRays); 864 i++; 865 } 866 867 if (i % 10000 == 0) 868 cout<<"."; 869 } 870 871 long t2 = GetTime(); 872 873 if (castDoubleRays) 874 cout << 2 * rays.size() / (1e3f * TimeDiff(t1, t2)) << "M rays/s" << endl; 875 else 876 cout << rays.size() / (1e3f * TimeDiff(t1, t2)) << "M rays/s" << endl; 877 } 878 1392 879 } 1393 880 … … 1429 916 const Vector3 &point, 1430 917 const Vector3 &direction 1431 ) 918 ) const 1432 919 { 1433 920 ray.Clear(); … … 1436 923 } 1437 924 1438 } 925 926 } -
GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.h
r1486 r1520 8 8 #include "KdTree.h" 9 9 10 // matt: remove qt dependencies 11 //#include <QObject> 10 12 11 13 12 namespace GtpVisibilityPreprocessor { … … 29 28 class Intersectable; 30 29 class VssRay; 30 class RayCaster; 31 31 32 32 33 /** Namespace for the external visibility preprocessor … … 45 46 { 46 47 //Q_OBJECT 47 48 friend class RayCaster; 49 friend class IntelRayCaster; 50 friend class InternalRayCaster; 51 48 52 public: 49 53 /** Default constructor initialising e.g., KD tree and BSP tree. … … 51 55 Preprocessor(); 52 56 53 57 virtual ~Preprocessor(); 54 58 55 59 /** Load the input scene. … … 123 127 bool ExportKdTree(const string filename); 124 128 125 /** Get Sample rays of particular type, returns false if this126 type of rays is not supported by the preprocessor127 */128 enum {129 OBJECT_BASED_DISTRIBUTION,130 DIRECTION_BASED_DISTRIBUTION,131 DIRECTION_BOX_BASED_DISTRIBUTION,132 SPATIAL_BOX_BASED_DISTRIBUTION,133 RSS_BASED_DISTRIBUTION,134 RSS_SILHOUETTE_BASED_DISTRIBUTION,135 VSS_BASED_DISTRIBUTION,136 OBJECT_DIRECTION_BASED_DISTRIBUTION,137 OBJECTS_INTERIOR_DISTRIBUTION138 };139 140 enum {141 INTERNAL_RAYCASTER = 0,142 INTEL_RAYCASTER143 };144 145 129 virtual bool 146 130 GenerateRays( … … 157 141 158 142 virtual void CastRays(SimpleRayContainer &rays, 159 VssRayContainer &vssRays); 143 VssRayContainer &vssRays, 144 const bool castDoubleRays); 160 145 161 146 /** Returns a view cells manager of the given name. … … 178 163 ); 179 164 180 Intersectable *181 CastSimpleRay(182 const Vector3 &viewPoint,183 const Vector3 &direction,184 const AxisAlignedBox3 &box,185 Vector3 &point,186 Vector3 &normal187 );188 165 189 166 //////////////////////////////////////////////// … … 234 211 float mVisibilityFilterWidth; 235 212 236 int GetRayCastMethod() { return mRayCastMethod; }237 void SetRayCastMethod(int rayCastMethod) { mRayCastMethod = rayCastMethod; }213 //int GetRayCastMethod() { return mRayCastMethod; } 214 //void SetRayCastMethod(int rayCastMethod) { mRayCastMethod = rayCastMethod; } 238 215 239 216 int mPass; … … 241 218 protected: 242 219 243 void SetupRay(Ray &ray, const Vector3 &point, const Vector3 &direction); 244 245 int 246 ProcessRay( 247 const Vector3 &viewPoint, 248 const Vector3 &direction, 249 Intersectable *objectA, 250 Vector3 &pointA, 251 const Vector3 &normalA, 252 Intersectable *objectB, 253 Vector3 &pointB, 254 const Vector3 &normalB, 255 const float probability, 256 VssRayContainer &vssRays, 257 const AxisAlignedBox3 &box); 258 259 int CastInternalRay( 260 const Vector3 &viewPoint, 261 const Vector3 &direction, 262 const float probability, 263 VssRayContainer &vssRays, 264 const AxisAlignedBox3 &box); 265 266 int CastIntelDoubleRay( 267 const Vector3 &viewPoint, 268 const Vector3 &direction, 269 const float probability, 270 VssRayContainer &vssRays, 271 const AxisAlignedBox3 &box); 272 273 Intersectable *CastIntelSingleRay( 274 const Vector3 &viewPoint, 275 const Vector3 &direction, 276 Vector3 &tPoint, 277 const AxisAlignedBox3 &box); 278 279 ///////////////////////// 280 281 int mRayCastMethod; 220 void SetupRay(Ray &ray, const Vector3 &point, const Vector3 &direction) const; 221 222 // matt: previously was a signal 223 void EvalPvsStat(); 224 225 ///////////////////////// 226 227 RayCaster *mRayCaster; 282 228 /// samples used for construction of the BSP view cells tree. 283 229 int mBspConstructionSamples; … … 287 233 */ 288 234 RenderSimulator *mRenderSimulator; 289 290 235 291 236 vector<FaceParentInfo> mFaceParents; 292 237 293 238 GlRendererBuffer *renderer; 294 // matt: remove qt dependencies 295 //signals: 296 void EvalPvsStat(); 297 298 protected: 299 300 301 void CastRays16(const int i, 302 SimpleRayContainer &rays, 303 VssRayContainer &vssRays, 304 const AxisAlignedBox3 &sbox); 239 305 240 306 241 }; 307 242 308 //extern Preprocessor *preprocessor;309 243 310 244 } -
GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.vcproj
r1501 r1520 217 217 OptimizeForProcessor="3" 218 218 OptimizeForWindowsApplication="TRUE" 219 AdditionalIncludeDirectories="..\src;..\..\..\..\..\..\NonGTP\Devil\include;..\..\..\..\..\..\NonGTP\Zlib\include;..\..\..\..\..\..\NonGTP\Xerces;..\..\..\..\..\..\NonGTP\Boost;..\MultiLevelRayTracing;"$(QTDIR)\include\QtCore" "219 AdditionalIncludeDirectories="..\src;..\..\..\..\..\..\NonGTP\Devil\include;..\..\..\..\..\..\NonGTP\Zlib\include;..\..\..\..\..\..\NonGTP\Xerces;..\..\..\..\..\..\NonGTP\Boost;..\MultiLevelRayTracing;"$(QTDIR)\include\QtCore";"$(QTDIR)\include\QtGui";"$(QTDIR)\include"" 220 220 PreprocessorDefinitions="WIN32;NDEBUG;_LIB;GTP_INTERNAL" 221 221 ExceptionHandling="TRUE" … … 364 364 <File 365 365 RelativePath=".\HierarchyManager.h"> 366 </File> 367 <File 368 RelativePath=".\IntelRayCaster.cpp"> 369 </File> 370 <File 371 RelativePath=".\IntelRayCaster.h"> 372 </File> 373 <File 374 RelativePath=".\InternalRayCaster.cpp"> 375 </File> 376 <File 377 RelativePath=".\InternalRayCaster.h"> 366 378 </File> 367 379 <File … … 556 568 </File> 557 569 <File 570 RelativePath=".\QtPreprocessorThread.cpp"> 571 </File> 572 <File 573 RelativePath=".\QtPreprocessorThread.h"> 574 </File> 575 <File 558 576 RelativePath="..\src\Ray.cpp"> 559 577 </File> 560 578 <File 561 579 RelativePath="..\src\Ray.h"> 580 </File> 581 <File 582 RelativePath=".\RayCaster.cpp"> 583 </File> 584 <File 585 RelativePath=".\RayCaster.h"> 562 586 </File> 563 587 <File -
GTP/trunk/Lib/Vis/Preprocessing/src/QtGlRenderer/QtGlRenderer.vcproj
r1270 r1520 103 103 Name="VCMIDLTool"/> 104 104 <Tool 105 Name="VCPostBuildEventTool"/> 105 Name="VCPostBuildEventTool" 106 Description=""copy dll to preprocessor dir"" 107 CommandLine="copy $(OutDir)\*.dll ..\..\bin\"/> 106 108 <Tool 107 109 Name="VCPreBuildEventTool"/> -
GTP/trunk/Lib/Vis/Preprocessing/src/QtPreprocessorThread.cpp
r1457 r1520 1 #ifdef GTP_INTERNAL 1 2 #include <QApplication> 2 3 3 #include "QtPreprocessorThread.h" 4 4 #include "Camera.h" … … 17 17 { 18 18 if (p->mQuitOnFinish) 19 connect(this, SIGNAL(finished()), qApp, SLOT(closeAllWindows(void))); 19 { 20 connect(this, SIGNAL(finished()), qApp, SLOT(closeAllWindows(void))); 21 } 20 22 } 21 23 … … 28 30 } 29 31 32 #endif -
GTP/trunk/Lib/Vis/Preprocessing/src/RssPreprocessor.cpp
r1454 r1520 12 12 #include "RenderSimulator.h" 13 13 #include "GlRenderer.h" 14 #include "SamplingStrategy.h" 15 14 16 15 17 namespace GtpVisibilityPreprocessor { … … 62 64 63 65 switch (sampleType) { 64 case RSS_BASED_DISTRIBUTION:65 case RSS_SILHOUETTE_BASED_DISTRIBUTION:66 case SamplingStrategy::RSS_BASED_DISTRIBUTION: 67 case SamplingStrategy::RSS_SILHOUETTE_BASED_DISTRIBUTION: 66 68 if (mRssTree) { 67 69 GenerateImportanceRays(mRssTree, number, rays); … … 554 556 555 557 if (mUseImportanceSampling) { 556 GenerateRays(mInitialSamples/3, S PATIAL_BOX_BASED_DISTRIBUTION, rays);557 GenerateRays(mInitialSamples/3, OBJECT_BASED_DISTRIBUTION, rays);558 GenerateRays(mInitialSamples/3, DIRECTION_BASED_DISTRIBUTION, rays);558 GenerateRays(mInitialSamples/3, SamplingStrategy::SPATIAL_BOX_BASED_DISTRIBUTION, rays); 559 GenerateRays(mInitialSamples/3, SamplingStrategy::OBJECT_BASED_DISTRIBUTION, rays); 560 GenerateRays(mInitialSamples/3, SamplingStrategy::DIRECTION_BASED_DISTRIBUTION, rays); 559 561 // GenerateRays(mInitialSamples/4, OBJECT_DIRECTION_BASED_DISTRIBUTION, rays); 560 562 } else { 561 int rayType =SPATIAL_BOX_BASED_DISTRIBUTION;563 int rayType = SamplingStrategy::SPATIAL_BOX_BASED_DISTRIBUTION; 562 564 if (mObjectBasedSampling) 563 rayType = OBJECT_BASED_DISTRIBUTION;565 rayType = SamplingStrategy::OBJECT_BASED_DISTRIBUTION; 564 566 else 565 567 if (mDirectionalSampling) 566 rayType = DIRECTION_BASED_DISTRIBUTION;568 rayType = SamplingStrategy::DIRECTION_BASED_DISTRIBUTION; 567 569 cout<<"Generating rays..."<<endl; 568 570 GenerateRays(mRssSamplesPerPass, rayType, rays); … … 571 573 572 574 cout<<"Casting initial rays..."<<endl<<flush; 573 CastRays(rays, mVssRays );575 CastRays(rays, mVssRays, true); 574 576 575 577 ExportObjectRays(mVssRays, 1546); … … 690 692 t1 = GetTime(); 691 693 692 GenerateRays(int(mRssSamplesPerPass*ratios[0]), RSS_BASED_DISTRIBUTION, rays);694 GenerateRays(int(mRssSamplesPerPass*ratios[0]), SamplingStrategy::RSS_BASED_DISTRIBUTION, rays); 693 695 694 696 rays.NormalizePdf((float)rays.size()); 695 697 696 CastRays(rays, tmpVssRays );698 CastRays(rays, tmpVssRays, true); 697 699 castRays += (int)rays.size(); 698 700 #if ADD_RAYS_IN_PLACE … … 711 713 if (ratios[1]!=0.0f) { 712 714 t1 = GetTime(); 713 GenerateRays(int(mRssSamplesPerPass*ratios[1]), S PATIAL_BOX_BASED_DISTRIBUTION, rays);714 CastRays(rays, tmpVssRays );715 GenerateRays(int(mRssSamplesPerPass*ratios[1]), SamplingStrategy::SPATIAL_BOX_BASED_DISTRIBUTION, rays); 716 CastRays(rays, tmpVssRays, true); 715 717 castRays += (int)rays.size(); 716 718 #if ADD_RAYS_IN_PLACE … … 733 735 if (ratios[2]!=0.0f) { 734 736 t1 = GetTime(); 735 GenerateRays(int(mRssSamplesPerPass*ratios[2]), DIRECTION_BASED_DISTRIBUTION, rays);736 CastRays(rays, tmpVssRays );737 GenerateRays(int(mRssSamplesPerPass*ratios[2]), SamplingStrategy::DIRECTION_BASED_DISTRIBUTION, rays); 738 CastRays(rays, tmpVssRays, true); 737 739 castRays += (int)rays.size(); 738 740 #if ADD_RAYS_IN_PLACE … … 775 777 } 776 778 else { 777 int rayType =SPATIAL_BOX_BASED_DISTRIBUTION;779 int rayType = SamplingStrategy::SPATIAL_BOX_BASED_DISTRIBUTION; 778 780 if (mObjectBasedSampling) 779 rayType =OBJECT_BASED_DISTRIBUTION;781 rayType = SamplingStrategy::OBJECT_BASED_DISTRIBUTION; 780 782 else 781 783 if (mDirectionalSampling) 782 rayType =DIRECTION_BASED_DISTRIBUTION;784 rayType = SamplingStrategy::DIRECTION_BASED_DISTRIBUTION; 783 785 784 786 cout<<"Generating rays..."<<endl; … … 788 790 789 791 cout<<"Casting rays..."<<endl; 790 CastRays(rays, vssRays );792 CastRays(rays, vssRays, true); 791 793 cout<<"done."<<endl; 792 794 castRays += (int)rays.size(); -
GTP/trunk/Lib/Vis/Preprocessing/src/SamplingPreprocessor.cpp
r1486 r1520 47 47 48 48 // cast ray to KD tree to find intersection with other objects 49 #if 0 49 50 object = CastSimpleRay(origin, 50 51 direction, … … 53 54 normal 54 55 ); 55 56 #endif 57 56 58 if (mDetectEmptyViewSpace && DotProd(normal, direction) >= 0) { 57 59 object = NULL; -
GTP/trunk/Lib/Vis/Preprocessing/src/SamplingStrategy.cpp
r1297 r1520 8 8 9 9 namespace GtpVisibilityPreprocessor { 10 11 12 SamplingStrategy::SamplingStrategy(const Preprocessor &preprocessor): 13 mPreprocessor(preprocessor) 14 { 15 } 16 17 18 SamplingStrategy::~SamplingStrategy() 19 { 20 } 21 10 22 11 23 … … 142 154 } 143 155 144 /* 156 #if 0 145 157 bool ObjectsInteriorDistribution::GenerateSample(SimpleRay &ray) const 146 158 { … … 170 182 171 183 return true; 172 }*/173 174 184 } 185 #endif 186 } -
GTP/trunk/Lib/Vis/Preprocessing/src/SamplingStrategy.h
r1021 r1520 15 15 public: 16 16 17 /** Sample rays of particular type 18 */ 19 enum 20 { 21 OBJECT_BASED_DISTRIBUTION, 22 DIRECTION_BASED_DISTRIBUTION, 23 DIRECTION_BOX_BASED_DISTRIBUTION, 24 SPATIAL_BOX_BASED_DISTRIBUTION, 25 RSS_BASED_DISTRIBUTION, 26 RSS_SILHOUETTE_BASED_DISTRIBUTION, 27 VSS_BASED_DISTRIBUTION, 28 OBJECT_DIRECTION_BASED_DISTRIBUTION, 29 OBJECTS_INTERIOR_DISTRIBUTION 30 }; 31 17 32 /** Default constructor 18 33 */ 19 SamplingStrategy(const Preprocessor &preprocessor): mPreprocessor(preprocessor) 20 {} 34 SamplingStrategy(const Preprocessor &preprocessor); 21 35 22 virtual ~SamplingStrategy() {};36 virtual ~SamplingStrategy(); 23 37 24 38 /** Each strategy has to implement this function. -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp
r1486 r1520 22 22 #include "OspTree.h" 23 23 #include "BvHierarchy.h" 24 #include "SamplingStrategy.h" 24 25 25 26 … … 110 111 if (strcmp(buf, "box") == 0) 111 112 { 112 mSamplingType = Preprocessor::SPATIAL_BOX_BASED_DISTRIBUTION;113 mSamplingType = SamplingStrategy::SPATIAL_BOX_BASED_DISTRIBUTION; 113 114 } 114 115 else if (strcmp(buf, "directional") == 0) 115 116 { 116 mSamplingType = Preprocessor::DIRECTION_BASED_DISTRIBUTION;117 mSamplingType = SamplingStrategy::DIRECTION_BASED_DISTRIBUTION; 117 118 } 118 119 else if (strcmp(buf, "object_directional") == 0) 119 120 { 120 mSamplingType = Preprocessor::OBJECT_DIRECTION_BASED_DISTRIBUTION;121 mSamplingType = SamplingStrategy::OBJECT_DIRECTION_BASED_DISTRIBUTION; 121 122 } 122 123 /*else if (strcmp(buf, "interior") == 0) … … 135 136 if (strcmp(buf, "box") == 0) 136 137 { 137 mEvaluationSamplingType = Preprocessor::SPATIAL_BOX_BASED_DISTRIBUTION;138 mEvaluationSamplingType = SamplingStrategy::SPATIAL_BOX_BASED_DISTRIBUTION; 138 139 } 139 140 else if (strcmp(buf, "directional") == 0) 140 141 { 141 mEvaluationSamplingType = Preprocessor::DIRECTION_BASED_DISTRIBUTION;142 mEvaluationSamplingType = SamplingStrategy::DIRECTION_BASED_DISTRIBUTION; 142 143 } 143 144 else if (strcmp(buf, "object_directional") == 0) 144 145 { 145 mEvaluationSamplingType = Preprocessor::OBJECT_DIRECTION_BASED_DISTRIBUTION;146 mEvaluationSamplingType = SamplingStrategy::OBJECT_DIRECTION_BASED_DISTRIBUTION; 146 147 } 147 148 /*else if (strcmp(buf, "interior") == 0) 148 149 { 149 mEvaluationSamplingType = Preprocessor::OBJECTS_INTERIOR_DISTRIBUTION;150 mEvaluationSamplingType = SamplingStrategy::OBJECTS_INTERIOR_DISTRIBUTION; 150 151 }*/ 151 152 else … … 271 272 272 273 // shoot simple ray and add it to importance samples 273 mPreprocessor->CastRays(simpleRays, passSamples );274 mPreprocessor->CastRays(simpleRays, passSamples, true); 274 275 Debug << "cast " << samplesPerPass << " samples in " << TimeDiff(startTime, GetTime()) * 1e-3 << " secs" << endl; 275 276 … … 394 395 const int n = mConstructionSamples; //+initialSamples; 395 396 // should we use directional samples? 396 bool dirSamples = (mSamplingType == Preprocessor::DIRECTION_BASED_DISTRIBUTION);397 bool dirSamples = (mSamplingType == SamplingStrategy::DIRECTION_BASED_DISTRIBUTION); 397 398 398 399 while (numSamples < n) … … 489 490 VssRayContainer visualizationSamples; 490 491 492 //////// 491 493 //-- visualization rays, e.g., to show some samples in the scene 492 494 CastPassSamples(mVisualizationSamples, 493 Preprocessor::DIRECTION_BASED_DISTRIBUTION,495 SamplingStrategy::DIRECTION_BASED_DISTRIBUTION, 494 496 visualizationSamples); 495 497 … … 841 843 842 844 // should directional sampling be used? 843 bool dirSamples = (mEvaluationSamplingType == Preprocessor::DIRECTION_BASED_DISTRIBUTION);845 bool dirSamples = (mEvaluationSamplingType == SamplingStrategy::DIRECTION_BASED_DISTRIBUTION); 844 846 845 847 cout << "reseting pvs ... ";
Note: See TracChangeset
for help on using the changeset viewer.