00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef __PLSCENE_SCENENODE_SKY_H__
00024 #define __PLSCENE_SCENENODE_SKY_H__
00025 #pragma once
00026
00027
00028
00029
00030
00031 #include <PLCore/Tools/Loadable.h>
00032 #include "PLScene/Scene/SceneNode.h"
00033
00034
00035
00036
00037
00038 namespace PLScene {
00039
00040
00041
00042
00043
00044 class SNSky;
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062 class SkyLayer : public PLCore::Object, public PLCore::Element<SkyLayer> {
00063
00064
00065
00066
00067
00068 friend class SNSky;
00069
00070
00071
00072
00073
00074 public:
00075
00076
00077
00078
00079 enum EType {
00080 Unknown = 0,
00081 Plane = 1,
00082 Cube = 2,
00083 Sphere = 3,
00084 Dome = 4,
00085 Cylinder = 5
00086 };
00087 pl_enum(EType)
00088 pl_enum_value(Unknown, "Unknown sky type")
00089 pl_enum_value(Plane, "Sky plane")
00090 pl_enum_value(Cube, "Sky cube")
00091 pl_enum_value(Sphere, "Sky sphere")
00092 pl_enum_value(Dome, "Sky dome")
00093 pl_enum_value(Cylinder, "Sky cylinder")
00094 pl_enum_end
00095
00096
00097
00098
00099
00100 pl_class(PLS_RTTI_EXPORT, SkyLayer, "PLScene", PLCore::Object, "Sky layer")
00101
00102 pl_attribute(Type, pl_enum_type(EType), Unknown, ReadWrite, GetSet, "Sky layer type", "")
00103 pl_attribute(Position, PLMath::Vector3, PLMath::Vector3(0.0f, 0.0f, 0.0f), ReadWrite, GetSet, "Sky layer position", "")
00104 pl_attribute(Rotation, PLMath::Vector3, PLMath::Vector3(0.0f, 0.0f, 0.0f), ReadWrite, GetSet, "Sky layer rotation", "")
00105 pl_attribute(Scale, PLMath::Vector3, PLMath::Vector3(1.0f, 1.0f, 1.0f), ReadWrite, GetSet, "Sky layer scale", "")
00106 pl_attribute(Name, PLCore::String, "", ReadWrite, GetSet, "Optional sky layer name. If not defined, a name is chosen automatically.", "")
00107 pl_class_end
00108
00109
00110
00111
00112
00113 public:
00114 PLS_API EType GetType() const;
00115 PLS_API void SetType(EType nValue);
00116 PLS_API const PLMath::Vector3 &GetPosition() const;
00117 PLS_API void SetPosition(const PLMath::Vector3 &vValue);
00118 PLS_API const PLMath::Vector3 &GetRotation() const;
00119 PLS_API void SetRotation(const PLMath::Vector3 &vValue);
00120 PLS_API const PLMath::Vector3 &GetScale() const;
00121 PLS_API void SetScale(const PLMath::Vector3 &vValue);
00122
00123
00124
00125
00126
00127 public:
00128
00129
00130
00131
00132 PLS_API virtual ~SkyLayer();
00133
00134
00135
00136
00137
00138
00139
00140
00141 PLS_API SNSky *GetSky() const;
00142
00143
00144
00145
00146
00147
00148
00149
00150 PLS_API PLMesh::MeshHandler *GetMeshHandler() const;
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164 PLS_API bool LoadMaterial(const PLCore::String &sFilename, PLCore::uint32 nMaterial = 0);
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177 PLS_API const PLMath::Matrix3x4 &GetTransformMatrix();
00178
00179
00180
00181
00182
00183 private:
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193 SkyLayer(const PLCore::String &sName, PLCore::ElementManager<SkyLayer> *pManager);
00194
00195
00196
00197
00198
00199 private:
00200 EType m_nType;
00201 PLMath::Vector3 m_vPos;
00202 PLMath::Vector3 m_vRot;
00203 PLMath::Vector3 m_vScale;
00204 PLMesh::MeshHandler *m_pMeshHandler;
00205 PLMath::Matrix3x4 m_mTrans;
00206 bool m_bRecalculateWorldMatrix;
00207
00208
00209 };
00210
00211
00212
00213
00214
00215 class SNSky : public SceneNode, public PLCore::ElementManager<SkyLayer>, public PLCore::Loadable {
00216
00217
00218
00219
00220
00221 pl_class(PLS_RTTI_EXPORT, SNSky, "PLScene", PLScene::SceneNode, "Sky scene node")
00222
00223
00224 pl_attribute(Flags, pl_flag_type(EFlags), NoCulling, ReadWrite, GetSet, "Flags", "")
00225 pl_attribute(MaxDrawDistance, float, -10000.0f, ReadWrite, ModifyAttr, "Maximum draw distance of the scene node to the camera, if 0 do always draw, if negative, do always draw this node before other", "")
00226 pl_attribute(AABBMin, PLMath::Vector3, PLMath::Vector3(-10000.0f, -10000.0f, -10000.0f), ReadWrite, GetSet, "Minimum position of the 'scene node space' axis aligned bounding box", "")
00227 pl_attribute(AABBMax, PLMath::Vector3, PLMath::Vector3( 10000.0f, 10000.0f, 10000.0f), ReadWrite, GetSet, "Maximum position of the 'scene node space' axis aligned bounding box", "")
00228
00229 pl_attribute(Filename, PLCore::String, "", ReadWrite, GetSet, "Sky filename", "Type='Sky'")
00230
00231 pl_constructor_0(DefaultConstructor, "Default constructor", "")
00232 pl_class_end
00233
00234
00235
00236
00237
00238 public:
00239 PLS_API void SetFilename(const PLCore::String &sValue);
00240
00241
00242
00243
00244
00245 public:
00246
00247
00248
00249
00250 PLS_API SNSky();
00251
00252
00253
00254
00255
00256 PLS_API virtual ~SNSky();
00257
00258
00259
00260
00261
00262 public:
00263 PLS_API virtual void DrawPre(PLRenderer::Renderer &cRenderer, const VisNode *pVisNode = nullptr) override;
00264
00265
00266
00267
00268
00269 private:
00270 virtual void InitFunction() override;
00271 virtual void OnActivate(bool bActivate) override;
00272
00273
00274
00275
00276
00277 private:
00278 virtual SkyLayer *CreateElement(const PLCore::String &sName) override;
00279
00280
00281
00282
00283
00284 public:
00285 PLS_API virtual bool Unload() override;
00286 PLS_API virtual PLCore::String GetLoadableTypeName() const override;
00287
00288
00289
00290
00291
00292 private:
00293 virtual bool CallLoadable(PLCore::File &cFile, PLCore::Loader &cLoader, const PLCore::String &sMethod, const PLCore::String &sParams) override;
00294
00295
00296
00297
00298
00299 private:
00300
00301
00302
00303
00304 void OnUpdate();
00305
00306
00307
00308
00309
00310 private:
00311 PLCore::EventHandler<> EventHandlerUpdate;
00312
00313
00314 };
00315
00316
00317
00318
00319
00320 }
00321
00322
00323 #endif // __PLSCENE_SCENENODE_SKY_H__