TRECISION: Kill 3Dinc and 3Dvar

This commit is contained in:
Strangerke 2021-05-11 00:21:41 +01:00 committed by SupSuper
parent 0106aa1d76
commit e1917b5524
16 changed files with 112 additions and 263 deletions

View file

@ -416,8 +416,8 @@ void Renderer3D::shadowScanEdge(int32 x1, int32 y1, int32 x2, int32 y2) {
--------------------------------------------------*/
void Renderer3D::init3DRoom(uint16 *destBuffer) {
_curPage = destBuffer;
_cx = (MAXX - 1) / 2;
_cy = (MAXY - 1) / 2;
_vm->_cx = (MAXX - 1) / 2;
_vm->_cy = (MAXY - 1) / 2;
for (int c = 0; c < ZBUFFERSIZE / 2; ++c)
_zBuffer[c] = 0x7FFF;
@ -498,7 +498,7 @@ void Renderer3D::drawCharacter(uint8 flag) {
int cfp = 0;
int cur = 0;
while (cur < actor->_curAction)
cfp += _defActionLen[cur++];
cfp += _vm->_defActionLen[cur++];
if (actor->_curAction == hWALKOUT)
cfp = 1;
@ -702,8 +702,8 @@ void Renderer3D::drawCharacter(uint8 flag) {
l1 = pa0 * e20 + pa1 * e21 + pa2 * e22;
l2 = pa0 * e30 + pa1 * e31 + pa2 * e32;
int _x2d = _cx + (int)((l0 * _curCamera->_fovX) / l2);
int _y2d = _cy + (int)((l1 * _curCamera->_fovY) / l2);
int _x2d = _vm->_cx + (int)((l0 * _curCamera->_fovX) / l2);
int _y2d = _vm->_cy + (int)((l1 * _curCamera->_fovY) / l2);
_vVertex[a]._x = _x2d;
_vVertex[a]._y = _y2d;
@ -729,7 +729,7 @@ void Renderer3D::drawCharacter(uint8 flag) {
actor->_lim[3] = (actor->_lim[3] >= _maxYClip - 1) ? _maxYClip : actor->_lim[3]++;
if (actor->_curAction == hLAST) // exit displacer
actor->_lim[2] = actor->_lim[3] - (((actor->_lim[3] - actor->_lim[2]) * actor->_curFrame) / _defActionLen[hLAST]);
actor->_lim[2] = actor->_lim[3] - (((actor->_lim[3] - actor->_lim[2]) * actor->_curFrame) / _vm->_defActionLen[hLAST]);
// set zbuffer vars
setZBufferRegion(actor->_lim[0], actor->_lim[2], actor->_lim[1] - actor->_lim[0]);
@ -866,6 +866,12 @@ PathFinding3D::PathFinding3D(TrecisionEngine *vm) : _vm(vm) {
_numPathNodes = 0;
_numSortPan = 0;
_x3d = 0.0f;
_y3d = 0.0f;
_z3d = 0.0f;
_curX = 0.0f;
_curZ = 0.0f;
}
PathFinding3D::~PathFinding3D() {
@ -1649,21 +1655,21 @@ void PathFinding3D::buildFramelist() {
int a = 0;
// compute offset
SVertex *v = _vm->_actor->_characterArea;
float firstframe = FRAMECENTER(v);
float firstframe = _vm->_actor->FRAMECENTER(v);
float startpos = 0.0;
// if he was already walking
int CurA, CurF, cfp;
if (_vm->_actor->_curAction == hWALK) {
// compute current frame
cfp = _defActionLen[hSTART] + 1 + _vm->_actor->_curFrame;
cfp = _vm->_defActionLen[hSTART] + 1 + _vm->_actor->_curFrame;
v += cfp * _vm->_actor->_vertexNum;
CurA = hWALK;
CurF = _vm->_actor->_curFrame;
// if it wasn't the last frame, take the next step
if (_vm->_actor->_curFrame < _defActionLen[hWALK] - 1) {
if (_vm->_actor->_curFrame < _vm->_defActionLen[hWALK] - 1) {
cfp++;
CurF++;
v += _vm->_actor->_vertexNum;
@ -1676,7 +1682,7 @@ void PathFinding3D::buildFramelist() {
//o CurF = _vm->_actor->_curAction - hSTOP1;
CurF = _vm->_actor->_curAction - hSTOP0;
cfp = _defActionLen[hSTART] + 1 + CurF;
cfp = _vm->_defActionLen[hSTART] + 1 + CurF;
v += cfp * _vm->_actor->_vertexNum;
} else {
// if he was standing, start working or turn
@ -1689,12 +1695,12 @@ void PathFinding3D::buildFramelist() {
// start from the first frame
v += _vm->_actor->_vertexNum;
}
oz = -FRAMECENTER(v) + firstframe;
oz = -_vm->_actor->FRAMECENTER(v) + firstframe;
// at this point, CurA / _curAction is either hSTART or hWALK
// until it arrives at the destination
while (((curlen = oz + FRAMECENTER(v) - firstframe) < len) || (!a)) {
while (((curlen = oz + _vm->_actor->FRAMECENTER(v) - firstframe) < len) || (!a)) {
_step[a]._pz = oz - firstframe; // where to render
_step[a]._dz = curlen; // where it is
_step[a]._curAction = CurA;
@ -1706,29 +1712,29 @@ void PathFinding3D::buildFramelist() {
CurF++;
cfp++;
if (CurF >= _defActionLen[CurA]) {
if (CurF >= _vm->_defActionLen[CurA]) {
if (CurA == hSTART) {
CurA = hWALK;
CurF = 0;
cfp = _defActionLen[hSTART] + 1;
cfp = _vm->_defActionLen[hSTART] + 1;
ox = 0.0;
} else if (CurA == hWALK) {
CurA = hWALK;
CurF = 0;
cfp = _defActionLen[hSTART] + 1;
cfp = _vm->_defActionLen[hSTART] + 1;
// end walk frame
ox = FRAMECENTER(v) - firstframe;
ox = _vm->_actor->FRAMECENTER(v) - firstframe;
v = &_vm->_actor->_characterArea[cfp * _vm->_actor->_vertexNum];
ox -= FRAMECENTER(v);
ox -= _vm->_actor->FRAMECENTER(v);
}
v = &_vm->_actor->_characterArea[cfp * _vm->_actor->_vertexNum];
// only if it doesn't end
if ((oz + ox + FRAMECENTER(v) - firstframe) < len)
if ((oz + ox + _vm->_actor->FRAMECENTER(v) - firstframe) < len)
oz += ox;
else
break;
@ -1753,12 +1759,12 @@ void PathFinding3D::buildFramelist() {
int b = 0;
cfp = 0;
while (b != CurA)
cfp += _defActionLen[b++];
cfp += _vm->_defActionLen[b++];
v = &_vm->_actor->_characterArea[cfp * _vm->_actor->_vertexNum];
for (b = 0; b < _defActionLen[CurA]; b++) {
curlen = oz + FRAMECENTER(v) - firstframe;
for (b = 0; b < _vm->_defActionLen[CurA]; b++) {
curlen = oz + _vm->_actor->FRAMECENTER(v) - firstframe;
_step[a]._pz = oz - firstframe; // where to render
_step[a]._dz = curlen; // where it is
_step[a]._curAction = CurA;
@ -2337,8 +2343,8 @@ void PathFinding3D::pointOut() {
Projects 2D point in a 3D world
--------------------------------------------------*/
void PathFinding3D::invPointProject(int x, int y) {
float px = (float)(x - _cx) / _vm->_actor->_camera->_fovX;
float py = (float)(y - _cy) / _vm->_actor->_camera->_fovY;
float px = (float)(x - _vm->_cx) / _vm->_actor->_camera->_fovX;
float py = (float)(y - _vm->_cy) / _vm->_actor->_camera->_fovY;
_x3d = (float)(px * _invP[0][0] + py * _invP[0][1] + _invP[0][2]);
_y3d = (float)(px * _invP[1][0] + py * _invP[1][1] + _invP[1][2]);

View file

@ -25,7 +25,6 @@
#include "trecision/defines.h"
#include "trecision/trecision.h"
#include "trecision/nl/3d/3dinc.h"
namespace Trecision {
struct SVVertex {
@ -33,6 +32,38 @@ struct SVVertex {
int32 _angle;
};
struct SSortPan {
int _num;
float _min;
};
struct SPathNode {
float _x, _z;
float _dist;
int16 _oldPanel;
int16 _curPanel;
};
struct SPan {
float _x1, _z1;
float _x2, _z2;
float _h;
int _flags;
char _near1;
char _near2;
char _col1;
char _col2;
};
struct SStep {
float _px, _pz;
float _dx, _dz;
float _theta;
int _curAction;
int _curFrame;
int16 _curPanel;
};
class Renderer3D {
private:
TrecisionEngine *_vm;
@ -102,6 +133,8 @@ private:
float _invP[3][3];
int _numPathNodes;
float _x3d, _y3d, _z3d;
float _curX, _curZ;
public:
PathFinding3D(TrecisionEngine *vm);

View file

@ -362,7 +362,7 @@ void Actor::actorDoAction(int action) {
int cur = 0;
while (cur < action)
cfp += _defActionLen[cur++];
cfp += _vm->_defActionLen[cur++];
v = &_characterArea[cfp * _vertexNum];
if (action == hWALKOUT)
@ -370,7 +370,7 @@ void Actor::actorDoAction(int action) {
else if (action == hLAST)
v = _characterArea;
len = _defActionLen[action];
len = _vm->_defActionLen[action];
uint16 stepIdx;
for (stepIdx = _vm->_pathFind->_curStep; stepIdx < len + _vm->_pathFind->_curStep; stepIdx++) {
@ -445,4 +445,8 @@ void Actor::read3D(Common::SeekableReadStream *ff) {
}
}
float Actor::FRAMECENTER(SVertex *v) {
return (-v[86]._z - v[164]._z) / 2.0;
}
} // End of namespace Trecision

View file

@ -36,7 +36,7 @@ public:
Actor(TrecisionEngine *vm);
~Actor();
SVertex *_characterArea; // TODO: Make it private
SVertex *_characterArea;
SVertex *_vertex;
SFace *_face;
@ -65,6 +65,8 @@ public:
void actorDoAction(int action);
void actorStop();
void read3D(Common::SeekableReadStream *ff);
float FRAMECENTER(SVertex *v);
}; // end of class
} // end of namespace

View file

@ -2409,4 +2409,13 @@ Management of "Use with"
#define MAXMESSAGE 128
#define PI 3.1415927f
#define PI2 6.2831853f
#define EPSILON 0.007f
#define MAXSTEP 1000
#define MAXPATHNODES 50
#define MAXPANELSINROOM 400
#endif

View file

@ -22,7 +22,6 @@
#include "common/config-manager.h"
#include "trecision/nl/3d/3dinc.h"
#include "trecision/nl/message.h"
#include "trecision/nl/proto.h"
#include "trecision/nl/struct.h"

View file

@ -20,7 +20,6 @@ MODULE_OBJS = \
video.o \
nl/regen.o \
nl/schedule.o \
nl/3d/3dvar.o \
nl/3d/3dwalk.o \
nl/ll/llmouse.o \
nl/ll/llscreen.o

View file

@ -1,137 +0,0 @@
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
#ifndef TRECISION_3DINC_H
#define TRECISION_3DINC_H
#include "common/str.h"
/*--------------------------------------------------
Useful global variables:
_panel s : where the panels are
_panelNum i : number of panels
_curPanel i : currently affected panel
_oldPanel i : starting panel
_curX f : X position of the affected panel
_curZ f : Z position of the affected panel
_cam s : camera
_proj f : camera projection matrix
_invP f : camera antiprojection matrix
_x3d,_y3d,_z3d f : float variables for output functions
_x2d, _y2d i : int variables for output functions
_cx, _cy i : center of the 2D screen
_actor s : actor structure
_step s : character frame structure
_pathNode s : path nodes
_numPathNodes i : number of path nodes
_curStep i : current character frame
_lastStep i : last character frame
_defActionLen u : character default action length
--------------------------------------------------*/
#define PI 3.1415927f
#define PI2 6.2831853f
#define EPSILON 0.007f
#define MAXPANELSINROOM 400
#define PANELIN 0x20000000
#define MAXPATHNODES 50
#define hSTAND 0
#define hSTART 1
#define hWALK 2
#define hEND 3
#define hSTOP0 4
#define hSTOP1 5
#define hSTOP2 6
#define hSTOP3 7
#define hSTOP4 8
#define hSTOP5 9
#define hSTOP6 10
#define hSTOP7 11
#define hSTOP8 12
#define hSTOP9 13
#define hWALKIN 14
#define hBOH 15
#define hUSEGG 16
#define hUSETT 17
#define hWALKOUT 18
#define hLAST 19 // Last Default Action
#define MAXSTEP 1000
#define FRAMECENTER(v) (-v[86]._z - v[164]._z) / 2.0
namespace Common {
class Serializer;
}
namespace Trecision {
struct SPan {
float _x1, _z1;
float _x2, _z2;
float _h;
int _flags;
char _near1;
char _near2;
char _col1;
char _col2;
};
struct SSortPan {
int _num;
float _min;
};
struct SPathNode {
float _x, _z;
float _dist;
int16 _oldPanel;
int16 _curPanel;
};
struct SStep {
float _px, _pz;
float _dx, _dz;
float _theta;
int _curAction;
int _curFrame;
int16 _curPanel;
};
class TrecisionEngine;
extern int _cx, _cy;
extern float _x3d, _y3d, _z3d;
extern float _curX, _curZ;
extern uint8 _defActionLen[];
} // End of namespace Trecision
#endif

View file

@ -1,83 +0,0 @@
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
#include "common/scummsys.h"
#include "trecision/nl/3d/3dinc.h"
/*------------------------------------------------
Useful Global Variables:
_panel s : Structure containing the panels
_panelNum i : Number of panels
_curPanel i : current Panel
_oldPanel i : starting Panel
_curX f : X position of the affected Panel
_curZ f : Z position of the affected Panel
_cam s : Camera
_proj f : camera projection matrix
_invP f : camera antiprojection matrix
_x3d, _y3d, _z3d f : Float variables for the ouput functions
_x2d, _y2d i : Int variables for the ouput functions
_cx, _cy i : Center of the 2D screen
_actor s : Actor structure
_step s : Character frame struture
_pathNode s : Path nodes
_numPathNodes i : Number of nodes
_curStep i : Character current frame
_lastStep i : character last frame
_defActionLen u : Default character action length
--------------------------------------------------*/
namespace Trecision {
int _cx, _cy;
float _x3d, _y3d, _z3d;
float _curX, _curZ;
uint8 _defActionLen[hLAST + 1] = {
/* STAND */ 1,
/* PARTE */ 1,
/* WALK */ 10,
/* END */ 1,
/* STOP0 */ 3,
/* STOP1 */ 4,
/* STOP2 */ 3,
/* STOP3 */ 2,
/* STOP4 */ 3,
/* STOP5 */ 4,
/* STOP6 */ 3,
/* STOP7 */ 3,
/* STOP8 */ 2,
/* STOP9 */ 3,
/* WALKI */ 12,
/* BOH */ 9,
/* UGG */ 41,
/* UTT */ 35,
/* WALKO */ 12,
/* LAST */ 15
};
} // End of namespace Trecision

View file

@ -34,7 +34,6 @@
#include "trecision/video.h"
#include "trecision/nl/proto.h"
#include "trecision/nl/struct.h"
#include "trecision/nl/3d/3dinc.h"
#include "trecision/nl/ll/llinc.h"
namespace Trecision {

View file

@ -33,7 +33,7 @@ namespace Trecision {
struct SDObj;
struct STexture;
struct SPan;
void PaintScreen(bool flag);
void PaintObjAnm(uint16 CurBox);

View file

@ -32,7 +32,6 @@
#include "trecision/text.h"
#include "trecision/trecision.h"
#include "trecision/video.h"
#include "trecision/nl/3d/3dinc.h"
#include "trecision/nl/proto.h"
#include "trecision/nl/struct.h"
#include "trecision/nl/ll/llinc.h"

View file

@ -215,8 +215,6 @@ void SoundManager::waitEndFading() {
}
void SoundManager::SoundPasso(int midx, int midz, int act, int frame, uint16 *list) {
extern uint8 _defActionLen[];
bool stepRight = false;
bool stepLeft = false;
@ -247,14 +245,14 @@ void SoundManager::SoundPasso(int midx, int midz, int act, int frame, uint16 *li
case hSTOP2:
case hSTOP3:
case hSTOP9:
if (frame >= _defActionLen[act] - 1)
if (frame >= _vm->_defActionLen[act] - 1)
stepLeft = true;
case hSTOP4:
case hSTOP5:
case hSTOP6:
case hSTOP7:
case hSTOP8:
if (frame >= _defActionLen[act] - 1)
if (frame >= _vm->_defActionLen[act] - 1)
stepRight = true;
break;
default:

View file

@ -35,13 +35,10 @@
#include "gui/saveload.h"
#include "trecision/trecision.h"
#include "anim.h"
#include "scheduler.h"
#include "trecision/anim.h"
#include "trecision/scheduler.h"
#include "trecision/actor.h"
#include "trecision/3d.h"
#include "trecision/nl/3d/3dinc.h"
#include "trecision/defines.h"
#include "trecision/nl/message.h"
#include "trecision/nl/proto.h"
@ -207,6 +204,7 @@ TrecisionEngine::~TrecisionEngine() {
delete[] _objPointers[i];
delete[] _maskPointers[i];
}
}
Common::Error TrecisionEngine::run() {

View file

@ -115,7 +115,7 @@ class TrecisionEngine : public Engine {
void loadSaveSlots(Common::StringArray &saveNames);
void openSys();
Graphics::Surface *convertScummVMThumbnail(Graphics::Surface *thumbnail);
STexture FTexture[MAXMAT];
SLight VLight[MAXLIGHT];
SCamera FCamera;
@ -339,7 +339,31 @@ public:
uint32 _characterSpeakTime;
int _actorPos;
int _cx, _cy;
int _forcedActorPos;
uint8 const _defActionLen[hLAST + 1] = {
/* STAND */ 1,
/* PARTE */ 1,
/* WALK */ 10,
/* END */ 1,
/* STOP0 */ 3,
/* STOP1 */ 4,
/* STOP2 */ 3,
/* STOP3 */ 2,
/* STOP4 */ 3,
/* STOP5 */ 4,
/* STOP6 */ 3,
/* STOP7 */ 3,
/* STOP8 */ 2,
/* STOP9 */ 3,
/* WALKI */ 12,
/* BOH */ 9,
/* UGG */ 41,
/* UTT */ 35,
/* WALKO */ 12,
/* LAST */ 15
};
};
extern TrecisionEngine *g_vm;

View file

@ -29,7 +29,6 @@
#include "trecision/graphics.h"
#include "trecision/logic.h"
#include "trecision/trecision.h"
#include "trecision/nl/3d/3dinc.h"
#include "trecision/nl/message.h"
#include "trecision/nl/proto.h"
#include "trecision/nl/struct.h"