21 #ifndef _S3DSCENE_HPP_ 22 #define _S3DSCENE_HPP_ 24 #include "StelOBJ.hpp" 26 #include "StelOpenGLArray.hpp" 27 #include "SceneInfo.hpp" 28 #include "Heightmap.hpp" 32 Q_DECLARE_LOGGING_CATEGORY(s3dscene)
40 Material() : traits(), bAlphatest(
false), bBackface(
false), fAlphaThreshold(0.5),
41 vis_fadeIn(-DBL_MAX, -DBL_MAX),vis_fadeOut(DBL_MAX,DBL_MAX),vis_fadeValue(1.0)
47 :
StelOBJ::Material(stelMat), traits(), bAlphatest(
false), bBackface(
false), fAlphaThreshold(0.5),
48 vis_fadeIn(-DBL_MAX, -DBL_MAX),vis_fadeOut(DBL_MAX,DBL_MAX),vis_fadeValue(1.0)
50 if(additionalParams.contains(
"bAlphatest"))
51 parseBool(additionalParams.value(
"bAlphatest"), bAlphatest);
52 if(additionalParams.contains(
"bBackface"))
53 parseBool(additionalParams.value(
"bBackface"), bBackface);
54 if(additionalParams.contains(
"fAlphaThreshold"))
55 parseFloat(additionalParams.value(
"fAlphaThreshold"), fAlphaThreshold);
56 if(additionalParams.contains(
"vis_fadeIn"))
58 traits.hasTimeFade =
true;
59 parseVec2d(additionalParams.value(
"vis_fadeIn"), vis_fadeIn);
61 if(additionalParams.contains(
"vis_fadeOut"))
63 traits.hasTimeFade =
true;
64 parseVec2d(additionalParams.value(
"vis_fadeOut"), vis_fadeOut);
71 bool hasDiffuseTexture;
91 float fAlphaThreshold;
99 void loadTexturesAsync();
104 bool updateFadeInfo(
double currentJD);
107 typedef QVector<Material> MaterialList;
109 typedef StelOBJ::ObjectList ObjectList;
111 explicit S3DScene(
const SceneInfo& info);
113 void setModel(
const StelOBJ& model);
114 void setGround(
const StelOBJ& ground);
116 const SceneInfo& getSceneInfo()
const {
return info; }
118 MaterialList& getMaterialList() {
return materials; }
119 const Material& getMaterial(
int index)
const {
return materials.at(index); }
120 const ObjectList& getObjects()
const {
return objects; }
126 void moveViewer(
const Vec3d& moveView);
129 void setViewerPosition(
const Vec3d& pos);
131 void setViewerPositionOnHeightmap(
const Vec2d& pos);
138 inline double getEyeHeight()
const {
return eye_height; }
139 inline void setEyeHeight(
double height) { eye_height = height; recalcEyePos();}
140 inline const AABBox& getSceneAABB()
const {
return sceneAABB; }
141 float getGroundHeightAtViewer()
const;
142 inline void setViewDirection(
const Vec3d& viewDir) { viewDirection = viewDir; }
143 inline const Vec3d& getViewDirection()
const {
return viewDirection; }
145 Vec3d getGridPosition()
const;
146 void setGridPosition(
const Vec3d& gridPos);
153 inline void glBind() { glArray.bind(); }
154 inline void glRelease() { glArray.release(); }
155 inline void glDraw(
int offset,
int count)
const { glArray.draw(offset,count); }
158 inline void recalcEyePos() { eyePosition = position; eyePosition[2]+=eye_height; }
159 MaterialList materials;
166 QMatrix4x4 zRot2Grid;
187 #endif // _S3DSCENE_HPP_ Vec2d getViewer2DPosition() const
Returns the viewer foot position, without the height.
bool hasSpecularity
True when tex_height is a valid texture.
Encapsulates vertex data stored in the OpenGL server memory, which can be used for fast drawing comma...
Contains all the metadata necessary for a Scenery3d scene, and can be loaded from special ...
This represents a heightmap for viewer-ground collision.
Define the StelTextureSP type.
bool hasEmissiveTexture
True when tex_Kd is a valid texture.
bool isFullyTransparent
True when the material has time-dependent display.
bool hasTransparency
True when both Ks and Ns are non-zero.
bool hasTimeFade
True when the material exhibits "true" transparency, that is when the tex_Kd has an alpha channel or ...
Defines a material loaded from an .mtl file.
float vis_fadeValue
Updated by S3DRenderer when necessary, otherwise always 1.0.
bool hasHeightTexture
True when tex_bump is a valid texture.
Extension of StelOBJ::Material which provides Scenery3d specific stuff.
bool isFading
True when the material is (currently) completely invisible.
const Vec3d & getViewerPosition() const
Get current viewer foot position.
const Vec3d & getEyePosition() const
Get current eye position (= foot position + eye height)
Representation of a custom subset of a Wavefront .obj file, including only triangle data and material...
bool isGLReady() const
Returns true if the scene is ready for GL rendering (glLoad succeded)
QSharedPointer< StelTexture > StelTextureSP
Use shared pointer to simplify memory managment.
An axis-aligned bounding-box class.
bool hasBumpTexture
True when tex_Ke is a valid texture.