Vector3List generatePoints3D(unsigned int n = 4) { Vector3List v; for (unsigned int i = 0; i < n; i++) { v.push_back(Vector3::Random()); } return v; }
PointFunctions::Vector3List getPointsFromFile3D(std::string filePath) { std::ifstream file; // creates stream myFile file.open(filePath.c_str()); // opens .txt file if(!file.is_open()) { // check file is open, quit if not ApproxMVBB_ERRORMSG("Could not open file: " << filePath) } PREC a, b, c; Vector3List v; while(file.good()) { file >> a >> b >> c; v.emplace_back(a, b, c); } file.close(); return v; }
float GetPriority() { const MemoryRecord *pTarget = GetClient()->GetTargetingSystem()->GetCurrentTargetRecord(); if ( !pTarget ) return 0.f; if ( mShootBarrel.IsValid() ) return 1.f; Vector3f vTargetPos = pTarget->PredictPosition( 1.f ); static float fSplashRadius = 256.f; SensoryMemory *sensory = GetClient()->GetSensoryMemory(); // Check for exploding barrels near my target. MemoryRecords records; Vector3List recordpos; FilterAllType filter( GetClient(), AiState::SensoryMemory::EntAny, records ); filter.MemorySpan( Utils::SecondsToMilliseconds( 7.f ) ); filter.AddGroup( ENT_GRP_PROP_EXPLODE ); //filter.AddClass( ENT_CLASS_EXPLODING_BARREL ); sensory->QueryMemory( filter ); sensory->GetRecordInfo( records, &recordpos, NULL ); for ( uint32_t i = 0; i < recordpos.size(); ++i ) { if ( SquaredLength( recordpos[ i ], vTargetPos ) < Mathf::Sqr( fSplashRadius ) ) { MemoryRecord *pRec = sensory->GetMemoryRecord( records[ i ] ); if ( pRec ) { mShootBarrel = pRec->GetEntity(); return 1.f; } } } return 0.f; }
void readOOBB(std::string filePath, Vector3& minP, Vector3& maxP, Matrix33& R_KI, Vector3List& pointList) { auto v = getPointsFromFile3D(filePath); if(v.size() != 5 + 8) { ApproxMVBB_ERRORMSG("Wrong number of points in OOBB file: " << filePath << " points: " << v.size()) } minP = v[0]; maxP = v[1]; R_KI.row(0) = v[2]; R_KI.row(1) = v[3]; R_KI.row(2) = v[4]; pointList.resize(8); for(unsigned int i = 0; i < 8; ++i) { pointList[i] = v[5 + i]; } }