Divide Framework 0.1
A free and open-source 3D Framework under heavy development
Loading...
Searching...
No Matches
Water.h
Go to the documentation of this file.
1/*
2 Copyright (c) 2018 DIVIDE-Studio
3 Copyright (c) 2009 Ionut Cava
4
5 This file is part of DIVIDE Framework.
6
7 Permission is hereby granted, free of charge, to any person obtaining a copy
8 of this software
9 and associated documentation files (the "Software"), to deal in the Software
10 without restriction,
11 including without limitation the rights to use, copy, modify, merge, publish,
12 distribute, sublicense,
13 and/or sell copies of the Software, and to permit persons to whom the
14 Software is furnished to do so,
15 subject to the following conditions:
16
17 The above copyright notice and this permission notice shall be included in
18 all copies or substantial portions of the Software.
19
20 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21 IMPLIED,
22 INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
23 PARTICULAR PURPOSE AND NONINFRINGEMENT.
24 IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
25 DAMAGES OR OTHER LIABILITY,
26 WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
27 IN CONNECTION WITH THE SOFTWARE
28 OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29
30 */
31
32#pragma once
33#ifndef DVD_WATER_PLANE_H_
34#define DVD_WATER_PLANE_H_
35
37
39
40namespace Divide {
41
42class Texture;
43class StaticCamera;
44class ShaderProgram;
45
47{
48 public:
49 explicit WaterPlane( const ResourceDescriptor<WaterPlane>& descriptor );
50 ~WaterPlane() override;
51
52 static bool PointUnderwater(const SceneGraphNode* sgn, const vec3<F32>& point) noexcept;
53
54 Handle<Quad3D> getQuad() const noexcept { return _plane; }
55
56 void updatePlaneEquation(const SceneGraphNode* sgn,
57 Plane<F32>& plane,
58 bool reflection,
59 F32 offset) const;
60
61 // width, length, depth
62 const vec3<U16>& getDimensions() const noexcept;
63
64 void saveToXML(boost::property_tree::ptree& pt) const override;
65 void loadFromXML(const boost::property_tree::ptree& pt) override;
66
67 PROPERTY_RW(FColour3, refractionTint);
68 PROPERTY_RW(FColour3, waterDistanceFogColour);
69 PROPERTY_R(F32, reflPlaneOffset, 0.0f);
70 PROPERTY_R(F32, refrPlaneOffset, 0.0f);
71 PROPERTY_RW(F32, specularShininess, 200.f);
72 PROPERTY_RW(vec2<F32>, noiseTile);
73 PROPERTY_RW(vec2<F32>, noiseFactor);
74 PROPERTY_RW(vec2<F32>, fogStartEnd);
75 PROPERTY_RW(U16, blurKernelSize, 9u);
76 PROPERTY_RW(bool, blurReflections, true);
77
78 protected:
79 friend class ResourceCache;
80 template <typename T> friend struct ResourcePool;
81
82 bool postLoad() override;
83 bool unload() override;
84
85 protected:
86 void buildDrawCommands(SceneGraphNode* sgn, GenericDrawCommandContainer& cmdsOut) override;
87
88 void postLoad(SceneGraphNode* sgn) override;
89
90 void sceneUpdate(U64 deltaTimeUS, SceneGraphNode* sgn, SceneState& sceneState) override;
91 void prepareRender(SceneGraphNode* sgn,
92 RenderingComponent& rComp,
93 RenderPackage& pkg,
94 GFX::MemoryBarrierCommand& postDrawMemCmd,
95 RenderStagePass renderStagePass,
96 const CameraSnapshot& cameraSnapshot,
97 bool refreshData) override;
98 protected:
99 template <typename T>
100 friend class ImplResourceLoader;
101
102 bool load( PlatformContext& context ) override;
103 void onEditorChange(std::string_view field) noexcept;
104
105 private:
106 void updateReflection(RenderPassManager* passManager, RenderCbkParams& renderParams, GFX::CommandBuffer& bufferInOut, GFX::MemoryBarrierCommand& memCmdInOut) const;
107 void updateRefraction(RenderPassManager* passManager, RenderCbkParams& renderParams, GFX::CommandBuffer& bufferInOut, GFX::MemoryBarrierCommand& memCmdInOut) const;
108
109 private:
110 vec3<U16> _dimensions{1u};
111 Handle<Quad3D> _plane{ INVALID_HANDLE<Quad3D> };
112 Camera* _reflectionCam{ nullptr };
113};
114
116
117} // namespace Divide
118
119#endif //DVD_WATER_PLANE_H_
#define PROPERTY_RW(...)
Convenience method to add a class member with public read access and write access.
#define PROPERTY_R(...)
Convenience method to add a class member with public read access but protected write access.
#define TYPEDEF_SMART_POINTERS_FOR_TYPE(T)
#define DEFINE_NODE_TYPE(Name, Enum)
Definition: SceneNodeFwd.h:120
Handle console commands that start with a forward slash.
Definition: AIProcessor.cpp:7
bool load() override
bool unload() override
uint16_t U16
eastl::fixed_vector< GenericDrawCommand, 1, true > GenericDrawCommandContainer
uint64_t U64