OpenGothic
Open source reimplementation of Gothic I and II
Loading...
Searching...
No Matches
meshobjects.h
Go to the documentation of this file.
1#pragma once
2
3#include <Tempest/Texture2d>
4#include <Tempest/Matrix4x4>
5#include <Tempest/UniformBuffer>
6
9#include "visualobjects.h"
10
11class Pose;
12class ProtoMesh;
13class LightSource;
14
15class MeshObjects final {
16 private:
18
19 public:
22
23 class Mesh;
24 class Node;
25
26 class Node final {
27 public:
28 Node(Node&&)=default;
29
30 const Bounds& bounds() const;
31 const Material& material() const;
32 Tempest::Matrix4x4 position() const;
33 const StaticMesh* mesh() const;
34
35 std::pair<uint32_t,uint32_t> meshSlice() const;
36
37 private:
38 Node(const Item* it):it(it){}
39 const Item* it=nullptr;
40
41 friend class Mesh;
42 };
43
44 class Mesh final {
45 public:
46 Mesh()=default;
47 Mesh(MeshObjects& owner, const StaticMesh& mesh, int32_t version, bool staticDraw);
48 Mesh(MeshObjects& owner, const StaticMesh& mesh, int32_t texVar, int32_t teethTex, int32_t bodyColor);
49 Mesh(MeshObjects& owner, const ProtoMesh& mesh, int32_t texVar, int32_t teethTex, int32_t bodyColor, bool staticDraw);
50 Mesh(Mesh&& other);
51 ~Mesh();
52 Mesh& operator = (Mesh&& other);
53
54 void setObjMatrix(const Tempest::Matrix4x4& mt);
55 void setSkeleton (const Skeleton* sk);
56 void setPose (const Tempest::Matrix4x4& obj, const Pose& p);
57 void setAsGhost (bool g);
58 void setFatness (float f);
59 void setWind (zenkit::AnimationType m, float intensity);
60 void startMMAnim (std::string_view anim, float intensity, uint64_t timeUntil);
61
62 bool isEmpty() const { return subCount==0; }
63 size_t nodesCount() const { return subCount; }
64 Node node(size_t i) const { return Node(&sub[i]); }
65
66 Bounds bounds() const;
67 const ProtoMesh* protoMesh() const { return proto; }
68
69 const PfxEmitterMesh* toMeshEmitter() const;
70
71 private:
72 void implSetObjMatrix(const Tempest::Matrix4x4& mt, const Tempest::Matrix4x4* tr);
73
74 std::unique_ptr<Item[]> sub;
75 size_t subCount=0;
76
77 std::unique_ptr<InstanceStorage::Id> anim;
78
79 const ProtoMesh* proto =nullptr;
80 const Skeleton* skeleton=nullptr;
81 const AttachBinder* binder =nullptr;
82 };
83
84 private:
85 VisualObjects& parent;
86
87 Item implGet(const StaticMesh& mesh, const StaticMesh::SubMesh& smesh,
88 int32_t texVar, int32_t teethTex, int32_t bodyColor,
89 bool staticDraw);
90
91 const Tempest::Texture2d* solveTex(const Tempest::Texture2d* def, std::string_view format,
92 int32_t v,int32_t c);
93 };
Definition item.h:14
void setPose(const Tempest::Matrix4x4 &obj, const Pose &p)
Mesh & operator=(Mesh &&other)
void setAsGhost(bool g)
void setWind(zenkit::AnimationType m, float intensity)
const ProtoMesh * protoMesh() const
Definition meshobjects.h:67
void setFatness(float f)
bool isEmpty() const
Definition meshobjects.h:62
void startMMAnim(std::string_view anim, float intensity, uint64_t timeUntil)
void setObjMatrix(const Tempest::Matrix4x4 &mt)
void setSkeleton(const Skeleton *sk)
Node node(size_t i) const
Definition meshobjects.h:64
const PfxEmitterMesh * toMeshEmitter() const
Bounds bounds() const
size_t nodesCount() const
Definition meshobjects.h:63
Tempest::Matrix4x4 position() const
const Material & material() const
const Bounds & bounds() const
std::pair< uint32_t, uint32_t > meshSlice() const
Node(Node &&)=default
const StaticMesh * mesh() const
Definition pose.h:16