Path: blob/master/RSDKv5/RSDK/Graphics/Legacy/Scene3DLegacy.cpp
1163 views
#include "v3/Scene3DLegacyv3.cpp"1#include "v4/Scene3DLegacyv4.cpp"23int32 RSDK::Legacy::vertexCount = 0;4int32 RSDK::Legacy::faceCount = 0;56RSDK::Legacy::Matrix RSDK::Legacy::matFinal;7RSDK::Legacy::Matrix RSDK::Legacy::matWorld;8RSDK::Legacy::Matrix RSDK::Legacy::matView;9RSDK::Legacy::Matrix RSDK::Legacy::matTemp;1011int32 RSDK::Legacy::projectionX = 136;12int32 RSDK::Legacy::projectionY = 160;1314int32 RSDK::Legacy::faceLineStart[SCREEN_YSIZE];15int32 RSDK::Legacy::faceLineEnd[SCREEN_YSIZE];16int32 RSDK::Legacy::faceLineStartU[SCREEN_YSIZE];17int32 RSDK::Legacy::faceLineEndU[SCREEN_YSIZE];18int32 RSDK::Legacy::faceLineStartV[SCREEN_YSIZE];19int32 RSDK::Legacy::faceLineEndV[SCREEN_YSIZE];2021void RSDK::Legacy::ProcessScanEdge(Vertex *vertA, Vertex *vertB)22{23int32 bottom, top;2425if (vertA->y == vertB->y)26return;27if (vertA->y >= vertB->y) {28top = vertB->y;29bottom = vertA->y + 1;30}31else {32top = vertA->y;33bottom = vertB->y + 1;34}35if (top > SCREEN_YSIZE - 1 || bottom < 0)36return;37if (bottom > SCREEN_YSIZE)38bottom = SCREEN_YSIZE;39int32 fullX = vertA->x << 16;40int32 deltaX = ((vertB->x - vertA->x) << 16) / (vertB->y - vertA->y);41if (top < 0) {42fullX -= top * deltaX;43top = 0;44}45for (int32 i = top; i < bottom; ++i) {46int32 trueX = fullX >> 16;47if (trueX < faceLineStart[i])48faceLineStart[i] = trueX;49if (trueX > faceLineEnd[i])50faceLineEnd[i] = trueX;51fullX += deltaX;52}53}54void RSDK::Legacy::ProcessScanEdgeUV(Vertex *vertA, Vertex *vertB)55{56int32 bottom, top;5758if (vertA->y == vertB->y)59return;60if (vertA->y >= vertB->y) {61top = vertB->y;62bottom = vertA->y + 1;63}64else {65top = vertA->y;66bottom = vertB->y + 1;67}68if (top > SCREEN_YSIZE - 1 || bottom < 0)69return;70if (bottom > SCREEN_YSIZE)71bottom = SCREEN_YSIZE;7273int32 fullX = vertA->x << 16;74int32 fullU = vertA->u << 16;75int32 fullV = vertA->v << 16;76int32 deltaX = ((vertB->x - vertA->x) << 16) / (vertB->y - vertA->y);7778int32 deltaU = 0;79if (vertA->u != vertB->u)80deltaU = ((vertB->u - vertA->u) << 16) / (vertB->y - vertA->y);8182int32 deltaV = 0;83if (vertA->v != vertB->v) {84deltaV = ((vertB->v - vertA->v) << 16) / (vertB->y - vertA->y);85}8687if (top < 0) {88fullX -= top * deltaX;89fullU -= top * deltaU;90fullV -= top * deltaV;91top = 0;92}93for (int32 i = top; i < bottom; ++i) {94int32 trueX = fullX >> 16;95if (trueX < faceLineStart[i]) {96faceLineStart[i] = trueX;97faceLineStartU[i] = fullU;98faceLineStartV[i] = fullV;99}100if (trueX > faceLineEnd[i]) {101faceLineEnd[i] = trueX;102faceLineEndU[i] = fullU;103faceLineEndV[i] = fullV;104}105fullX += deltaX;106fullU += deltaU;107fullV += deltaV;108}109}110111