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 73 uint8 numVertices = 0;
86 out.row1.x = matrix.row1.x * vec.x;
87 out.row1.y = matrix.row1.y * vec.x;
88 out.row1.z = matrix.row1.z * vec.x;
90 out.row2.x = matrix.row2.x * vec.y;
91 out.row2.y = matrix.row2.y * vec.y;
92 out.row2.z = matrix.row2.z * vec.y;
94 out.row3.x = matrix.row3.x * vec.z;
95 out.row3.y = matrix.row3.y * vec.z;
96 out.row3.z = matrix.row3.z * vec.z;
104 struct RenderCommand {
106 int16 renderType = 0;
114 uint8 *dataPtr =
nullptr;
122 struct CmdRenderLine {
123 uint8 colorIndex = 0;
138 struct CmdRenderSphere {
140 uint8 polyRenderType = 0;
150 int16 normalTable[500]{0};
154 ModelData _modelData;
157 void animModel(ModelData *modelData,
const BodyData &bodyData, RenderCommand *renderCmds,
const IVec3 &angleVec,
const IVec3 &renderPos,
Common::Rect &modelRect);
158 bool computeSphere(int32 x, int32 y, int32 radius,
int &vtop,
int &vbottom);
159 bool renderObjectIso(
const BodyData &bodyData, RenderCommand **renderCmds, ModelData *modelData,
Common::Rect &modelRect);
160 IVec3 longInverseRot(int32 x, int32 y, int32 z);
161 inline IVec3 getCameraAnglePositions(
const IVec3 &vec) {
162 return longInverseRot(vec.x, vec.y, vec.z);
175 IVec3 _projectionCenter{320, 200, 0};
177 int32 _kFactor = 128;
178 int32 _lFactorX = 1024;
179 int32 _lFactorY = 840;
186 RenderCommand _renderCmds[1000];
191 uint8 _renderCoordinatesBuffer[10000]{0};
195 int16* _tabVerticG =
nullptr;
196 int16* _tabVerticD =
nullptr;
197 int16* _tabCoulG =
nullptr;
198 int16* _tabCoulD =
nullptr;
199 int16* _taby0 =
nullptr;
200 int16* _taby1 =
nullptr;
201 int16* _tabx0 =
nullptr;
202 int16* _tabx1 =
nullptr;
204 bool _typeProj = TYPE_3D;
206 void svgaPolyCopper(int16 vtop, int16 vbottom, uint16 color)
const;
207 void svgaPolyBopper(int16 vtop, int16 vbottom, uint16 color)
const;
208 void svgaPolyTriste(int16 vtop, int16 vbottom, uint16 color)
const;
209 void svgaPolyTele(int16 vtop, int16 vbottom, uint16 color)
const;
210 void svgaPolyTrans(int16 vtop, int16 vbottom, uint16 color)
const;
211 void svgaPolyTrame(int16 vtop, int16 vbottom, uint16 color)
const;
212 void svgaPolyGouraud(int16 vtop, int16 vbottom)
const;
213 void svgaPolyDith(int16 vtop, int16 vbottom)
const;
214 void svgaPolyMarbre(int16 vtop, int16 vbottom, uint16 color)
const;
215 void svgaPolyTriche(int16 vtop, int16 vbottom, uint16 color)
const;
216 bool computePoly(int16 polyRenderType,
const ComputedVertex *vertices, int32 numVertices, int16 &vtop, int16 &vbottom);
218 const RenderCommand *depthSortRenderCommands(int32 numOfPrimitives);
219 uint8 *preparePolygons(
const Common::Array<BodyPolygon>& polygons, int32 &numOfPrimitives, RenderCommand **renderCmds, uint8 *renderBufferPtr, ModelData *modelData);
220 uint8 *prepareSpheres(
const Common::Array<BodySphere>& spheres, int32 &numOfPrimitives, RenderCommand **renderCmds, uint8 *renderBufferPtr, ModelData *modelData);
221 uint8 *prepareLines(
const Common::Array<BodyLine>& lines, int32 &numOfPrimitives, RenderCommand **renderCmds, uint8 *renderBufferPtr, ModelData *modelData);
225 void fillTextPolyNoClip(int32 top, int32 bottom,
const uint8 *holomapImage, uint32 holomapImageSize);
226 void fillHolomapTriangle(int16 *pDest, int32 x1, int32 y1, int32 x2, int32 y2);
230 int16 leftClip(int16 polyRenderType,
ComputedVertex** offTabPoly, int32 numVertices);
231 int16 rightClip(int16 polyRenderType,
ComputedVertex** offTabPoly, int32 numVertices);
232 int16 topClip(int16 polyRenderType,
ComputedVertex** offTabPoly, int32 numVertices);
233 int16 bottomClip(int16 polyRenderType,
ComputedVertex** offTabPoly, int32 numVertices);
234 int32 computePolyMinMax(int16 polyRenderType,
ComputedVertex **offTabPoly, int32 numVertices, int16 &vtop, int16 &vbottom);
239 void init(int32 w, int32 h);
241 void setCameraRotation(int32 x, int32 y, int32 z);
249 IVec2 rotate(int32 side, int32 forward, int32 angle)
const;
251 void setLightVector(int32 angleX, int32 angleY, int32 angleZ);
252 IVec3 longWorldRot(int32 x, int32 y, int32 z);
256 void fillVertices(int16 vtop, int16 vbottom, uint8 renderType, uint16 color);
260 return projectPoint(pos.x, pos.y, pos.z);
263 void projIso(
IVec3 &pos, int32 x, int32 y, int32 z);
265 IVec3 projectPoint(int32 cX, int32 cY, int32 cZ);
267 void setFollowCamera(int32 transPosX, int32 transPosY, int32 transPosZ, int32 cameraAlpha, int32 cameraBeta, int32 cameraGamma, int32 cameraZoom);
268 void setPosCamera(int32 x, int32 y, int32 z);
269 IVec3 setAngleCamera(int32 alpha, int32 beta, int32 gamma);
270 IVec3 setInverseAngleCamera(int32 alpha, int32 beta, int32 gamma);
272 inline IVec3 setBaseRotation(
const IVec3 &rot) {
273 return setAngleCamera(rot.x, rot.y, rot.z);
276 void setProjection(int32 x, int32 y, int32 depthOffset, int32 scaleX, int32 scaleY);
277 void setIsoProjection(int32 x, int32 y, int32
scale);
279 bool affObjetIso(int32 x, int32 y, int32 z, int32 angleX, int32 angleY, int32 angleZ,
const BodyData &bodyData,
Common::Rect &modelRect);
281 inline bool renderIsoModel(
const IVec3 &pos, int32 angleX, int32 angleY, int32 angleZ,
const BodyData &bodyData,
Common::Rect &modelRect) {
282 return affObjetIso(pos.x, pos.y, pos.z, angleX, angleY, angleZ, bodyData, modelRect);
288 void renderBehaviourModel(int32 boxLeft, int32 boxTop, int32 boxRight, int32 boxBottom, int32 y, int32 angle,
const BodyData &bodyData,
RealValue &
move);
297 void draw3dObject(int32 x, int32 y,
const BodyData &bodyData, int32 angle, int32 cameraZoom);
299 void asmTexturedTriangleNoClip(
const ComputedVertex vertexCoordinates[3],
const ComputedVertex textureCoordinates[3],
const uint8 *holomapImage, uint32 holomapImageSize);
302 inline void Renderer::setCameraRotation(int32 x, int32 y, int32 z) {
Definition: renderer.h:78
Graphics::Surface * scale(const Graphics::Surface &srcImage, int xSize, int ySize)
Definition: renderer.h:100
Definition: renderer.h:71
Definition: achievements_tables.h:27
Out move(In first, In last, Out dst)
Definition: algorithm.h:109
Definition: renderer.h:63
Definition: bodytypes.h:54