| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- //********************************** Banshee Engine (www.banshee3d.com) **************************************************//
- //**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
- #include "Components/BsCLight.h"
- #include "RTTI/BsCLightRTTI.h"
- #include "Scene/BsSceneManager.h"
- namespace bs
- {
- CLight::CLight()
- {
- setFlag(ComponentFlag::AlwaysRun, true);
- setName("Light");
- }
- CLight::CLight(const HSceneObject& parent, LightType type, Color color,
- float intensity, float range, bool castsShadows, Degree spotAngle, Degree spotFalloffAngle)
- : Component(parent), mType(type), mColor(color), mIntensity(intensity), mRange(range),
- mCastsShadows(castsShadows), mSpotAngle(spotAngle), mSpotFalloffAngle(spotFalloffAngle)
- {
- setFlag(ComponentFlag::AlwaysRun, true);
- setName("Light");
- }
- CLight::~CLight()
- {
- if(mInternal != nullptr)
- mInternal->destroy();
- }
- Sphere CLight::getBounds() const
- {
- mInternal->_updateState(*SO());
- return mInternal->getBounds();
- }
- void CLight::onInitialized()
- {
- // If mInternal already exists this means this object was deserialized,
- // so all we need to do is initialize it.
- if (mInternal != nullptr)
- mInternal->initialize();
- else
- {
- mInternal = Light::create(mType, mColor, mIntensity,
- mRange, mCastsShadows, mSpotAngle, mSpotFalloffAngle);
- }
- gSceneManager()._bindActor(mInternal, sceneObject());
- }
- void CLight::onDestroyed()
- {
- gSceneManager()._unbindActor(mInternal);
- }
-
- RTTITypeBase* CLight::getRTTIStatic()
- {
- return CLightRTTI::instance();
- }
- RTTITypeBase* CLight::getRTTI() const
- {
- return CLight::getRTTIStatic();
- }
- }
|