ScummVM API documentation
slice_renderer.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 BLADERUNNER_SLICE_RENDERER_H
23 #define BLADERUNNER_SLICE_RENDERER_H
24 
25 #include "bladerunner/color.h"
26 #include "bladerunner/vector.h"
27 #include "bladerunner/view.h"
28 #include "bladerunner/matrix.h"
29 
30 #include "common/rect.h"
31 
32 #include "graphics/surface.h"
33 
34 namespace Common {
35 class MemoryReadStream;
36 }
37 
38 namespace BladeRunner {
39 
40 class ScreenEffects;
41 class BladeRunnerEngine;
42 class Lights;
43 class SetEffects;
44 
46  BladeRunnerEngine *_vm;
47 
48  int _animation;
49  int _frame;
50  Vector3 _position;
51  float _facing;
52  float _scale;
53 
54  ScreenEffects *_screenEffects;
55  View *_view;
56  Lights *_lights;
57  SetEffects *_setEffects;
58 
59  void *_sliceFramePtr;
60 
61  // Animation frame data
62  Vector2 _frameScale;
63  float _frameBottomZ;
64  Vector2 _framePos;
65  float _frameSliceHeight;
66  uint32 _framePaletteIndex;
67  uint32 _frameSliceCount;
68 
69  Matrix3x2 _mvpMatrix;
70  Vector3 _startScreenVector;
71  Vector3 _endScreenVector;
72  float _startSlice;
73  float _endSlice;
74  Common::Rect _screenRectangle;
75 
76  int _m11lookup[256];
77  int _m12lookup[256];
78  int _m13;
79  int _m21lookup[256];
80  int _m22lookup[256];
81  int _m23;
82 
83  bool _animationsShadowEnabled[997];
84 
85  Vector3 _shadowPolygonDefault[12];
86  Vector3 _shadowPolygonCurrent[12];
87 
88  Color _setEffectColor;
89  Color _lightsColor;
90 
91  Graphics::PixelFormat _pixelFormat;
92 
93 public:
95  ~SliceRenderer();
96 
97  void setScreenEffects(ScreenEffects *aesc);
98  void setView(View *view);
99  void setLights(Lights *lights);
100  void setSetEffects(SetEffects *setEffects);
101 
102  void setupFrameInWorld(int animationId, int animationFrame, Vector3 position, float facing, float scale = 1.0f);
103  void getScreenRectangle(Common::Rect *screenRectangle, int animationId, int animationFrame, Vector3 position, float facing, float scale);
104  void drawInWorld(int animationId, int animationFrame, Vector3 position, float facing, float scale, Graphics::Surface &surface, uint16 *zbuffer);
105  void drawOnScreen(int animationId, int animationFrame, int screenX, int screenY, float facing, float scale, Graphics::Surface &surface);
106 
107  void preload(int animationId);
108 
109  void disableShadows(int *animationsIdsList, int listSize);
110 
111 private:
112  void calculateBoundingRect();
113  Matrix3x2 calculateFacingRotationMatrix();
114  void loadFrame(int animation, int frame);
115 
116  void drawSlice(int slice, bool advanced, int y, Graphics::Surface &surface, uint16 *zbufferLine);
117  void drawShadowInWorld(int transparency, Graphics::Surface &surface, uint16 *zbuffer);
118  void drawShadowPolygon(int transparency, Graphics::Surface &surface, uint16 *zbuffer);
119 };
120 
122  Lights *_lights;
123  Color _cacheColor[20];
124  float _cacheCounter[20];
125  float _cacheStart[20];
126  int _cacheRecalculation;
127 
128 public:
129  Color _finalColor;
130 
131 public:
132  SliceRendererLights(Lights *lights);
133 
134  void calculateColorBase(Vector3 position1, Vector3 position2, float height);
135  void calculateColorSlice(Vector3 position);
136 };
137 
138 } // End of namespace BladeRunner
139 
140 #endif
Definition: slice_renderer.h:121
Definition: view.h:33
Definition: surface.h:66
Definition: pixelformat.h:138
Definition: actor.h:31
Definition: rect.h:144
Graphics::Surface * scale(const Graphics::Surface &srcImage, int xSize, int ySize)
Definition: color.h:29
Definition: set_effects.h:33
Definition: vector.h:29
Definition: algorithm.h:29
Definition: lights.h:33
Definition: matrix.h:29
Definition: vector.h:47
Definition: slice_renderer.h:45
Definition: bladerunner.h:113
Definition: screen_effects.h:39