ScummVM API documentation
tinyglactor.h
1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 #ifndef STARK_GFX_TINYGL_ACTOR_H
23 #define STARK_GFX_TINYGL_ACTOR_H
24 
25 #include "engines/stark/gfx/renderentry.h"
26 #include "engines/stark/visual/actor.h"
27 #include "engines/stark/gfx/tinygl.h"
28 
29 #include "graphics/tinygl/tinygl.h"
30 
31 #include "common/hashmap.h"
32 #include "common/hash-ptr.h"
33 
34 namespace Stark {
35 namespace Gfx {
36 
37 class TinyGLDriver;
38 
39 struct _ActorVertex {
40  float pos1x;
41  float pos1y;
42  float pos1z;
43  float pos2x;
44  float pos2y;
45  float pos2z;
46  uint32 bone1;
47  uint32 bone2;
48  float boneWeight;
49  float normalx;
50  float normaly;
51  float normalz;
52  float texS;
53  float texT;
54  float x;
55  float y;
56  float z;
57  float nx;
58  float ny;
59  float nz;
60  float sx;
61  float sy;
62  float sz;
63  float r;
64  float g;
65  float b;
66 };
68 
70 public:
72  virtual ~TinyGLActorRenderer();
73 
74  void render(const Math::Vector3d &position, float direction, const LightEntryArray &lights) override;
75 
76 protected:
78 
79  TinyGLDriver *_gfx;
80 
81  ActorVertex *_faceVBO;
82  FaceBufferMap _faceEBO;
83 
84  void clearVertices();
85  void uploadVertices();
86  ActorVertex *createModelVBO(const Model *model);
87  uint32 *createFaceEBO(const Face *face);
88  void setLightArrayUniform(const LightEntryArray &lights);
89 
90  Math::Vector3d getShadowLightDirection(const LightEntryArray &lights, const Math::Vector3d &actorPosition, Math::Matrix3 worldToModelRot);
91 
92  bool getPointLightContribution(LightEntry *light, const Math::Vector3d &actorPosition,
93  Math::Vector3d &direction, float weight = 1.0f);
94  bool getDirectionalLightContribution(LightEntry *light, Math::Vector3d &direction);
95  bool getSpotLightContribution(LightEntry *light, const Math::Vector3d &actorPosition, Math::Vector3d &direction);
96 };
97 
98 } // End of namespace Gfx
99 } // End of namespace Stark
100 
101 #endif // STARK_GFX_TINYGL_ACTOR_H
Definition: model.h:91
Definition: array.h:52
Definition: renderentry.h:44
Definition: tinyglactor.h:39
Definition: tinyglactor.h:69
Definition: actor.h:50
Definition: model.h:48
Definition: console.h:27
Definition: tinygl.h:37