]> icculus.org git repositories - taylor/freespace2.git/blob - include/pofview.h
rendering functions mostly done; more complete shader setup
[taylor/freespace2.git] / include / pofview.h
1 /*
2  * Copyright (C) Volition, Inc. 1999.  All rights reserved.
3  *
4  * All source code herein is the property of Volition, Inc. You may not sell 
5  * or otherwise commercially exploit the source or things you created based on
6  * the source.
7  */
8
9 // PofView.h : main header file for the POFVIEW application
10 //
11
12 #ifndef _POFVIEW_H
13 #define _POFVIEW_H
14
15 #include "wx/wxprec.h"
16
17 #ifndef WX_PRECOMP
18         #include "wx/wx.h"
19 #endif
20
21 #include "wx/artprov.h"
22 #include "wx/treectrl.h"
23 #include "wx/glcanvas.h"
24 #include "wx/aboutdlg.h"
25
26 #include "vecmat.h"
27 #include "physics.h"
28 #include "model.h"
29
30 ///////////////////////////////////////////////////////////////////////////////
31 /// Class AboutBox
32 ///////////////////////////////////////////////////////////////////////////////
33 class AboutBox : public wxDialog
34 {
35         private:
36
37         protected:
38                 wxStaticBitmap* m_bitmap2;
39                 wxStaticText* m_staticText3;
40                 wxStaticText* m_staticText4;
41                 wxButton* m_button2;
42
43         public:
44
45                 AboutBox( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxT("About PofView"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxDEFAULT_DIALOG_STYLE );
46                 ~AboutBox();
47
48 };
49
50 ///////////////////////////////////////////////////////////////////////////////
51 /// Class SubobjectsDialog
52 ///////////////////////////////////////////////////////////////////////////////
53 class SubobjectsDialog : public wxDialog
54 {
55         private:
56                 polymodel *m_pm;
57                 void AddModel(int sm, wxTreeItemId parent);
58
59                 wxDECLARE_EVENT_TABLE();
60
61         protected:
62
63                 enum {
64                         ID_OBJ_TREE = 1000
65                 };
66
67                 wxTreeCtrl* m_treeCtrlSubobjects;
68                 wxStaticText* m_staticTextName;
69                 wxTextCtrl* m_textCtrlName;
70                 wxStaticText* m_staticTextBspGenVersion;
71                 wxTextCtrl* m_textCtrlBspGenVersion;
72                 wxStaticText* m_staticTextPolys;
73                 wxTextCtrl* m_textCtrlNumPolys;
74                 wxStaticText* m_staticTextVerts;
75                 wxTextCtrl* m_textCtrlNumVerts;
76                 wxStaticText* m_staticTextMovementType;
77                 wxTextCtrl* m_textCtrlMovementType;
78                 wxStaticText* m_staticTextMovementAxis;
79                 wxTextCtrl* m_textCtrlMovementAxis;
80                 wxStaticText* m_staticTextDetail1;
81                 wxStaticText* m_staticTextDetail2;
82                 wxStaticText* m_staticTextDetail3;
83                 wxStaticText* m_staticTextDetail4;
84                 wxStaticText* m_staticTextDetail5;
85                 wxStaticText* m_staticTextDetail6;
86                 wxStaticText* m_staticTextPOFInfo;
87
88                 void OnSelChanged(wxTreeEvent& event);
89
90         public:
91
92                 SubobjectsDialog( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxT("Subobjects"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxDEFAULT_DIALOG_STYLE );
93                 ~SubobjectsDialog();
94
95                 void ParseModel();
96 };
97
98 ///////////////////////////////////////////////////////////////////////////////
99 /// Class PofViewTimer
100 ///////////////////////////////////////////////////////////////////////////////
101
102 class PofViewCanvas;
103
104 class PofViewTimer : public wxTimer
105 {
106         private:
107                 PofViewCanvas *m_canvas;
108                 int m_thrust_timer;
109
110         public:
111                 PofViewTimer(PofViewCanvas *canvas);
112
113                 ~PofViewTimer();
114
115                 void Notify();
116 };
117
118
119 ///////////////////////////////////////////////////////////////////////////////
120 /// Class PofViewCanvas
121 ///////////////////////////////////////////////////////////////////////////////
122 class PofViewCanvas : public wxGLCanvas
123 {
124         private:
125                 bool first_frame;
126                 float m_ViewerZoom;
127                 vector m_ViewerPos;
128                 matrix m_ViewerOrient;
129                 matrix m_ObjectOrient;
130
131                 physics_info m_ViewerPhysics;
132                 control_info m_Viewer_ci;
133
134                 int m_mouse_inited;
135                 int m_mouse_x;
136                 int m_mouse_y;
137                 int m_mouse_dx;
138                 int m_mouse_dy;
139
140                 PofViewTimer *m_timer;
141
142                 bool thrust_anim_inited;
143
144                 float model_thrust;
145                 int model_afterburner;
146
147                 int shipp_thruster_bitmap;
148                 float shipp_thruster_frame;
149
150                 int shipp_thruster_glow_bitmap;
151                 float shipp_thruster_glow_frame;
152                 float shipp_thruster_glow_noise;
153
154                 void InitThrusters();
155
156                 wxDECLARE_EVENT_TABLE();
157
158         protected:
159                 void OnPaint(wxPaintEvent& event);
160                 void OnSize(wxSizeEvent& event);
161                 void OnEraseBackground(wxEraseEvent& event);
162                 void OnMouse(wxMouseEvent& event);
163
164         public:
165
166                 PofViewCanvas(wxWindow *parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = 0, const wxString& name = wxT("TestGLCanvas"));
167
168                 virtual ~PofViewCanvas();
169
170                 void Render();
171                 void DoThrusterFrame(float frame_time);
172                 void MoveViewer(float frame_time);
173 };
174
175 ///////////////////////////////////////////////////////////////////////////////
176 /// Class PofViewFrame
177 ///////////////////////////////////////////////////////////////////////////////
178 class PofViewFrame : public wxFrame
179 {
180         private:
181                 wxString m_file_name;
182                 int m_model_num;
183                 int m_current_detail_level;
184
185                 bool pofview_initted;
186
187                 wxGLContext* m_glContext;
188
189                 void MakeMenuBar();
190                 void MakeToolBar();
191
192                 void SetToolDefaults();
193                 void SetTools();
194
195                 void PofviewInit();
196
197                 wxDECLARE_EVENT_TABLE();
198
199         protected:
200
201                 enum
202                 {
203                         ID_M_VIEW_TOOLBAR = 1000,
204                         ID_M_VIEW_STATUSBAR,
205                         ID_M_VIEW_OUTLINE,
206                         ID_M_VIEW_LIGHTING,
207                         ID_M_VIEW_PIVTOS,
208                         ID_M_VIEW_PATHS,
209                         ID_M_VIEW_RADIUS,
210                         ID_M_VIEW_THRUSTERS,
211                         ID_M_VIEW_TEXTURING,
212                         ID_M_VIEW_SMOOTHING,
213                         ID_M_VIEW_SHIELDS,
214                         ID_M_VIEW_INVISIBLE,
215                         ID_M_VIEW_BAYPATHS,
216                         ID_M_VIEW_AUTOCENTER,
217                         ID_M_WINDOW_NEW,
218                         ID_M_WINDOW_CASCADE,
219                         ID_M_WINDOW_TILE,
220                         ID_M_WINDOW_ARRANGE,
221                         ID_M_TOOLPRINT,
222                         ID_M_TOOLABOUT,
223                         // **************
224                         // do not alter order!!!
225                         ID_M_TOOLDEBRIS,
226                         ID_M_TOOLDETAIL1,
227                         ID_M_TOOLDETAIL2,
228                         ID_M_TOOLDETAIL3,
229                         ID_M_TOOLDETAIL4,
230                         ID_M_TOOLDETAIL5,
231                         ID_M_TOOLDETAIL6,
232                         // **************
233                         ID_M_TOOLSHOWTREE,
234                         ID_M_TOOLSHOWDAMAGED,
235                         ID_M_TOOLTOGGLELIGHTS,
236                         ID_M_TOOLTOGGLETURRETS
237                 };
238
239                 wxMenuBar* m_menubar1;
240                 wxMenu* m_menuFile;
241                 wxMenu* m_menuEdit;
242                 wxMenu* m_menuView;
243                 wxMenu* m_menuHelp;
244                 wxToolBar* m_toolBar1;
245                 wxPanel* m_panel1;
246                 wxStatusBar* m_statusBar1;
247                 PofViewCanvas* m_canvas;
248
249                 void OnFileOpen( wxCommandEvent& event );
250                 void OnFileClose( wxCommandEvent& event );
251                 void OnFilePrintSetup( wxCommandEvent& event );
252                 void OnExit( wxCommandEvent& event );
253                 void OnViewToolbar( wxCommandEvent& event );
254                 void OnViewStatusBar( wxCommandEvent& event );
255                 void OnHelpAbout( wxCommandEvent& event );
256                 void OnSetDetail( wxCommandEvent& event );
257                 void OnShowTree( wxCommandEvent& event );
258
259         public:
260
261                 PofViewFrame( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxT("PofView"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxDEFAULT_FRAME_STYLE|wxTAB_TRAVERSAL );
262
263                 ~PofViewFrame();
264
265                 void SetDetailLevel(int detail_lvl);
266
267                 const wxString GetFileName() { return m_file_name; }
268                 int GetModelnum() { return m_model_num; }
269                 int GetDetailLevel() { return m_current_detail_level; }
270
271                 bool ShowOutline() { return m_menuView->IsChecked(ID_M_VIEW_OUTLINE); }
272                 bool ShowShields() { return m_menuView->IsChecked(ID_M_VIEW_SHIELDS); }
273                 bool ShowInvisible() { return m_menuView->IsChecked(ID_M_VIEW_INVISIBLE); }
274                 bool ShowThrusters() { return m_menuView->IsChecked(ID_M_VIEW_THRUSTERS); }
275                 bool ShowPivots() { return m_menuView->IsChecked(ID_M_VIEW_PIVTOS); }
276                 bool ShowPaths() { return m_menuView->IsChecked(ID_M_VIEW_PATHS); }
277                 bool ShowRadius() { return m_menuView->IsChecked(ID_M_VIEW_RADIUS); }
278                 bool ShowBayPaths() { return m_menuView->IsChecked(ID_M_VIEW_BAYPATHS); }
279
280                 bool ShowDamaged() { return m_toolBar1->GetToolState(ID_M_TOOLSHOWDAMAGED); }
281
282                 bool UseSmoothing() { return m_menuView->IsChecked(ID_M_VIEW_SMOOTHING); }
283                 bool UseTexturing() { return m_menuView->IsChecked(ID_M_VIEW_TEXTURING); }
284                 bool UseAutocenter() { return m_menuView->IsChecked(ID_M_VIEW_AUTOCENTER); }
285                 bool UseLighting() { return m_menuView->IsChecked(ID_M_VIEW_LIGHTING); }
286
287                 bool LightingOn() { return m_toolBar1->GetToolState(ID_M_TOOLTOGGLELIGHTS); }
288 };
289
290 #endif