ScummVM API documentation
pan_bitmap.h
1 
2 /* ScummVM - Graphic Adventure Engine
3  *
4  * ScummVM is the legal property of its developers, whose names
5  * are too numerous to list here. Please refer to the COPYRIGHT
6  * file distributed with this source distribution.
7  *
8  * This program is free software: you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation, either version 3 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program. If not, see <http://www.gnu.org/licenses/>.
20  *
21  */
22 
23 #ifndef BAGEL_BAGLIB_PAN_BITMAP_H
24 #define BAGEL_BAGLIB_PAN_BITMAP_H
25 
26 #include "bagel/spacebar/boflib/gfx/bitmap.h"
27 #include "bagel/spacebar/boflib/fixed.h"
28 
29 namespace Bagel {
30 namespace SpaceBar {
31 
32 #define MAX_DIV_VIEW (12.8 / 3) // Ratio for 480x380 Screen
33 #define DEF_FOV (360 / MAX_DIV_VIEW) // 1TO1 Paint FOV
34 
35 class CBagPanBitmap : public CBofBitmap {
36 public:
37  enum Direction {
38  kDirNONE = 0x0,
39  kDirUP = 0x01,
40  kDirDOWN = 0x02,
41  kDirLEFT = 0x04,
42  kDirRIGHT = 0x08,
43  kDirVIEW = 0x10
44  };
45 
46 private:
47  CBofRect _xCurrView; // Viewport Window size (0->Width-1,0->Height-1,1->Width+Width/4,1->Height)
48  double _xFOVAngle; // Field of view in radians
49  CBofPoint _xRotateRate; // Rate of rotation on increment left, right ...
50  bool _bActiveScrolling; // True when there should be screen updates
51  bool _bPanorama; // True when the bitmap is a 360 panorama
52  Direction _xDirection; // Set direction for next update
53  int _nCorrWidth; // Size of each correction band
54  CBofFixed *_pCosineTable; // Lookup table for cosine values
55  int _nNumDegrees; // Number of lookups in the cosine table
56  bool _bIsValid; // Is the bmp a valid object
57 
58  void normalizeViewSize();
59  void generateCosineTable();
60 
61 public:
62  CBagPanBitmap(const char *pszFileName, CBofPalette *pPalette, const CBofRect &xViewSize = CBofRect());
63  virtual ~CBagPanBitmap();
64 
65  bool isValid() const {
66  return _bIsValid;
67  }
68  bool isPan() const {
69  return _bPanorama;
70  }
71 
72  ErrorCode paint(CBofBitmap *pBmp, CBofPoint xDstOffset = CBofPoint(0, 0));
73  ErrorCode paintUncorrected(CBofBitmap *pBmp, CBofRect &dstRect);
74  ErrorCode paintWarped(CBofBitmap *pBmp, const CBofRect &dstRect, const CBofRect &srcRect, int offset = 0, CBofBitmap *pSrcBmp = nullptr, const CBofRect &preSrcRect = CBofRect());
75 
76  CBofRect getWarpSrcRect();
77  CBofPoint warpedPoint(CBofPoint &xPoint);
78 
79  const CBofRect getMaxView(CBofSize s = CBofSize(640, 480));
80 
81  void setCorrWidth(int nWidth, bool bUpdate = true);
82 
83  void rotateRight(int nXRotRate = 0);
84  void rotateLeft(int nXRotRate = 0);
85  void rotateUp(int nYRotRate = 0);
86  void rotateDown(int nYRotRate = 0);
87 
88  Direction updateView();
89 
90  void setCurrView(const CBofRect &xCurrView);
91  void offsetCurrView(const CBofPoint &xOffset);
92  void setFOV(double degrees, bool bUpdate = true);
93 
94  void setViewSize(const CBofSize &xViewSize, bool bUpdate = true);
95  CBofSize setUnityViewSize();
96  double setUnityFOV();
97 
98  double getFOV() const {
99  return _xFOVAngle;
100  }
101  const CBofSize getViewSize() const {
102  return CBofSize(_xCurrView.size());
103  }
104  const CBofRect getCurrView() const {
105  return _xCurrView;
106  }
107 
108  Direction getDirection() const {
109  return _xDirection;
110  }
111 
112  void setRotateRate(const CBofPoint &xRotRate) {
113  _xRotateRate = xRotRate;
114  }
115  void setDirection(const Direction xDirection) {
116  _xDirection = xDirection;
117  }
118  int getCorrWidth() {
119  return _nCorrWidth;
120  }
121 
122  void activateScrolling(bool val = true) {
123  _bActiveScrolling = val;
124  }
125  void deActivateScrolling() {
126  activateScrolling(false);
127  }
128 
129 };
130 
131 } // namespace SpaceBar
132 } // namespace Bagel
133 
134 #endif
Definition: size.h:32
Definition: rect.h:35
Definition: palette.h:64
Definition: afxwin.h:27
Definition: point.h:32
Definition: fixed.h:32
Definition: bitmap.h:57
Definition: pan_bitmap.h:35