1 /* -*- c++ -*-
2 FILE: MagicCube4dView.h
3 RCS REVISION: $Revision: 1.8 $
4 
5 COPYRIGHT: (c) 1999 -- 2003 Melinda Green, Don Hatch, and Jay Berkenbilt - Superliminal Software
6 
7 LICENSE: Free to use and modify for non-commercial purposes as long as the
8     following conditions are adhered to:
9     1) Obvious credit for the source of this code and the designs it embodies
10        are clearly made, and
11     2) Ports and derived versions of 4D Magic Cube programs are not distributed
12        without the express written permission of the authors.
13 
14 DESCRIPTION:
15     interface of the CMagicCube4dView class
16 */
17 
18 /////////////////////////////////////////////////////////////////////////////
19 
20 #include "WrapD3D.h"
21 #include "d3drm.h"
22 #include "d3drmwin.h"
23 #include "MagicCubeObj.h"
24 
25 class CMagicCube4dView : public CView
26 {
27 protected: // create from serialization only
28     CMagicCube4dView();
29     DECLARE_DYNCREATE(CMagicCube4dView)
30 
31 // Attributes
32 public:
33     CMagicCube4dDoc* GetDocument();
34 
35 private:
36     WrapD3D m_wrapd3d;
37     int m_width, m_height;
38     IDirect3D* m_d3d;
39     IDirect3DDevice* m_d3ddev;
40     IDirect3DViewport* m_d3dview;
41     IDirect3DRM* m_d3drm;
42     IDirect3DRMFrame *m_scene, *m_objs, *m_camera, *m_lights;
43     IDirectDrawClipper* m_clipper;
44     IDirect3DRMDevice* m_d3drmdev;
45     IDirect3DRMWinDevice* m_d3drmwindev;
46     IDirect3DRMViewport* m_view;
47     IDirect3DRMLight *m_dir_light, *m_amb_light;
48     int m_nslices;
49     MagicCubeObject* m_puzzle;
50     bool m_left_mouse_down, m_left_dragged;
51     bool m_update_needed;
52     double m_last_point[2];
53     FILE* m_tmp_logfile;
54     enum ScrambleState {
55         SCRAMBLE_NONE,
56         SCRAMBLE_PARTIAL,
57         SCRAMBLE_FULL,
58     } m_scramble_state;
59     int m_user_twists;
60     int m_user_twisting;
61     int m_user_twist_mask;
62     bool m_shift_down;
63     bool m_software_render_only;
64     void Init3D(int w, int h);
65     void NewPuzzle(int ns);
66     void Scramble(int scrambulations);
67     void DoPick(int x, int y, int dir, int rotate);
68     void InitDrawing();
69 
70 // Operations
71 public:
72     BOOL Update3d();
73 
74 // Overrides
75     // ClassWizard generated virtual function overrides
76     //{{AFX_VIRTUAL(CMagicCube4dView)
77     public:
78     virtual void OnDraw(CDC* pDC);  // overridden to draw this view
79     protected:
80     virtual void OnActivateView(BOOL bActivate, CView* pActivateView, CView* pDeactiveView);
81     //}}AFX_VIRTUAL
82 
83 // Implementation
84 public:
85     virtual ~CMagicCube4dView();
86 #ifdef _DEBUG
87     virtual void AssertValid() const;
88     virtual void Dump(CDumpContext& dc) const;
89 #endif
90 
91 protected:
92 
93 // Generated message map functions
94 protected:
95     //{{AFX_MSG(CMagicCube4dView)
96     afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
97     afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
98     afx_msg void OnMouseMove(UINT nFlags, CPoint point);
99     afx_msg void OnRButtonUp(UINT nFlags, CPoint point);
100     afx_msg void OnEditUndo();
101     afx_msg void OnScramble1();
102     afx_msg void OnScramble2();
103     afx_msg void OnScramble3();
104     afx_msg void OnScramble4();
105     afx_msg void OnScramble5();
106     afx_msg void OnScramble6();
107     afx_msg void OnScramble7();
108     afx_msg void OnScramble8();
109     afx_msg void OnScrambleFull();
110     afx_msg void OnSolve();
111     afx_msg void OnReset();
112     afx_msg void OnNewPuzzle2();
113     afx_msg void OnNewPuzzle3();
114     afx_msg void OnNewPuzzle4();
115     afx_msg void OnNewPuzzle5();
116     afx_msg void OnFileSave();
117     afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
118     afx_msg void OnKeyUp(UINT nChar, UINT nRepCnt, UINT nFlags);
119     afx_msg void OnKillFocus(CWnd* pNewWnd);
120     afx_msg void OnRenderingSoftwareonly();
121     afx_msg void OnRenderingDefault();
122     //}}AFX_MSG
123     DECLARE_MESSAGE_MAP()
124 };
125 
126 #ifndef _DEBUG  // debug version in MagicCube4dView.cpp
GetDocument()127 inline CMagicCube4dDoc* CMagicCube4dView::GetDocument()
128    { return (CMagicCube4dDoc*)m_pDocument; }
129 #endif
130 
131 /////////////////////////////////////////////////////////////////////////////
132 
133 // Local Variables:
134 // c-basic-offset: 4
135 // c-comment-only-line-offset: 0
136 // c-file-offsets: ((defun-block-intro . +) (block-open . 0) (substatement-open . 0) (statement-cont . +) (statement-case-open . +4) (arglist-intro . +) (arglist-close . +) (inline-open . 0))
137 // indent-tabs-mode: nil
138 // End:
139