/* -*- c++ -*- FILE: MagicCubeObj.h RCS REVISION: $Revision: 1.10 $ COPYRIGHT: (c) 1999 -- 2003 Melinda Green, Don Hatch, and Jay Berkenbilt - Superliminal Software LICENSE: Free to use and modify for non-commercial purposes as long as the following conditions are adhered to: 1) Obvious credit for the source of this code and the designs it embodies are clearly made, and 2) Ports and derived versions of 4D Magic Cube programs are not distributed without the express written permission of the authors. DESCRIPTION: This class is the primary event handling class for the Windows portion of the MagicCube4d code. */ #ifndef MAGICCUBEOBJ_H #define MAGICCUBEOBJ_H #include "Preferences.h" #include "Flexible.h" #include "MagicCube.h" #include "Polymgr.h" #include "Puzzlest.h" #include "History.h" #include // The MagicCubeObject class represents the displayable geometric // representation of a puzzle. typedef real Vert3[3]; typedef real Vert4[4]; typedef int Quad[4]; class MagicCubeObject:public Flexible { public: MagicCubeObject (int nslices, FILE *fp, const double colors[][3], LPDIRECT3DRMDEVICE d, LPDIRECT3DRM lpd3drm); virtual ~MagicCubeObject (); virtual int UpdateVertexData(D3DVERTEX v[]); void Reset(); int TwistAbout(int stickerid, int dir, int depth); int RotateFaceToCenter(int sticker_geom_id); bool Undo(bool across_scramble_boundary_ok = false); void Cheat(); void Scramble(int n_scramblechens); int IsSolved() const; int IsValid() const { return m_is_valid; } int IsAnimating() const { return m_twist_dir; } void SaveTo(FILE *) const; int ReadFrom(FILE *); struct IdColor { int id; int color; }; private: void set_vert_colors(D3DVERTEX v[]); void update_sticker_map(); Preferences m_preferences; PolygonManager4D *m_polymgr; // source of polygons representing puzzle state History *m_history; PuzzleState *m_puzzle_state; int m_nslices; int m_nstickers; // m_nslices^3 * 8 int m_nverts; // 8 * m_nstickers int m_nquads; // 6 * m_nstickers Vert3 *m_verts3; // [m_nverts][3] Quad *m_quads; // [m_nquads][4] int *m_culled; // [m_nquads] int *m_stickerids; // [m_nquads] int m_is_valid; real m_faceshrink; real m_stickershrink; struct stickerspec m_twist_grip; // grip currently twisting about int m_twist_dir; // direction int m_twist_slicemask; // which slices to twist (0x1 == top slice, etc.) real m_twist_inc; // additional twisting per frame int m_twist_nframes; // number of frames in twist animation int m_twist_frame_number; // current twist frame in animation IdColor *m_geom2id; // sticker pos in display list to puzzle state id map int m_undoing; // set to non-zero when starting an undo animation int m_cheating; // set to non-zero when playing history back to start }; #endif // Local Variables: // c-basic-offset: 4 // c-comment-only-line-offset: 0 // 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)) // indent-tabs-mode: nil // End: