ScummVM API documentation
spacechase3d.h
1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * Additional copyright for this file:
8  * Copyright (C) 1995-1997 Presto Studios, Inc.
9  *
10  * This program is free software: you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation, either version 3 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program. If not, see <http://www.gnu.org/licenses/>.
22  *
23  */
24 
25 #ifndef PEGASUS_NEIGHBORHOOD_MARS_SPACECHASE3D_H
26 #define PEGASUS_NEIGHBORHOOD_MARS_SPACECHASE3D_H
27 
28 #include "pegasus/neighborhood/mars/constants.h"
29 
30 namespace Pegasus {
31 
32 // This is approximately right for a field of view of 72 degrees
33 // (Should be set to the tangent of FOV).
34 //static const float kTangentFOV = 0.76254;
35 static const float kTangentFOV = 1.0;
36 
37 // Define these as macros and they can be used to define constants...
38 #define convertSpaceXToScreenH(x, z) \
39  ((x) / (z) * (kScreenWidth / (2 * kTangentFOV)) + kShuttleWindowMidH)
40 
41 #define convertSpaceYToScreenV(y, z) \
42  (kShuttleWindowMidV - (y) / (z) * (kScreenWidth / (2 * kTangentFOV)))
43 
44 #define convertScreenHToSpaceX(x, d) \
45  (((2.0F * kTangentFOV) / kScreenWidth) * ((float)(x) - kShuttleWindowMidH) * (d))
46 
47 #define convertScreenVToSpaceY(y, d) \
48  (((2.0F * kTangentFOV) / kScreenWidth) * ((float)kShuttleWindowMidV - (y)) * (d))
49 
50 struct Point3D {
51  float x, y, z;
52 
53  Point3D() : x(0), y(0), z(0) {}
54  Point3D(float x1, float y1, float z1) : x(x1), y(y1), z(z1) {}
55  bool operator==(const Point3D &p) const { return x == p.x && y == p.y && z == p.z; }
56  bool operator!=(const Point3D &p) const { return x != p.x || y != p.y || z != p.z; }
57 
58  void translate(float dx, float dy, float dz) {
59  x += dx;
60  y += dy;
61  z += dz;
62  }
63 };
64 
65 static const int kScreenWidth = kShuttleWindowWidth;
66 
67 bool isNegative(int a);
68 bool isPositive(int a);
69 int sign(int a);
70 bool sameSign(int a, int b);
71 
72 void project3DTo2D(const Point3D &pt3D, Common::Point &pt2D);
73 void project2DTo3D(const Common::Point &pt2D, const float screenDistance, Point3D &pt3D);
74 
75 void linearInterp(const Point3D &pt1, const Point3D &pt2, const float t, Point3D &pt3);
76 void linearInterp(const Point3D &pt1, const float x2, const float y2, const float z2, const float t, Point3D &pt3);
77 void linearInterp(const float x1, const float y1, const float z1, const Point3D &pt2, const float t, Point3D &pt3);
78 void linearInterp(const float x1, const float y1, const float z1, const float x2,
79  const float y2, const float z2, const float t, Point3D &pt3);
80 
81 void linearInterp(const Common::Point &pt1, const Common::Point &pt2, const float t, Common::Point &pt3);
82 void linearInterp(const Common::Point &pt1, const float h2, const float v2, const float t, Common::Point &pt3);
83 void linearInterp(const float h1, const float v1, const Common::Point &pt2, const float t, Common::Point &pt3);
84 void linearInterp(const float h1, const float v1, const float h2, const float v2, const float t, Common::Point &pt3);
85 
86 float linearInterp(const float arg1, const float arg2, const float t);
87 
88 } // End of namespace Pegasus
89 
90 #endif
Definition: spacechase3d.h:50
Definition: rect.h:45
Definition: ai_action.h:33