forked from Borf/NetworkEngine
-
Notifications
You must be signed in to change notification settings - Fork 0
/
WaterComponent.h
59 lines (49 loc) · 1.29 KB
/
WaterComponent.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#pragma once
#include <VrLib/gl/VBO.h>
#include <VrLib/gl/VIO.h>
#include <VrLib/tien/components/Renderable.h>
namespace vrlib
{
class Texture;
namespace gl { class VAO; class CubeMap;}
namespace tien { class Terrain; }
}
class WaterComponent : public vrlib::tien::components::Renderable
{
class WaterRenderContext : public Renderable::RenderContext, public vrlib::Singleton<WaterRenderContext>
{
public:
enum class RenderUniform
{
modelMatrix,
projectionMatrix,
normalMatrix,
eyePos,
time,
envMap,
numWaves,
amplitude,
wavelength,
speed,
direction
};
glm::mat4 view;
vrlib::gl::Shader<RenderUniform>* renderShader;
virtual void init() override;
virtual void frameSetup(const glm::mat4 &projectionMatrix, const glm::mat4 &viewMatrix) override;
};
vrlib::gl::CubeMap* cubemap;
vrlib::gl::VBO<vrlib::gl::VertexP3> vbo;
vrlib::gl::VIO<unsigned int> vio;
vrlib::gl::VAO* vao;
public:
float time;
bool setup = false;
vrlib::Texture* WaterTexture;
WaterComponent(const glm::vec2 &size, float resolution);
virtual void update(float elapsedTime, vrlib::tien::Scene& scene) override;
virtual void drawDeferredPass() override {};
virtual void drawForwardPass() override;
virtual void drawShadowMap() override;
json toJson(json &meshes) const;
};