本文整理汇总了C++中CCopyEntity类的典型用法代码示例。如果您正苦于以下问题:C++ CCopyEntity类的具体用法?C++ CCopyEntity怎么用?C++ CCopyEntity使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CCopyEntity类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SetLightsToShader
/// Update light-related shader variables
void SetLightsToShader( CCopyEntity& entity, ShaderManager& rShaderMgr )
{
shared_ptr<ShaderLightManager> pShaderLightMgr = rShaderMgr.GetShaderLightManager();
int i, num_current_lights = entity.GetNumLights();
LightEntity *pLightEntity = NULL;
// clear any lights currenly stored in the shader light manager
pShaderLightMgr->ClearLights();
ShaderLightParamsWriter light_params_writer( pShaderLightMgr.get() );
for( i=0; i<num_current_lights; i++ )
{
EntityHandle<LightEntity>& light_entity = entity.GetLight( i );
LightEntity *pLightEntity = light_entity.GetRawPtr();
if( !pLightEntity )
continue;
// pLightEntity->SetLightToShader( pShaderLightMgr );
// copy light properties to the shader registers
pLightEntity->GetLightObject()->Accept( light_params_writer );
}
pShaderLightMgr->CommitChanges();
}
示例2: UpdateEntityForRendering
/// Update shader params loaders for the entity.
/// Shader params loaders are shared by entities, and need to be updated every time an entity is rendered.
void UpdateEntityForRendering( CCopyEntity& entity )
{
BaseEntity& base_entity = *(entity.pBaseEntity);
// light params writer
if( entity.GetEntityFlags() & BETYPE_LIGHTING )
{
UpdateLightInfo( entity );
if( base_entity.MeshProperty().m_pShaderLightParamsLoader )
{
// Set the entity to the light params loader, because a single light params loader
// is shared by all the entities of this base entity.
base_entity.MeshProperty().m_pShaderLightParamsLoader->SetEntity( entity.Self().lock() );
}
}
const float offset_world_transform_threshold = 150000.0f;
if( square(offset_world_transform_threshold) < Vec3LengthSq(entity.GetWorldPose().vPosition) )
{
Camera* pCam = entity.GetStage()->GetCurrentCamera();
if( pCam )
{
sg_pWorldTransLoader->SetActive( true );
sg_pWorldTransLoader->SetCameraPosition( pCam->GetPosition() );
}
else
sg_pWorldTransLoader->SetActive( false );
}
else
sg_pWorldTransLoader->SetActive( false );
}
示例3: GetSoundManager
void CStage::UpdateListener()
{
Matrix34 cam_pose;
Camera *pCamera;
// get the pose of the current camera
pCamera = this->GetCurrentCamera();
if( pCamera )
{
pCamera->GetPose( cam_pose );
}
else
{
CCopyEntity* pEntity = this->GetEntitySet()->GetCameraEntity();
if( pEntity )
cam_pose = pEntity->GetWorldPose();
else
cam_pose.Identity();
}
// update listener for sound manager
GetSoundManager().SetListenerPose( cam_pose );
CCopyEntity *pCameraEntity = this->GetEntitySet()->GetCameraEntity();
if( pCameraEntity )
GetSoundManager().SetListenerVelocity( pCameraEntity->Velocity() );
GetSoundManager().CommitDeferredSettings();
}
示例4: RegisterAsPlanarMirror
Result::Name RegisterAsPlanarMirror( CCopyEntity& entity, BasicMesh& mesh, int subset_index )
{
const AABB3& aabb = mesh.GetAABB(subset_index);
EntityRenderManager& entity_render_mgr
= *(entity.GetStage()->GetEntitySet()->GetRenderManager());
// >>> TODO: support planes that are not axis-aligned or facing along the negative half-space
SPlane plane;
int plane_axis = 1;
if( aabb.vMax.x - aabb.vMin.x < 0.001f ) plane_axis = 0;
else if( aabb.vMax.y - aabb.vMin.y < 0.001f ) plane_axis = 1;
else if( aabb.vMax.z - aabb.vMin.z < 0.001f ) plane_axis = 2;
else plane_axis = 1;
plane.normal = Vector3(0,0,0);
plane.normal[plane_axis] = 1;
plane.dist = aabb.vMax[plane_axis];
Result::Name res = entity_render_mgr.AddPlanarReflector( EntityHandle<>( entity.Self() ), plane );
if( res != Result::SUCCESS )
return Result::UNKNOWN_ERROR;
entity.RaiseEntityFlags( BETYPE_PLANAR_REFLECTOR );
// Create shader variable loader for mirror
if( !entity.m_pMeshRenderMethod )
{
if( entity.pBaseEntity->MeshProperty().m_pMeshRenderMethod )
{
entity.m_pMeshRenderMethod
= entity.pBaseEntity->MeshProperty().m_pMeshRenderMethod->CreateCopy();
if( !entity.m_pMeshRenderMethod )
return Result::UNKNOWN_ERROR;
}
else
return Result::UNKNOWN_ERROR;
}
// create a planar reflection entity
// shared_ptr<MeshContainerRenderMethod> pMeshRenderMethodCopy
// = entity.m_pMeshRenderMethod->CreateCopy();
shared_ptr<MirroredSceneTextureParam> pTexParam;
pTexParam.reset( new MirroredSceneTextureParam( EntityHandle<>( entity.Self() ) ) );
pTexParam->m_fReflection = mesh.GetMaterial(subset_index).m_Mat.fReflection;
// pMeshRenderMethodCopy->SetShaderParamsLoaderToAllMeshRenderMethods( pTexParam );
// test - we assume that the entity's mesh is composed of polygons that belong to a single plane.
entity.m_pMeshRenderMethod->SetShaderParamsLoaderToAllMeshRenderMethods( pTexParam );
// Move the indices of the planar reflection subset(s)
// to the render method of the planar reflection entity
return Result::SUCCESS;
}
示例5: Update
void AlphaEntity::Update( float dt )
{
CCopyEntity *pParent = m_pParent;
if( !pParent )
return;
SetWorldPose( pParent->GetWorldPose() );
}
示例6: GetPlayerPosition
static Vector3 GetPlayerPosition()
{
CCopyEntity *pPlayer = GetPlayerEntity();
if( pPlayer )
return pPlayer->GetWorldPosition();
else
return Vector3(0,0,0);
}
示例7: UpdateGraphics
void EntityManager::UpdateGraphics()
{
if( m_pEntityInUse )
{
for( CCopyEntity* pEntity = m_pEntityInUse.get();
pEntity != NULL;
pEntity = pEntity->m_pNextRawPtr )
{
pEntity->UpdateGraphics();
}
}
}
示例8: UpdateLightInfo
void UpdateLightInfo( CCopyEntity& entity )
{
if( entity.Lighting() )
{
if( entity.sState & CESTATE_LIGHT_INFORMATION_INVALID )
{
// need to update light information - find lights that reaches to this entity
entity.ClearLights();
entity.GetStage()->GetEntitySet()->UpdateLights( &entity );
entity.sState &= ~CESTATE_LIGHT_INFORMATION_INVALID;
}
}
}
示例9: LifeTimer
void CBE_GeneralEntity::Act(CCopyEntity* pCopyEnt)
{
float frametime = m_pStage->GetFrameTime();
if( m_sGEAttribute & GETYPE_LIFETIMER )
{
float& rfLifeTimer = LifeTimer(pCopyEnt);
rfLifeTimer -= frametime;
if( rfLifeTimer <= 0.0f )
{
// lifetime has expired - terminate the entity
if( 0 < strlen(m_Explosion.GetBaseEntityName()) )
{
// create explosion animation
m_pStage->CreateEntity( m_Explosion, pCopyEnt->GetWorldPosition(), Vector3(0,0,0), pCopyEnt->GetDirection() );
}
m_pStage->TerminateEntity( pCopyEnt );
return;
}
}
if( pCopyEnt->bNoClip
&& !(pCopyEnt->GetEntityFlags() & BETYPE_RIGIDBODY) )
{
// TODO: pose update for collidable enitity
pCopyEnt->SetWorldPosition( pCopyEnt->GetWorldPosition() + pCopyEnt->Velocity() * frametime );
}
// if( 0 < strlen(m_SmokeTrace.GetBaseEntityName()) )
if( 0 < m_vecSmokeTrail.size() )
{
int i, num = (int)m_vecSmokeTrail.size();
for( i=0; i<num; i++ )
{
CCopyEntity* pSmokeTrace = pCopyEnt->GetChild(i);
if( IsValidEntity( pSmokeTrace ) )
pSmokeTrace->Act(); // update smoke trace
}
}
if( pCopyEnt->GetEntityFlags() & BETYPE_ENVMAPTARGET )
{
}
/** if( pCopyEnt->GetChild(0) )
pCopyEnt->GetChild(0)->Act();**/
}
示例10: SinglePlayerInfo
void CBE_Enemy::SearchPlayer(CCopyEntity* pCopyEnt, short& rsMode,
Vector3& rvDesiredDirection, float* pfSqDistToPlayer)
{
// ========= enable the following 2 lines to use enemy observation mode ==========
// rsMode = CEnemyState::STATE_SEARCH;
// return;
Vector3 vStart, vMyselfToPlayer;
CCopyEntity* pPlayer = SinglePlayerInfo().GetCurrentPlayerBaseEntity()->GetPlayerCopyEntity();
vStart = pCopyEnt->GetWorldPosition() + pCopyEnt->GetDirection() * 1.42f;
vMyselfToPlayer = pPlayer->GetWorldPosition() - vStart;
// chehck the distance to the player
float fSqDist = Vec3LengthSq( vMyselfToPlayer );
if( pfSqDistToPlayer )
*pfSqDistToPlayer = fSqDist;
if( 40000 < fSqDist )
{ // too far from the player
rsMode = CEnemyState::STATE_SEARCH;
return;
}
if( !CheckRayToPlayer(pCopyEnt) )
{
rsMode = CEnemyState::STATE_SEARCH; // there is an obstacle between the player
return;
}
// set 'rvDesiredDirection' - unit vector pointing at the target(player)
Vec3Normalize( vMyselfToPlayer, vMyselfToPlayer );
rvDesiredDirection = vMyselfToPlayer;
float fDotProduct = Vec3Dot( pCopyEnt->GetDirection(), vMyselfToPlayer );
// 'fDotProduct' ranges from -1 through 1
if( 0 < fDotProduct )
{ //the player is visible from this entity
rsMode = CEnemyState::STATE_ATTACK; // move to attack mode
}
else
{
if( fSqDist < 400.0f )
rsMode = CEnemyState::STATE_ATTACK; // close enough to hear the player
else
rsMode = CEnemyState::STATE_SEARCH;
}
}
示例11: RenderEntity
void BaseEntity::RenderEntity( CCopyEntity& entity )
{
UpdateEntityForRendering( entity );
// default render states for fixed function pipeline
// default alpha-blending settings (premultiplied alpha)
GraphicsDevice().Enable( RenderStateType::ALPHA_BLEND );
GraphicsDevice().SetSourceBlendMode( AlphaBlend::One );
GraphicsDevice().SetDestBlendMode( AlphaBlend::InvSrcAlpha );
if( entity.m_pMeshRenderMethod )
{
entity.m_pMeshRenderMethod->RenderMesh( entity.m_MeshHandle, entity.GetWorldPose() );
}
else if( m_MeshProperty.m_pMeshRenderMethod )
{
m_MeshProperty.m_pMeshRenderMethod->RenderMesh( entity.m_MeshHandle, entity.GetWorldPose() );
}
// entity.m_pMeshRenderMethod->RenderMeshContainerNode( *(entity.m_pMeshNode.get()), m_vecpShaderParamsWriterBuffer );
}
示例12: SafeDelete
EntityHandle<> CStage::LoadStaticGeometryFromFile( const std::string filename )
{
SafeDelete( m_pStaticGeometry );
m_pStaticGeometry = CreateStaticGeometry( this, filename );
if( !m_pStaticGeometry )
return EntityHandle<>();
// register the static geometry as an entity
// - the entity is used to render the static geometry
BaseEntityHandle baseentity_handle;
baseentity_handle.SetBaseEntityName( "StaticGeometry" );
CCopyEntityDesc desc;
desc.strName = filename;
desc.pBaseEntityHandle = &baseentity_handle;
desc.pUserData = m_pStaticGeometry;
CCopyEntity *pStaticGeometryEntity = CreateEntity( desc );
if( !pStaticGeometryEntity )
return EntityHandle<>();
// shared_ptr<CStaticGeometryEntity> pEntity( new CStaticGeometryEntity );
// pEntity->SetStaticGeometry( m_pStaticGeometry );
// EntityHandle<CStaticGeometryEntity> entity
// = CreateEntity( pEntity, baseentity_handle );
m_pEntitySet->WriteEntityTreeToFile( "debug/entity_tree - loaded static geometry.txt" );
// load the static geometry from file
this->PauseTimer();
bool loaded = m_pStaticGeometry->LoadFromFile( filename );
this->ResumeTimer();
return EntityHandle<>( pStaticGeometryEntity->Self() );
// return entity;
}
示例13: InitMeshRenderMethod
// sets the following shader params loaders to the render method of an entity
// - CEntityShaderLightParamsLoader
// - Set if the BETYPE_LIGHTING flag is on
// - BlendTransformsLoader
// - Set if pEntity->m_MeshHandle is a skeletal mesh
void InitMeshRenderMethod( CCopyEntity &entity, shared_ptr<BlendTransformsLoader> pBlendTransformsLoader )
{
if( !entity.m_pMeshRenderMethod )
{
entity.m_pMeshRenderMethod.reset( new MeshContainerRenderMethod );
// entity.m_pMeshRenderMethod->MeshRenderMethod().resize( 1 );
}
if( entity.GetEntityFlags() & BETYPE_LIGHTING )
{
shared_ptr<CEntityShaderLightParamsLoader> pLightParamsLoader( new CEntityShaderLightParamsLoader() );
pLightParamsLoader->SetEntity( entity.Self() );
entity.m_pMeshRenderMethod->SetShaderParamsLoaderToAllMeshRenderMethods( pLightParamsLoader );
}
// Not used now.
// Item entities set this in its own member function ItemEntity::InitMesh().
// Does any entity other than item entty need this?
if( pBlendTransformsLoader )
entity.m_pMeshRenderMethod->SetShaderParamsLoaderToAllMeshRenderMethods( pBlendTransformsLoader );
/*
shared_ptr<BasicMesh> pMesh = entity.m_MeshHandle.GetMesh();
if( pMesh && pMesh->GetMeshType() == MeshType::SKELETAL )
{
// shared_ptr<SkeletalMesh> pSkeletalMesh
// = boost::dynamic_pointer_cast<SkeletalMesh,BasicMesh>(pMesh);
if( !pBlendTransformsLoader )
pBlendTransformsLoader.reset( new BlendTransformsLoader() );
entity.m_pMeshRenderMethod->SetShaderParamsLoaderToAllMeshRenderMethods( pBlendTransformsLoader );
}*/
if( true /* world position of entity has large values */ )
{
entity.m_pMeshRenderMethod->SetShaderParamsLoaderToAllMeshRenderMethods( sg_pWorldTransLoader );
}
}
示例14: Act
void CES_Search::Act( CCopyEntity& rEntity, CBE_Enemy& rBaseEntity, float dt )
{
// first, get the extra data of 'pCopyEnt'
SBE_EnemyExtraData* pExtraData = rBaseEntity.GetExtraData( rEntity.iExtraDataIndex );
short& rsCurrentState = rEntity.s1;
float& rfSensoringInterval = rEntity.f1;
Vector3& rvDesiredDirection = rEntity.v1;
float fSqDistToPlayer;
rfSensoringInterval += dt;
if( 0.32f <= rfSensoringInterval )
{
rfSensoringInterval = 0;
// check if the player is in a visible position and update 'rvDesiredDirection' and 'rsMode'
short sSearchResult = 0;
rBaseEntity.SearchPlayer( &rEntity, sSearchResult, rvDesiredDirection, &fSqDistToPlayer );
if( sSearchResult == STATE_ATTACK )
{ // the player is in sight - engage
rsCurrentState = STATE_ATTACK;
rBaseEntity.UpdateDesiredYawAndPitch( &rEntity, rvDesiredDirection );
pExtraData->vLastCheckedDirectionToPlayer = rvDesiredDirection;
pExtraData->fLastCheckedSqDistToPlayer = fSqDistToPlayer;
pExtraData->vLastCheckedPlayerPosition = rvDesiredDirection * (float)sqrt(fSqDistToPlayer);
return;
}
else
{ // lost sight of the player
if( pExtraData->vLastCheckedPlayerPosition != Vector3(0,0,0) )
{
Vector3 vDir = pExtraData->vLastCheckedPlayerPosition - rEntity.GetWorldPosition();
Vec3Normalize( rvDesiredDirection, vDir );
}
}
}
rBaseEntity.SearchManeuver(&rEntity,pExtraData);
}
示例15: SetAsEnvMapTarget
/// Perhaps this should be a member of CCopyEntity, not BaseEntity
/// - m_pStage is the only member of the base entity
/// - CCopyEnttiy has m_pStage
void BaseEntity::SetAsEnvMapTarget( CCopyEntity& entity )
{
if( entity.GetEntityFlags() & BETYPE_ENVMAPTARGET )
{
// shared_ptr<CubeTextureParamsLoader> pCubeTexLoader( new CCubeTextureParamsLoader() );
// pCubeTexLoader->SetCubeTexture( 0, m_pStage->GetEntitySet()->GetRenderManager()->GetEnvMapTexture(entity.GetID()) );
// entity.m_pMeshRenderMethod->AddShaderParamsLoaderToAllRenderMethods( pCubeTexLoader );
/*
if( 0 < entity.m_pMeshRenderMethod->MeshRenderMethod().size() )
{
// shader LOD: fixed to 0
entity.m_pMeshRenderMethod->MeshRenderMethod(0).m_vecpShaderParamsLoader.push_back( pCubeTexLoader );
}
else
{
// alpha entity?
}*/
}
}