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/boflib/gfx/bitmap.h"
27 #include "bagel/boflib/fixed.h"
28 
29 namespace Bagel {
30 
31 #define MAX_DIV_VIEW (12.8 / 3) // Ratio for 480x380 Screen
32 #define DEF_FOV (360 / MAX_DIV_VIEW) // 1TO1 Paint FOV
33 
34 class CBagPanBitmap : public CBofBitmap {
35 public:
36  enum Direction {
37  kDirNONE = 0x0,
38  kDirUP = 0x01,
39  kDirDOWN = 0x02,
40  kDirLEFT = 0x04,
41  kDirRIGHT = 0x08,
42  kDirVIEW = 0x10
43  };
44 
45 private:
46  CBofRect _xCurrView; // Viewport Window size (0->Width-1,0->Height-1,1->Width+Width/4,1->Height)
47  double _xFOVAngle; // Field of view in radians
48  CBofPoint _xRotateRate; // Rate of rotation on increment left, right ...
49  bool _bActiveScrolling; // True when there should be screen updates
50  bool _bPanorama; // True when the bitmap is a 360 panorama
51  Direction _xDirection; // Set direction for next update
52  int _nCorrWidth; // Size of each correction band
53  CBofFixed *_pCosineTable; // Lookup table for cosine values
54  int _nNumDegrees; // Number of lookups in the cosine table
55  bool _bIsValid; // Is the bmp a valid object
56 
57  void normalizeViewSize();
58  void generateCosineTable();
59 
60 public:
61  CBagPanBitmap(const char *pszFileName, CBofPalette *pPalette, const CBofRect &xViewSize = CBofRect());
62  virtual ~CBagPanBitmap();
63 
64  bool isValid() const {
65  return _bIsValid;
66  }
67  bool isPan() const {
68  return _bPanorama;
69  }
70 
71  ErrorCode paint(CBofBitmap *pBmp, CBofPoint xDstOffset = CBofPoint(0, 0));
72  ErrorCode paintUncorrected(CBofBitmap *pBmp, CBofRect &dstRect);
73  ErrorCode paintWarped(CBofBitmap *pBmp, const CBofRect &dstRect, const CBofRect &srcRect, int offset = 0, CBofBitmap *pSrcBmp = nullptr, const CBofRect &preSrcRect = CBofRect());
74 
75  CBofRect getWarpSrcRect();
76  CBofPoint warpedPoint(CBofPoint &xPoint);
77 
78  const CBofRect getMaxView(CBofSize s = CBofSize(640, 480));
79 
80  void setCorrWidth(int nWidth, bool bUpdate = true);
81 
82  void rotateRight(int nXRotRate = 0);
83  void rotateLeft(int nXRotRate = 0);
84  void rotateUp(int nYRotRate = 0);
85  void rotateDown(int nYRotRate = 0);
86 
87  Direction updateView();
88 
89  void setCurrView(const CBofRect &xCurrView);
90  void offsetCurrView(const CBofPoint &xOffset);
91  void setFOV(double degrees, bool bUpdate = true);
92 
93  void setViewSize(const CBofSize &xViewSize, bool bUpdate = true);
94  CBofSize setUnityViewSize();
95  double setUnityFOV();
96 
97  double getFOV() const {
98  return _xFOVAngle;
99  }
100  const CBofSize getViewSize() const {
101  return CBofPoint(_xCurrView.size());
102  }
103  const CBofRect getCurrView() const {
104  return _xCurrView;
105  }
106 
107  Direction getDirection() const {
108  return _xDirection;
109  }
110 
111  void setRotateRate(const CBofPoint &xRotRate) {
112  _xRotateRate = xRotRate;
113  }
114  void setDirection(const Direction xDirection) {
115  _xDirection = xDirection;
116  }
117  int getCorrWidth() {
118  return _nCorrWidth;
119  }
120 
121  void activateScrolling(bool val = true) {
122  _bActiveScrolling = val;
123  }
124  void deActivateScrolling() {
125  activateScrolling(false);
126  }
127 
128 };
129 
130 } // namespace Bagel
131 
132 #endif
Definition: size.h:31
Definition: bitmap.h:55
Definition: rect.h:36
Definition: pan_bitmap.h:34
Definition: fixed.h:31
Definition: bagel.h:31
Definition: point.h:34
Definition: palette.h:69