/* -*- c++ -*- FILE: Polymgr.h RCS REVISION: $Revision: 1.15 $ 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 manages the rendering of the puzzle as a collection of polygons. */ #ifndef POLYMGR_H #define POLYMGR_H #include "MagicCube.h" class Preferences; class PolygonManager4D { public: PolygonManager4D(Preferences&); // length = -1 means no change to length void reset(int length = -1); void setShrinkers(real face_val, real sticker_val); void calc3DTo2DFrameInfo( /* INPUTS */ int nverts3, real verts3[][3], int nquads3, int quads3[][4], int stickerids3[], real tilt, real twirl, real eyez, real sunvec[3], int sunvec_is_in_objspace, int cullverts, int cullbackfaces, int zsort, /* OUTPUTS */ int *Nverts2, real verts2[][2], int *Nquads2, int quads2[][4], int quadids2[], real brightnesses[]); real getTwistTotalAngle(int dim, int dir); int getTwistNFrames(struct stickerspec *grip); int makeRangesInt(int slicesmask, int whichaxis, int sgn, int ranges[MAXLENGTH][2]); int oppositeFace(int f); static int faceOfGrip(int id); static void fillStickerspecFromIdAndLength(struct stickerspec *sticker, int length); static void fillStickerspecFromId(struct stickerspec *sticker); static void fillStickerspecFromFaceAndIdAndLength(struct stickerspec *sticker, int length); static void fillStickerspecFromFaceAndId(struct stickerspec *sticker); static void fillStickerspecFromCoordsAndLength(struct stickerspec *sticker, int length); static void fillStickerspecFromCoords(struct stickerspec *sticker); /* * Get a sticker for which a CCW twist is the same transformation * as the given face-to-center rotation. */ int facetocenterToGrip(int facetocenter, struct stickerspec *sticker); void calc2DFrameInfo( /* INPUTS */ struct stickerspec *sticker, int dir, int slicesmask, real frac, real (*interp)(real), int nverts4, real untwisted_verts4[][4], real eyew, int cullcells, real tilt, real twirl, real eyez, real sunvec[3], int sunvec_is_in_objspace, int cullverts, int cullbackfaces, int zsort, /* OUTPUTS */ int *Nverts2, real verts2[][2], int *Nquads2, int quads2[][4], int quadids[], real brightnesses[]); /* brightnesses not calculated if NULL */ /* * returns 1 if landed on a sticker, 0 otherwise */ int pick(int x, int y, struct frame *frame, struct stickerspec *sticker); /* * "grip" is equal to the sticker id * if length=3; otherwise * it's equal to the stickerid on the 3x3x3x3 puzzle * that corresponds to the twist. * NOTE: this is mostly the same as pick(). * returns 1 if landed on a sticker, 0 otherwise */ int pickGrip(int x, int y, struct frame *frame, struct stickerspec *sticker); void getUntwistedFrame(struct frame *frame); void getFrame(struct stickerspec *sticker, int dir, int slicesmask, int seqno, int outof, struct frame *frame); void calc3DFrameInfo( /* INPUTS */ struct stickerspec *grip, int dir, int slicesmask, real frac, real (*interp)(real), int nverts4, real untwisted_verts4[][4], // NULL if use pristine real eyew, int cullcells, /* OUTPUTS */ int *Nverts3, real verts3[][3], int *Nquads3, int quads3[][4], int stickerids3[], int stickers_inverted[]); // NULL if not needed int getUntwistedVerts4(real verts4[][4], real faceshrink, real stickershrink); void incTilt(real inc); void incTwirl(real inc); static int intpow(int x, int y) { return y == 0 ? 1 : intpow(x, y - 1) * x; } private: int makeRangesReal(int slicesmask, int, // whichaxis, int sgn, real ranges[MAXLENGTH][2]); Preferences& preferences; int n_untwisted_verts4; real untwisted_verts4[MAXVERTS][4]; real faceshrink, stickershrink; /* bleah... need to reuse this when twisting */ int nframes_90, nframes_120, nframes_180; /* FIX THIS-- decide on a consistent way to define variables */ /* * Yes, these should probably be in a data structure: */ int n_untwisted_verts3; real untwisted_verts3[MAXVERTS][3]; int n_untwisted_quads3; int untwisted_quads3[MAXQUADS][4]; int untwisted_stickerids3[MAXSTICKERS]; /* NOTE stickerids3 is indexed by verts/8 whereas quadids2 is indexed by stickers */ }; #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: