TRECISION: Turn Actor into a class, rewrite some parts of readActor()

This commit is contained in:
Strangerke 2021-03-31 23:27:49 +01:00 committed by SupSuper
parent f048dbb08d
commit c295c89a9f
18 changed files with 323 additions and 286 deletions

View File

@ -55,7 +55,7 @@ goto done
echo.
echo Creating project files with all engines enabled (stable and unstable)
echo.
create_project ..\.. --enable-all-engines --use-canonical-lib-names --msvc
create_project ..\.. --disable-all-engines --use-canonical-lib-names --msvc --enable-engine=trecision
goto done
:stable

View File

@ -3492,7 +3492,7 @@ bool LogicManager::operateInventory() {
break;
case iTELECOMANDO44:
if ((_actor._px < 5057.6) && (_vm->_obj[oPUPAZZO44]._mode & OBJMODE_OBJSTATUS) && (_vm->_curRoom == r43)) {
if ((g_vm->_actor->_px < 5057.6) && (_vm->_obj[oPUPAZZO44]._mode & OBJMODE_OBJSTATUS) && (_vm->_curRoom == r43)) {
doEvent(MC_SYSTEM, ME_CHANGEROOM, MP_SYSTEM, r46, 0, 7, _vm->_useWith[WITH]);
printSentence = false;
}

View File

@ -38,9 +38,9 @@ void actorDoAction(int whatAction) {
int len;
_curStep = 1;
float px = _actor._px + _actor._dx;
float pz = _actor._pz + _actor._dz;
float theta = _actor._theta;
float px = g_vm->_actor->_px + g_vm->_actor->_dx;
float pz = g_vm->_actor->_pz + g_vm->_actor->_dz;
float theta = g_vm->_actor->_theta;
int b = 0;
_step[b]._px = px;
@ -57,7 +57,7 @@ void actorDoAction(int whatAction) {
float ox = cos(t);
float oz = sin(t);
SVertex *v = (SVertex *)_characterArea;
SVertex *v = _characterArea;
float firstFrame = FRAMECENTER(v);
if (whatAction > hLAST) {
@ -68,12 +68,12 @@ void actorDoAction(int whatAction) {
int cur = 0;
while (cur < whatAction)
cfp += _defActionLen[cur++];
v = (SVertex *)_characterArea + cfp * _actor._vertexNum;
v = &_characterArea[cfp * g_vm->_actor->_vertexNum];
if (whatAction == hWALKOUT)
v = (SVertex *)_characterArea + _actor._vertexNum;
v = &_characterArea[g_vm->_actor->_vertexNum];
else if (whatAction == hLAST)
v = (SVertex *)_characterArea;
v = _characterArea;
len = _defActionLen[whatAction];
}
@ -92,12 +92,12 @@ void actorDoAction(int whatAction) {
_step[b]._theta = theta;
_step[b]._curPanel = _curPanel;
v += _actor._vertexNum;
v += g_vm->_actor->_vertexNum;
if (whatAction > hLAST)
v = (SVertex *)((uint8 *)v + 4);
else if (whatAction == hLAST)
v = (SVertex *)_characterArea;
v = _characterArea;
}
_step[b]._px = px;
@ -125,12 +125,12 @@ void actorDoAction(int whatAction) {
void actorStop() {
int b = 0;
_step[b]._px = _actor._px + _actor._dx;
_step[b]._pz = _actor._pz + _actor._dz;
_step[b]._px = g_vm->_actor->_px + g_vm->_actor->_dx;
_step[b]._pz = g_vm->_actor->_pz + g_vm->_actor->_dz;
_step[b]._dx = 0.0;
_step[b]._dz = 0.0;
_step[b]._theta = _actor._theta;
_step[b]._theta = g_vm->_actor->_theta;
_step[b]._curAction = hSTAND;
_step[b]._curFrame = 0;
_step[b]._curPanel = _curPanel;
@ -147,17 +147,17 @@ void actorStop() {
void setPosition(int num) {
extern SLight *_light;
_light = _actor._light;
_light = g_vm->_actor->_light;
for (int a = 0; a < _actor._lightNum; a++) {
for (int a = 0; a < g_vm->_actor->_lightNum; a++) {
// If it's off
if (_light->_inten == 0) {
// If it's the required position
if (_light->_position == num) {
_actor._px = _light->_x;
_actor._pz = _light->_z;
_actor._dx = 0.0;
_actor._dz = 0.0;
g_vm->_actor->_px = _light->_x;
g_vm->_actor->_pz = _light->_z;
g_vm->_actor->_dx = 0.0;
g_vm->_actor->_dz = 0.0;
float ox = _light->_dx;
float oz = _light->_dz;
@ -176,19 +176,19 @@ void setPosition(int num) {
if (theta < 0.0)
theta += 360.0;
_actor._theta = theta;
g_vm->_actor->_theta = theta;
_curStep = 0;
_lastStep = 0;
_curPanel = -1;
_oldPanel = -1;
_step[0]._px = _actor._px + _actor._dx;
_step[0]._pz = _actor._pz + _actor._dz;
_step[0]._px = g_vm->_actor->_px + g_vm->_actor->_dx;
_step[0]._pz = g_vm->_actor->_pz + g_vm->_actor->_dz;
_step[0]._dx = 0.0;
_step[0]._dz = 0.0;
_step[0]._theta = _actor._theta;
_step[0]._theta = g_vm->_actor->_theta;
_step[0]._curAction = hSTAND;
_step[0]._curFrame = 0;
_step[0]._curPanel = _curPanel;
@ -209,9 +209,9 @@ void goToPosition(int num) {
extern SLight *_light;
extern float _lookX, _lookZ;
_light = (SLight *)_actor._light;
_light = g_vm->_actor->_light;
for (int a = 0; a < _actor._lightNum; a++) {
for (int a = 0; a < g_vm->_actor->_lightNum; a++) {
// If it's off and if it's a position
if (_light->_inten == 0) {
// If it's the right position
@ -224,12 +224,12 @@ void goToPosition(int num) {
_curStep = 0;
_lastStep = 0;
_step[0]._px = _actor._px + _actor._dx;
_step[0]._pz = _actor._pz + _actor._dz;
_step[0]._px = g_vm->_actor->_px + g_vm->_actor->_dx;
_step[0]._pz = g_vm->_actor->_pz + g_vm->_actor->_dz;
_step[0]._dx = 0.0;
_step[0]._dz = 0.0;
_step[0]._theta = _actor._theta;
_step[0]._theta = g_vm->_actor->_theta;
_step[0]._curAction = hSTAND;
_step[0]._curFrame = 0;
_step[0]._curPanel = _curPanel;

View File

@ -116,7 +116,16 @@ struct SStep {
short _curPanel;
};
struct SActor {
class TrecisionEngine;
class SActor {
private:
TrecisionEngine *_vm;
public:
SActor(TrecisionEngine *vm);
~SActor();
SVertex *_vertex;
SFace *_face;
SLight *_light;
@ -142,7 +151,6 @@ extern SPan _panel[];
extern SSortPan _sortPan[];
extern SPathNode _pathNode[];
extern SStep _step[];
extern SActor _actor;
extern float _proj[3][3];
extern float _invP[3][3];

View File

@ -617,37 +617,37 @@ int8 clockWise(int16 x1, int16 y1, int16 x2, int16 y2, int16 x3, int16 y3) {
void drawCharacter(uint8 flag) {
// Compute pointer to frame
if (flag & CALCPOINTS) {
if (_actor._curAction <= hLAST) {
if (g_vm->_actor->_curAction <= hLAST) {
int cfp = 0;
int cur = 0;
while (cur < _actor._curAction)
while (cur < g_vm->_actor->_curAction)
cfp += _defActionLen[cur++];
if (_actor._curAction == hWALKOUT)
if (g_vm->_actor->_curAction == hWALKOUT)
cfp = 1;
cfp += _actor._curFrame;
cfp += g_vm->_actor->_curFrame;
if (_actor._curAction == hLAST)
if (g_vm->_actor->_curAction == hLAST)
cfp = 0;
_actor._vertex = (SVertex *)_characterArea + cfp * _actor._vertexNum;
g_vm->_actor->_vertex = &_characterArea[cfp * g_vm->_actor->_vertexNum];
} else {
_actor._vertex = (SVertex *)(_actionPointer[_actionPosition[actionInRoom(_actor._curAction)] + _actor._curFrame]);
g_vm->_actor->_vertex = (SVertex *)(_actionPointer[_actionPosition[actionInRoom(g_vm->_actor->_curAction)] + g_vm->_actor->_curFrame]);
if (_actor._vertex == NULL)
return ;
if (g_vm->_actor->_vertex == nullptr)
return;
}
}
_camera = _actor._camera;
_light = _actor._light;
_texture = _actor._texture;
_vertex = _actor._vertex;
_face = _actor._face;
_camera = g_vm->_actor->_camera;
_light = g_vm->_actor->_light;
_texture = g_vm->_actor->_texture;
_vertex = g_vm->_actor->_vertex;
_face = g_vm->_actor->_face;
int CurVertexNum = _actor._vertexNum;
int FaceNum = _actor._faceNum;
int CurVertexNum = g_vm->_actor->_vertexNum;
int FaceNum = g_vm->_actor->_faceNum;
if (flag & CALCPOINTS) {
_shadowLightNum = 0;
@ -671,14 +671,14 @@ void drawCharacter(uint8 flag) {
float l1 = 0.0;
float l2 = 0.0;
_actor._lim[0] = 32000;
_actor._lim[1] = -32000;
_actor._lim[2] = 32000;
_actor._lim[3] = -32000;
_actor._lim[4] = 32000;
_actor._lim[5] = -32000;
g_vm->_actor->_lim[0] = 32000;
g_vm->_actor->_lim[1] = -32000;
g_vm->_actor->_lim[2] = 32000;
g_vm->_actor->_lim[3] = -32000;
g_vm->_actor->_lim[4] = 32000;
g_vm->_actor->_lim[5] = -32000;
float t = (_actor._theta * PI2) / 360.0;
float t = (g_vm->_actor->_theta * PI2) / 360.0;
float cost = cos(t);
float sint = sin(t);
@ -692,14 +692,14 @@ void drawCharacter(uint8 flag) {
float tz = 0;
float pa0, pa1, pa2;
for (int b = 0; b < _actor._lightNum; b++) {
for (int b = 0; b < g_vm->_actor->_lightNum; b++) {
// if off lint == 0
// if it has a shadow lint & 0x80
int lint = _light->_inten & 0x7F;
if (lint) { // if it's not turned off
tx = _light->_x - _actor._px - _actor._dx; // computes direction vector
tz = _light->_z - _actor._pz - _actor._dz; // between light and actor
tx = _light->_x - g_vm->_actor->_px - g_vm->_actor->_dx; // computes direction vector
tz = _light->_z - g_vm->_actor->_pz - g_vm->_actor->_dz; // between light and actor
ty = _light->_y;
if (_light->_position) { // if it's attenuated
@ -757,7 +757,7 @@ void drawCharacter(uint8 flag) {
}
if ((_light->_inten & 0x80) && lint) { // if it's shadowed and still on
_vertex = _actor._vertex;
_vertex = g_vm->_actor->_vertex;
// casts shadow vertices
for (int a = 0; a < _shadowVertsNum; a++) {
@ -784,7 +784,7 @@ void drawCharacter(uint8 flag) {
l1 = (l1 * t);
l2 = (l2 * t);
_vertex = (SVertex *)(_actor._vertex);
_vertex = g_vm->_actor->_vertex;
for (int a = 0; a < CurVertexNum; a++) {
pa0 = _vertex->_nx;
pa1 = _vertex->_ny;
@ -805,12 +805,12 @@ void drawCharacter(uint8 flag) {
for (int a = 0; a < CurVertexNum; a++)
_vVertex[a]._angle = CLIP(_vVertex[a]._angle, 0, 180);
_vertex = (SVertex *)(_actor._vertex);
_vertex = g_vm->_actor->_vertex;
// Calculate the distance of the character from the room
tx = _camera->_ex - _actor._px;
ty = _camera->_ey - _actor._py;
tz = _camera->_ez - _actor._pz;
tx = _camera->_ex - g_vm->_actor->_px;
ty = _camera->_ey - g_vm->_actor->_py;
tz = _camera->_ez - g_vm->_actor->_pz;
dist = tx * e30 + ty * e31 + tz * e32;
@ -839,37 +839,37 @@ void drawCharacter(uint8 flag) {
_vVertex[a]._y = (short)_y2d;
_vVertex[a]._z = (short)((dist - l2) * 128.0);
_actor._lim[0] = MIN(_x2d, _actor._lim[0]);
_actor._lim[1] = MAX(_x2d, _actor._lim[1]);
_actor._lim[2] = MIN(_y2d, _actor._lim[2]);
_actor._lim[3] = MAX(_y2d, _actor._lim[3]);
g_vm->_actor->_lim[0] = MIN(_x2d, g_vm->_actor->_lim[0]);
g_vm->_actor->_lim[1] = MAX(_x2d, g_vm->_actor->_lim[1]);
g_vm->_actor->_lim[2] = MIN(_y2d, g_vm->_actor->_lim[2]);
g_vm->_actor->_lim[3] = MAX(_y2d, g_vm->_actor->_lim[3]);
_actor._lim[4] = MIN(_vVertex[a]._z, _actor._lim[4]);
_actor._lim[5] = MAX(_vVertex[a]._z, _actor._lim[5]);
g_vm->_actor->_lim[4] = MIN(_vVertex[a]._z, g_vm->_actor->_lim[4]);
g_vm->_actor->_lim[5] = MAX(_vVertex[a]._z, g_vm->_actor->_lim[5]);
_vertex++;
}
_actor._lim[4] = (short)dist;
_actor._lim[5] = (short)dist;
g_vm->_actor->_lim[4] = (short)dist;
g_vm->_actor->_lim[5] = (short)dist;
// vertex clipping
_actor._lim[0] = (_actor._lim[0] <= _minXClip + 1) ? _minXClip : _actor._lim[0]--;
_actor._lim[1] = (_actor._lim[1] >= _maxXClip - 1) ? _maxXClip : _actor._lim[1]++;
_actor._lim[2] = (_actor._lim[2] <= _minYClip + 1) ? _minYClip : _actor._lim[2]--;
_actor._lim[3] = (_actor._lim[3] >= _maxYClip - 1) ? _maxYClip : _actor._lim[3]++;
g_vm->_actor->_lim[0] = (g_vm->_actor->_lim[0] <= _minXClip + 1) ? _minXClip : g_vm->_actor->_lim[0]--;
g_vm->_actor->_lim[1] = (g_vm->_actor->_lim[1] >= _maxXClip - 1) ? _maxXClip : g_vm->_actor->_lim[1]++;
g_vm->_actor->_lim[2] = (g_vm->_actor->_lim[2] <= _minYClip + 1) ? _minYClip : g_vm->_actor->_lim[2]--;
g_vm->_actor->_lim[3] = (g_vm->_actor->_lim[3] >= _maxYClip - 1) ? _maxYClip : g_vm->_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]);
if (g_vm->_actor->_curAction == hLAST) // exit displacer
g_vm->_actor->_lim[2] = g_vm->_actor->_lim[3] - (((g_vm->_actor->_lim[3] - g_vm->_actor->_lim[2]) * g_vm->_actor->_curFrame) / _defActionLen[hLAST]);
// set zbuffer vars
setZBufferRegion(_actor._lim[0], _actor._lim[2], _actor._lim[1] - _actor._lim[0]);
setZBufferRegion(g_vm->_actor->_lim[0], g_vm->_actor->_lim[2], g_vm->_actor->_lim[1] - g_vm->_actor->_lim[0]);
}
if (flag & DRAWFACES) {
int px0, px1, px2, py0, py1, py2, p0, p1, p2;
if (_actor._curAction == hLAST)
setClipping(0, _actor._lim[2], MAXX, _actor._lim[3]);
if (g_vm->_actor->_curAction == hLAST)
setClipping(0, g_vm->_actor->_lim[2], MAXX, g_vm->_actor->_lim[3]);
for (int b = 0; b < _shadowLightNum; b++) {
for (int a = 0; a < _shadowFacesNum; a++) {
@ -914,7 +914,7 @@ void drawCharacter(uint8 flag) {
}
p0 = 0;
for (int b = _zBufStartY; b < _actor._lim[3]; b++) {
for (int b = _zBufStartY; b < g_vm->_actor->_lim[3]; b++) {
px0 = b * _screenMaxX + _zBufStartX;
for (int a = 1; a < _zBufWid; a++) {
py1 = (_zBuf[p0] >= 0x7FF0) * 0x8000 * _shadowSplit;
@ -966,7 +966,7 @@ void drawCharacter(uint8 flag) {
}
p0++;
}
if (_actor._curAction == hLAST)
if (g_vm->_actor->_curAction == hLAST)
setClipping(0, TOP, MAXX, AREA + TOP);
}
}

View File

@ -54,7 +54,6 @@ SSortPan _sortPan[32];
SPathNode _pathNode[MAXPATHNODES];
SStep _step[MAXSTEP];
SActor _actor;
float _proj[3][3];
float _invP[3][3];

View File

@ -43,11 +43,11 @@ int read3D(Common::String c) {
CloseSys("Can't open 3D file!\n");
// read rooms and lights
FastFileRead(ff, _actor._camera, sizeof(SCamera));
FastFileRead(ff, &_actor._lightNum, 4);
FastFileRead(ff, _actor._light, sizeof(SLight) * _actor._lightNum);
FastFileRead(ff, g_vm->_actor->_camera, sizeof(SCamera));
FastFileRead(ff, &g_vm->_actor->_lightNum, 4);
FastFileRead(ff, g_vm->_actor->_light, sizeof(SLight) * g_vm->_actor->_lightNum);
if (_actor._lightNum > 40)
if (g_vm->_actor->_lightNum > 40)
CloseSys("Too many lights");
// read panels
@ -56,15 +56,15 @@ int read3D(Common::String c) {
FastFileClose(ff);
// projection matrix
_proj[0][0] = _actor._camera->_e1[0];
_proj[0][1] = _actor._camera->_e1[1];
_proj[0][2] = _actor._camera->_e1[2];
_proj[1][0] = _actor._camera->_e2[0];
_proj[1][1] = _actor._camera->_e2[1];
_proj[1][2] = _actor._camera->_e2[2];
_proj[2][0] = _actor._camera->_e3[0];
_proj[2][1] = _actor._camera->_e3[1];
_proj[2][2] = _actor._camera->_e3[2];
_proj[0][0] = g_vm->_actor->_camera->_e1[0];
_proj[0][1] = g_vm->_actor->_camera->_e1[1];
_proj[0][2] = g_vm->_actor->_camera->_e1[2];
_proj[1][0] = g_vm->_actor->_camera->_e2[0];
_proj[1][1] = g_vm->_actor->_camera->_e2[1];
_proj[1][2] = g_vm->_actor->_camera->_e2[2];
_proj[2][0] = g_vm->_actor->_camera->_e3[0];
_proj[2][1] = g_vm->_actor->_camera->_e3[1];
_proj[2][2] = g_vm->_actor->_camera->_e3[2];
// Compute 3x3 inverse matrix for 2D points on 3D
float det = _proj[0][0] * _proj[1][1] * _proj[2][2] +
@ -112,8 +112,8 @@ int read3D(Common::String c) {
void findPath() {
int b;
_actor._px += _actor._dx;
_actor._pz += _actor._dz;
g_vm->_actor->_px += g_vm->_actor->_dx;
g_vm->_actor->_pz += g_vm->_actor->_dz;
int inters = 0;
_numPathNodes = 0;
@ -123,35 +123,35 @@ void findPath() {
// behind the starting panel
((pointInside(b = _oldPanel, (double)_curX, (double)_curZ)) ||
// behind the panel corner1
((distF(_panel[_oldPanel]._x1, _panel[_oldPanel]._z1, _actor._px, _actor._pz) < EPSILON) &&
((distF(_panel[_oldPanel]._x1, _panel[_oldPanel]._z1, g_vm->_actor->_px, g_vm->_actor->_pz) < EPSILON) &&
(pointInside(b = _panel[_oldPanel]._near1, (double)_curX, (double)_curZ) ||
pointInside(b = _panel[_oldPanel]._near2, (double)_curX, (double)_curZ))) ||
// behind the panel corner2
((distF(_panel[_oldPanel]._x2, _panel[_oldPanel]._z2, _actor._px, _actor._pz) < EPSILON) &&
((distF(_panel[_oldPanel]._x2, _panel[_oldPanel]._z2, g_vm->_actor->_px, g_vm->_actor->_pz) < EPSILON) &&
(pointInside(b = _panel[_oldPanel]._near2, (double)_curX, (double)_curZ) ||
pointInside(b = _panel[_oldPanel]._near1, (double)_curX, (double)_curZ))))) {
_curX = _actor._px;
_curZ = _actor._pz;
_actor._px -= _actor._dx;
_actor._pz -= _actor._dz;
_curX = g_vm->_actor->_px;
_curZ = g_vm->_actor->_pz;
g_vm->_actor->_px -= g_vm->_actor->_dx;
g_vm->_actor->_pz -= g_vm->_actor->_dz;
_curPanel = b;
_numPathNodes = 0;
lookAt(_lookX, _lookZ);
return ;
}
float dist = distF(_actor._px, _actor._pz, _curX, _curZ);
float dist = distF(g_vm->_actor->_px, g_vm->_actor->_pz, _curX, _curZ);
for (b = 0; b < _panelNum; b++) {
if (_panel[b]._flags & 0x80000000) { // it must be a wide panel
if (intersectLineLine(_panel[b]._x1, _panel[b]._z1,
_panel[b]._x2, _panel[b]._z2,
_actor._px, _actor._pz, _curX, _curZ)) {
g_vm->_actor->_px, g_vm->_actor->_pz, _curX, _curZ)) {
inters++;
_pathNode[_numPathNodes]._x = _x3d;
_pathNode[_numPathNodes]._z = _z3d;
_pathNode[_numPathNodes]._dist = distF(_actor._px, _actor._pz, _x3d, _z3d);
_pathNode[_numPathNodes]._dist = distF(g_vm->_actor->_px, g_vm->_actor->_pz, _x3d, _z3d);
_pathNode[_numPathNodes]._oldp = b;
_pathNode[_numPathNodes]._curp = b;
_numPathNodes++;
@ -167,10 +167,10 @@ void findPath() {
// If the click is inside the nearby panel
if ((_curPanel < 0) && (pointInside(b, (double)_curX, (double)_curZ))) {
_curX = _actor._px;
_curZ = _actor._pz;
_actor._px -= _actor._dx;
_actor._pz -= _actor._dz;
_curX = g_vm->_actor->_px;
_curZ = g_vm->_actor->_pz;
g_vm->_actor->_px -= g_vm->_actor->_dx;
g_vm->_actor->_pz -= g_vm->_actor->_dz;
_curPanel = b;
lookAt(_lookX, _lookZ);
@ -191,8 +191,8 @@ void findPath() {
// always adds start and finish node only in on a panel
inters++;
_pathNode[_numPathNodes]._x = _actor._px;
_pathNode[_numPathNodes]._z = _actor._pz;
_pathNode[_numPathNodes]._x = g_vm->_actor->_px;
_pathNode[_numPathNodes]._z = g_vm->_actor->_pz;
_pathNode[_numPathNodes]._dist = 0.0;
_pathNode[_numPathNodes]._oldp = _oldPanel;
_pathNode[_numPathNodes]._curp = _oldPanel;
@ -310,7 +310,7 @@ void findPath() {
_pathNode[_numPathNodes]._x = _curX;
_pathNode[_numPathNodes]._z = _curZ;
_pathNode[_numPathNodes]._dist = distF(_actor._px, _actor._pz, _curX, _curZ);
_pathNode[_numPathNodes]._dist = distF(g_vm->_actor->_px, g_vm->_actor->_pz, _curX, _curZ);
_pathNode[_numPathNodes]._oldp = _curPanel;
_pathNode[_numPathNodes]._curp = _curPanel;
_numPathNodes ++;
@ -318,8 +318,8 @@ void findPath() {
findShortPath();
displayPath();
} else { // otherwise if it's direct
_pathNode[_numPathNodes]._x = _actor._px;
_pathNode[_numPathNodes]._z = _actor._pz;
_pathNode[_numPathNodes]._x = g_vm->_actor->_px;
_pathNode[_numPathNodes]._z = g_vm->_actor->_pz;
_pathNode[_numPathNodes]._dist = 0.0;
_pathNode[_numPathNodes]._oldp = _oldPanel;
_pathNode[_numPathNodes]._curp = _oldPanel;
@ -327,7 +327,7 @@ void findPath() {
_pathNode[_numPathNodes]._x = _curX;
_pathNode[_numPathNodes]._z = _curZ;
_pathNode[_numPathNodes]._dist = distF(_actor._px, _actor._pz, _curX, _curZ);
_pathNode[_numPathNodes]._dist = distF(g_vm->_actor->_px, g_vm->_actor->_pz, _curX, _curZ);
_pathNode[_numPathNodes]._oldp = _curPanel;
_pathNode[_numPathNodes]._curp = _curPanel;
_numPathNodes++;
@ -335,8 +335,8 @@ void findPath() {
displayPath();
}
_actor._px -= _actor._dx;
_actor._pz -= _actor._dz;
g_vm->_actor->_px -= g_vm->_actor->_dx;
g_vm->_actor->_pz -= g_vm->_actor->_dz;
}
/*------------------------------------------------
Look for the shorter route avoiding obstacle
@ -350,8 +350,8 @@ void findShortPath() {
int count = 0;
// Add departure
TempPath[count]._x = _actor._px;
TempPath[count]._z = _actor._pz;
TempPath[count]._x = g_vm->_actor->_px;
TempPath[count]._z = g_vm->_actor->_pz;
TempPath[count]._dist = 0.0;
TempPath[count]._oldp = _oldPanel;
TempPath[count]._curp = _oldPanel;
@ -634,14 +634,9 @@ float evalPath(int a, float destX, float destZ, int nearP) {
Build list containing all the frames
--------------------------------------------------*/
void buildFramelist() {
int a, b, c, CurA, CurF, cfp;
float ox, oz, cx, cz;
float startpos, approx, theta = 0.0, oldtheta, firstframe;
SVertex *v;
// controlla che in nessun caso attraversi o sfiori un pannello stretto
for (a = 1; a < _numPathNodes; a++) {
for (c = 0; c < _panelNum; c++) {
for (int a = 1; a < _numPathNodes; a++) {
for (int c = 0; c < _panelNum; c++) {
// non deve intersecare pannello stretto mai
if (!(_panel[c]._flags & 0x80000000)) {
if (intersectLineLine(_panel[c]._x1, _panel[c]._z1,
@ -658,10 +653,10 @@ void buildFramelist() {
float len = 0.0;
float curlen = 0.0;
ox = _pathNode[0]._x;
oz = _pathNode[0]._z;
float ox = _pathNode[0]._x;
float oz = _pathNode[0]._z;
for (a = 1; a < _numPathNodes; a++) {
for (int a = 1; a < _numPathNodes; a++) {
len += dist3D(_pathNode[a]._x, 0.0, _pathNode[a]._z, ox, 0.0, oz);
ox = _pathNode[a]._x;
@ -673,37 +668,38 @@ void buildFramelist() {
return;
}
a = 0;
// calcola offset
v = (SVertex *)_characterArea;
firstframe = FRAMECENTER(v);
startpos = 0.0;
int a = 0;
// compute offset
SVertex *v = _characterArea;
float firstframe = FRAMECENTER(v);
float startpos = 0.0;
// se stava gia' camminando
if (_actor._curAction == hWALK) {
int CurA, CurF, cfp;
if (g_vm->_actor->_curAction == hWALK) {
// calcola frame attuale
cfp = _defActionLen[hSTART] + 1 + _actor._curFrame;
v += cfp * _actor._vertexNum;
cfp = _defActionLen[hSTART] + 1 + g_vm->_actor->_curFrame;
v += cfp * g_vm->_actor->_vertexNum;
CurA = hWALK;
CurF = _actor._curFrame;
CurF = g_vm->_actor->_curFrame;
// se non era all'ultimo frame fa il passo dodpo
if (_actor._curFrame < _defActionLen[hWALK] - 1) {
cfp ++;
CurF ++;
v += _actor._vertexNum;
if (g_vm->_actor->_curFrame < _defActionLen[hWALK] - 1) {
cfp++;
CurF++;
v += g_vm->_actor->_vertexNum;
}
}
// se era in stop riparte
else if ((_actor._curAction >= hSTOP0) && (_actor._curAction <= hSTOP9)) {
else if ((g_vm->_actor->_curAction >= hSTOP0) && (g_vm->_actor->_curAction <= hSTOP9)) {
// calcola frame attuale
CurA = hWALK;
//o CurF = _actor._curAction - hSTOP1;
CurF = _actor._curAction - hSTOP0;
//o CurF = g_vm->_actor->_curAction - hSTOP1;
CurF = g_vm->_actor->_curAction - hSTOP0;
cfp = _defActionLen[hSTART] + 1 + CurF;
v += cfp * _actor._vertexNum;
v += cfp * g_vm->_actor->_vertexNum;
}
// se era fermo, partiva o girava riparte da stand
else {
@ -714,19 +710,19 @@ void buildFramelist() {
CurF = 0;
// parte dal primo frame
v += _actor._vertexNum;
v += g_vm->_actor->_vertexNum;
}
oz = - FRAMECENTER(v) + firstframe;
// finche' non arrivo al punto destinazione
// until it arrives at the destination
while (((curlen = oz + FRAMECENTER(v) - firstframe) < len) || (!a)) {
_step[a]._pz = oz - firstframe; // dove renderizzare
_step[a]._dz = curlen; // dove si trova
_step[a]._pz = oz - firstframe; // where to render
_step[a]._dz = curlen; // where it is
_step[a]._curAction = CurA;
_step[a]._curFrame = CurF;
a ++;
v += _actor._vertexNum;
v += g_vm->_actor->_vertexNum;
CurF++;
cfp ++;
@ -743,19 +739,17 @@ void buildFramelist() {
CurF = 0;
cfp = _defActionLen[hSTART] + 1;
// frame fine camminata
// end walk frame
ox = FRAMECENTER(v) - firstframe;
v = (SVertex *)_characterArea;
v += cfp * _actor._vertexNum;
v = &_characterArea[cfp * g_vm->_actor->_vertexNum];
ox -= FRAMECENTER(v);
}
v = (SVertex *)_characterArea;
v += cfp * _actor._vertexNum;
v = &_characterArea[cfp * g_vm->_actor->_vertexNum];
// solo se non finisce
// only if it doesn't end
if ((oz + ox + FRAMECENTER(v) - firstframe) < len)
oz += ox;
else
@ -777,13 +771,12 @@ void buildFramelist() {
CurF = 0;
b = 0;
int b = 0;
cfp = 0;
while (b != CurA)
cfp += _defActionLen[b++];
v = (SVertex *)_characterArea;
v += cfp * _actor._vertexNum;
v = &_characterArea[cfp * g_vm->_actor->_vertexNum];
for (b = 0; b < _defActionLen[CurA]; b++) {
curlen = oz + FRAMECENTER(v) - firstframe;
@ -794,11 +787,12 @@ void buildFramelist() {
a ++;
CurF ++;
v += _actor._vertexNum;
v += g_vm->_actor->_vertexNum;
}
// di quanto ha sbagliato?
approx = (len - curlen - EPSILON) / (a - 2);
float approx = (len - curlen - EPSILON) / (a - 2);
float theta = 0.0;
// riaggiusta tutti i passi di modo che arrivi nel pto esatto cliccato
for (b = 1; b < a; b++) {
// controlla che non inverta passi
@ -811,7 +805,7 @@ void buildFramelist() {
_step[b]._dz += (approx * b);
}
}
cx = _step[b - 1]._dz;
float cx = _step[b - 1]._dz;
_lastStep = b; // ultimo step
_curStep = 0; // step attuale
@ -822,7 +816,7 @@ void buildFramelist() {
len = 0.0;
startpos = 0.0;
oldtheta = -1.0;
float oldtheta = -1.0;
for (a = 0; a < _numPathNodes - 1; a++) {
curlen = 0.0;
len += dist3D(_pathNode[a]._x, 0.0, _pathNode[a]._z,
@ -876,7 +870,7 @@ void buildFramelist() {
_curStep = 0; // step attuale
// angolo di partenza
oldtheta = _actor._theta;
oldtheta = g_vm->_actor->_theta;
// primo angolo camminata
theta = _step[0]._theta;
@ -904,7 +898,7 @@ void buildFramelist() {
oz = sin(theta) * curlen;
cx = _step[b]._px + _step[b]._dx;
cz = _step[b]._pz + _step[b]._dz;
float cz = _step[b]._pz + _step[b]._dz;
_step[b]._px += _step[b]._dx - ox;
_step[b]._pz += _step[b]._dz - oz;
@ -944,7 +938,7 @@ void buildFramelist() {
oz = sin(oldtheta) * curlen;
cx = _step[b - 1]._px + _step[b - 1]._dx;
cz = _step[b - 1]._pz + _step[b - 1]._dz;
float cz = _step[b - 1]._pz + _step[b - 1]._dz;
_step[b - 1]._px += _step[b - 1]._dx - ox;
_step[b - 1]._pz += _step[b - 1]._dz - oz;
@ -985,14 +979,14 @@ void buildFramelist() {
Prende prossimo frame camminata
--------------------------------------------------*/
int nextStep() {
_actor._px = _step[_curStep]._px;
_actor._pz = _step[_curStep]._pz;
_actor._dx = _step[_curStep]._dx;
_actor._dz = _step[_curStep]._dz;
_actor._theta = _step[_curStep]._theta;
_actor._curAction = _step[_curStep]._curAction;
_actor._curFrame = _step[_curStep]._curFrame;
_curPanel = _step[_curStep]._curPanel;
g_vm->_actor->_px = _step[_curStep]._px;
g_vm->_actor->_pz = _step[_curStep]._pz;
g_vm->_actor->_dx = _step[_curStep]._dx;
g_vm->_actor->_dz = _step[_curStep]._dz;
g_vm->_actor->_theta = _step[_curStep]._theta;
g_vm->_actor->_curAction = _step[_curStep]._curAction;
g_vm->_actor->_curFrame = _step[_curStep]._curFrame;
_curPanel = _step[_curStep]._curPanel;
// avanza solo se non e' ultimo frame
if (_curStep < _lastStep) {
_curStep ++;
@ -1230,8 +1224,8 @@ void putPix(int x, int y, uint16 c) {
void whereIs(int px, int py) {
float inters = 32000.0;
_actor._px += _actor._dx;
_actor._pz += _actor._dz;
g_vm->_actor->_px += g_vm->_actor->_dx;
g_vm->_actor->_pz += g_vm->_actor->_dz;
_oldPanel = _curPanel;
_curPanel = -2;
@ -1251,7 +1245,7 @@ void whereIs(int px, int py) {
// try all the panels and choose the closest one
for (int b = 0; b < _panelNum; b++) {
if (intersectLinePanel(&_panel[b], x, y, z)) {
float temp = dist3D(_actor._camera->_ex, _actor._camera->_ey, _actor._camera->_ez, _x3d, _y3d, _z3d);
float temp = dist3D(g_vm->_actor->_camera->_ex, g_vm->_actor->_camera->_ey, g_vm->_actor->_camera->_ez, _x3d, _y3d, _z3d);
if (temp < inters) {
inters = temp;
@ -1267,8 +1261,8 @@ void whereIs(int px, int py) {
pointOut();
_actor._px -= _actor._dx;
_actor._pz -= _actor._dz;
g_vm->_actor->_px -= g_vm->_actor->_dx;
g_vm->_actor->_pz -= g_vm->_actor->_dz;
}
/*------------------------------------------------
@ -1337,7 +1331,7 @@ void pointOut() {
}
// check intersection with camera
if (intersectLineLine(_panel[b]._x1, _panel[b]._z1, _panel[b]._x2, _panel[b]._z2, _actor._camera->_ex, _actor._camera->_ez, _curX, _curZ)) {
if (intersectLineLine(_panel[b]._x1, _panel[b]._z1, _panel[b]._x2, _panel[b]._z2, g_vm->_actor->_camera->_ex, g_vm->_actor->_camera->_ez, _curX, _curZ)) {
temp = distF(_curX, _curZ, _x3d, _z3d);
if (temp < inters) {
@ -1351,7 +1345,7 @@ void pointOut() {
// check intersection with character
if (intersectLineLine(_panel[b]._x1, _panel[b]._z1,
_panel[b]._x2, _panel[b]._z2,
_actor._px, _actor._pz, _curX, _curZ)) {
g_vm->_actor->_px, g_vm->_actor->_pz, _curX, _curZ)) {
temp = distF(_curX, _curZ, _x3d, _z3d);
if (temp < inters) {
@ -1498,32 +1492,32 @@ void viewPanel(SPan *p) {
Projects 3D point on 2D screen
--------------------------------------------------*/
void pointProject(float x, float y, float z) {
float pa0 = _actor._camera->_ex - x;
float pa1 = _actor._camera->_ey - y;
float pa2 = _actor._camera->_ez - z;
float pa0 = g_vm->_actor->_camera->_ex - x;
float pa1 = g_vm->_actor->_camera->_ey - y;
float pa2 = g_vm->_actor->_camera->_ez - z;
float p0 = pa0 * _proj[0][0] + pa1 * _proj[0][1] + pa2 * _proj[0][2];
float p1 = pa0 * _proj[1][0] + pa1 * _proj[1][1] + pa2 * _proj[1][2];
float p2 = pa0 * _proj[2][0] + pa1 * _proj[2][1] + pa2 * _proj[2][2];
_x2d = _cx + (int)((p0 * _actor._camera->_fovX) / p2);
_y2d = _cy + (int)((p1 * _actor._camera->_fovY) / p2);
_x2d = _cx + (int)((p0 * g_vm->_actor->_camera->_fovX) / p2);
_y2d = _cy + (int)((p1 * g_vm->_actor->_camera->_fovY) / p2);
}
/*------------------------------------------------
Projects 2D point in a 3D world
--------------------------------------------------*/
void invPointProject(int x, int y) {
float px = (float)(x - _cx) / _actor._camera->_fovX;
float py = (float)(y - _cy) / _actor._camera->_fovY;
float px = (float)(x - _cx) / g_vm->_actor->_camera->_fovX;
float py = (float)(y - _cy) / g_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]);
_z3d = (float)(px * _invP[2][0] + py * _invP[2][1] + _invP[2][2]);
_x3d += _actor._camera->_ex;
_y3d += _actor._camera->_ey;
_z3d += _actor._camera->_ez;
_x3d += g_vm->_actor->_camera->_ex;
_y3d += g_vm->_actor->_camera->_ey;
_z3d += g_vm->_actor->_camera->_ez;
}
/*------------------------------------------------
@ -1534,9 +1528,9 @@ int intersectLinePanel(SPan *p, float x, float y, float z) {
if (p->_flags & 0x80000000)
return false;
float x1 = _actor._camera->_ex;
float y1 = _actor._camera->_ey;
float z1 = _actor._camera->_ez;
float x1 = g_vm->_actor->_camera->_ex;
float y1 = g_vm->_actor->_camera->_ey;
float z1 = g_vm->_actor->_camera->_ez;
float dx = (x - x1);
float dy = (y - y1);
@ -1586,9 +1580,9 @@ int intersectLinePanel(SPan *p, float x, float y, float z) {
Intersects 3D line with the floor
--------------------------------------------------*/
int intersectLineFloor(float x, float y, float z) {
float x1 = _actor._camera->_ex;
float y1 = _actor._camera->_ey;
float z1 = _actor._camera->_ez;
float x1 = g_vm->_actor->_camera->_ex;
float y1 = g_vm->_actor->_camera->_ey;
float z1 = g_vm->_actor->_camera->_ez;
float dx = (x - x1);
float dy = (y - y1);
@ -1660,10 +1654,8 @@ void initSortPan() {
// Sort panel blocks by increasing distance from the camera
for (b = 0; b < _panelNum; b++) {
if (!(_panel[b]._flags & 0x80000000)) {
float dist1 = dist3D(_actor._camera->_ex, 0.0, _actor._camera->_ez,
_panel[b]._x1, 0.0, _panel[b]._z1);
float dist2 = dist3D(_actor._camera->_ex, 0.0, _actor._camera->_ez,
_panel[b]._x2, 0.0, _panel[b]._z2);
float dist1 = dist3D(g_vm->_actor->_camera->_ex, 0.0, g_vm->_actor->_camera->_ez, _panel[b]._x1, 0.0, _panel[b]._z1);
float dist2 = dist3D(g_vm->_actor->_camera->_ex, 0.0, g_vm->_actor->_camera->_ez, _panel[b]._x2, 0.0, _panel[b]._z2);
float min = MIN(dist1, dist2);
@ -1720,14 +1712,14 @@ void actorOrder() {
return ;
}
float ox = _actor._px + _actor._dx - _actor._camera->_ex;
float oz = _actor._pz + _actor._dz - _actor._camera->_ez;
float ox = g_vm->_actor->_px + g_vm->_actor->_dx - g_vm->_actor->_camera->_ex;
float oz = g_vm->_actor->_pz + g_vm->_actor->_dz - g_vm->_actor->_camera->_ez;
float dist = sqrt(ox * ox + oz * oz);
float lx = (-oz / dist) * LARGEVAL;
float lz = (ox / dist) * LARGEVAL;
ox = _actor._px + _actor._dx;
oz = _actor._pz + _actor._dz;
ox = g_vm->_actor->_px + g_vm->_actor->_dx;
oz = g_vm->_actor->_pz + g_vm->_actor->_dz;
// It must be copied in front of the nearest box
_actorPos = _sortPan[1]._num;
@ -1737,9 +1729,9 @@ void actorOrder() {
// If it's not wide and belongs to this level
if (!(_panel[a]._flags & 0x80000000) && (_panel[a]._flags & (1 << (_sortPan[b]._num - 1)))) {
// If it intersects the center of the character camera
if (intersectLineLine(_panel[a]._x1, _panel[a]._z1, _panel[a]._x2, _panel[a]._z2, _actor._camera->_ex, _actor._camera->_ez, ox, oz)
|| intersectLineLine(_panel[a]._x1, _panel[a]._z1, _panel[a]._x2, _panel[a]._z2, _actor._camera->_ex, _actor._camera->_ez, ox + lx, oz + lz)
|| intersectLineLine(_panel[a]._x1, _panel[a]._z1, _panel[a]._x2, _panel[a]._z2, _actor._camera->_ex, _actor._camera->_ez, ox - lx, oz - lz)) {
if (intersectLineLine(_panel[a]._x1, _panel[a]._z1, _panel[a]._x2, _panel[a]._z2, g_vm->_actor->_camera->_ex, g_vm->_actor->_camera->_ez, ox, oz)
|| intersectLineLine(_panel[a]._x1, _panel[a]._z1, _panel[a]._x2, _panel[a]._z2, g_vm->_actor->_camera->_ex, g_vm->_actor->_camera->_ez, ox + lx, oz + lz)
|| intersectLineLine(_panel[a]._x1, _panel[a]._z1, _panel[a]._x2, _panel[a]._z2, g_vm->_actor->_camera->_ex, g_vm->_actor->_camera->_ez, ox - lx, oz - lz)) {
// If it intersects it must be copied after the next box
_actorPos = _sortPan[b + 1]._num;
}

View File

@ -222,9 +222,9 @@ void doMouse() {
Flagskiptalk = Flagskipenable;
break;
}
if (_actor._curAction > hWALKIN)
if (g_vm->_actor->_curAction > hWALKIN)
break;
if (FlagWalkNoInterrupt && (_actor._curAction != hSTAND))
if (FlagWalkNoInterrupt && (g_vm->_actor->_curAction != hSTAND))
break;
if ((FlagDialogActive) && (FlagDialogMenuActive)) {
@ -831,7 +831,8 @@ void doIdle() {
if (FlagDialogActive) {
if (g_vm->_animMgr->_fullMotionEnd != g_vm->_animMgr->_curAnimFrame[1])
g_vm->_animMgr->_fullMotionEnd = g_vm->_animMgr->_curAnimFrame[1] + 1;
} else if (!FlagSomeOneSpeak && !g_vm->_flagscriptactive && !FlagDialogActive && !FlagDialogMenuActive && (_actor._curAction < hWALKIN) && !FlagUseWithStarted && g_vm->_animMgr->_playingAnims[1] == 0 && FlagShowCharacter) {
} else if (!FlagSomeOneSpeak && !g_vm->_flagscriptactive && !FlagDialogActive && !FlagDialogMenuActive
&& (g_vm->_actor->_curAction < hWALKIN) && !FlagUseWithStarted && g_vm->_animMgr->_playingAnims[1] == 0 && FlagShowCharacter) {
actorStop();
nextStep();
Mouse(MCMD_ON);
@ -846,7 +847,8 @@ void doIdle() {
// Sys
case 0x3B:
if (!FlagSomeOneSpeak && !g_vm->_flagscriptactive && !FlagDialogActive && !FlagDialogMenuActive && (_actor._curAction < hWALKIN) && !FlagUseWithStarted && g_vm->_animMgr->_playingAnims[1] == 0 && FlagShowCharacter) {
if (!FlagSomeOneSpeak && !g_vm->_flagscriptactive && !FlagDialogActive && !FlagDialogMenuActive
&& (g_vm->_actor->_curAction < hWALKIN) && !FlagUseWithStarted && g_vm->_animMgr->_playingAnims[1] == 0 && FlagShowCharacter) {
actorStop();
nextStep();
Mouse(MCMD_ON);
@ -861,7 +863,8 @@ void doIdle() {
// Save
case 0x3C:
if (!FlagSomeOneSpeak && !g_vm->_flagscriptactive && !FlagDialogActive && !FlagDialogMenuActive && (_actor._curAction < hWALKIN) && !FlagUseWithStarted && g_vm->_animMgr->_playingAnims[1] == 0 && FlagShowCharacter) {
if (!FlagSomeOneSpeak && !g_vm->_flagscriptactive && !FlagDialogActive && !FlagDialogMenuActive
&& (g_vm->_actor->_curAction < hWALKIN) && !FlagUseWithStarted && g_vm->_animMgr->_playingAnims[1] == 0 && FlagShowCharacter) {
IconSnapShot();
DataSave();
g_vm->showInventoryName(NO_OBJECTS, false);
@ -872,7 +875,8 @@ void doIdle() {
// Load
case 0x3D:
if (!FlagSomeOneSpeak && !g_vm->_flagscriptactive && !FlagDialogActive && !FlagDialogMenuActive && (_actor._curAction < hWALKIN) && !FlagUseWithStarted && g_vm->_animMgr->_playingAnims[1] == 0 && FlagShowCharacter) {
if (!FlagSomeOneSpeak && !g_vm->_flagscriptactive && !FlagDialogActive && !FlagDialogMenuActive
&& (g_vm->_actor->_curAction < hWALKIN) && !FlagUseWithStarted && g_vm->_animMgr->_playingAnims[1] == 0 && FlagShowCharacter) {
IconSnapShot();
if (!DataLoad()) {
g_vm->showInventoryName(NO_OBJECTS, false);

View File

@ -205,9 +205,9 @@ void doInvOperate() {
void doDoing() {
switch (g_vm->_curMessage->_event) {
case ME_INITOPENCLOSE:
if (_actor._curAction == hSTAND)
if (g_vm->_actor->_curAction == hSTAND)
REEVENT;
else if (_actor._curFrame == 4)
else if (g_vm->_actor->_curFrame == 4)
doEvent(g_vm->_curMessage->_class, ME_OPENCLOSE, g_vm->_curMessage->_priority, g_vm->_curMessage->_u16Param1, g_vm->_curMessage->_u16Param2, g_vm->_curMessage->_u8Param, g_vm->_curMessage->_u32Param);
else
REEVENT;
@ -226,7 +226,7 @@ void doDoing() {
// no break!
case ME_WAITOPENCLOSE:
RegenRoom();
if (_actor._curAction == hSTAND)
if (g_vm->_actor->_curAction == hSTAND)
g_vm->_flagMouseEnabled = true;
break;
}
@ -431,12 +431,12 @@ void AtEndChangeRoom() {
StartCharacterAction(a1B11ESCETOMBINO, 0, 0, 0);
else if ((g_vm->_curRoom == r1D) && (g_vm->_oldRoom == r1B) && (g_vm->_obj[oDONNA1D]._mode & OBJMODE_OBJSTATUS)) {
StartCharacterAction(a1D1SCENDESCALE, 0, 1, 0);
_actor._lim[0] = 60;
_actor._lim[2] = 240;
g_vm->_actor->_lim[0] = 60;
g_vm->_actor->_lim[2] = 240;
} else if ((g_vm->_curRoom == r1D) && (g_vm->_oldRoom == r1B) && !(g_vm->_obj[oDONNA1D]._mode & OBJMODE_OBJSTATUS)) {
StartCharacterAction(a1D12SCENDESCALA, 0, 1, 0);
_actor._lim[0] = 60;
_actor._lim[2] = 240;
g_vm->_actor->_lim[0] = 60;
g_vm->_actor->_lim[2] = 240;
} else if ((g_vm->_curRoom == r1B) && (g_vm->_oldRoom == r1D))
StartCharacterAction(a1B4ESCEBOTOLA, 0, 0, 0);
else if ((g_vm->_curRoom == r1B) && (g_vm->_oldRoom == r18) && (g_vm->_animMgr->_animTab[aBKG1B]._flag & SMKANIM_OFF1))

View File

@ -41,6 +41,7 @@
#define MAXSYSTEXT 30
#define MAXFILEREF 5000
#include "trecision/nl/3d/3drend.h"
namespace Common {
class SeekableReadStream;
@ -109,7 +110,7 @@ extern uint16 _actionPosition[];
// DATA POINTER
extern uint8 *TextArea;
// 3D AREA
extern uint8 *_characterArea;
extern SVertex *_characterArea;
extern uint8 *BaseHeadTexture;
extern uint8 AddObjectMaterial;
// MEMORY

View File

@ -324,12 +324,12 @@ bool syncSaveData(int slot, char *desc, bool save) {
ser.syncAsSint16LE(FlagCharacterExist);
ser.syncBytes(/*OldInv*/ g_vm->_inventory, MAXICON);
ser.syncBytes(g_vm->_cyberInventory, MAXICON);
ser.syncAsFloatLE(_actor._px);
ser.syncAsFloatLE(_actor._py);
ser.syncAsFloatLE(_actor._pz);
ser.syncAsFloatLE(_actor._dx);
ser.syncAsFloatLE(_actor._dz);
ser.syncAsFloatLE(_actor._theta);
ser.syncAsFloatLE(g_vm->_actor->_px);
ser.syncAsFloatLE(g_vm->_actor->_py);
ser.syncAsFloatLE(g_vm->_actor->_pz);
ser.syncAsFloatLE(g_vm->_actor->_dx);
ser.syncAsFloatLE(g_vm->_actor->_dz);
ser.syncAsFloatLE(g_vm->_actor->_theta);
ser.syncAsSint32LE(_curPanel);
ser.syncAsSint32LE(_oldPanel);

View File

@ -56,7 +56,7 @@ void DemoOver();
void CheckFileInCD(Common::String name);
void openSys();
void OpenVideo();
uint32 ReadActor(const char *filename, uint8 *Area);
void ReadActor(const char *filename);
void CloseSys(const char *str);
void ReadLoc();
void TendIn();

View File

@ -57,7 +57,7 @@ uint8 *SpeechBuf[2];
uint16 *ExtraObj2C;
uint16 *ExtraObj41D;
// 3D AREA
uint8 *_characterArea;
SVertex *_characterArea;
// MEMORY
uint32 GameBytePointer;
uint32 GameWordPointer;
@ -193,15 +193,17 @@ void OpenVideo() {
FTexture[hh]._palette = nullptr;
FTexture[hh]._flag = TEXTUREACTIVE + TEXTURECYLIND;
_characterArea = (uint8 *)(MemoryArea + GameBytePointer);
GameBytePointer += ReadActor("jm.om", (uint8 *)_characterArea);
delete g_vm->_actor;
g_vm->_actor = new SActor(g_vm);
_actor._vertexNum = VertexNum;
_actor._faceNum = FaceNum;
_actor._light = (SLight *)&VLight;
_actor._lightNum = LightNum;
_actor._camera = (SCamera *)&FCamera;
_actor._texture = (STexture *)&FTexture[0];
ReadActor("jm.om");
g_vm->_actor->_vertexNum = VertexNum;
g_vm->_actor->_faceNum = FaceNum;
g_vm->_actor->_light = (SLight *)&VLight;
g_vm->_actor->_lightNum = LightNum;
g_vm->_actor->_camera = (SCamera *)&FCamera;
g_vm->_actor->_texture = (STexture *)&FTexture[0];
TextArea = (uint8 *)(MemoryArea + GameBytePointer);
GameBytePointer += MAXTEXTAREA;
@ -255,7 +257,7 @@ void OpenVideo() {
/*-----------------13/09/95 11.59-------------------
ReadActor
--------------------------------------------------*/
uint32 ReadActor(const char *filename, uint8 *Area) {
void ReadActor(const char *filename) {
extern uint16 _textureMat[256][91];
extern int16 _textureCoord[MAXFACE][3][2];
@ -268,19 +270,15 @@ uint32 ReadActor(const char *filename, uint8 *Area) {
int32 ActionNum = ff->readSint32LE();
VertexNum = ff->readSint32LE();
_actor._vertexNum = VertexNum;
g_vm->_actor->_vertexNum = VertexNum;
_actor._vertex = (SVertex *)Area;
_characterArea = Area;
int32 Read = FastFileRead(ff, _actor._vertex, sizeof(SVertex) * VertexNum * ActionNum);
_characterArea = new SVertex[VertexNum * ActionNum];
g_vm->_actor->_vertex = _characterArea;
FastFileRead(ff, g_vm->_actor->_vertex, sizeof(SVertex) * VertexNum * ActionNum);
FaceNum = ff->readUint32LE();
_actor._faceNum = FaceNum;
g_vm->_actor->_faceNum = FaceNum;
Area += Read;
_actor._face = (SFace *)Area;
Read += FastFileRead(ff, _actor._face, sizeof(SFace) * FaceNum);
FastFileClose(ff);
ff = FastFileOpen("mat.tex");
@ -298,17 +296,18 @@ uint32 ReadActor(const char *filename, uint8 *Area) {
}
}
g_vm->_actor->_face = new SFace[FaceNum];
for (int i = 0; i < FaceNum; ++i) {
_actor._face[i]._a = ff->readSint16LE();
_actor._face[i]._b = ff->readSint16LE();
_actor._face[i]._c = ff->readSint16LE();
_actor._face[i]._mat = ff->readSint16LE();
g_vm->_actor->_face[i]._a = ff->readSint16LE();
g_vm->_actor->_face[i]._b = ff->readSint16LE();
g_vm->_actor->_face[i]._c = ff->readSint16LE();
g_vm->_actor->_face[i]._mat = ff->readSint16LE();
}
FastFileClose(ff);
_actor._curFrame = 0;
_actor._curAction = hSTAND;
g_vm->_actor->_curFrame = 0;
g_vm->_actor->_curAction = hSTAND;
// fixup Microprose head correction
#define P1 306
@ -319,17 +318,17 @@ uint32 ReadActor(const char *filename, uint8 *Area) {
double v1[3], v2[3], v[3], q[3], m1[3][3], m2[3][3], s;
int c, d, f;
v1[0] = _actor._vertex[P2]._x - _actor._vertex[P1]._x;
v1[1] = _actor._vertex[P2]._y - _actor._vertex[P1]._y;
v1[2] = _actor._vertex[P2]._z - _actor._vertex[P1]._z;
v1[0] = g_vm->_actor->_vertex[P2]._x - g_vm->_actor->_vertex[P1]._x;
v1[1] = g_vm->_actor->_vertex[P2]._y - g_vm->_actor->_vertex[P1]._y;
v1[2] = g_vm->_actor->_vertex[P2]._z - g_vm->_actor->_vertex[P1]._z;
s = sqrt(v1[0] * v1[0] + v1[1] * v1[1] + v1[2] * v1[2]);
v1[0] /= s;
v1[1] /= s;
v1[2] /= s;
v2[0] = _actor._vertex[P3]._x - _actor._vertex[P1]._x;
v2[1] = _actor._vertex[P3]._y - _actor._vertex[P1]._y;
v2[2] = _actor._vertex[P3]._z - _actor._vertex[P1]._z;
v2[0] = g_vm->_actor->_vertex[P3]._x - g_vm->_actor->_vertex[P1]._x;
v2[1] = g_vm->_actor->_vertex[P3]._y - g_vm->_actor->_vertex[P1]._y;
v2[2] = g_vm->_actor->_vertex[P3]._z - g_vm->_actor->_vertex[P1]._z;
s = sqrt(v2[0] * v2[0] + v2[1] * v2[1] + v2[2] * v2[2]);
v2[0] /= s;
v2[1] /= s;
@ -356,7 +355,7 @@ uint32 ReadActor(const char *filename, uint8 *Area) {
m1[0][2] = v1[2];
for (int b = 0; b < ActionNum; b++) {
SVertex *sv = (SVertex *)(_actor._vertex + b * VertexNum);
SVertex *sv = (SVertex *)(g_vm->_actor->_vertex + b * VertexNum);
v1[0] = sv[P2]._x - sv[P1]._x;
v1[1] = sv[P2]._y - sv[P1]._y;
@ -398,9 +397,9 @@ uint32 ReadActor(const char *filename, uint8 *Area) {
v2[1] = sv[P1]._y;
v2[2] = sv[P1]._z;
v1[0] = _actor._vertex[P1]._x;
v1[1] = _actor._vertex[P1]._y;
v1[2] = _actor._vertex[P1]._z;
v1[0] = g_vm->_actor->_vertex[P1]._x;
v1[1] = g_vm->_actor->_vertex[P1]._y;
v1[2] = g_vm->_actor->_vertex[P1]._z;
for (int e = 279; e < 383; e++) {
for (f = 0; f < 84; f++) {
@ -440,8 +439,6 @@ uint32 ReadActor(const char *filename, uint8 *Area) {
}
}
}
return (Read + 8 + 4);
}
/* -----------------27/06/97 17.52-------------------

View File

@ -65,7 +65,7 @@ void DemoOver();
void CheckFileInCD(Common::String name);
void openSys();
void OpenVideo();
uint32 ReadActor(const char *filename, uint8 *Area);
void ReadActor(const char *filename);
int actionInRoom(int curA);
void ReadLoc();
void TendIn();

View File

@ -73,10 +73,10 @@ void PaintScreen(uint8 flag) {
DObj.y = TOP;
DObj.dx = SCREENLEN;
DObj.dy = AREA;
DObj.l[0] = _actor._lim[0];
DObj.l[1] = _actor._lim[2] - TOP;
DObj.l[2] = _actor._lim[1];
DObj.l[3] = _actor._lim[3] - TOP;
DObj.l[0] = g_vm->_actor->_lim[0];
DObj.l[1] = g_vm->_actor->_lim[2] - TOP;
DObj.l[2] = g_vm->_actor->_lim[1];
DObj.l[3] = g_vm->_actor->_lim[3] - TOP;
DObj.buf = ImagePointer;
DObj.flag = COPYTORAM;
DrawObj(DObj);
@ -229,7 +229,7 @@ void PaintScreen(uint8 flag) {
TextStatus = TEXT_DRAW; // Activate text update
}
SoundPasso((_actor._lim[1] + _actor._lim[0]) / 2, (_actor._lim[5] + _actor._lim[4]) / 2, _actor._curAction, _actor._curFrame, g_vm->_room[g_vm->_curRoom]._sounds);
SoundPasso((g_vm->_actor->_lim[1] + g_vm->_actor->_lim[0]) / 2, (g_vm->_actor->_lim[5] + g_vm->_actor->_lim[4]) / 2, g_vm->_actor->_curAction, g_vm->_actor->_curFrame, g_vm->_room[g_vm->_curRoom]._sounds);
#if USE_DIRTY_RECTS
for (int liv = 0; liv < g_vm->_limitsNum; liv++) {
@ -458,19 +458,19 @@ void PaintObjAnm(uint16 CurBox) {
drawCharacter(CALCPOINTS);
// enlarge the rectangle of the character
if (g_vm->_limits[g_vm->_actorLimit][0] > _actor._lim[0])
g_vm->_limits[g_vm->_actorLimit][0] = _actor._lim[0];
if (g_vm->_limits[g_vm->_actorLimit][0] > g_vm->_actor->_lim[0])
g_vm->_limits[g_vm->_actorLimit][0] = g_vm->_actor->_lim[0];
if (g_vm->_limits[g_vm->_actorLimit][1] > _actor._lim[2])
g_vm->_limits[g_vm->_actorLimit][1] = _actor._lim[2];
if (g_vm->_limits[g_vm->_actorLimit][1] > g_vm->_actor->_lim[2])
g_vm->_limits[g_vm->_actorLimit][1] = g_vm->_actor->_lim[2];
if (g_vm->_limits[g_vm->_actorLimit][2] < _actor._lim[1])
g_vm->_limits[g_vm->_actorLimit][2] = _actor._lim[1];
if (g_vm->_limits[g_vm->_actorLimit][2] < g_vm->_actor->_lim[1])
g_vm->_limits[g_vm->_actorLimit][2] = g_vm->_actor->_lim[1];
if (g_vm->_limits[g_vm->_actorLimit][3] < _actor._lim[3])
g_vm->_limits[g_vm->_actorLimit][3] = _actor._lim[3];
if (g_vm->_limits[g_vm->_actorLimit][3] < g_vm->_actor->_lim[3])
g_vm->_limits[g_vm->_actorLimit][3] = g_vm->_actor->_lim[3];
resetZBuffer(_actor._lim[0], _actor._lim[2], _actor._lim[1], _actor._lim[3]);
resetZBuffer(g_vm->_actor->_lim[0], g_vm->_actor->_lim[2], g_vm->_actor->_lim[1], g_vm->_actor->_lim[3]);
drawCharacter(DRAWFACES);
//FlagPaintCharacter = false;

View File

@ -275,7 +275,7 @@ void CharacterContinueTalk() {
substringagain = (CurSubString < (SubStringUsed - 1));
if (FlagCharacterExist)
PositionString(_actor._lim[0], _actor._lim[2], SubString[CurSubString], &posx, &posy, true);
PositionString(g_vm->_actor->_lim[0], g_vm->_actor->_lim[2], SubString[CurSubString], &posx, &posy, true);
else
PositionString(MAXX / 2, 30, SubString[CurSubString], &posx, &posy, false);
@ -361,7 +361,7 @@ void SomeOneContinueTalk() {
if (SpeakSomeOnePerson)
PositionString(g_vm->_obj[SpeakSomeOnePerson]._lim[0], g_vm->_obj[SpeakSomeOnePerson]._lim[1], SubString[CurSubString], &posx, &posy, false);
else
PositionString(_actor._lim[0], _actor._lim[2], SubString[CurSubString], &posx, &posy, true);
PositionString(g_vm->_actor->_lim[0], g_vm->_actor->_lim[2], SubString[CurSubString], &posx, &posy, true);
g_vm->clearText();
if (ConfMan.getBool("subtitles"))

View File

@ -161,6 +161,7 @@ TrecisionEngine::TrecisionEngine(OSystem *syst) : Engine(syst) {
TextureArea = nullptr;
Icone = nullptr;
ZBuffer = nullptr;
_actor = nullptr;
}
TrecisionEngine::~TrecisionEngine() {
@ -172,6 +173,7 @@ TrecisionEngine::~TrecisionEngine() {
delete[] TextureArea;
delete[] Icone;
delete[] ZBuffer;
delete _actor;
}
Common::Error TrecisionEngine::run() {
@ -491,4 +493,35 @@ Common::String TrecisionEngine::getSavegameName(int slotNumber) {
return _targetName + Common::String::format(".%03d", slotNumber);
}
SActor::SActor(TrecisionEngine *vm) : _vm(vm) {
_vertex = nullptr;
_face = nullptr;
_light = nullptr;
_camera = nullptr;
_texture = nullptr;
_vertexNum = 0;
_faceNum = 0;
_lightNum = 0;
_matNum = 0;
_px = _py = _pz = 0.0;
_dx = _dz = 0.0;
_theta = 0.0;
for (int i = 0; i < 6; ++i)
_lim[i] = 0;
_curFrame = 0;
_curAction = 0;
}
SActor::~SActor() {
// delete _vertex; TODO: Delete[] _characterArea instead!
delete[] _face;
// delete _light;
// delete _camera;
// delete _texture;
}
} // End of namespace Trecision

View File

@ -26,6 +26,7 @@
#include "engines/engine.h"
#include "common/keyboard.h"
#include "graphics/pixelformat.h"
#include "nl/3d/3dinc.h"
#include "trecision/nl/struct.h"
#include "trecision/nl/ll/llinc.h"
@ -199,6 +200,8 @@ public:
uint8 *TextureArea;
uint16 *Icone;
int16 *ZBuffer;
SActor *_actor;
};
extern TrecisionEngine *g_vm;