-
Notifications
You must be signed in to change notification settings - Fork 0
/
rock.h
52 lines (44 loc) · 1.22 KB
/
rock.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
#pragma once
#include "d3dwrap.h"
#include <functional>
#include <memory>
class Camera;
struct RockLod
{
VertexBuffer mVertexBuffer;
IndexBuffer mIndexBuffer;
int mIndexCount;
VertexBuffer mInstanceBuffer;
int mInstanceCount;
D3DXVECTOR4 mSphere;
RockLod() noexcept
: mVertexBuffer{ makeVertexBuffer() }
, mIndexBuffer{ makeIndexBuffer() }
, mIndexCount{ 0 }
, mInstanceBuffer{ makeVertexBuffer() }
, mInstanceCount{ 0 }
{
}
};
enum class RockRenderMode { NORMAL, REFLECT, REFRACT, UNDERWATER_REFLECT, CASTER };
class Rock
{
public:
Rock(std::shared_ptr<IDirect3DDevice9> pDevice, Camera* pCamera, IDirect3DTexture9* pShadowZ);
bool init(const std::function<float(float, float)>& height, const std::function<float(float, float)>& angle);
void update([[maybe_unused]] float tick = 1.0f);
void draw(RockRenderMode mode, const D3DXMATRIX& matLightViewProj) const;
private:
void createInstances();
std::shared_ptr<IDirect3DDevice9> mDevice;
Camera* mCamera;
IDirect3DTexture9* mShadowZ;
RockLod mLod[3];
Texture mTexture[2];
Effect mEffect;
VertexDeclaration mVertexDeclaration;
D3DXVECTOR3 mCamPos;
D3DXVECTOR3 mCamDir;
std::function<float(float, float)> mHeight;
std::function<float(float, float)> mAngle;
};