21 #include "CaelumPrecompiled.h" 23 #include "InternalUtilities.h" 31 Ogre::SceneManager *sceneMgr,
32 Ogre::SceneNode *caelumRootNode,
33 const Ogre::String &meshName
40 mSunEntity.reset (sceneMgr->createEntity (
"Caelum/SphereSun" + uniqueSuffix, meshName));
41 mSunEntity->setMaterialName (mSunMaterial->getName ());
42 mSunEntity->setCastShadows (
false);
43 mSunEntity->setRenderQueueGroup (CAELUM_RENDER_QUEUE_SUN);
45 mNode->attachObject (mSunEntity.get ());
54 mSunMaterial->setSelfIllumination (colour);
62 Ogre::Real sunDistance =
mRadius -
mRadius * Ogre::Math::Tan (Ogre::Degree (0.01));
67 float scale = factor * sunDistance * Ogre::Math::Tan (Ogre::Degree (0.01));
68 mNode->setScale (Ogre::Vector3::UNIT_SCALE * scale);
74 Ogre::SceneManager *sceneMgr,
75 Ogre::SceneNode *caelumRootNode,
76 const Ogre::String &sunTextureName,
77 const Ogre::Degree& sunTextureAngularSize
80 mSunTextureAngularSize(sunTextureAngularSize)
110 assert(
mSunMaterial->getBestTechnique ()->getPass (0)->getTextureUnitState (0));
111 mSunMaterial->getBestTechnique ()->getPass (0)->getTextureUnitState (0)->setTextureName (textureName);
129 mNode->setScale (Ogre::Vector3::UNIT_SCALE * scale);
void setBodyColour(const Ogre::ColourValue &colour)
Sets the sun sphere colour.
virtual void notifyCameraChanged(Ogre::Camera *cam)
Handle camera change.
virtual void notifyCameraChanged(Ogre::Camera *cam)
Handle camera change.
SpriteSun(Ogre::SceneManager *sceneMgr, Ogre::SceneNode *caelumRootNode, const Ogre::String &sunTextureName="sun_disc.png", const Ogre::Degree &sunTextureAngularSize=Ogre::Degree(3.77f))
Constructor.
virtual void notifyCameraChanged(Ogre::Camera *cam)=0
Notify new camera conditions.
float mRadius
Base distance of the light.
Base class for sky lights (sun and moon).
Ogre::SceneNode * mNode
The sun scene node.
static const Ogre::String pointerToString(void *pointer)
Quickly format a pointer as a string; in hex.
static Ogre::MaterialPtr checkLoadMaterialClone(const Ogre::String &originalName, const Ogre::String &cloneName)
Creates a private clone of a material from a script.
virtual ~SpriteSun()
Destructor.
virtual void setBodyColour(const Ogre::ColourValue &colour)
Sets the colour to draw the light's body with.
void setBodyColour(const Ogre::ColourValue &colour)
Sets the sun sphere colour.
PrivateBillboardSetPtr mSunBillboardSet
The sun sprite / billboard.
PrivateMaterialPtr mSunMaterial
The sun material.
static const Ogre::String SUN_MATERIAL_NAME
Name of the sun material.
Ogre::ColourValue mBodyColour
Body sphere colour, as set by setBodyColour.
void setSunTextureAngularSize(const Ogre::Degree &sunTextureAngularSize)
Updates the sun size.
virtual ~SphereSun()
Destructor.
Ogre::Degree mSunTextureAngularSize
The sun sprite visible angle.
Ogre::Vector3 mDirection
The latest normalised sun direction.
static const Ogre::String SUN_MATERIAL_NAME
Name of the sun material.
void reset(const InnerPointerType &newInner=TraitsT::getNullValue())
Change the inner value.
void setSunTexture(const Ogre::String &textureName)
Updates the sun material.
SphereSun(Ogre::SceneManager *sceneMgr, Ogre::SceneNode *caelumRootNode, const Ogre::String &meshName="sphere.mesh")
Constructor.