void CAStarProcess::Init() { //ScriptMInstance->RunCode( "init()" ); CPhysicsManager* l_PM = PhysXMInstance; m_pAStarScene = new CAStar(); m_pAStarScene->Init(); CPhysicUserData* userData = new CPhysicUserData( "CharacterController" ); userData->SetPaint( true ); userData->SetColor( colWHITE ); m_vPUD.push_back( userData ); Math::Vect3f l_Pos = CameraMInstance->GetCurrentCamera()->GetPosition(); m_PhysicController = new CPhysicController( 0.5f, 2, 0.2f, 0.5f, 0.5f, ECG_PLAYER, userData, l_Pos ); l_PM->AddPhysicController( m_PhysicController ); CPhysicUserData* l_PUD = new CPhysicUserData( "Plane" ); l_PUD->SetPaint( true ); l_PUD->SetColor( colWHITE ); m_vPUD.push_back( l_PUD ); CPhysicActor* l_pPhysicActor = new CPhysicActor( l_PUD ); l_pPhysicActor->AddBoxShape( Math::Vect3f( 1000, 0.0f, 1000 ), Math::Vect3f( 0, -0.5f, 0 ) ); m_vPA.push_back( l_pPhysicActor ); l_PM->AddPhysicActor( l_pPhysicActor ); m_PointInicial = Math::Vect3f( 6, 0, -6 ); m_PointFinal = Math::Vect3f( 6, 0, 6 ); m_Path = m_pAStarScene->GetPath( m_PointInicial, m_PointFinal ); }
void CZombie::InicializaController() { CPhysicUserData *userdata = new CPhysicUserData(GetInstance()->GetName()); userdata->SetColor(colGREEN); userdata->SetPaint(true); GetInstance()->SetPosition(Vect3f(GetInstance()->GetPosition().x,GetInstance()->GetPosition().y + 1.0f,GetInstance()->GetPosition().z)); // m_pPhysicController = new CPhysicController(0.5f,2.0f,2.0f,0.1f,2.0f,1,userdata,GetInstance()->GetPosition()); m_pPhysicController = new CPhysicController(0.5f, 1.3f, 40.0f, 0.01f, 0.3f, PX_MSK_ENEMY_CONTROLLER, userdata, GetInstance()->GetPosition()); CORE->GetPhysicsManager()->AddPhysicController(m_pPhysicController); }
void CPhysicsManager::OverlapSphereActorGrenade (float radiusSphere, const Vect3f& posSphere, std::vector<CPhysicUserData*> impactObjects, float _fPower) { assert(m_pScene); NxSphere worldSphere(NxVec3(posSphere.x,posSphere.y,posSphere.z), radiusSphere); NxU32 nbShapes = m_pScene->getNbDynamicShapes(); NxShape** shapes = new NxShape* [nbShapes]; for (NxU32 i = 0; i < nbShapes; i++) { shapes[i] = NULL; } //NX_DYNAMIC_SHAPES m_pScene->overlapSphereShapes(worldSphere, NX_DYNAMIC_SHAPES, nbShapes, shapes, NULL); for (NxU32 i = 0; i < nbShapes; i++) { if( shapes[i] != NULL ) { NxActor* actor = &shapes[i]->getActor(); CPhysicUserData* physicObject = (CPhysicUserData*)actor->userData; //Si está petando aquí quiere decir que se ha registrado un objeto físico sin proporcionarle ID assert(physicObject); //Antes de meterlo comprobamos que no exista ya (un objeto fisico puede estar compuesto por varias shapes) std::vector<CPhysicUserData*>::iterator it(impactObjects.begin()); std::vector<CPhysicUserData*>::iterator itEnd(impactObjects.end()); bool find = false; while (it!=itEnd) { CPhysicUserData* id = *it; if( id == physicObject) find = true; ++it; } if(!find) { impactObjects.push_back(physicObject); physicObject->SetColor(colRED); ApplyExplosion(actor,posSphere,radiusSphere,_fPower); } } //delete &shapes[i]; } delete shapes; /*for (NxU32 i = 0; i < nbShapes; i++) { delete &shapes[i]; }*/ }