22 #ifndef TWINE_RENDERER_RENDERER_H 23 #define TWINE_RENDERER_RENDERER_H 25 #include "common/endian.h" 26 #include "common/rect.h" 27 #include "common/scummsys.h" 28 #include "twine/parser/bodytypes.h" 29 #include "twine/twine.h" 31 #define POLYGONTYPE_FLAT 0 32 #define POLYGONTYPE_TELE 1 34 #define POLYGONTYPE_COPPER 2 35 #define POLYGONTYPE_BOPPER 3 36 #define POLYGONTYPE_MARBLE 4 37 #define POLYGONTYPE_TRANS 5 38 #define POLYGONTYPE_TRAME 6 39 #define POLYGONTYPE_GOURAUD 7 40 #define POLYGONTYPE_DITHER 8 41 #define POLYGONTYPE_OUTLINE 9 70 uint8 numVertices = 0;
83 out.row1.x = matrix.row1.x * vec.x;
84 out.row1.y = matrix.row1.y * vec.x;
85 out.row1.z = matrix.row1.z * vec.x;
87 out.row2.x = matrix.row2.x * vec.y;
88 out.row2.y = matrix.row2.y * vec.y;
89 out.row2.z = matrix.row2.z * vec.y;
91 out.row3.x = matrix.row3.x * vec.z;
92 out.row3.y = matrix.row3.y * vec.z;
93 out.row3.z = matrix.row3.z * vec.z;
101 struct RenderCommand {
103 int16 renderType = 0;
111 uint8 *dataPtr =
nullptr;
119 struct CmdRenderLine {
120 uint8 colorIndex = 0;
135 struct CmdRenderSphere {
137 uint8 polyRenderType = 0;
147 int16 normalTable[500]{0};
151 ModelData _modelData;
154 void animModel(ModelData *modelData,
const BodyData &bodyData, RenderCommand *renderCmds,
const IVec3 &angleVec,
const IVec3 &renderPos,
Common::Rect &modelRect);
155 bool computeSphere(int32 x, int32 y, int32 radius,
int &vtop,
int &vbottom);
156 bool renderObjectIso(
const BodyData &bodyData, RenderCommand **renderCmds, ModelData *modelData,
Common::Rect &modelRect);
157 IVec3 longInverseRot(int32 x, int32 y, int32 z);
158 inline IVec3 getCameraAnglePositions(
const IVec3 &vec) {
159 return longInverseRot(vec.x, vec.y, vec.z);
172 IVec3 _projectionCenter{320, 200, 0};
174 int32 _kFactor = 128;
175 int32 _lFactorX = 1024;
176 int32 _lFactorY = 840;
183 RenderCommand _renderCmds[1000];
188 uint8 _renderCoordinatesBuffer[10000]{0};
192 int16* _tabVerticG =
nullptr;
193 int16* _tabVerticD =
nullptr;
194 int16* _tabCoulG =
nullptr;
195 int16* _tabCoulD =
nullptr;
196 int16* _taby0 =
nullptr;
197 int16* _taby1 =
nullptr;
198 int16* _tabx0 =
nullptr;
199 int16* _tabx1 =
nullptr;
201 bool _isUsingIsoProjection =
false;
203 void svgaPolyCopper(int16 vtop, int16 vbottom, uint16 color)
const;
204 void svgaPolyBopper(int16 vtop, int16 vbottom, uint16 color)
const;
205 void svgaPolyTriste(int16 vtop, int16 vbottom, uint16 color)
const;
206 void svgaPolyTele(int16 vtop, int16 vbottom, uint16 color)
const;
207 void svgaPolyTrans(int16 vtop, int16 vbottom, uint16 color)
const;
208 void svgaPolyTrame(int16 vtop, int16 vbottom, uint16 color)
const;
209 void svgaPolyGouraud(int16 vtop, int16 vbottom)
const;
210 void svgaPolyDith(int16 vtop, int16 vbottom)
const;
211 void svgaPolyMarbre(int16 vtop, int16 vbottom, uint16 color)
const;
212 void svgaPolyTriche(int16 vtop, int16 vbottom, uint16 color)
const;
213 bool computePoly(int16 polyRenderType,
const ComputedVertex *vertices, int32 numVertices, int16 &vtop, int16 &vbottom);
215 const RenderCommand *depthSortRenderCommands(int32 numOfPrimitives);
216 uint8 *preparePolygons(
const Common::Array<BodyPolygon>& polygons, int32 &numOfPrimitives, RenderCommand **renderCmds, uint8 *renderBufferPtr, ModelData *modelData);
217 uint8 *prepareSpheres(
const Common::Array<BodySphere>& spheres, int32 &numOfPrimitives, RenderCommand **renderCmds, uint8 *renderBufferPtr, ModelData *modelData);
218 uint8 *prepareLines(
const Common::Array<BodyLine>& lines, int32 &numOfPrimitives, RenderCommand **renderCmds, uint8 *renderBufferPtr, ModelData *modelData);
222 void fillTextPolyNoClip(int32 top, int32 bottom,
const uint8 *holomapImage, uint32 holomapImageSize);
223 void fillHolomapTriangle(int16 *pDest, int32 x1, int32 y1, int32 x2, int32 y2);
226 int16 leftClip(int16 polyRenderType,
ComputedVertex** offTabPoly, int32 numVertices);
227 int16 rightClip(int16 polyRenderType,
ComputedVertex** offTabPoly, int32 numVertices);
228 int16 topClip(int16 polyRenderType,
ComputedVertex** offTabPoly, int32 numVertices);
229 int16 bottomClip(int16 polyRenderType,
ComputedVertex** offTabPoly, int32 numVertices);
230 int32 computePolyMinMax(int16 polyRenderType,
ComputedVertex **offTabPoly, int32 numVertices, int16 &vtop, int16 &vbottom);
235 void init(int32 w, int32 h);
237 void setCameraRotation(int32 x, int32 y, int32 z);
245 IVec2 rotate(int32 side, int32 forward, int32 angle)
const;
247 void setLightVector(int32 angleX, int32 angleY, int32 angleZ);
248 IVec3 longWorldRot(int32 x, int32 y, int32 z);
252 void fillVertices(int16 vtop, int16 vbottom, uint8 renderType, uint16 color);
256 return projectPoint(pos.x, pos.y, pos.z);
259 void projIso(
IVec3 &pos, int32 x, int32 y, int32 z);
261 IVec3 projectPoint(int32 cX, int32 cY, int32 cZ);
263 void setFollowCamera(int32 transPosX, int32 transPosY, int32 transPosZ, int32 cameraAlpha, int32 cameraBeta, int32 cameraGamma, int32 cameraZoom);
264 void setPosCamera(int32 x, int32 y, int32 z);
265 IVec3 setAngleCamera(int32 x, int32 y, int32 z);
266 IVec3 setInverseAngleCamera(int32 x, int32 y, int32 z);
268 inline IVec3 setBaseRotation(
const IVec3 &rot) {
269 return setAngleCamera(rot.x, rot.y, rot.z);
272 void setProjection(int32 x, int32 y, int32 depthOffset, int32 scaleX, int32 scaleY);
273 void setIsoProjection(int32 x, int32 y, int32
scale);
275 bool affObjetIso(int32 x, int32 y, int32 z, int32 angleX, int32 angleY, int32 angleZ,
const BodyData &bodyData,
Common::Rect &modelRect);
277 inline bool renderIsoModel(
const IVec3 &pos, int32 angleX, int32 angleY, int32 angleZ,
const BodyData &bodyData,
Common::Rect &modelRect) {
278 return affObjetIso(pos.x, pos.y, pos.z, angleX, angleY, angleZ, bodyData, modelRect);
284 void renderBehaviourModel(int32 boxLeft, int32 boxTop, int32 boxRight, int32 boxBottom, int32 y, int32 angle,
const BodyData &bodyData,
ActorMoveStruct &
move);
293 void draw3dObject(int32 x, int32 y,
const BodyData &bodyData, int32 angle, int32 cameraZoom);
295 void asmTexturedTriangleNoClip(
const ComputedVertex vertexCoordinates[3],
const ComputedVertex textureCoordinates[3],
const uint8 *holomapImage, uint32 holomapImageSize);
298 inline void Renderer::setCameraRotation(int32 x, int32 y, int32 z) {
Definition: renderer.h:75
Graphics::Surface * scale(const Graphics::Surface &srcImage, int xSize, int ySize)
Definition: renderer.h:97
Definition: renderer.h:68
constexpr remove_reference_t< T > && move(T &&t) noexcept
Definition: util.h:209
Definition: achievements_tables.h:27
Definition: renderer.h:60
Definition: bodytypes.h:54