コード例 #1
0
ファイル: Trigger.cpp プロジェクト: Bewolf2/projectanarchy
void RPG_Trigger::PostInitialize()
{
  RPG_BaseEntity::PostInitialize();

  if(Vision::Editor.IsPlayingTheGame() && !m_displayDebug)
  {
    // Trigger should be invisible during the game unless we're displaying the mesh for debug purposes.
    SetVisibleBitmask(VIS_ENTITY_INVISIBLE);
  }

  // create a box based off of the entity scaling. a scale of (1,1,1) = .001 meter cube in havok units.
  
  m_aabb.setInvalid();

  m_aabb.set(-GetScaling() * 0.5f, GetScaling() * 0.5f);

  hkvMat4 aabbTransform(GetRotationMatrix(), GetPosition());
  m_aabb.transformFromOrigin(aabbTransform);

  hkVector4 minBoundary;
  RPG_VisionHavokConversion::VisionToHavokPoint(m_aabb.m_vMin, minBoundary);

  hkVector4 maxBoundary;
  RPG_VisionHavokConversion::VisionToHavokPoint(m_aabb.m_vMax, maxBoundary);

  // Create the AABB
  hkAabb fixedAabb;
  fixedAabb.setEmpty();
  fixedAabb.m_min = minBoundary;
  fixedAabb.m_max = maxBoundary;

  // Create the phantom
  m_aabbPhantom = new RPG_AabbPhantom(this, fixedAabb);

  // Set entity type for the triggers' data collection
  //m_aabbPhantom->setUserData( (hkUlong)this );

  // Add the phantom to the world
  
  vHavokPhysicsModule::GetInstance()->MarkForWrite();
  {
    vHavokPhysicsModule::GetInstance()->GetPhysicsWorld()->addPhantom(m_aabbPhantom);
  }
  vHavokPhysicsModule::GetInstance()->UnmarkForWrite();


  // Set color
  //HK_SET_OBJECT_COLOR((hkUlong)fixedPhantomCallbackShapeRB->getCollidable(), m_fixedPhantomCallbackShape->m_colourNoHit);

  // Cache trigger sources: note that these may not exist in serialized scenes if nothing referenced them
  if(!m_onEnterSource)
    m_onEnterSource = static_cast<VisTriggerSourceComponent_cl*>(Components().GetComponentOfTypeAndName(V_RUNTIME_CLASS(VisTriggerSourceComponent_cl), "OnEnter"));

  if(!m_onExitSource)
    m_onExitSource = static_cast<VisTriggerSourceComponent_cl*>(Components().GetComponentOfTypeAndName(V_RUNTIME_CLASS(VisTriggerSourceComponent_cl), "OnExit"));

  if(!m_onInsideSource)
    m_onInsideSource = static_cast<VisTriggerSourceComponent_cl*>(Components().GetComponentOfTypeAndName(V_RUNTIME_CLASS(VisTriggerSourceComponent_cl), "OnInside"));
}
コード例 #2
0
void RPG_SpawnPoint::PostInitialize()
{
  RPG_BaseEntity::PostInitialize();

  if(Vision::Editor.IsPlayingTheGame() && !m_displayDebug)
  {
    // Spawn Point should be invisible during the game unless we're displaying the mesh for debug purposes.
    SetVisibleBitmask(VIS_ENTITY_INVISIBLE);
  }
}
コード例 #3
0
void AttachedTorch_cl::InitFunction()
{
  SetVisibleBitmask( 0 );
  SetCastShadows(FALSE);
  m_pShadowCaster = Vision::Game.CreateEntity("VisBaseEntity_cl", GetPosition(), "Data\\Vision\\Samples\\Engine\\Common\\Models\\Warrior\\TorchBottom.MODEL");
  m_pShadowCaster->AttachToParent(this);
  m_pShadowCaster->SetVisibleBitmask( 0 );
  m_pShadowCaster->SetCastShadows( FALSE );
  hkvVec3 vScale(2.5f, 2.5f, 1.0f);
  m_pShadowCaster->SetScaling(vScale);
}
コード例 #4
0
void VParticleWallmarkGroup::RecomputeBoundingBox()
{
  VParticleWallmark* p = (VParticleWallmark *)GetParticles();
  hkvAlignedBBox oldBBox = m_BoundingBox; 
  m_BoundingBox.setInvalid();
  for (int i=0;i<m_iHighWaterMark;i++,p++)
    if (p->IsValid())
      p->InflateBoundingBox(m_BoundingBox);

  if (m_BoundingBox.isValid())
  {
    // actually all other tests are too error-prone for frequently resizing boxes
    if (m_spVisObj==NULL)
      m_spVisObj = new VisVisibilityObjectAABox_cl(VISTESTFLAGS_FRUSTUMTEST|VISTESTFLAGS_ACTIVE);
    m_spVisObj->SetActivate(TRUE);

    // build visibility assignment on our own. automatic update is too error prone by going through portals
    if (oldBBox!=m_BoundingBox)
    {
      m_spVisObj->SetWorldSpaceBoundingBox(m_BoundingBox);
      VisObject3DVisData_cl *pVisData = m_spVisObj->GetVisData();
      pVisData->SetAutomaticUpdate(false);
      VisVisibilityZone_cl *pZones[4096];
      const int iVisCount = Vision::GetSceneManager()->FindVisibilityZones(m_BoundingBox,pZones,4096);
      pVisData->UpdateNodeList(iVisCount,pZones);
    }
    SetVisibilityObject(m_spVisObj);
    SetVisibleBitmask(0xffffffff);
  }
  else
  {
    if (m_spVisObj)
      m_spVisObj->SetActivate(FALSE);
    SetVisibleBitmask(0);
  }
  m_bBBoxValid = true;
}
コード例 #5
0
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);
}
コード例 #6
0
void SimpleSkeletalAnimatedObject_cl::SetActivate(bool bStatus) 
{
  SetCastShadows(bStatus);
  SetVisibleBitmask(bStatus ? 0xffffffff : 0);

  if (m_pLookAtTarget != NULL) 
    m_pLookAtTarget->SetVisibleBitmask(bStatus ? 0xffffffff : 0);

  if (bStatus)
  {
    SetMode(m_eSampleMode);
  }
  else
  {
    SetAnimConfig(NULL);
  }
}
コード例 #7
0
  // constructor that takes an entity that it attaches to along with the surface name that it uses for picking and displaying
VMonitorGUIContext::VMonitorGUIContext(VGUIManager *pManager, VisSurface_cl *pScreenSrf)
  : IVGUIContext(pManager)
  , m_fTraceRange(100.f)
{
  m_pGUISurface = pScreenSrf;

  // create a render context texture to render the GUI into
  VisRenderableTextureConfig_t config;

  config.m_iHeight = 512;
  config.m_iWidth  = 512;
  config.m_eFormat = VTextureLoader::DEFAULT_RENDERTARGET_FORMAT_32BPP;
  

  VisRenderableTexture_cl *pTex =  Vision::TextureManager.CreateRenderableTexture("<Monitor>",config);
  m_ClientRect.Set(0,0,(float)config.m_iWidth,(float)config.m_iHeight);
  
  config.m_eFormat = VVideo::GetSupportedDepthStencilFormat(VTextureLoader::D24S8, *Vision::Video.GetCurrentConfig());
  config.m_bRenderTargetOnly = true;
  config.m_bIsDepthStencilTarget = true;
  VisRenderableTexture_cl *pDepthStencilTarget =  Vision::TextureManager.CreateRenderableTexture("<MonitorDS>",config);

  m_spRenderContext = new VisRenderContext_cl();
  m_spRenderContext->SetRenderLoop(new MonitorRenderLoop(this));
  m_spRenderContext->SetRenderTarget(0, pTex);
  m_spRenderContext->SetDepthStencilTarget(pDepthStencilTarget);
  m_spRenderContext->SetCamera(new VisContextCamera_cl());
  m_spRenderContext->SetVisibilityCollector(new VisionVisibilityCollector_cl());

  m_spRenderContext->SetRenderFilterMask(VIS_ENTITY_VISIBLE_IN_TEXTURE);
  SetVisibleBitmask(VIS_ENTITY_VISIBLE_IN_TEXTURE);

  // register the context
  Vision::Contexts.AddContext(m_spRenderContext);

  // replace the base texture of this surface by GUI context texture
  pScreenSrf->SetBaseTexture(pTex);

  // we need the base uv coordinates to detect mouse movement on the surface
  Vision::CollisionToolkit.SetTraceLineSettings(VIS_TRACESETTINGS_DEFAULT|VIS_TRACESETTINGS_STOREBASEUV);

  OnItemClick += this; // listen to the item click event
}
コード例 #8
0
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);
}