int DEMTerrain::ReadDEMFile(const std::string& file) { GDALAllRegister(); dataset_ = (GDALDataset*)(GDALOpen(file.c_str(),GA_ReadOnly)); if (dataset_ == NULL) return -1; double geoTransform[6]; int w = dataset_->GetRasterXSize(); int h = dataset_->GetRasterYSize(); if(dataset_->GetGeoTransform(geoTransform)==CE_None) { SetLocator(w,h,geoTransform); SetHeightField(w,h,geoTransform); } return 0; }
void CPropVehicleManhack::UpdateManhackView( CBasePlayer *pPlayer ) { CNPC_Manhack *pManhack=GetManhack(); if (pManhack != NULL) { m_angManhackEye = pManhack->GetAbsAngles(); //vehicleEyeAngles; m_vecManhackEye = pManhack->GetManhackView(); //vehicleEyeOrigin; m_iManhackHealth = pManhack->m_iHealth; Vector vecDir = pManhack->GetAbsVelocity(); VectorNormalize(vecDir); m_vecFlyingDirection = vecDir; UpdateHead(); if (GlobalEntity_GetState("manhacks_use_short_distances") == GLOBAL_ON) { Vector vecDistance = (pManhack->GetAbsOrigin() - GetAbsOrigin()); float flHeight = vecDistance.z / manhack_small_distances_max_height.GetFloat(); vecDistance.z = 0.0f; vecDistance = vecDistance / manhack_small_distances_max_distance.GetFloat(); vecDistance.z = flHeight; m_iManhackDistance = (int)( vecDistance.Length() * 100.0f ); } else { m_iManhackDistance = (int)( (float) (pManhack->GetAbsOrigin() - GetAbsOrigin()).Length() / manhack_max_distance.GetFloat() * 100.0f); } if (m_iManhackDistance >= 90 && m_flLastWarningSound < gpGlobals->curtime ) { pManhack->EmitSound("NPC_Turret.Retire"); m_flLastWarningSound = gpGlobals->curtime + 1.00f; } // Vector vecForward; m_hPlayer->GetVectors(&vecForward, NULL, NULL); trace_t tr; UTIL_TraceLine( m_vecManhackEye, m_vecManhackEye + (vecForward * 1024), MASK_SHOT, pManhack, COLLISION_GROUP_NONE, &tr ); //NDebugOverlay::Line( m_vecManhackEye, tr.endpos, 255, 255, 0, true, 1.0f ); if (tr.m_pEnt && pPlayer && pPlayer->IRelationType( tr.m_pEnt ) == D_HT) { m_hTarget = tr.m_pEnt; } else { m_hTarget = pManhack->GetEnemy(); } m_iTargetType = HLSS_SelectTargetType(m_hTarget); } else { DevMsg("NULL Manhack\n"); m_hManhack = NULL; SetLocator( NULL ); } }
bool CPropVehicleManhack::FindNextManhack(bool bRemoveIfNone) { int manhackIndex=-1; CNPC_Manhack *newManhack; bool bFound = false; for (int i=1; i<NUMBER_OF_MAX_CONTROLLABLE_MANHACKS; i++) { manhackIndex = (m_iCurrentManhackIndex + i) % NUMBER_OF_MAX_CONTROLLABLE_MANHACKS; if (m_hSetOfManhacks[manhackIndex] != NULL) { newManhack = dynamic_cast<CNPC_Manhack*>((CBaseEntity*)m_hSetOfManhacks[manhackIndex]); int iDistance = -1; if (newManhack != NULL ) { if (GlobalEntity_GetState("manhacks_use_short_distances") == GLOBAL_ON) { Vector vecDistance = (newManhack->GetAbsOrigin() - GetAbsOrigin()); float flHeight = vecDistance.z / manhack_small_distances_max_height.GetFloat(); vecDistance.z = 0.0f; vecDistance = vecDistance / manhack_small_distances_max_distance.GetFloat(); vecDistance.z = flHeight; iDistance = (int)( vecDistance.Length() * 100.0f ); } else { iDistance = (int)( (float) (newManhack->GetAbsOrigin() - GetAbsOrigin()).Length() / manhack_max_distance.GetFloat() * 100.0f); } } if (newManhack != NULL && newManhack->m_iHealth > 0 )//(newManhack->GetAbsOrigin() - GetAbsOrigin()).Length() < manhack_max_distance.GetFloat() ) { if (iDistance <= 100) { m_iCurrentManhackIndex = manhackIndex; m_hManhack = m_hSetOfManhacks[manhackIndex]; SetLocator( m_hManhack ); m_iManhackHealth = newManhack->m_iHealth; if (GetDriver()) { newManhack->SetControllable(true); if (manhack_dont_draw.GetBool()) { newManhack->AddEffects( EF_NODRAW ); newManhack->ShowRedGlow(false); } } return true; } } else { m_hSetOfManhacks[manhackIndex] = NULL; } } } if (!bFound && bRemoveIfNone) { SetLocator( NULL ); ForcePlayerOut(); DestroyAllManhacks(); UTIL_Remove(this); return true; } return false; }