21 #include "CaelumPrecompiled.h" 22 #include "ImageStarfield.h" 23 #include "InternalUtilities.h" 29 const Ogre::String ImageStarfield::DEFAULT_TEXTURE_NAME =
"Starfield.jpg";
33 Ogre::SceneManager *sceneMgr,
34 Ogre::SceneNode *caelumRootNode,
35 const Ogre::String &textureName
38 mInclination = Ogre::Degree (0);
43 setTexture (textureName);
45 sceneMgr->getRenderQueue ()->getQueueGroup (CAELUM_RENDER_QUEUE_STARFIELD)->setShadowsEnabled (
false);
49 mEntity.reset(sceneMgr->createEntity (
"Caelum/StarfieldDome" + uniqueSuffix, STARFIELD_DOME_NAME));
50 mEntity->setMaterialName (mStarfieldMaterial->getName());
51 mEntity->setRenderQueueGroup (CAELUM_RENDER_QUEUE_STARFIELD);
52 mEntity->setCastShadows (
false);
54 mNode.reset (caelumRootNode->createChildSceneNode ());
55 mNode->attachObject (mEntity.get ());
68 mNode->setScale (Ogre::Vector3::UNIT_SCALE * radius);
76 Ogre::Quaternion orientation = Ogre::Quaternion::IDENTITY;
77 orientation = orientation * Ogre::Quaternion (Ogre::Radian (
mInclination + Ogre::Degree (90)), Ogre::Vector3::UNIT_X);
78 orientation = orientation * Ogre::Quaternion (Ogre::Radian (-time * 2 * Ogre::Math::PI), Ogre::Vector3::UNIT_Y);
80 mNode->setOrientation (orientation);
85 mStarfieldMaterial->getBestTechnique ()->getPass (0)->getTextureUnitState (0)->setTextureName (mapName);
PrivateSceneNodePtr mNode
Reference to the dome node.
virtual void notifyCameraChanged(Ogre::Camera *cam)=0
Notify new camera conditions.
void setTexture(const Ogre::String &mapName)
Updates the starfield material.
ImageStarfield(Ogre::SceneManager *sceneMgr, Ogre::SceneNode *caelumRootNode, const Ogre::String &textureName=DEFAULT_TEXTURE_NAME)
Constructor.
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.
static void generateSphericDome(const Ogre::String &name, int segments, DomeType domeType)
Creates a longitude-latitude sky dome.
void setInclination(Ogre::Degree inc)
Sets the starfield inclination.
virtual void setFarRadius(Ogre::Real radius)
Abstract method to set the radius for this elements Derived classes should override this and resize t...
static const Ogre::String STARFIELD_MATERIAL_NAME
Name of the starfield material.
virtual void notifyCameraChanged(Ogre::Camera *cam)
Handle camera change.
static const Ogre::String STARFIELD_DOME_NAME
Name of the spheric dome resource.
virtual ~ImageStarfield()
Destructor.
virtual void setFarRadius(Ogre::Real radius)
Handle far radius.
Ogre::Degree mInclination
Inclination of the starfield.
void update(const float time)
Updates the starfield position/orientation.
PrivateMaterialPtr mStarfieldMaterial
Reference to the (cloned) starfield material.