This is CubeCell.h in view mode; [Download] [Up]
/******************************************************************************
*
* poly program : CubeCell.h nov 6 91 david stes
*
* a CubeCell is an ActionCell that implements a Cube control. but it can as
* well be used to fill a Matrix with.
*
* CubeCell has a method to draw a (three dimensional) cube and a method to
* track the mouse as long as it points to some point of the cube.
*
* to make rotating the cube even more intuitive, one of the 6 faces is
* coloured in a different shade than the other ones. it's the original front
* face (after a reset).
*
* instance variables
* mat[3][3]....................transformation matrix
* oi,oj,ok.....................label of current frontmost corner
* radius.......................radius of sphere containing cube
* base.........................(x,y) of center sphere
* track........................radius of tracking sphere
* tracksgn.....................whether we track pts with pos or neg z
* trckmat......................matrix for change of base
* ops[5].......................drawing instructions
* bbox[4]......................user path bounding box (=cellframe)
*
* public methods
* -init.............................initializing a new CubeCell
*
* -reset............................initialize matrix to frontview
* -setmatrix........................copy into transformation matrix
* -getmatrix........................get copy of transformation matrix
* -rotate::.........................rotate by [0,2pi[ then by ]-pi/2,+pi/2[
*
* -drawcube.........................draw the cube
* -drawInside:inView:...............static drawing (implements drawSelf)
*
* -startTrackingAt:inView:..........the three methods that implement the
* inherited trackMouse method
* -continueTracking:at:inView.......
* -stopTracking:at:inView:mouseIsUp:
*
* history
* nov 6 91 : v0.0 stes create
* nov 9 91 : v0.1 stes changed instance vars (use matrix instead of angles)
* jan24 91 : v0.2 stes cleaning up in order to make public/palette-tize
*
******************************************************************************/
#import <appkit/ActionCell.h> /* the Class we're subclassing */
#import <objc/objc.h> /* BOOL */
#import <appkit/graphics.h> /* NXRect,NXPoint etc. */
@interface CubeCell : ActionCell
{
float mat[3][3];
/* private */
int oi,oj,ok;
float radius;
NXPoint base;
float track;
int tracksgn;
float trckmat[3][3];
char ops[5];
float bbox[4];
}
/* public methods */
- init;
- reset;
- setmatrix:(float *)set;
- getmatrix:(float *)get;
- rotate :(float)ph
:(float)th;
- drawcube;
- drawInside : (const NXRect *)cellframe
inView: controlView;
- calcCellSize : (NXSize *)theSize
inRect : (const NXRect *)aRect;
- (BOOL)startTrackingAt : (const NXPoint *)startPoint
inView: controlView;
- (BOOL)continueTracking : (const NXPoint *)lastPoint
at: (const NXPoint *)currentPoint
inView: controlView;
- read :(NXTypedStream *)s;
- write:(NXTypedStream *)s;
@endThese are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.