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  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20  *
21  */
22 
23 #ifndef TITANIC_STAR_CLOSEUP_H
24 #define TITANIC_STAR_CLOSEUP_H
25 
26 #include "titanic/star_control/fvector.h"
27 #include "titanic/star_control/fpose.h"
28 #include "titanic/star_control/surface_area.h"
29 #include "common/array.h"
30 
31 namespace Titanic {
32 
33 class CErrorCode;
34 class CCamera;
35 class CSurfaceArea;
36 
37 /**
38  * Handles drawing a 3D rendered closeup of a star
39  */
40 class CStarCloseup {
41 	struct Data1 {
42 		int _index1;
43 		int _index2;
Data1Data144 		Data1() : _index1(0), _index2(0) {}
45 	};
46 
47 	struct SubEntry {
48 		Common::Array<Data1> _data1;
49 		Common::Array<FVector> _data2;
~SubEntrySubEntry50 		~SubEntry() { clear(); }
51 
52 		/**
53 		 * Clears the entry
54 		 */
55 		void clear();
56 	};
57 
58 	struct Entry {
59 		int _field0;
60 		byte _pixel1;
61 		byte _pixel2;
62 		byte _pixel3;
63 		int _field8;
64 		int _fieldC;
65 		double _field10;
66 		double _field14;
67 
EntryEntry68 		Entry() : _field0(0), _pixel1(0), _pixel2(0), _pixel3(0), _field8(0),
69 				_fieldC(0), _field10(0), _field14(0) {}
70 	};
71 
72 	struct GridEntry : public FVector {
73 		FPoint _position;
74 
GridEntryGridEntry75 		GridEntry() : FVector() {}
76 	};
77 
78 	/**
79 	 * Maintains a pre-calculated table of sine values
80 	 * TODO: May be able to reuse common/sinetables.h
81 	 */
82 	struct SineTable {
83 	private:
84 		Common::Array<float> _data;
85 	public:
SineTableSineTable86 		SineTable() {}
87 
88 		/**
89 		 * Sets up the table
90 		 */
91 		bool setup();
92 
93 		/**
94 		 * Get a value
95 		 */
96 		double operator[](int idx) { return _data[idx]; }
97 	};
98 private:
99 	bool _flag;
100 	FPose _sub1, _sub2;
101 	SubEntry _array[5];
102 	Entry _entries[1284];
103 	int _multiplier;
104 	SineTable _sineTable;
105 	Common::Array<GridEntry> _grid;
106 private:
107 	/**
108 	 * Sets up the data for an array entry
109 	 * @return	True if success
110 	 */
111 	bool setupEntry(int width, int height, int index, float val);
112 
113 	/**
114 	 * Secondary setup method
115 	 * @return	True if success
116 	 */
117 	bool setup2(int val1, int val2);
118 public:
119 	CStarCloseup();
~CStarCloseup()120 	virtual ~CStarCloseup() {}
121 
122 	virtual bool setup();
123 
124 	/**
125 	 * Draws the star globe
126 	 */
127 	virtual void draw(const FPose &pose, const FVector &vector, const FVector &vector2,
128 		CSurfaceArea *surfaceArea, CCamera *camera);
129 
130 	virtual void proc3(CErrorCode *errorCode);
131 
get4()132 	bool get4() const { return _flag; }
set4(bool val)133 	void set4(bool val) { _flag = val; }
134 
135 	void fn1();
136 };
137 
138 } // End of namespace Titanic
139 
140 #endif /* TITANIC_STAR_CLOSEUP_H */
141