-
Notifications
You must be signed in to change notification settings - Fork 3
/
GrassComponent.h
58 lines (49 loc) · 1.34 KB
/
GrassComponent.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
#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; }
namespace tien { class Terrain; }
}
class GrassComponent : public vrlib::tien::components::Renderable
{
class GrassRenderContext : public Renderable::RenderContext, public vrlib::Singleton<GrassRenderContext>
{
public:
enum class RenderUniform
{
modelMatrix,
projectionMatrix,
viewMatrix,
modelViewProjectionMatrix,
normalMatrix,
s_texture,
time,
vColor,
fAlphaTest,
fAlphaMultiplier,
gSampler,
grassSize
};
glm::mat4 viewprojection;
vrlib::gl::Shader<RenderUniform>* renderShader;
virtual void init() override;
virtual void frameSetup(const glm::mat4 &projectionMatrix, const glm::mat4 &viewMatrix) override;
};
vrlib::gl::VBO<vrlib::gl::VertexP3> vbo;
vrlib::gl::VIO<unsigned int> vio;
vrlib::gl::VAO* vao;
vrlib::tien::Terrain &terrain;
public:
float time;
vrlib::Texture* grassTexture;
GrassComponent(vrlib::tien::Terrain &terrain);
virtual void update(float elapsedTime, vrlib::tien::Scene& scene) override;
virtual void drawDeferredPass() override;
virtual void drawForwardPass() override {};
virtual void drawShadowMap() override;
virtual nlohmann::json toJson(nlohmann::json &meshes) const override;
};