36 , mMoonHaloIntensity(0.4f)
37 , mMoonHaloStrength(0.9f)
38 , mMoonMaterial(
Ogre::MaterialPtr())
54 mMoonMaterial =
static_cast<Ogre::MaterialPtr
>(Ogre::MaterialManager::getSingleton().getByName(
"SkyX_Moon"));
58 SkyXLOG(
"Error while creating SkyX::MoonManager, material not found");
98 Ogre::Real center = 0, radius = 0, radius_add = 0, interpolation = 0, halo_flip = 0;
100 Ogre::Vector3 halo1, halo2;
108 center = (1+phase)/2;
111 interpolation = center*4;
113 if (interpolation < 1.0f/3)
115 interpolation /= 1.0f/3;
116 halo1 = Ogre::Vector3(0.25, 0.5, (1-interpolation)*interpolation);
117 halo2 = Ogre::Vector3(0.25, 0.5, interpolation);
119 else if (interpolation < 2.0f/3)
121 interpolation -= 1.0f/3;
122 interpolation /= 1.0f/3;
123 halo1 = Ogre::Vector3(0.25, 0.5, 1-interpolation);
124 halo2 = Ogre::Vector3(0.0, 0.5, interpolation);
128 interpolation -= 2.0f/3;
129 interpolation /= 1.0f/3;
130 halo1 = Ogre::Vector3(0.0, 0.5, 1-interpolation);
131 halo2 = Ogre::Vector3(0.75, 0.0, interpolation);
134 radius_add = 0.1*center/(0.25001-center);
136 radius += radius_add;
137 center += radius_add;
145 interpolation = 1-center*4;
147 if (interpolation < 1.0f/3)
149 interpolation /= 1.0f/3;
150 halo1 = Ogre::Vector3(0.75, 0.0, 1-interpolation);
151 halo2 = Ogre::Vector3(0.5, 0.0, interpolation);
153 else if (interpolation < 2.0f/3)
155 interpolation -= 1.0f/3;
156 interpolation /= 1.0f/3;
157 halo1 = Ogre::Vector3(0.5, 0.0, 1-interpolation);
158 halo2 = Ogre::Vector3(0.25, 0.0, interpolation);
162 interpolation -= 2.0f/3;
163 interpolation /= 1.0f/3;
164 halo1 = Ogre::Vector3(0.25, 0.0, 1-interpolation);
165 halo2 = Ogre::Vector3(0.00, 0.0, interpolation);
168 radius_add = 0.1*center/(0.25001-center);
170 radius += radius_add;
171 center += radius_add;
188 interpolation = center*4;
190 if (interpolation < 1.0f/3)
192 interpolation /= 1.0f/3;
193 halo1 = Ogre::Vector3(0.00, 0.0, 1-interpolation);
194 halo2 = Ogre::Vector3(0.25, 0.0, interpolation);
196 else if (interpolation < 2.0f/3)
198 interpolation -= 1.0f/3;
199 interpolation /= 1.0f/3;
200 halo1 = Ogre::Vector3(0.25, 0.0, 1-interpolation);
201 halo2 = Ogre::Vector3(0.5, 0.0, interpolation);
205 interpolation -= 2.0f/3;
206 interpolation /= 1.0f/3;
207 halo1 = Ogre::Vector3(0.5, 0.0, 1-interpolation);
208 halo2 = Ogre::Vector3(0.75, 0.0, interpolation);
211 radius_add = 0.1*center/(0.25001-center);
213 radius += radius_add;
214 center += radius_add;
222 center = (1-phase)/2;
225 interpolation = 1-center*4;
227 if (interpolation < 1.0f/3)
229 interpolation /= 1.0f/3;
230 halo1 = Ogre::Vector3(0.75, 0.0, 1-interpolation);
231 halo2 = Ogre::Vector3(0.0, 0.5, interpolation);
233 else if (interpolation < 2.0f/3)
235 interpolation -= 1.0f/3;
236 interpolation /= 1.0f/3;
237 halo1 = Ogre::Vector3(0.0, 0.5, 1-interpolation);
238 halo2 = Ogre::Vector3(0.25, 0.5, interpolation);
242 interpolation -= 2.0f/3;
243 interpolation /= 1.0f/3;
244 halo1 = Ogre::Vector3(0.25, 0.5, 1-interpolation);
245 halo2 = Ogre::Vector3(0.25, 0.5, (1-interpolation)*interpolation);
248 radius_add = 0.1*center/(0.25001-center);
250 radius += radius_add;
251 center += radius_add;
257 mMoonMaterial->getTechnique(0)->getPass(0)->getFragmentProgramParameters()->setNamedConstant(
"uMoonPhase", Ogre::Vector3(radius, center + 0.5f,
mMoonHaloStrength));
262 mMoonMaterial->getTechnique(0)->getPass(0)->getFragmentProgramParameters()->setNamedConstant(
"uMoonHalo1", halo1);
263 mMoonMaterial->getTechnique(0)->getPass(0)->getFragmentProgramParameters()->setNamedConstant(
"uMoonHalo2", halo2);
264 mMoonMaterial->getTechnique(0)->getPass(0)->getFragmentProgramParameters()->setNamedConstant(
"uMoonHaloFlip", halo_flip);
280 Ogre::Math::Cos(Ogre::Math::ASin((size/2)/radius))*radius;
282 mMoonSceneNode->setPosition(c->getDerivedPosition() + moonRelativePos);
284 if (moonRelativePos.y < -size/2)
293 ->getVertexProgramParameters()->setNamedConstant(
"uSkydomeCenter", c->getDerivedPosition());
308 mMoonBillboard->setBounds(Ogre::AxisAlignedBox(-size/2, -size/2, -size/2,
309 size/2, size/2, size/2), 1);