home *** CD-ROM | disk | FTP | other *** search
-
- /* ControlPoint.m Peter Wickersham
- *
- * Methods for ControlPoint class.
- *
- */
-
- #import "../Stone3DAPI/Stone3D.h"
- #import "ControlPoint.h"
- #import "Camera.h"
-
- #import <ri/ri.h>
-
- #define RADIUS 0.025
-
- @implementation ControlPoint
-
- // Initialize the bounding box and standard Shape stuff.
- - init
- {
- [super init];
- [self calcBoundingBox];
- return self;
- }
-
- // Return the current translation of the ControlPoint by yanking the val ues
- // directly out of our transformation matrix.
- - trans:(RtFloat *)t
- {
- bcopy((char *)&transform[3][0],(char *)t,(3*sizeof(RtFloat)));
- return self;
- }
-
- // We need to implement calcBoundingBox in order for the control tools to be
- // able to select our points.
- - calcBoundingBox
- {
- // X Min and X Max
- boundingBox[0] = -RADIUS;
- boundingBox[1] = RADIUS;
-
- // Y Min and Y Max
- boundingBox[2] = -RADIUS;
- boundingBox[3] = RADIUS;
-
- // Z Min and Z Max
- boundingBox[4] = -RADIUS;
- boundingBox[5] = RADIUS;
- return self;
- }
-
- // doRenderSelf: is where we generate RIB for rendering. See Patch.m for
- // more details.
- - doRenderSelf: (Camera *) camera
- {
- RtFloat newFidel[2] = {4.0 , 2.0};
- RtInt fidel;
- RtFloat oldFidel[2];
-
- // If we are rendering to the screen then do it at a low resolution,
- // making to sure to store the Camera's current fidelity setting.
- if (NXDrawingStatus == NX_DRAWING) {
- fidel = [camera fidelity];
- oldFidel[0]=oldFidel[1]=fidel;
- [super doRenderSelf:camera];
- RiGeometricApproximation(RI_TESSELATION,RI_PARAMETRIC,
- (RtPointer)newFidel,RI_NULL);
- }
-
- // Draw our control point as a sphere
- RiSphere(RADIUS, -RADIUS, RADIUS, 360.0, RI_NULL);
-
- // Restore the Camera's settings
- if (NXDrawingStatus == NX_DRAWING) {
- RiGeometricApproximation(RI_TESSELATION,RI_PARAMETRIC,
- (RtPointer)oldFidel,RI_NULL);
- }
-
- return self;
- }