21 #include "CaelumPrecompiled.h" 22 #include "CaelumExceptions.h" 23 #include "InternalUtilities.h" 33 Ogre::SceneManager *sceneMgr,
34 Ogre::SceneNode *caelumRootNode,
35 const Ogre::String& moonTextureName,
36 Ogre::Degree angularSize
39 mAngularSize(angularSize)
47 assert (!mMoonMaterial.
isNull ());
48 assert (mMoonMaterial->getTechnique (0));
49 assert (mMoonMaterial->getTechnique (0)->getPass (0));
50 assert (mMoonMaterial->getTechnique (0)->getPass( 0)->hasFragmentProgram ());
51 mParams.setup(mMoonMaterial->getBestTechnique ()->getPass (0)->getFragmentProgramParameters ());
55 mMoonBB.
reset(sceneMgr->createBillboardSet(
"Caelum/Moon/MoonBB" + uniqueSuffix, 1));
56 mMoonBB->setMaterialName (mMoonMaterial->getName());
57 mMoonBB->setCastShadows (
false);
58 mMoonBB->setRenderQueueGroup (CAELUM_RENDER_QUEUE_MOON);
59 mMoonBB->setDefaultDimensions (1.0f, 1.0f);
60 mMoonBB->createBillboard (Ogre::Vector3::ZERO);
62 mBackBB.
reset(sceneMgr->createBillboardSet(
"Caelum/Moon/BackBB" + uniqueSuffix, 1));
63 mBackBB->setMaterialName (mBackMaterial->getName());
64 mBackBB->setCastShadows (
false);
65 mBackBB->setRenderQueueGroup (CAELUM_RENDER_QUEUE_MOON_BACKGROUND);
66 mBackBB->setDefaultDimensions (1.0f, 1.0f);
67 mBackBB->createBillboard (Ogre::Vector3::ZERO);
69 mNode->attachObject (mMoonBB.get());
70 mNode->attachObject (mBackBB.get());
80 mMoonBB->getBillboard(0)->setColour(colour);
86 assert(mMoonMaterial->getBestTechnique ());
87 assert(mMoonMaterial->getBestTechnique ()->getPass (0));
88 assert(mMoonMaterial->getBestTechnique ()->getPass (0)->getTextureUnitState (0));
89 mMoonMaterial->getBestTechnique ()->getPass (0)->getTextureUnitState (0)->setTextureName (textureName);
90 mBackMaterial->getBestTechnique ()->getPass (0)->getTextureUnitState (0)->setTextureName (textureName);
94 mAngularSize = moonTextureAngularSize;
102 Ogre::Real moonDistance =
mRadius -
mRadius * Ogre::Math::Tan(mAngularSize);
107 float scale = factor * moonDistance * Ogre::Math::Tan(mAngularSize);
108 mNode->setScale (Ogre::Vector3::UNIT_SCALE * scale);
111 void Moon::Params::setup(Ogre::GpuProgramParametersSharedPtr fpParams)
113 this->fpParams = fpParams;
114 this->phase.bind(fpParams,
"phase");
118 mParams.phase.set(mParams.fpParams, phase);
123 mMoonBB->setBillboardType(Ogre::BBT_ORIENTED_COMMON);
124 mMoonBB->setCommonDirection(moonNorthPoleDir);
127 void Moon::setQueryFlags (uint flags) {
128 mMoonBB->setQueryFlags (flags);
129 mBackBB->setQueryFlags (flags);
132 uint Moon::getQueryFlags ()
const {
133 assert (mMoonBB->getQueryFlags () == mBackBB->getQueryFlags ());
134 return mMoonBB->getQueryFlags ();
137 void Moon::setVisibilityFlags (uint flags) {
138 mMoonBB->setVisibilityFlags (flags);
139 mBackBB->setVisibilityFlags (flags);
142 uint Moon::getVisibilityFlags ()
const {
143 assert (mMoonBB->getVisibilityFlags () == mBackBB->getVisibilityFlags ());
144 return mMoonBB->getVisibilityFlags ();
static const Ogre::String MOON_BACKGROUND_MATERIAL_NAME
Name of the moon background material.
virtual void notifyCameraChanged(Ogre::Camera *cam)
Handle camera change.
virtual void notifyCameraChanged(Ogre::Camera *cam)=0
Notify new camera conditions.
void setMoonNorthPoleDirection(const Ogre::Vector3 &moonNorthPoleDir)
Set Moon`s north pole direction.
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.
void setBodyColour(const Ogre::ColourValue &colour)
Sets the moon sphere colour.
static Ogre::MaterialPtr checkLoadMaterialClone(const Ogre::String &originalName, const Ogre::String &cloneName)
Creates a private clone of a material from a script.
void setPhase(Ogre::Real phase)
Set the moon's phase.
virtual void setBodyColour(const Ogre::ColourValue &colour)
Sets the colour to draw the light's body with.
static const Ogre::String MOON_MATERIAL_NAME
Name of the moon material.
void setMoonTextureAngularSize(const Ogre::Degree &moonTextureAngularSize)
Updates the moon size.
bool isNull() const
Check if this is null.
Ogre::ColourValue mBodyColour
Body sphere colour, as set by setBodyColour.
void setMoonTexture(const Ogre::String &textureName)
Updates the moon material.
Ogre::Vector3 mDirection
The latest normalised sun direction.
void reset(const InnerPointerType &newInner=TraitsT::getNullValue())
Change the inner value.
Moon(Ogre::SceneManager *sceneMgr, Ogre::SceneNode *caelumRootNode, const Ogre::String &moonTextureName="moon_disc.dds", Ogre::Degree angularSize=Ogre::Degree(3.77f))
Constructor.