Exemplo n.º 1
0
CPhysicUserData* CPhysicsManager::RaycastClosestActor( const Vect3f _vPosRay, const Vect3f& _vDirRay, uint32 _uiImpactMask, SCollisionInfo& _Info, float _uiMaxDistance )
{
  //NxUserRaycastReport::ALL_SHAPES
	assert(m_pScene != NULL);

	NxRay ray; 
	ray.dir =  NxVec3 ( _vDirRay.x, _vDirRay.y, _vDirRay.z );
	ray.orig = NxVec3 ( _vPosRay.x, _vPosRay.y, _vPosRay.z );

	NxRaycastHit hit;
	NxShape* closestShape = NULL;
	
	//closestShape = m_pScene->raycastClosestShape ( ray, NX_ALL_SHAPES, hit, _uiImpactMask,  NX_MAX_F32, _uiImpactMask );
	//closestShape = m_pScene->raycastClosestShape( ray, NX_ALL_SHAPES, hit, 0xffffffff, NX_MAX_F32, 0xffffffff, NULL, NULL );
	NxReal l_Distance = (NxReal) _uiMaxDistance;

	// --- Jordi : Provisional. Cal deixar aquesta linia i modificar la col·lisió de càmera 
	closestShape = m_pScene->raycastClosestShape( ray, NX_ALL_SHAPES, hit, _uiImpactMask, l_Distance );
	if (!closestShape) 
	{
		//No hemos tocado a ningún objeto físico de la escena.
		return NULL;
	}
	NxActor* actor = &closestShape->getActor();
	CPhysicUserData* impactObject =(CPhysicUserData*)actor->userData;
	//Si está petando aquí quiere decir que se ha registrado un objeto físico sin proporcionarle UserData
	assert(impactObject);

	_Info.m_fDistance		= hit.distance;
	_Info.m_Normal			= Vect3f(hit.worldNormal.x, hit.worldNormal.y, hit.worldNormal.z ); 
	_Info.m_CollisionPoint	= Vect3f(hit.worldImpact.x, hit.worldImpact.y, hit.worldImpact.z ); 

	return impactObject;
}
Exemplo n.º 2
0
bool CZombie::GeneraManoIzquierda()
{
  m_triggerManoIzquierda = new CTrigger();
  assert (m_triggerManoIzquierda);

  m_bIsOk = m_triggerManoIzquierda->Init();
  if(!m_bIsOk)
  {
    LOGGER->AddNewLog(ELL_WARNING,"a CTrigger instace couldnt allocate memory");  
    return false;
  }

  m_triggerManoIzquierda->SetActive(false);
  m_triggerManoIzquierda->SetDimensions(Vect3f(0.15f,0.15f,0.15f));
  m_triggerManoIzquierda->SetEntity("mi_amigo");
  m_triggerManoIzquierda->SetPosition(Vect3f(0,-2,0));
  
  std::string l_sNameTrigger = GetUserData()->GetName();

  l_sNameTrigger += " ManoIzquierda";
  std::string l_script;
  baseUtils::FormatSrting( l_script, "golpea_mano_izquierda(\"%s\", \"%s\")", l_sNameTrigger.c_str(), m_triggerManoIzquierda->GetEntity().c_str());
  m_triggerManoIzquierda->SetOnEnterCode(l_script);
  m_actManoIzquierda = CORE->GetTriggerManager()->GeneraTrigger(l_sNameTrigger, m_triggerManoIzquierda, true);
  return true;
}
Exemplo n.º 3
0
void CEnemyInstance::InitInstance(CXMLTreeNode& _XMLParams)
{
    m_vPosition = _XMLParams.GetVect3fProperty("pos",Vect3f(0.0f));
    m_vRotate = _XMLParams.GetVect3fProperty("rot",Vect3f(0.0f));

    SetOk(true);
}
Exemplo n.º 4
0
CPhysicUserData* CPhysicsManager::RaycastClosestActor (const Vect3f posRay, const Vect3f& dirRay, uint32 impactMask, SCollisionInfo& info )
{
	//NxUserRaycastReport::ALL_SHAPES
	assert(m_pScene != NULL);

	NxRay ray; 
	ray.dir =  NxVec3(dirRay.x, dirRay.y, dirRay.z);
	ray.orig = NxVec3(posRay.x, posRay.y, posRay.z);

	NxRaycastHit hit;
	NxShape* closestShape = NULL;

	closestShape = m_pScene->raycastClosestShape(ray, NX_ALL_SHAPES, hit, impactMask);
	if (!closestShape) 
	{
		//No hemos tocado a ningún objeto físico de la escena.
		return NULL;
	}
	NxActor* actor = &closestShape->getActor();
	CPhysicUserData* impactObject =(CPhysicUserData*)actor->userData;
	//Si está petando aquí quiere decir que se ha registrado un objeto físico sin proporcionarle UserData
	assert(impactObject);

	info.m_fDistance	= hit.distance;
	info.m_Normal				= Vect3f(hit.worldNormal.x, hit.worldNormal.y, hit.worldNormal.z ); 
	info.m_CollisionPoint	= Vect3f(hit.worldImpact.x, hit.worldImpact.y, hit.worldImpact.z ); 

	return impactObject;
}
Exemplo n.º 5
0
//-----------------------------------------
//perseguir por posicion de personaje(sin colisiones)
//-----------------------------------------
//void CZombie::Perseguir(Vect3f hisPosition,float _elapsedtime)
//{
//  Vect3f myPosition = GetInstance()->GetPosition();
//  GetEjeMovimientoIA()->MovAgentIA(hisPosition,myPosition,GetMoveSpeed(),_elapsedtime);
//  
//  //posicion y rotacion del muñeco
//  
////  GetInstance()->SetPosition(Vect3f(myPosition.x,0,myPosition.z));
//  //GetInstance()->SetYaw(-(GetEjeMovimientoIA()->m_fAngleTotalPlayer2));
//
//  CRenderableObject* myinstance = CORE->GetRenderableObjectsManager()->GetInstance(this->GetInstance()->GetName());
//  myinstance->SetPosition(Vect3f(myPosition.x,0,myPosition.z));
//  myinstance->SetYaw(-(GetEjeMovimientoIA()->m_fAngleTotalPlayer2));
//  SetInstance((CRenderableAnimatedInstanceModel*)myinstance);
//}
//-----------------------------------------
//perseguir por vector director
//-----------------------------------------
void CZombie::Perseguir(Vect3f hisPosition,float _elapsedtime, float height)
{
  Vect3f myPosition = GetInstance()->GetPosition();
  float mySpeed = GetMoveSpeed();

  GetEjeMovimientoIA()->MovAgentIA(hisPosition,myPosition,mySpeed,_elapsedtime);
  
  Vect3f aux = GetEjeMovimientoIA()->GetVectorDirector();
  aux.y = 0.0f;
  GetPhysicController()->Move(aux /** _elapsedtime*/ * mySpeed, _elapsedtime);

  Vect3f controllerPosition = GetPhysicController()->GetPosition();
  //controllerPosition.y = 0.0f;
  //myinstance->SetPosition(Vect3f(myPosition.x,0,myPosition.z));
  CRenderableObject* myinstance = GetInstance();
  float l_fPosY = controllerPosition.y - GetPhysicController()->GetRadius()*height ;
  if(height == 1.0f)//boss
    myinstance->SetPosition(Vect3f(controllerPosition.x, l_fPosY -(height/4.0f), controllerPosition.z));
  else              //zombie
    myinstance->SetPosition(Vect3f(controllerPosition.x, l_fPosY, controllerPosition.z));
    
  myinstance->SetYaw(-(GetEjeMovimientoIA()->m_fAngleTotalPlayer2));
  
  SetInstance((CRenderableAnimatedInstanceModel*)myinstance);
}
Exemplo n.º 6
0
bool CComponentPlayerController::Init(CGameEntity *_pEntity)
{
  m_pMovement = _pEntity->GetComponent<CComponentMovement>(ECT_MOVEMENT);
  assert(m_pMovement); //TODO fer missatges d'error més elavorats

  m_pObject3D = _pEntity->GetComponent<CComponentObject3D>(ECT_OBJECT_3D);
  assert(m_pObject3D); //TODO fer missatges d'error més elavorats

  CComponentRenderableObject *l_pComponentRO = _pEntity->GetComponent<CComponentRenderableObject>(ECT_RENDERABLE_OBJECT);
  assert(l_pComponentRO); //TODO fer missatges d'error més elavorats
  m_pAnimatedModel = dynamic_cast<CRenderableAnimatedInstanceModel*>(l_pComponentRO->GetRenderableObject());
  assert(m_pAnimatedModel); //TODO fer missatges d'error més elavorats

  m_bGodMode     =
  m_bSemigodMode =
  m_bShootActive   = 
  m_bGrenadeActive =
  m_bForceActive   = false;

  m_vPickUps.clear();

  m_pForceEmiter1 = ENTITY_MANAGER->InitParticles("electric_small", Vect3f( 1,0,0), Vect3f(.15f));
  m_pForceEmiter2 = ENTITY_MANAGER->InitParticles("electric_small", Vect3f(-1,0,0), Vect3f(.15f));

  SetOk(true);
  return IsOk();
}
Exemplo n.º 7
0
void CViewer::InitFreeMode()
{
  CORE->GetRenderer()->SetUniqueRenderPath("HDR");

  m_fVelocity = 5.0f;

  CORE->GetRenderableObjectsManager()->SetAllVisibility(true);

  if(m_pCharacter)
  {
    m_pTargetObject->SetYaw(m_pCharacter->GetYaw()-m_fInitialCharacterYaw);
    m_pTargetObject->SetPosition(m_pCharacter->GetPosition());
    ((CShoulderCamera*)m_pObjectCamera)->SetShoulderDistance(0.85f);
    ((CShoulderCamera*)m_pObjectCamera)->SetZoom(1.8f);
  }else{
    m_pTargetObject->SetYaw(0.0f);
    m_pTargetObject->SetPosition(Vect3f(m_pTargetObject->GetPosition().x,0.0f,m_pTargetObject->GetPosition().z));
    ((CShoulderCamera*)m_pObjectCamera)->SetShoulderDistance(0.0f);
    ((CShoulderCamera*)m_pObjectCamera)->SetZoom(0.0f);
  }

  m_pTargetObject->SetPitch(0.0f);

  ((CShoulderCamera*)m_pObjectCamera)->SetShoulderHeight(1.55f);

  m_pObjectModeLight = (CDirectionalLight*)CORE->GetLightManager()->GetResource("ObjectModeLight");

  if(m_pObjectModeLight)
  {
    m_pObjectModeLight->SetActive(false);
  }

  UpdatePosition(Vect3f(0.0f),0.0f,0.0f);
  UpdateCamera(0.0f,0.0f);
}
/// <summary>
/// Carga el .xml de triggers.
/// </summary>
///<param name="FileName">Ubicación del archivo xml.</param>
bool CTriggerManager::Load(const std::string &FileName)
{
	m_bIsOk = true;

  m_FileName = FileName;

	CXMLTreeNode filexml;
	if (!filexml.LoadFile(FileName.c_str()))
	{
    //Guardar el mensaje de error en el LOGGER
		LOGGER->AddNewLog(ELL_ERROR, "CTriggerManager::Load ---Error al cargar el XML---");
		m_bIsOk = false;
	}
	else
	{
		CXMLTreeNode triggers = filexml["triggers"];
		int numNodes = triggers.GetNumChildren();
		if (triggers.Exists())
		{
		//<triggers>
			//<trigger name="Trigger_EntradaPuerta" entity="character" position="13.4664 0.0 -3.93624" max="-0.600954 4.70389 -1.79946" 
			//min="0.600954 0.0 1.79946" active="true" onEnter="testEnter" onLeave="testLeave" rotation="" size="1.0"/>
		//</triggers> 
      CTrigger* l_Trigger;

			for (int i = 0; i < numNodes; ++i) 
			{
				if (!triggers(i).IsComment())
        {
          //crea trigger info
          l_Trigger = new CTrigger();
          l_Trigger->Init();

        	l_Trigger->SetName(triggers(i).GetPszProperty("name", ""));
          l_Trigger->SetEntity(triggers(i).GetPszProperty("entity", ""));
          l_Trigger->SetPosition(triggers(i).GetVect3fProperty("position", Vect3f(0.0f,0.0f,0.0f)));
					l_Trigger->SetMax(triggers(i).GetVect3fProperty("max", Vect3f(0.0f,0.0f,0.0f)));
					l_Trigger->SetMin(triggers(i).GetVect3fProperty("min", Vect3f(0.0f,0.0f,0.0f)));
					l_Trigger->SetActive(triggers(i).GetBoolProperty("active", false));
					l_Trigger->SetTriggerActive(triggers(i).GetBoolProperty("active", false));
					l_Trigger->SetOnEnterCode(triggers(i).GetPszProperty("onEnter", ""));
          l_Trigger->SetOnLeaveCode(triggers(i).GetPszProperty("onLeave", ""));
					l_Trigger->SetRotationX(triggers(i).GetFloatProperty("rotationX"));
					l_Trigger->SetRotationY(triggers(i).GetFloatProperty("rotationY"));
					l_Trigger->SetRotationZ(triggers(i).GetFloatProperty("rotationZ"));
					l_Trigger->SetSize(triggers(i).GetVect3fProperty("size", Vect3f(0.0f,0.0f,0.0f)));
					l_Trigger->SetDimensions(triggers(i).GetVect3fProperty("size", Vect3f(0.0f,0.0f,0.0f)));
					GeneraTrigger(l_Trigger->GetName(), l_Trigger, false);
          m_vTriggers.push_back(l_Trigger);
        }
      }
    }
    else
    {
      m_bIsOk = false;
    }
  }
  return m_bIsOk;
}
Exemplo n.º 9
0
CSteeringEntity::CSteeringEntity( void )
	: m_pController			( NULL ) 
	, m_pHeadingSmoother	( NULL )
	, m_SmoothingOn			( true )
	, m_SmoothedHeading		( Vect3f(0,0,0) )
{
	// colocamos el smoother
	m_pHeadingSmoother = new CSmoother<Vect3f>(10, Vect3f(0.0, 0.0, 0.0)); 
}
Exemplo n.º 10
0
void CViewer::CreateObjectModeLight()
{
  m_pObjectModeLight = CORE->GetLightManager()->CreateDirectionalLight("ObjectModeLight",
                                                                        Vect3f(0.0f),
                                                                        Vect3f(1.0f,1.0f,1.0f),
                                                                        CColor(Vect3f(1.0f,1.0f,1.0f)),
                                                                        50.0f,
                                                                        80.0f,
                                                                        false);
}
Exemplo n.º 11
0
bool CBiotestProcess::Init()
{
  LOGGER->AddNewLog(ELL_INFORMATION,"CBiotestProcess::Init");

  
  // ------------------------- noves partícules ----------------------------------------

  //m_pCoreEmiterManager = new CCoreEmiterManager();
  //m_pCoreEmiterManager->Load("Data/XML/CoreEmiters.xml");

  m_pEmiter  = new CEmiterInstance();
  m_pEmiter->Init("bubble", CObject3D(Vect3f(-14.6275f, 0.833153f, -4.08485f),0,0), Vect3f(0.391403f, 0.702762f, 0.194437f));


  // -----------------------------------------------------------------------------------


  //m_pSceneEffectManager = CORE->GetSceneEffectManager();
  CORE->GetLightManager()->SetLightsEnabled(true);

  
  CORE->GetEntityManager()->LoadEntitiesFromXML("Data/Levels/Level -2/XML/GameEntities - Laboratori.xml");
  CORE->GetEntityManager()->LoadEntitiesFromXML("Data/Levels/Level -2/XML/GameEntities - Menjador.xml");
  CORE->GetEntityManager()->LoadEntitiesFromXML("Data/Levels/Level -2/XML/GameEntities - Passadis.xml");
  CORE->GetEntityManager()->LoadEntitiesFromXML("Data/Levels/Level -2/XML/GameEntities - video.xml");
  CORE->GetEntityManager()->CreateLevelControllerEntity(false);
  
  CGameEntity* l_pPlayerEntity = CORE->GetEntityManager()->GetEntity("Player");
  m_pCamera = l_pPlayerEntity->GetComponent<CComponent3rdPSCamera>()->GetCamera();
  
  /*Vect3f l_vOmniColor = Vect3f(.5f,.5f,.5f);
  m_pOmniLight = CORE->GetLightManager()->CreateOmniLight("OmniViewerLight",Vect3f(0.0f),CColor(l_vOmniColor),0.1f,17.0f);
  m_pOmniLight->SetActive(true);*/

  
  CORE->GetIAManager()->CompleteGraph();

  m_pSpotLight = CORE->GetLightManager()->CreateSpotLight("FreeModeLight",
                                                          Vect3f(0.0f,15.0f,0.0f),
                                                          Vect3f(0.3f,-1.0f,0.0f),
                                                          CColor(Vect3f(1.0f,1.0f,1.0f)),
                                                          20.0f,
                                                          80.0f,
                                                          10.0f,
                                                          45.0f,
                                                          false );

  m_pSpotLight->SetActive(true);

  SetOk(true);
  return IsOk();
}
Exemplo n.º 12
0
CBillboard::CBillboard(void)
	: m_vPosition	( Vect3f(0.f,0.f,0.f) )
	, m_bIsVisible	( false )
	, m_fWidth		( 1.f )
	, m_fHeight		( 1.f )
	, m_PointA		( Vect3f(0.f,0.f,0.f) )
	, m_PointB		( Vect3f(0.f,0.f,0.f) )
	, m_PointC		( Vect3f(0.f,0.f,0.f) )
	, m_PointD		( Vect3f(0.f,0.f,0.f) )
	, m_Texture		( NULL )
{
	m_Texture = CORE->GetTextureManager()->GetNoTexture();
}
Exemplo n.º 13
0
//----------------------------------------------------------------------------
// Init data
//----------------------------------------------------------------------------
bool CLanza::Init(int i)
{
  std::string l_sNombreLanza = "";
  baseUtils::FormatSrting(l_sNombreLanza, "Lanza%d",i);
  
  m_pRenderableAnimatedInstanceModel = (CRenderableAnimatedInstanceModel*)CORE->GetRenderableObjectsManager()->AddAnimatedModelInstance(
    "lanza", 
    l_sNombreLanza,
    Vect3f(0.0f,-5.0f,0.0f), 
    0.0f,
    0.0f,
    0.0f);


  m_bIsOk = m_pRenderableAnimatedInstanceModel? true:false;
  if (!m_bIsOk)
  {
    Release();
  }

  m_fTiempoAnimacion = GetTiempoAnimacion();
  if(m_fTiempoAnimacion == 0.0f)
  {
    Release();
  }
  return m_bIsOk;
}
Exemplo n.º 14
0
void CSpirit::ObtieneVectoresDireccion(CRenderableObject* player,float& l_fYawPlayer, float& dir)
{
  l_fYawPlayer = - (player->GetYaw() + FLOAT_HALF_PI_VALUE);

  Vect3f l_V3DirOptimo =  m_V3Pos - player->GetPosition();

  dir = l_V3DirOptimo.GetAngleY() - FLOAT_HALF_PI_VALUE;
  fmod(dir, FLOAT_PI_VALUE);

  m_vecPlayer = Vect3f(10.f,1.0f,0.0f);
  m_vecPlayer.RotateY(l_fYawPlayer);

  m_vecSpirit = Vect3f(10.f,1.0f,0.0f);
  m_vecSpirit.RotateY(dir);

}
Exemplo n.º 15
0
Mat44f CPhysXProcess::GetBoneLeftHandedAbsoluteTransformation(CalBone* _pBone)
{
   //rotacio i translacio del bone (absoluta)
  CalVector l_vTranslation = _pBone->getTranslationAbsolute();
  CalQuaternion l_RotationQuaternion = _pBone->getRotationAbsolute();

  //passem el quaternion a left handed
  l_RotationQuaternion.x = -l_RotationQuaternion.x;
  l_RotationQuaternion.y = -l_RotationQuaternion.y;
  l_RotationQuaternion.z = -l_RotationQuaternion.z;

  //creem la matriu de transformacio Cal3d (absolute) -> Mat44f
  CalMatrix l_RotationMatrix(l_RotationQuaternion);

  Mat33f l_Rotation = Mat33f( l_RotationMatrix.dxdx   ,l_RotationMatrix.dydx  ,l_RotationMatrix.dzdx,
                              l_RotationMatrix.dxdy   ,l_RotationMatrix.dydy  ,l_RotationMatrix.dzdy,
                              l_RotationMatrix.dxdz   ,l_RotationMatrix.dydz  ,l_RotationMatrix.dzdz);

  float l_fAngleX = FLOAT_PI_VALUE - l_Rotation.GetAngleX();
  float l_fAngleY = FLOAT_PI_VALUE - l_Rotation.GetAngleY();
  float l_fAngleZ = FLOAT_PI_VALUE - l_Rotation.GetAngleZ();

  Mat44f l_Transform;
  l_Transform.SetIdentity();
  l_Transform.RotByAnglesYXZ(l_fAngleY,l_fAngleX,l_fAngleZ);
  l_Transform.Translate(Vect3f(-l_vTranslation.x,l_vTranslation.y,l_vTranslation.z));

  return l_Transform;
}
Exemplo n.º 16
0
void CWolfHowlEnemiesState::Execute( CCharacter* _pCharacter, float _ElapsedTime )
{
	if (!m_pWolf) 
	{
		m_pWolf = dynamic_cast<CWolf*> (_pCharacter);
	}
	
	// Si se ha iniciado la animación
	/*if ( m_pAnimationCallback->IsAnimationStarted() ) 
	{*/
		// Compruebo si la animación a finalizado
		if ( m_pAnimationCallback->IsAnimationFinished() )
		{
			ShowEnemiesToHelp();

			// Volvemos al reposo
			m_pWolf->GetLogicFSM()->ChangeState( m_pWolf->GetIdleState());
			m_pWolf->GetGraphicFSM()->ChangeState(m_pWolf->GetIdleAnimationState());
		}
	//}
	
	// Reseteamos la velocidad del enemigo
	m_pWolf->GetSteeringEntity()->SetVelocity(Vect3f(0,0,0));
	m_pWolf->MoveTo2(_pCharacter->GetSteeringEntity()->GetVelocity(), _ElapsedTime);
}
Exemplo n.º 17
0
void CParticleSettingsManager::AddDefaultSettings(const std::string &name)
{
	assert(name != "");

	if( GetResource(name) == NULL )
	{
		TParticleSystemSettings* l_pSettings = new TParticleSystemSettings();

		l_pSettings->m_Name = name;
		l_pSettings->m_TextureName = "";
		l_pSettings->m_MaxParticles = 100;
		l_pSettings->m_Duration = 0.f;
		l_pSettings->m_DurationRandomness = 0.f;
		l_pSettings->m_EmitterVelocitySensitivity = 0.f;
		l_pSettings->m_MinHorizontalVelocity = 0.f;
		l_pSettings->m_MaxHorizontalVelocity = 0.f;
		l_pSettings->m_MinVerticalVelocity = 0.f;
		l_pSettings->m_MaxVerticalVelocity = 0.f;
		l_pSettings->m_Gravity = Vect3f(0.f, 0.f, 0.f);
		l_pSettings->m_EndVelocity = 0.f;
		l_pSettings->m_MinColor = colBLACK;
		l_pSettings->m_MaxColor = colBLACK;
		l_pSettings->m_MinRotateSpeed = 0.f;
		l_pSettings->m_MaxRotateSpeed = 0.f;
		l_pSettings->m_MinEndSize = 0.f;
		l_pSettings->m_MaxEndSize = 0.f;
		l_pSettings->m_BlendState = TGraphicBlendStates::NonPremultiplied;

		AddResource(name, l_pSettings);
	}
	else
	{
		LOGGER->AddNewLog(ELL_WARNING, "CParticleSettingsManager::AddDefaultSettings->Los settings con nombre %s ya existen.", name.c_str());
	}
}
Exemplo n.º 18
0
bool CEffect::SetLight(CLight* light)
{
	if(!light->GetVisible())
	{
		return false;
	}

	//CLight::TLightType l_LightType = CLight::OMNI;
	CLight::TLightType l_LightType = light->GetType();

	m_LightsType[0] = static_cast<int>(l_LightType);

	m_LightsStartRangeAttenuation[0] = light->GetStartRangeAttenuation();
	m_LightsEndRangeAttenuation[0] = light->GetEndRangeAttenuation();
	m_LightsPosition[0] = light->GetPosition();
	m_LightsIntensity[0] = light->GetIntensity();
	m_LightLinNearFar[0] = light->GetLightLinNearFar();

	CColor l_Color = light->GetColor();
	m_LightsColor[0] = Vect3f(l_Color.GetRed()/255.0f, l_Color.GetGreen()/255.0f, l_Color.GetBlue()/255.0f);

	if( l_LightType == CLight::DIRECTIONAL )
	{
		CDirectionalLight* l_DirLight = static_cast<CDirectionalLight*>(light);
		m_LightsDirection[0] = l_DirLight->GetDirection();
	}
	else if( l_LightType == CLight::SPOT )
	{
		CSpotLight* l_SpotLight = static_cast<CSpotLight*>(light);
		m_LightsDirection[0] = l_SpotLight->GetDirection();
		m_LightsAngle[0] = l_SpotLight->GetAngle();
		m_LightsFallOff[0] = l_SpotLight->GetFallOff();
	}

	m_LightShadowViewProjection[0] = light->GetProjectionShadowMap() * light->GetViewShadowMap();

	if(light->GetGenerateDynamicShadowMap()) 
	{
		m_LightsDynamicShadowMap[0] = light->GetDynamicShadowMap();
		m_LightsDynamicShadowMapEnable[0] = true;
	}
	else
	{
		m_LightsDynamicShadowMap[0] = NULL;
		m_LightsDynamicShadowMapEnable[0] = false;
	}

	if(light->GetGenerateStaticShadowMap())
	{
		m_LightsStaticShadowMap[0] = light->GetStaticShadowMap();
		m_LightsStaticShadowMapEnable[0] = true;
	}
	else
	{
		m_LightsStaticShadowMap[0] = NULL;
		m_LightsStaticShadowMapEnable[0] = false;
	}

	return true;
}
Exemplo n.º 19
0
CFreeCamera::CFreeCamera(float zn, float zf, float fov, float aspect, Vect3f& Position):
CFPSCamera (zn, zf,fov, aspect,new CObject3D(Position, Vect3f(1.0f),0.0f,0.0f)),	
	m_fDeltaPitch(0.0f), m_fDeltaYaw(0.0f),	m_fSpeed(SLOW_FREE_CAMERA),m_CameraMovement(IDDLE),m_bIsRunning(false)
{
	

}
CInstanceMesh* CRenderableObjectsLayersManager::AddDynamic( const CXMLTreeNode& atts )
{
    CInstanceMesh* l_InstanceMesh = new CInstanceMesh( atts );
    if(!l_InstanceMesh->IsOk())
    {
        LOG_WARNING_APPLICATION("The instance mesh %s, is not correct, it would not be rendererd", l_InstanceMesh->GetName().c_str());
        CHECKED_DELETE(l_InstanceMesh);

        return NULL;
    }

    // User data
    CPhysicUserData * lData = new CPhysicUserData(l_InstanceMesh->GetName());
    lData->SetGroup(ECG_DYNAMIC_OBJECTS);

    // Phyx actor
    CPhysicActor* l_MeshActor = new CPhysicActor(lData);
    l_MeshActor->SetCollisionGroup(ECG_DYNAMIC_OBJECTS);

    // Obtain a box from the static mesh aabb
    CStaticMesh* l_StaticMesh = l_InstanceMesh->GetStaticMesh();
    Math::AABB3f l_AABB = l_StaticMesh->GetAABB();
    Math::Vect3f l_Pos = l_InstanceMesh->GetTransform() * l_AABB.GetCenter();

    l_MeshActor->AddBoxShape(Vect3f(l_AABB.GetWidth() * 0.5f, l_AABB.GetHeight() * 0.5f, l_AABB.GetDepth() * 0.5f), l_Pos);
    l_MeshActor->CreateBody(1.0f);

    l_InstanceMesh->SetActor(l_MeshActor);
    l_InstanceMesh->SetType("dynamic");

    PhysXMInstance->AddPhysicActor(l_MeshActor, false);

    return l_InstanceMesh;
}
Exemplo n.º 21
0
void CZombie::DestruyeZombie(char fase)
{
  switch (fase)
  {
    case 0:  

    if(m_triggerManoDerecha)
    {
      EscondePunyos();
      m_triggerManoDerecha->SetActive(false);
    } 
    if(m_triggerManoIzquierda)
    {
      EscondePunyos();
      m_triggerManoIzquierda->SetActive(false);
    }

      SetState( MUERTO );
      m_faseEstado = INIT;
    case 1:
      GetInstance()->SetVisible(false);

    case 2:
      GetPhysicController()->GetUserData()->SetPaint(false);
      GetPhysicController()->SetPosition(Vect3f(0,-5,0));
  }
}
Exemplo n.º 22
0
bool CSpirit::GoContento(float elapsedTime)
{
  CRenderableObject* player = CORE->GetRenderableObjectsManager()->GetInstance("mi_amigo");
  Mat44f l_pos, l_pos_p, t;
  l_pos.SetIdentity();
  l_pos_p.SetIdentity();
  t.SetIdentity();
  if(m_uiNumeroVueltasContento > m_uiNumeroVueltasContentoActual)
  {
    t.Translate(Vect3f(cos(m_fAngleTurn) * m_fDistNear, 1.0f, sin(m_fAngleTurn)* m_fDistNear));

    l_pos_p = player->GetMat44();

    if(m_fAngleTurn < FLOAT_2PI_VALUE )
    {
      m_fAngleTurn += (RADIANS * m_fSpeedRotationContento * elapsedTime);
    }
    else
    {
      m_uiNumeroVueltasContentoActual ++;
      m_fAngleTurn = 0.0f;
    }

    l_pos =  l_pos_p * t; 
    m_V3Pos = l_pos.GetPos();
    return false;
  }
  else
  {
    Reload();
    m_uiNumeroVueltasContentoActual = 0;
    m_fAngleTurn = 0.0f;
    return true;
  }
}
Exemplo n.º 23
0
Vect3f CComponentPhysXController::GetPosition() const
{
  if(m_pPhysXController)
    return m_pPhysXController->GetPosition();

  return Vect3f(0.0f);
}
Exemplo n.º 24
0
void CParticleProcess::Update(float _fElapsedTime)
{
   if(m_pObject)// && m_pObjectBot) 
  {
    //Actualitze el pitch i el yaw segons els delta del mouse
    float l_fPitch, l_fYaw;

    Vect3i l_vVec = INPUT_MANAGER->GetMouseDelta();

    l_fPitch = m_pObject->GetPitch();
    l_fYaw   = m_pObject->GetYaw();
  
    m_pObject->SetYaw(l_fYaw-l_vVec.x*_fElapsedTime);
    //m_pObjectBot->SetYaw(m_pObject->GetYaw()-FLOAT_PI_VALUE/2.0f);

    l_fPitch -= l_vVec.y*_fElapsedTime;
    if(l_fPitch < - FLOAT_PI_VALUE/3) l_fPitch = - FLOAT_PI_VALUE/3;
    if(l_fPitch >   FLOAT_PI_VALUE/3) l_fPitch =   FLOAT_PI_VALUE/3;
    m_pObject->SetPitch(l_fPitch);


    //m_pObjectBot->SetPosition(Vect3f(m_pObject->GetPosition().x, m_pObjectBot->GetPosition().y, m_pObject->GetPosition().z));
  
    l_fPitch = m_pObject->GetPitch();
    //l_fPitch = l_fPitch+FLOAT_PI_VALUE/2;
    //l_fYaw = m_pObjectBot->GetYaw();
    l_fYaw = l_fYaw+FLOAT_PI_VALUE/2;
    //l_fRoll = m_pObjectBot->GetRoll();

    CSpotLight* l_pSpot = (CSpotLight*)CORE->GetLightManager()->GetResource("Spot01");
    if(l_pSpot)
    {
      l_pSpot->SetPosition(Vect3f(m_pObject->GetPosition().x, m_pObject->GetPosition().y, m_pObject->GetPosition().z));

      //CDirectionalLight* l_dir = (CDirectionalLight*)CORE->GetLightManager()->GetResource("Direct01");
      Vect3f l_vec(cos(l_fYaw) * cos(l_fPitch), sin(l_fPitch),sin(l_fYaw) * cos(l_fPitch) );
      l_pSpot->SetDirection(Vect3f(l_vec.x,l_vec.y,l_vec.z));
    }

    if(m_bStateChanged)
    {
      //((CRenderableAnimatedInstanceModel*)m_pObjectBot)->GetAnimatedInstanceModel()->BlendCycle(m_iState,0);

      m_bStateChanged = false;
    }
  }
}
Exemplo n.º 25
0
CPhysicUserData* CComponentPlayerController::CheckCover(SCollisionInfo& _sCInfo)
{  
  CCamera* l_pCamera = GetEntity()->GetComponent<CComponent3rdPSCamera>(ECT_3RD_PERSON_SHOOTER_CAMERA)->GetCamera();
  Vect3f l_vPos = m_pObject3D->GetPosition() - Vect3f(0.0f,0.5f,0.0f);

  Mat33f l_mRot;
  l_mRot.SetIdentity();
  l_mRot.RotByAngleY(m_pObject3D->GetYaw());

  Vect3f l_vDir = l_mRot*Vect3f(1.0f,0.0f,0.0f);

  CPhysicsManager *l_pPM = CORE->GetPhysicsManager();

  CPhysicUserData* l_pUserData = l_pPM->RaycastClosestActor(l_vPos,l_vDir,l_pPM->GetCollisionMask(ECG_COBERTURES),_sCInfo);

  return l_pUserData;
}
Exemplo n.º 26
0
CLight::CLight(CXMLTreeNode &TreeNode) : CNamed(TreeNode)
{
	m_Type = GetLightTypeByName(TreeNode.GetPszProperty("type"));
	m_Position = TreeNode.GetVect3fProperty("pos", Vect3f(0.0f, 0.0f, 0.0f), true);
	m_Color = CColor(TreeNode.GetVect4fProperty("color", Vect4f(255.0f, 255.0f, 255.0f, 0.0f), true));
	m_StartRangeAttenuation = TreeNode.GetFloatProperty("att_start_range");
	m_EndRangeAttenuation = TreeNode.GetFloatProperty("att_end_range");
	m_Intensity = TreeNode.GetFloatProperty("intensity");
}
Exemplo n.º 27
0
void CWolfDefenseState::OnExit( CCharacter* _pCharacter )
{
	m_pWolf->GetSteeringEntity()->SetVelocity(Vect3f(0,0,0));
	m_pWolf->GetBehaviors()->SeekOff();

	// Restauramos la velocidad original
	m_pWolf->GetSteeringEntity()->SetMaxSpeed(m_pWolf->GetProperties()->GetMaxSpeed());
	StopImpact(_pCharacter);
}
Exemplo n.º 28
0
void CZombie::HumoMuerte(Vect3f pos)
{
	Vect3f l_v3Pos = Vect3f(pos.x, (pos.y+1.0f), pos.z);
	//render
	std::string l_sNameParticle = "pHumo";
	CBillboardAnimation * l_pBillboardAnimation1 = CORE->GetBillboardManager()->GetBAnimationByInstance(l_sNameParticle);
	l_pBillboardAnimation1->SetPos(l_v3Pos);
	l_pBillboardAnimation1->SetEnd(false);
}
Exemplo n.º 29
0
//-----------------------------------------
// encarando por vector director
//-----------------------------------------
void CZombie::Encarando(Vect3f hisPosition,float _elapsedtime, float height)
{
  Vect3f myPosition = GetInstance()->GetPosition();
  GetEjeMovimientoIA()->MovAgentIA(hisPosition,myPosition,0.0f,_elapsedtime,true);
  
  Vect3f controllerPosition = GetPhysicController()->GetPosition();
  //controllerPosition.y = 0.0f;
  //myinstance->SetPosition(Vect3f(myPosition.x,0,myPosition.z));
  CRenderableObject* myinstance = GetInstance();
  float l_fPosY = controllerPosition.y - GetPhysicController()->GetRadius()*height;
  if(height == 1.0f)//boss
    myinstance->SetPosition(Vect3f(controllerPosition.x, l_fPosY -(height/4.0f), controllerPosition.z));
  else              //zombie
    myinstance->SetPosition(Vect3f(controllerPosition.x, l_fPosY, controllerPosition.z));

  myinstance->SetYaw(-(GetEjeMovimientoIA()->m_fAngleTotalPlayer2));
  SetInstance((CRenderableAnimatedInstanceModel*)myinstance);
}
CFreeCameraComponent::CFreeCameraComponent(CXMLTreeNode& node, CElement* Owner)
	: CComponent(node, Owner)
{
	SetNameFromParentName( Owner->getName() );

	m_camController = new CFreeCameraController();

	Vect3f fwd = node.GetVect3fProperty("forward", Vect3f( 1, 0, 0), false);
	Vect3f off = node.GetVect3fProperty( "offset", Vect3f( 0, 0, 0 ), false );
	float fov = node.GetFloatProperty( "fov", -1, false );

	m_camController->SetForward( fwd );
	m_camController->SetOffset( off );

	if ( fov > 0 )
	{
		m_camController->SetFOV( mathUtils::Deg2Rad(fov)/2 );
	}
}