1 /*
2 This file is part of Caelum.
3 See http://www.ogre3d.org/wiki/index.php/Caelum
4 
5 Copyright (c) 2008 Caelum team. See Contributors.txt for details.
6 
7 Caelum is free software: you can redistribute it and/or modify
8 it under the terms of the GNU Lesser General Public License as published
9 by the Free Software Foundation, either version 3 of the License, or
10 (at your option) any later version.
11 
12 Caelum is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 GNU Lesser General Public License for more details.
16 
17 You should have received a copy of the GNU Lesser General Public License
18 along with Caelum. If not, see <http://www.gnu.org/licenses/>.
19 */
20 
21 #ifndef CAELUM__MOON_H
22 #define CAELUM__MOON_H
23 
24 #include "CaelumPrerequisites.h"
25 #include "SkyLight.h"
26 #include "FastGpuParamRef.h"
27 #include "PrivatePtr.h"
28 
29 namespace Caelum
30 {
31     /** Class representing the moon.
32      *  Drawn as two billboards; one after the stars and one after the skydome.
33      *  Drawing it before the skydome will make it invisible in daylight; and that's bad.
34      */
35     class CAELUM_EXPORT Moon:
36             public BaseSkyLight
37     {
38 	public:
39 		/// Name of the moon material.
40 		static const Ogre::String MOON_MATERIAL_NAME;
41 
42         /// Name of the moon background material.
43 		static const Ogre::String MOON_BACKGROUND_MATERIAL_NAME;
44 
45 	private:
46         /// Material for MoonBB
47 		PrivateMaterialPtr mMoonMaterial;
48 
49 		/// The moon sprite.
50 		PrivateBillboardSetPtr mMoonBB;
51 
52         /// Material for mBackBB
53 		PrivateMaterialPtr mBackMaterial;
54 
55         /// The moon's background; used to block the stars.
56 		PrivateBillboardSetPtr mBackBB;
57 
58 		/// The moon sprite visible angle
59 		Ogre::Degree mAngularSize;
60 
61         struct Params {
62             void setup(Ogre::GpuProgramParametersSharedPtr fpParams);
63 
64             Ogre::GpuProgramParametersSharedPtr fpParams;
65             FastGpuParamRef phase;
66         } mParams;
67 
68 	public:
69 		/** Constructor.
70 		 */
71 		Moon (
72 				Ogre::SceneManager *sceneMgr,
73 				Ogre::SceneNode *caelumRootNode,
74 				const Ogre::String& moonTextureName = "moon_disc.dds",
75 				Ogre::Degree angularSize = Ogre::Degree(3.77f));
76 
77 		virtual ~Moon ();
78 
79 		/** Updates the moon material.
80 			@param textureName The new moon texture name.
81 		 */
82 		void setMoonTexture (const Ogre::String &textureName);
83 
84 		/** Updates the moon size.
85 			@param moon TextureAngularSize The new moon texture angular size.
86 		 */
87 		void setMoonTextureAngularSize(const Ogre::Degree& moonTextureAngularSize);
88 
89 		/** Sets the moon sphere colour.
90 			@param colour The colour used to draw the moon
91 		 */
92 		void setBodyColour (const Ogre::ColourValue &colour);
93 
94 		/// Set the moon's phase
95 		void setPhase (Ogre::Real phase);
96 
97 		/// Set Moon`s north pole direction
98 		void setMoonNorthPoleDirection(const Ogre::Vector3& moonNorthPoleDir);
99 
100     public:
101 		/// Handle camera change.
102 		virtual void notifyCameraChanged (Ogre::Camera *cam);
103 
104         virtual void setQueryFlags (uint flags);
105         virtual uint getQueryFlags () const;
106         virtual void setVisibilityFlags (uint flags);
107         virtual uint getVisibilityFlags () const;
108     };
109 }
110 
111 #endif // CAELUM__MOON_H
112