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); } } }
void VAnimationEventEffectTrigger::OnAnimationEvent() { // Get the active event trigger info VEventEffectTriggerInfo_t* info = (VEventEffectTriggerInfo_t*) m_pActiveTriggerInfo; // Check if effect file is specified if (info == NULL || info->m_spEffectFile == NULL) return; // Get bone translation and orientation (if bone ID is 0 no bone has been specified) VisBaseEntity_cl* pEntity = (VisBaseEntity_cl *)m_pOwner; hkvVec3 vPos = pEntity->GetPosition() + info->m_vPositionOffset; hkvVec3 vOri = pEntity->GetOrientation() + info->m_vOrientationOffset; if (info->m_iAttachToBone != -1) { hkvQuat vRot; pEntity->GetBoneCurrentWorldSpaceTransformation(info->m_iAttachToBone, vPos, vRot); // Add position and orientation offset vPos = PositionOffset + vPos; hkvQuat vOffsetRot; vOffsetRot.setFromEulerAngles (vOri.data[2], vOri.data[1], vOri.data[0]); vRot = vRot.multiplyReverse (vOffsetRot); vRot.getAsEulerAngles (vOri.z, vOri.y, vOri.x); } // Trigger effect VisParticleEffect_cl* pEffectInstance = info->m_spEffectFile->CreateParticleEffectInstance(vPos, vOri); pEffectInstance->SetRemoveWhenFinished(true); }
// --------------------------------------------------------------------------------- // Method: ResetWorld // Notes: This function is used by the LoadGame function to get rid of all // serializeable entities. // --------------------------------------------------------------------------------- void ResetWorld() { int i; int iNumOfAllEntities = VisBaseEntity_cl::ElementManagerGetSize(); // send CLEANUP messages to all the entities that are about to be freed, so // that they have a chance of cleaning up whatever is necessary before the // world is destroyed for (i = 0; i < iNumOfAllEntities; i++) { VisBaseEntity_cl *pEnt = VisBaseEntity_cl::ElementManagerGet(i); if ( pEnt ) { if ( pEnt->IsOfType(SerializeBaseEntity_cl::GetClassTypeId()) ) { Vision::Game.SendMsg(pEnt, MSG_SER_CLEANUP, 0, 0 ); } } } // now actually free all the serializeable entities for (i = 0; i < iNumOfAllEntities; i++) { VisBaseEntity_cl *pEnt = VisBaseEntity_cl::ElementManagerGet(i); if ( pEnt ) { if ( pEnt->IsOfType(SerializeBaseEntity_cl::GetClassTypeId()) ) { pEnt->DisposeObject(); } } } }
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; }
inline ComponentType* GetComponentOfBaseType() const { VisBaseEntity_cl* pEntity = GetEntity(); if (pEntity == NULL) return NULL; return pEntity->Components().GetComponentOfBaseType<ComponentType>(); }
void VAnimationEventEffectTrigger::MessageFunction( int iID, INT_PTR iParamA, INT_PTR iParamB ) { IVTransitionEventTrigger::MessageFunction(iID, iParamA, iParamB); #ifdef WIN32 if (iID == VIS_MSG_EDITOR_GETSTANDARDVALUES) { // Get bone names const char *szKey = (const char *)iParamA; if (!strcmp(szKey,"Bone")) { // Check for model and skeleton VisBaseEntity_cl* pEntity = (VisBaseEntity_cl *)m_pOwner; if (pEntity == NULL) return; VDynamicMesh* pMesh = pEntity->GetMesh(); if (pMesh == NULL) return; VisSkeleton_cl *pSkeleton = pMesh->GetSkeleton(); if (pSkeleton == NULL) return; // Fill list with bone names (first entry is empty) VStrList *pDestList = (VStrList*) iParamB; pDestList->AddString(" "); for (int i = 0; i < pSkeleton->GetBoneCount(); i++) pDestList->AddString(pSkeleton->GetBone(i)->m_sBoneName.AsChar()); } } #endif }
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(); } }
void IController::RemoveLast(void) { VisBaseEntity_cl *ent = entityStack->pop(); if (ent != NULL) { ent->DisposeObject(); } }
bool VAnimationEventEffectTrigger::CommonInit() { // Initialize base component if (!IVTransitionEventTrigger::CommonInit()) return false; // Get owner entity VisBaseEntity_cl *pEntity = (VisBaseEntity_cl *)m_pOwner; if (pEntity == NULL) return false; // Fill the event trigger info if (m_iEventTriggerInfoCount <= 0) { VEventEffectTriggerInfo_t* info = NULL; if(m_pActiveTriggerInfo == NULL) //make sure it does not get created more than once { // Create new list with only one entry and set properties info = new VEventEffectTriggerInfo_t(); } else { info = (VEventEffectTriggerInfo_t*)m_pActiveTriggerInfo; } info->m_vPositionOffset = PositionOffset; info->m_vOrientationOffset= OrientationOffset; // Get effect file info->m_spEffectFile = VisParticleGroupManager_cl::GlobalManager().LoadFromFile(EffectFilename); if (info->m_spEffectFile == NULL || !GetEventTriggerInfoBaseData(info)) { V_SAFE_DELETE(info); m_pActiveTriggerInfo = NULL; return false; } // Get Bone Index if specified if (!AttachToBone.IsEmpty()) { VDynamicMesh* pMesh = pEntity->GetMesh(); if (pMesh == NULL) return false; VisSkeleton_cl *pSkeleton = pMesh->GetSkeleton(); if (pSkeleton == NULL) return false; info->m_iAttachToBone = pSkeleton->GetBoneIndexByName(AttachToBone); } // Set it as the active event trigger info m_pActiveTriggerInfo = info; } return true; }
VisBaseEntity_cl* IController::AddCube(float x, float y, float z) { VisBaseEntity_cl *ent = Vision::Game.CreateEntity("VisBaseEntity_cl", hkvVec3(x, y, z), "Models\\Misc\\Cube.Model"); vHavokRigidBody *cube = new vHavokRigidBody(); cube->Havok_TightFit = true; ent->AddComponent(cube); //EntityStack stack = *entityStack; //stack.push(ent); entityStack->push(ent); return ent; }
VisBaseEntity_cl* IController::AddRagdoll(float x, float y, float z) { VisBaseEntity_cl *ent = Vision::Game.CreateEntity("VisBaseEntity_cl", hkvVec3(x, y, z), "Models\\Warrior\\Warrior.model"); vHavokRagdoll *ragdoll = new vHavokRagdoll(); ragdoll->SetRagdollCollisionFile("Models\\Warrior\\WarriorRagdoll.hkt"); ent->AddComponent(ragdoll); //EntityStack stack = *entityStack; //stack.push(ent); entityStack->push(ent); return ent; }
//////////////////////////// Water Simulation Controls ////////////////////////////////////////////////////////////// VisBaseEntity_cl *IController::AddWaterDrop(float x, float y, float z, float scaling) { VisBaseEntity_cl *ent = Vision::Game.CreateEntity("VisBaseEntity_cl", hkvVec3(x, y, z), "Assets\\Models\\Misc\\Sphere.Model"); ent->SetScaling(scaling); vHavokRigidBody *sphere = new vHavokRigidBody(); sphere->Havok_TightFit = true; sphere->Havok_Restitution = .35f; ent->AddComponent(sphere); ent->Tag(); entityStack->push(ent); return ent; }
VisBaseEntity_cl* IController::AddSphere(float x, float y, float z) { VisBaseEntity_cl *ent = Vision::Game.CreateEntity("VisBaseEntity_cl", hkvVec3(x, y, z), "Models\\Misc\\Sphere.Model"); vHavokRigidBody *sphere = new vHavokRigidBody(); sphere->Havok_TightFit = true; sphere->Havok_Restitution = 1.0f; ent->AddComponent(sphere); //EntityStack stack = *entityStack; //stack.push(ent); entityStack->push(ent); return ent; }
/// Finds and stores the level info object. void RPG_GameManager::FindLevelInfo() { // find the level info object VisBaseEntity_cl* levelInfo = Vision::Game.SearchEntity(RPG_LevelInfo::GetStaticKey()); if(levelInfo && levelInfo->IsOfType(V_RUNTIME_CLASS(RPG_LevelInfo))) { // store the level info object if we found one m_levelInfo = static_cast<RPG_LevelInfo*>(levelInfo); } }
// Some sample scenes create an automatic path camera, which doesn't work with // our multi-context approach to rendering stereoscopic images, so we'll have to // find and deactivate them. void DeactivatePathCameraEntities() { for (unsigned int i=0;i<VisBaseEntity_cl::ElementManagerGetSize();i++) { VisBaseEntity_cl *pEnt = VisBaseEntity_cl::ElementManagerGet(i); if ( pEnt && pEnt->GetTypeId() == PathCameraEntity::GetClassTypeId() ) { PathCameraEntity* pPathCam = ( PathCameraEntity* ) pEnt; pPathCam->Stop(); } } }
EngineInstancePathCamera::EngineInstancePathCamera() { VisBaseEntity_cl *pEntity = Vision::Game.CreateEntity("PathCameraEntity",hkvVec3(0,0,0)); Debug::Assert(pEntity!=nullptr,"Could not create Cloth entity!"); // reference the entity with a weak pointer. This will make sure that we correctly get a null pointer // if the entity gets deleted in the engine m_pEntityWP = new VWeakPtr<VisBaseEntity_cl>(pEntity->GetWeakReference()); m_pSpriteTex = Vision::TextureManager.Load2DTexture("textures\\videoCamera.dds",VTM_FLAG_DEFAULT_NON_MIPMAPPED); m_pSpriteTex->AddRef(); }
// Helper for OnRunGameLoop // Post-physics loop: posthink & modulesystem-notifications void VisionApp_cl::RunThink(float fElapsedTime) { const VisEntityCollection_cl &relevantEntities = Vision::Game.GetThinkingEntities(); VISION_PROFILE_FUNCTION(VIS_PROFILE_GAMELOOP_THINKFUNCTION); int &i = relevantEntities.m_iIterator; // use this iterator to keep counter in-sync if collection changes during loop for (i=0; i<relevantEntities.GetNumEntries(); i++) { VisBaseEntity_cl *pEntity = relevantEntities.GetEntry(relevantEntities.m_iIterator); VASSERT(pEntity->GetThinkFunctionStatus()); // entity code postthink pEntity->ThinkFunction(); } }
///< Spawn the Ai Character and perform any setup we need to of them. void RPG_AiSpawnPoint::OnSpawn() { // only spawn if we haven't already. @todo: add support for spawning waves of characters. if(m_spawned) { return; } m_spawned = true; bool success = false; if(!m_prefabName.IsEmpty()) { VisBaseEntity_cl* entity = RPG_GameManager::s_instance.CreateEntityFromPrefab(m_prefabName, GetPosition(), GetOrientation()); if(entity) { if(entity->IsOfType(V_RUNTIME_CLASS(RPG_Character))) { m_character = static_cast<RPG_Character*>(entity); } success = true; } } else if(!m_spawnScript.IsEmpty()) { VisBaseEntity_cl* entity = RPG_GameManager::s_instance.CreateEntityFromScript(m_spawnScript, GetPosition(), GetOrientation()); VASSERT(entity); if(entity) { if(entity->IsOfType(V_RUNTIME_CLASS(RPG_Character))) { m_character = static_cast<RPG_Character*>(entity); } success = true; } } if(!success) { hkvLog::Warning("Ai Spawner has no Prefab defined, and no valid Script definition!"); } }
void ParticleRainController::RainBalls(int numOfBalls){ while (ballCount < numOfBalls){ int randomx = rand() % 6000 - 3255; int randomy = rand() % 6000 - 1416; VisBaseEntity_cl *ent = Vision::Game.CreateEntity("VisBaseEntity_cl", hkvVec3(randomx, randomy, 3000), "Models\\Misc\\Sphere.Model"); vHavokRigidBody *ball = new vHavokRigidBody(); ball->Havok_TightFit = true; ball->Havok_Mass = 5.0f; ball->Havok_Restitution = 1.0f; ball->Shape_Type = ShapeType_SPHERE; ent->SetScaling(1.0f); ent->AddComponent(ball); ++ballCount; } ballCount = 0; }
void VFmodAnimationEventSoundTrigger::OnAnimationEvent() { // Get the active event trigger info VFmodEventSoundTriggerInfo_t* info = (VFmodEventSoundTriggerInfo_t*) m_pActiveTriggerInfo; // Check if effect file is specified if (info == NULL || info->m_spSoundResource == NULL) return; // Get entity position VisBaseEntity_cl* pEntity = (VisBaseEntity_cl *)m_pOwner; hkvVec3 vPos = pEntity->GetPosition(); // Trigger sound effect VFmodSoundObject* pSound = info->m_spSoundResource->CreateInstance(vPos, VFMOD_FLAG_NONE); if(pSound) pSound->Play(); }
// --------------------------------------------------------------------------------- // Method: LoadMap // Notes: // --------------------------------------------------------------------------------- void LoadMap(int iMap, BOOL bLoadEntities) { g_spMap = NULL; // load map strcpy(g_pszCurrentMap, g_pszMaps[iMap]); g_iCurrentMap = iMap; spApp->LoadScene(g_pszCurrentMap); hkvVec3 vStart; // try to find the Player_Start placeholder entity VisBaseEntity_cl* pStart = Vision::Game.SearchEntity("Player_Start"); if (pStart) vStart = pStart->GetPosition(); else vStart.set (-350.f, 200.f, 200.f); if ( bLoadEntities ) { // create player entity (in case the entities are not loaded from the savegame) Vision::Game.CreateEntity("SerializePlayer_cl", vStart); // create 3 spotlight entities hkvVec3 Placement; Placement.set ( -200, 500, 200 ); Vision::Game.CreateEntity("SerializeSpotlight_cl", Placement ); Placement.set ( -300, 0, 100 ); Vision::Game.CreateEntity("SerializeSpotlight_cl", Placement ); Placement.set ( 40, -600, 100 ); Vision::Game.CreateEntity("SerializeSpotlight_cl", Placement ); } // create some screen masks int w = Vision::Video.GetXRes(); int h = Vision::Video.GetYRes(); // set up "current map" screen mask g_spMap = new VisScreenMask_cl(g_pszMapIcons[iMap], TEXTURE_LOADING_FLAGS); g_spMap->SetPos( w - 48.f - 8.f, (float)h - 48.f - 8.f ); g_spMap->SetTransparency(VIS_TRANSP_ALPHA); g_spMap->SetColor(g_iOverlayColor); g_spMap->SetVisible(TRUE); }
WaterSimulationController::WaterSimulationController(void) { #if defined(_VISION_ANDROID) //free camera for android (joystick/finger camera) VisBaseEntity_cl* pCam = Vision::Game.CreateEntity("VFreeCamera", hkvVec3::ZeroVector()); pCam->SetPosition(-290, -220, 680); //spawns with same coordinates as windows pCam->SetOrientation(20, 67, 19); #endif #if defined(WIN32) VisBaseEntity_cl *pCamera = Vision::Game.SearchEntity("tankcamera"); Vision::Camera.AttachToEntity(pCamera, hkvVec3::ZeroVector()); #endif /*#if defined(_VISION_ANDROID) pMod = static_cast<vHavokPhysicsModule*>(vHavokPhysicsModule::GetInstance()); pMotionInput = (VMotionInputAndroid*)(&VInputManager::GetInputDevice(INPUT_DEVICE_MOTION_SENSOR)); pMotionInput->SetEnabled(true); #endif*/ }
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; }
/// Creates an entity from a Lua script definition. VisBaseEntity_cl* RPG_GameManager::CreateEntityFromScript(const VString& scriptName, const hkvVec3& position, const hkvVec3& orientation) { VScriptResourceManager* scriptManager = static_cast<VScriptResourceManager*>(Vision::GetScriptManager()); VScriptResource* scriptRes = scriptManager->LoadScriptFile(scriptName); IVScriptInstance* script = scriptRes->CreateScriptInstance(); VASSERT(script); if(script) { // get the entity class type to create char* className = NULL; script->ExecuteFunctionArg("GetEntityClassType", "*>s", &className); // create the entity VisBaseEntity_cl* entity = Vision::Game.CreateEntity(className, position); VASSERT(entity); if(entity) { entity->SetOrientation(orientation); // attach the script scriptManager->SetScriptInstance(entity, script); if(entity->IsOfType(V_RUNTIME_CLASS(RPG_BaseEntity))) { RPG_BaseEntity* rpgEntity = static_cast<RPG_BaseEntity*>(entity); #if (RPG_SERIALIZATION_SCRIPT_PROPERTIES) rpgEntity->InitializeProperties(); #endif rpgEntity->PostInitialize(); } return entity; } } return NULL; }
bool WaterSimulationController::Run(VInputMap* inputMap){ if(inputMap->GetTrigger(CUSTOM_CONTROL_ONE)){ VisBaseEntity_cl *ent = this->AddSphere(0, 0, 300); ent->SetScaling(0.15f); ent->RemoveAllComponents(); vHavokRigidBody *sphere = new vHavokRigidBody(); sphere->Havok_TightFit = true; sphere->Havok_Restitution = 0.1f; ent->AddComponent(sphere); } if(inputMap->GetTrigger(CUSTOM_CONTROL_TWO)){ TriggerBoxEntity_cl *triggerbox = vdynamic_cast <TriggerBoxEntity_cl *> (Vision::Game.SearchEntity("triggerbox")); if(triggerbox->IsEnabled()) triggerbox->SetEnabled(false); else if(!triggerbox->IsEnabled()) triggerbox->SetEnabled(true); } return true; }
static void LookAtBox(const hkvAlignedBBox &bbox) { if (!bbox.isValid()) return; VisBaseEntity_cl* pCenterEntity = Vision::Game.CreateEntity("VisBaseEntity_cl", bbox.getCenter()); const float fBBRadius = bbox.getBoundingSphere().m_fRadius; float fFovX, fFovY; Vision::Contexts.GetMainRenderContext()->GetFinalFOV(fFovX, fFovY); const float fDist = fBBRadius / hkvMath::tanDeg(hkvMath::Min(fFovX, fFovY) * 0.5f); VOrbitCamera* pOrbitCamera = new VOrbitCamera(); pOrbitCamera->MinimalDistance = fDist * 0.01f; pOrbitCamera->MaximalDistance = fDist * 100.0f; pOrbitCamera->CameraDistance = fDist; pCenterEntity->AddComponent(pOrbitCamera); }
// Helper for OnRunGameLoop // The update loop is responsible for deleting "dead" entities and updating the core engine's variables void VisionApp_cl::RunUpdateLoop() { VISION_PROFILE_FUNCTION( VIS_PROFILE_GAMELOOP_UPDATELOOP ); // Delete "dead" entities from previous frame Vision::Game.FreeRemovedEntities(); const VisEntityCollection_cl &updatedEntities = Vision::Game.GetUpdatedEntities(); const int iNumEntities = updatedEntities.GetNumEntries(); int &i = updatedEntities.m_iIterator; // use this iterator to keep counter in-sync if collection changes during loop for (i=0; i<iNumEntities; i++) { VisBaseEntity_cl *pEntity = updatedEntities.GetEntry(i); if (!pEntity) continue; VISION_PROFILE_FUNCTION(VIS_PROFILE_GAMELOOP_MODULESYSHANDLE); // send notifications to module system (e.g. all children like bound entities, lights, particles, ...) pEntity->Handle(); // update visibility bounding box pEntity->UpdateVisBoundingBox(); // update core engine variables if ( pEntity->IsCoreUpdateRequired() ) pEntity->UpdateEntityChangedStatus(); // reset the status flags pEntity->ResetStatusFlags(); } }
// Render shaders on entities void VPostProcessTranslucencies::DrawEntitiesShaders(const VisEntityCollection_cl &EntityCollection, VPassType_e ePassType) { VisDrawCallInfo_t SurfaceShaderList[RLP_MAX_ENTITY_SURFACESHADERS]; unsigned int iNumEntities = EntityCollection.GetNumEntries(); unsigned int i; Vision::RenderLoopHelper.BeginEntityRendering(); for (i=0; i<iNumEntities; i++) { VisBaseEntity_cl *pEntity = EntityCollection.GetEntry(i); // Foreground entities will be handled separately if (pEntity->IsObjectAlwaysInForegroundEnabled()) continue; if ( pEntity->HasShadersForPass(ePassType) ) { // Get a list of the corresponding pass type surface shaders VisShaderSet_cl *pShaderSet = pEntity->GetActiveShaderSet(); if (pShaderSet == NULL) continue; int iNumSurfaceShaders = pShaderSet->GetShaderAssignmentList(SurfaceShaderList, ePassType, RLP_MAX_ENTITY_SURFACESHADERS); VASSERT(iNumSurfaceShaders < RLP_MAX_ENTITY_SURFACESHADERS); if (iNumSurfaceShaders == 0) continue; VDynamicMesh *pMesh = pEntity->GetMesh(); // If the model has lit surfaces, and if the shaders makes use of the lighting information, we need to set up // the global lights. if (pMesh != NULL && pMesh->HasLitSurfaces() && (pShaderSet->GetCombinedTrackingMask()&(VSHADER_TRACKING_LIGHTGRID_PS|VSHADER_TRACKING_LIGHTGRID_GS|VSHADER_TRACKING_LIGHTGRID_VS)) ) { Vision::RenderLoopHelper.TrackLightGridInfo(pEntity); } // Render the entity with the surface shader list Vision::RenderLoopHelper.RenderEntityWithSurfaceShaderList(pEntity, iNumSurfaceShaders, SurfaceShaderList); } } Vision::RenderLoopHelper.EndEntityRendering(); }
void VLineFollowerComponent::PerFrameUpdate() { VisBaseEntity_cl* pOwner = (VisBaseEntity_cl *)GetOwner(); if (!pOwner || !m_pFollowPath) return; hkvVec3 vPos; hkvVec3 vDir; m_pFollowPath->EvalPoint(m_fCurrentPathPos, vPos, &vDir); vPos.z = pOwner->GetPosition().z; float fDiff = Vision::GetTimer()->GetTimeDifference(); if((vPos - pOwner->GetPosition()).getLength() < Path_TriggerDistance) { if(fDiff>0.1) m_fCurrentPathPos += (3/Path_NumberSteps); else m_fCurrentPathPos += (1/Path_NumberSteps); if (m_fCurrentPathPos>1.f) { if (m_pFollowPath->IsClosed()) m_fCurrentPathPos = hkvMath::mod (m_fCurrentPathPos,1.f); else m_fCurrentPathPos = 1.f; } m_pFollowPath->EvalPoint(m_fCurrentPathPos, vPos, &vDir); vPos.z = pOwner->GetPosition().z; if(Vision::Editor.IsAnimatingOrPlaying() && Debug_DisplayBoxes) Vision::Game.DrawCube(vPos,80.f); } else { if(Vision::Editor.IsAnimatingOrPlaying() && Debug_DisplayBoxes) Vision::Game.DrawCube(vPos,80.f,V_RGBA_YELLOW); } // Orient the entity in the right direction hkvMat3 mRot(hkvNoInitialization); mRot.setLookInDirectionMatrix (vPos - pOwner->GetPosition()); mRot = mRot.multiply (m_mDeltaRotation); pOwner->SetRotationMatrix(mRot); // The animation we are playing should have motion delta which will // move towards the target position. No animation, well lets add at // least some motion delta if (!m_bPlayingAnim) { pOwner->SetMotionDeltaLocalSpace( hkvVec3(1.f,0.f,0.f)*(Model_CapsuleRadius*fDiff) ); } }
void VPostProcessTranslucencies::MaskOutForegroundEntities(const VisEntityCollection_cl &EntityCollection) { unsigned int iNumEntities = EntityCollection.GetNumEntries(); // this collection only contains foreground objects if (m_spForegroundMaskTechnique==NULL || iNumEntities==0) return; unsigned int i; const hkvMat4* pLastProj = NULL; INSERT_PERF_MARKER_SCOPE("VPostProcessTranslucencies::MaskOutForegroundEntities"); Vision::RenderLoopHelper.BeginEntityRendering(); for (i=0; i<iNumEntities; i++) { VisBaseEntity_cl *pEntity = EntityCollection.GetEntry(i); VASSERT_MSG(pEntity->IsObjectAlwaysInForegroundEnabled(), "Only entities with this flag should be passed to this function"); if (!pEntity->HasShadersForPass(VPT_PrimaryOpaquePass)) continue; const hkvMat4* pThisProj = pEntity->GetCustomProjectionMatrixForForegroundObject(); if (pThisProj!=pLastProj) { VisRenderStates_cl::SetCurrentProjectionMatrix(pThisProj); pLastProj = pThisProj; } // depth fill pass Vision::RenderLoopHelper.RenderEntityWithShaders(pEntity, m_spForegroundMaskTechnique->GetShaderCount(), m_spForegroundMaskTechnique->GetShaderList()); } Vision::RenderLoopHelper.EndEntityRendering(); // reset to context projection matrix if (pLastProj) { VisRenderStates_cl::SetCurrentProjectionMatrix(NULL); } }