void MergedModelFactory_cl::DeleteModels()
{
  // Detach camera 
  m_pCameraEntity->DetachFromParent();

  // Delete model preview
  if (m_pPreviewModelEntities != NULL)
  {
    m_vPos = m_pPreviewModelEntities[0]->GetPosition();
    m_vOri = m_pPreviewModelEntities[0]->GetOrientation();

    for (int i = 0; i < BARBARIAN_MAX; i++)
      V_SAFE_DISPOSEOBJECT(m_pPreviewModelEntities[i]);
  }

  V_SAFE_DELETE_ARRAY(m_pPreviewModelEntities);

  // Delete merged model
  if (m_pMergedModelEntity != NULL)
  {
    m_vPos = m_pMergedModelEntity->GetPosition();
    m_vOri = m_pMergedModelEntity->GetOrientation();

    VDynamicMesh::GetResourceManager().RemoveResource(m_pMergedModelEntity->GetMesh());

    V_SAFE_DISPOSEOBJECT(m_pMergedModelEntity);
  }
}
MergedModelFactory_cl::~MergedModelFactory_cl()
{
  // Delete merged model
  if (m_pMergedModelEntity)
     V_SAFE_DISPOSEOBJECT(m_pMergedModelEntity);
  
  // Delete model preview
  if (m_pPreviewModelEntities != NULL)
    for (int i = 0; i < BARBARIAN_MAX; i++)
      V_SAFE_DISPOSEOBJECT(m_pPreviewModelEntities[i])

  V_SAFE_DELETE_ARRAY(m_pPreviewModelEntities);
}
void AttachedTorch_cl::Hide()
{
  if (!m_bVisible) return;

  m_bVisible = false;

  SetVisibleBitmask( 0 );
  SetCastShadows(FALSE);

  m_pShadowCaster->SetVisibleBitmask( 0 );
  m_pShadowCaster->SetCastShadows(FALSE);

  V_SAFE_DISPOSEOBJECT(m_pLight);
  V_SAFE_DISPOSEOBJECT(m_spTorchParticles);
}
Example #4
0
 /// \brief
 ///   Helper function to remove objects from the scene again. Only makes sense if m_bOutputInstances was 'true' at instantiation time
 inline void DisposeObjects()
 {
   const int iCount = hkvMath::Min(m_iInstanceCount, (int)m_Instances.GetSize()); // this handles m_bOutputInstances==false gracefully
   // delete in reverse order. This ensures children get deleted first which avoids deletion issues
   for (int i=iCount-1;i>=0;i--)
     V_SAFE_DISPOSEOBJECT(m_Instances.GetDataPtr()[i]);
 }
void AnimatedWarrior_cl::DeInitFunction()
{
  SetEnabled(false);

  V_SAFE_DISPOSEOBJECT(m_pTorch);

  m_spLayerMixer = NULL;
  m_spAnimConfig = NULL;
}
void CRBX_ModelViewCtrl::SetEntity(VisBaseEntity_cl *pEntity)
{
	V_SAFE_DISPOSEOBJECT(m_pEntity);
	m_pEntity = pEntity;	
  
	hkvAlignedBBox modelbox;
	m_pEntity->GetMesh()->GetVisibilityBoundingBox(modelbox);
	
	hkvVec3 vPos = m_pEntity->GetPosition();

	vPos.z += -modelbox.m_vMin.z;
	m_pEntity->SetPosition(vPos);

	SetFitModel();
}
void AttachedTorch_cl::Show()
{
  if (m_bVisible) return;

  m_bVisible = true;

  SetVisibleBitmask( 1 );
  SetCastShadows(FALSE);

  m_pShadowCaster->SetVisibleBitmask( ENTITY_CAST_SHADOW );
  m_pShadowCaster->SetCastShadows(TRUE);

  V_SAFE_DISPOSEOBJECT(m_pLight);

  if (m_spTorchParticles)
  {
    m_spTorchParticles->Dispose(); 
    m_spTorchParticles = NULL;
  }

  m_pTorchFX = VisParticleGroupManager_cl::GlobalManager().LoadFromFile("Data\\Vision\\Samples\\Engine\\Common\\Models\\Warrior\\TorchFire.xml");
  VASSERT(m_pTorchFX);
  m_pTorchFX->SetResourceFlag(VRESOURCEFLAG_AUTODELETE);

  m_pLight = new VisLightSource_cl(VIS_LIGHT_POINT, 800);
  VASSERT(m_pLight);

  m_pLight->SetMultiplier(1.5f);
  m_pLight->SetLightInfluenceBitMasks(0xFFFFFFFF, 0xFFFFFFFF);
  m_pLight->SetColor(VColorRef(255,180,105));
  m_pLight->SetAttenuation(VIS_LIGHT_ATTEN_CUSTOM);

#if defined(SUPPORTS_SHADOW_MAPS) && !defined(_VISION_MOBILE) && !defined( HK_ANARCHY )
  VShadowMapComponentPoint* pShadowMapComponent = new VShadowMapComponentPoint();
  pShadowMapComponent->SetShadowMapSize(256);
  pShadowMapComponent->SetShadowMappingMode(SHADOW_MAPPING_MODE_PCF8);
  m_pLight->AddComponent(pShadowMapComponent);
#endif

  hkvVec3 vPdir(0.0f, -90.0f, 0.0f);
  m_spTorchParticles = m_pTorchFX->CreateParticleEffectInstance(GetPosition(), vPdir);
}
void TransitionCharacter_cl::DeInitFunction()
{
  V_SAFE_DISPOSEOBJECT(m_pStateMachine);
}
AttachedTorch_cl::~AttachedTorch_cl(void)
{
  Hide();
  Detach();
  V_SAFE_DISPOSEOBJECT(m_pLight);
}
void TransitionBarbarian_cl::DeInitFunction()
{
  V_SAFE_DISPOSEOBJECT(m_pStateMachine);
}
CRBX_ModelViewCtrl::~CRBX_ModelViewCtrl()
{
	V_SAFE_DISPOSEOBJECT(m_pEntity);
	V_SAFE_DISPOSEOBJECT(m_pWorldAxisEntity);
	V_SAFE_DISPOSEOBJECT(m_pLight);
}