00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #include "SkyDomeComponent.h"
00019 #include "../../core/GameManager.h"
00020
00021
00022
00023
00024 SkyDomeComponent::SkyDomeComponent(Entity *parent, u32 hRes, u32 vRes, f32 texturePerc,
00025 f32 spherePerc, f32 radius)
00026 : SceneComponent(parent, true)
00027 {
00028 if(pParent != NULL)
00029 init(hRes, vRes, texturePerc, spherePerc, radius);
00030 }
00031
00032
00033 SkyDomeComponent::SkyDomeComponent(Entity *parent, const std::string &fileName, u32 hRes, u32 vRes,
00034 f32 texturePerc, f32 spherePerc, f32 radius)
00035 : SceneComponent(parent, true)
00036 {
00037 if(pParent != NULL)
00038 {
00039 init(hRes, vRes, texturePerc, spherePerc, radius);
00040 setMaterialTexture(0, fileName);
00041 }
00042 }
00043
00044
00045 SkyDomeComponent::SkyDomeComponent(Entity *parent, ITexture *texture, u32 hRes, u32 vRes,
00046 f32 texturePerc, f32 spherePerc, f32 radius)
00047 : SceneComponent(parent, true)
00048 {
00049 if(pParent != NULL)
00050 {
00051 init(hRes, vRes, texturePerc, spherePerc, radius);
00052 setMaterialTexture(0, texture);
00053 }
00054 }
00055
00056
00057 SkyDomeComponent::~SkyDomeComponent()
00058 {
00059 }
00060
00061
00062 void SkyDomeComponent::init(u32 hRes, u32 vRes, f32 texturePerc, f32 spherePerc, f32 radius)
00063 {
00064
00065 mSceneNode = GameManager::Instance()->getSceneManager()->addSkyDomeSceneNode(0, hRes,
00066 vRes, texturePerc, spherePerc, radius, 0, pParent->getID());
00067
00068
00069 mTriSelector = NULL;
00070 mMetaSelector = NULL;
00071 }
00072
00073
00074 bool SkyDomeComponent::parseXML(IXMLReader *file, Entity *entity)
00075 {
00076
00077 SkyDomeComponent *component = NULL;
00078
00079
00080 if(file->getNodeType() == io::EXN_ELEMENT)
00081 {
00082 if(stringw("SkyDomeComponent") == file->getNodeName())
00083 {
00084 u32 hRes = file->getAttributeValueAsInt(L"hRes");
00085 u32 vRes = file->getAttributeValueAsInt(L"vRes");
00086 f32 texturePerc = file->getAttributeValueAsFloat(L"texturePerc");
00087 f32 spherePerc = file->getAttributeValueAsFloat(L"spherePerc");
00088 f32 radius = file->getAttributeValueAsFloat(L"radius");
00089
00090
00091 component = new SkyDomeComponent(entity, hRes, vRes, texturePerc, spherePerc, radius);
00092 }
00093 }
00094
00095 if(component == NULL)
00096 return false;
00097
00098
00099 while(file->read())
00100 {
00101 switch(file->getNodeType())
00102 {
00103 case io::EXN_ELEMENT:
00104
00105
00106 SceneComponent::parseBaseXML(file, component);
00107
00108 break;
00109
00110 case io::EXN_ELEMENT_END:
00111
00112
00113 if(stringw("SkyDomeComponent") == file->getNodeName())
00114 return true;
00115
00116 break;
00117
00118 default:
00119
00120 break;
00121 }
00122 }
00123
00124
00125 return false;
00126 }
00127
00128