Project

General

Profile

SO3Engine
SO3Moon.cpp
Go to the documentation of this file.
1/*
2-----------------------------------------------------------------------------
3This source file is part of OpenSpace3D
4For the latest info, see http://www.openspace3d.com
5
6Copyright (c) 2012 I-maginer
7
8This program is free software; you can redistribute it and/or modify it under
9the terms of the GNU Lesser General Public License as published by the Free Software
10Foundation; either version 2 of the License, or (at your option) any later
11version.
12
13This program is distributed in the hope that it will be useful, but WITHOUT
14ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
16
17You should have received a copy of the GNU Lesser General Public License along with
18this program; if not, write to the Free Software Foundation, Inc., 59 Temple
19Place - Suite 330, Boston, MA 02111-1307, USA, or go to
20http://www.gnu.org/copyleft/lesser.txt
21
22-----------------------------------------------------------------------------
23*/
24
32#include "SO3Renderer/SO3Root.h"
35
36namespace SO3
37{
38
39SMoon::SMoon(SEnvironment* parent, const std::string& moonName) : SSkyLight(parent, moonName, Ogre::ColourValue(0.155, 0.155, 0.155))
40{
41 moonPhase = 0.0f;
42 moonTextureName = "SkyX_Moon.png";
44}
45
46SMoon::SMoon() : SSkyLight(0, "", Ogre::ColourValue::Black)
47{
48 // Forbiden (private)
49}
50
52{
53}
54
55const Ogre::Real SMoon::GetPhase()
56{
57 return moonPhase;
58}
59
60const Ogre::Vector3 SMoon::ComputeDirectionImpl(const double& julianDay)
61{
62 // Compute the moon phase too
63 SAstronomy::GetMoonPhase(julianDay, moonPhase);
64
65 // Compute the moon light direcion
66 return GetMoonDirection(julianDay);
67}
68
69const Ogre::Vector3 SMoon::GetMoonDirection(const double& jday)
70{
71 Ogre::Degree azimuth, altitude;
72 {
73 ScopedHighPrecissionFloatSwitch precisionSwitch;
75 }
76 Ogre::Vector3 res = MakeDirection(azimuth, altitude);
77 return res;
78}
79
81{
82 return moonTextureName;
83}
84
85void SMoon::SetTextureName(const std::string& newTextureName)
86{
87 moonTextureName = newTextureName;
88}
89
90}
static void GetHorizontalMoonPosition(const double &jday, const double &longitude, const double &latitude, double &azimuth, double &altitude)
static void GetMoonPhase(const double &jday, float &moonPhase)
Ogre::Degree GetLatitude()
Ogre::Degree GetLongitude()
void SetTextureName(const std::string &newTextureName)
Definition SO3Moon.cpp:85
std::string GetTextureName()
Definition SO3Moon.cpp:80
virtual const Ogre::Vector3 ComputeDirectionImpl(const double &julianDay)
Definition SO3Moon.cpp:60
const Ogre::Real GetPhase()
Definition SO3Moon.cpp:55
void SetCastShadowEnable(const bool &enable)
SEnvironment * parentEnvironment
Definition SO3SkyLight.h:45
const Ogre::Vector3 MakeDirection(const Ogre::Degree &azimuth, const Ogre::Degree &altitude)