本文整理汇总了C++中VisBaseEntity_cl::Components方法的典型用法代码示例。如果您正苦于以下问题:C++ VisBaseEntity_cl::Components方法的具体用法?C++ VisBaseEntity_cl::Components怎么用?C++ VisBaseEntity_cl::Components使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类VisBaseEntity_cl
的用法示例。
在下文中一共展示了VisBaseEntity_cl::Components方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetComponentOfBaseType
inline ComponentType* GetComponentOfBaseType() const
{
VisBaseEntity_cl* pEntity = GetEntity();
if (pEntity == NULL)
return NULL;
return pEntity->Components().GetComponentOfBaseType<ComponentType>();
}
示例2: DeactivateAllCameras
void VCameraHandling::DeactivateAllCameras()
{
// Deactivate all orbit and path cameras.
const unsigned int uiNumEntities = VisBaseEntity_cl::ElementManagerGetSize();
for (unsigned int uiElementIndex = 0; uiElementIndex < uiNumEntities; uiElementIndex++)
{
VisBaseEntity_cl* pEntity = VisBaseEntity_cl::ElementManagerGet(uiElementIndex);
if (pEntity == NULL)
continue;
VFreeCamera* pFreeCamera = vdynamic_cast<VFreeCamera*>(pEntity);
VOrbitCamera* pOrbitCamera = pEntity->Components().GetComponentOfBaseType<VOrbitCamera>();
PathCameraEntity* pPathCamera = vdynamic_cast<PathCameraEntity*>(pEntity);
if (pFreeCamera != NULL)
pFreeCamera->SetThinkFunctionStatus(FALSE);
if (pOrbitCamera != NULL)
pOrbitCamera->SetEnabled(false);
if (pPathCamera != NULL)
pPathCamera->Stop();
}
}
示例3: OnAfterSceneLoaded
void RPG_GameManager::OnAfterSceneLoaded()
{
RPG_RendererUtil::StoreViewParams(m_storedViewParams);
// Set up game view params
RPG_ViewParams viewParams = m_storedViewParams;
{
viewParams.m_projectionType = VIS_PROJECTIONTYPE_PERSPECTIVE;
viewParams.m_nearClip = 50.f;
viewParams.m_farClip = 2500.f;
viewParams.m_fovX = 0.f;
viewParams.m_fovY = 50.f;
}
RPG_RendererUtil::LoadViewParams(viewParams);
// Local player
VisBaseEntity_cl* playerEntity = SpawnPlayer("Prefabs\\Demo_Player_Hero.vprefab");
if(playerEntity)
{
RPG_PlayerControllerComponent *const playerController = static_cast<RPG_PlayerControllerComponent*>
(playerEntity->Components().GetComponentOfBaseType(V_RUNTIME_CLASS(RPG_PlayerControllerComponent)));
VASSERT(playerController);
if(playerController)
{
RPG_PlayerUI::s_instance.SetController(playerController);
}
}
}
示例4: SpawnPlayer
VisBaseEntity_cl* MyGameManager::SpawnPlayer(const VString& prefabName, hkvVec3 const& position, hkvVec3 const& orientation)
{
VisBaseEntity_cl* playerEntity = CreateEntityFromPrefab(prefabName, position, orientation);
playerEntity->InitFunction();
if(playerEntity)
{
PlayerComponent *const playerController = static_cast<PlayerComponent*>
(playerEntity->Components().GetComponentOfBaseType(V_RUNTIME_CLASS(PlayerComponent)));
//VASSERT(playerController);
if(playerController)
{
spGUIContext = new VGUIMainContext(NULL);
// Create a GUI context
mDialog = new PlayerDialog(playerController);
mDialog->InitDialog(spGUIContext, NULL, NULL);
spGUIContext->ShowDialog(mDialog);
spGUIContext->SetActivate(true);
}
m_playerEntity = playerEntity->GetWeakReference();
//Vision::Message.Add(1, "Spawn");
}
return playerEntity;
}
示例5: InitFunction
void GameState::InitFunction()
{
// Add target component
VisTriggerTargetComponent_cl *pTargetComp = new VisTriggerTargetComponent_cl();
AddComponent(pTargetComp);
// Get trigger box entity
VisBaseEntity_cl *pTriggerBoxEntity = Vision::Game.SearchEntity("TriggerBox");
VASSERT(pTriggerBoxEntity);
// Find source component
VisTriggerSourceComponent_cl* pSourceComp = vstatic_cast<VisTriggerSourceComponent_cl*>(
pTriggerBoxEntity->Components().GetComponentOfTypeAndName(VisTriggerSourceComponent_cl::GetClassTypeId(), "OnObjectEnter"));
VASSERT(pSourceComp != NULL);
// Link source and target component
IVisTriggerBaseComponent_cl::OnLink(pSourceComp, pTargetComp);
m_eState = GAME_STATE_RUN;
}
示例6: MessageFunction
void IVTransitionEventTrigger::MessageFunction( int iID, INT_PTR iParamA, INT_PTR iParamB )
{
IVAnimationEventTrigger::MessageFunction(iID, iParamA, iParamB);
#ifdef WIN32
if (iID == VIS_MSG_EDITOR_GETSTANDARDVALUES)
{
// Get bone names
const char *szKey = (const char *)iParamA;
if (!strcmp(szKey,"Event"))
{
// Check for model and skeleton
VisBaseEntity_cl* pEntity = (VisBaseEntity_cl *)m_pOwner;
if (pEntity == NULL)
return;
// Check if there is a transition state machine component
VTransitionStateMachine* tsm = static_cast<VTransitionStateMachine*> (pEntity->Components().GetComponentOfType(V_RUNTIME_CLASS(VTransitionStateMachine)));
if (tsm == NULL)
return;
// Fill list with event names (first entry is empty)
VStrList *pDestList = (VStrList*) iParamB;
int count = tsm->GetTransitionTable()->GetNumSequenceDefs();
for (int i = 0; i < count; i++)
{
int events = tsm->GetTransitionTable()->GetSequenceDefByIndex(i)->GetNumAnimationEvents();
for (int e = 0; e < events; e++)
{
pDestList->AddUniqueString(tsm->GetTransitionTable()->GetSequenceDefByIndex(i)->GetAnimationEventByIndex(e)->GetEventString());
}
}
}
}
#endif
}
示例7: CommonInit
bool IVTransitionEventTrigger::CommonInit()
{
// Initialize base component
if (!IVAnimationEventTrigger::CommonInit())
return false;
// Get owner entity
VisBaseEntity_cl *pEntity = (VisBaseEntity_cl *)m_pOwner;
if (pEntity == NULL)
return false;
// Check if there is a transition state machine component and register this instance as an
// event listener. If no TSM is present do not return false as the base class might still
// have been initialized successfully listening to animation events triggered by the Vision
// animation system.
VTransitionStateMachine* tsm = static_cast<VTransitionStateMachine*> (pEntity->Components().GetComponentOfType(V_RUNTIME_CLASS(VTransitionStateMachine)));
if (tsm != NULL)
{
tsm->AddEventListener(this);
tsm->SetForwardingAnimEvents(true);
}
return true;
}
示例8: BuildCameraList
void VCameraHandling::BuildCameraList()
{
VAppMenu* pMainMenu = GetParent()->GetAppModule<VAppMenu>();
if (pMainMenu == NULL)
return;
int iActionIndex = 0;
VAppMenuItems menuItems;
menuItems.Add(VAppMenuItem("<Switch to Free Camera>", iActionIndex++, 0, false));
#if defined(WIN32) && !defined(_VISION_WINRT)
// Add option to disable WASD controls.
m_iWASDActionIndex = iActionIndex++;
menuItems.Add(VAppMenuItem("<Toggle Free Camera WASD Controls>", m_iWASDActionIndex, 1, true, m_bWASDEnabled));
#endif
// Find camera objects in the scene.
// Only store element manager indices in order to be able to detect removed objects.
unsigned int uiNumOrbitCameras = 0;
unsigned int uiNumCameraPositions = 0;
unsigned int uiNumPathCameras = 0;
const unsigned int uiNumEntities = VisBaseEntity_cl::ElementManagerGetSize();
for (unsigned int uiElementIndex = 0; uiElementIndex < uiNumEntities; uiElementIndex++)
{
VisBaseEntity_cl* pEntity = VisBaseEntity_cl::ElementManagerGet(uiElementIndex);
if (pEntity == NULL)
continue;
// Try to convert the entity to all of the supported camera types.
VOrbitCamera* pOrbitCamera = pEntity->Components().GetComponentOfBaseType<VOrbitCamera>();
CameraPositionEntity* pCameraPosition = vdynamic_cast<CameraPositionEntity*>(pEntity);
PathCameraEntity* pPathCamera = vdynamic_cast<PathCameraEntity*>(pEntity);
// Menu name data
const char* szKey = "";
const char* szCameraType = "";
unsigned int uiSortingKey = 0;
unsigned int uiCameraIndex = 0;
if (pOrbitCamera != NULL)
{
// If the owner entity's key is not set, use the model's file name.
const char* szKey = pEntity->GetObjectKey();
if (VStringUtil::IsEmpty(szKey))
szKey = (pEntity->GetMesh() ? pEntity->GetMesh()->GetFilename() : "");
szCameraType = "OrbitCamera";
uiSortingKey = 2;
uiCameraIndex = uiNumOrbitCameras++;
}
else if (pCameraPosition != NULL)
{
szKey = pEntity->GetObjectKey();
szCameraType = "CameraPosition";
uiSortingKey = 3;
uiCameraIndex = uiNumCameraPositions++;
}
else if (pPathCamera != NULL)
{
szKey = pEntity->GetObjectKey();
szCameraType = "PathCamera";
uiSortingKey = 4;
uiCameraIndex = uiNumPathCameras++;
}
else
{
// If we haven't found a free camera entity yet, try to store this one.
if (m_spFreeCamera == NULL)
m_spFreeCamera = vdynamic_cast<VFreeCamera*>(pEntity);
// No camera found.
continue;
}
// Generate menu name.
VString sMenuName;
if (VStringUtil::IsEmpty(szKey))
sMenuName.Format("%s%02d", szCameraType, uiCameraIndex + 1);
else
sMenuName.Format("%s%02d (%s)", szCameraType, uiCameraIndex + 1, szKey);
menuItems.Add(VAppMenuItem(sMenuName, iActionIndex, uiSortingKey, false));
m_actionMap.SetAt(iActionIndex++, EntityAccessor(pEntity, sMenuName));
}
m_callbacks.Append(pMainMenu->RegisterGroup(m_sMenuGroupName, menuItems, NULL, VAPP_DEFAULT_SORTING_2 + 1));
RegisterCallbacks();
}