summaryrefslogtreecommitdiff
path: root/game/scenary/foliage.h
blob: 824a644429f12f16b2af7bcd8b8d79fbea2a251f (plain)
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
#pragma once

#include "assetFactory/asset.h"
#include "gfx/gl/instanceVertices.h"
#include "gfx/gl/shadowStenciller.h"
#include "gfx/models/texture.h"
#include "gfx/renderable.h"

class SceneShader;
class ShadowMapper;
class Location;

class Foliage : public Asset, public Renderable, public StdTypeDefs<Foliage> {
	Mesh::Ptr bodyMesh;
	Texture::Ptr texture;
	glVertexArray instanceVAO;
	glVertexArray instancePointVAO;

public:
	using LocationVertex = std::pair<glm::mat3, GlobalPosition3D>;
	mutable InstanceVertices<LocationVertex> instances;
	void render(const SceneShader &) const override;
	void shadows(const ShadowMapper &) const override;
	void updateStencil(const ShadowStenciller &) const override;
	glTexture shadowStencil = ShadowStenciller::createStencilTexture(256, 256);

protected:
	friend Persistence::SelectionPtrBase<std::shared_ptr<Foliage>>;
	bool persist(Persistence::PersistenceStore & store) override;
	void postLoad() override;
};