This is Kitchen.m in view mode; [Download] [Up]
/* Kitchen.m - Model for simple kitchen * Copyright (C) 1993 Corona Design, Inc. All rights reserved. * * Abstract * This model shows a simple kitchen with a counter * and a bookcase on the wall. * * RCS path: * $Source: /Users/pkron/Projects/voxel/Pyramid/RCS/Kitchen.m,v $ * Modified: $Date: 93/09/15 12:35:00 $ by $Author: pkron $ * Current State: $State: Exp $ locked by $Locker: $ */ #import "Kitchen.h" #import "SpatialView.h" static void pointCopy( POINT *a, POINT *b) { (*a)[0] = (*b)[0]; (*a)[1] = (*b)[1]; (*a)[2] = (*b)[2]; (*a)[3] = (*b)[3]; } @implementation Kitchen // utility routine to draw a line // to a point in space - drawLineTo: (POINT *)aPoint { // map and project the point first map( transform, aPoint); project( aPoint); PSlineto( (*aPoint)[0], (*aPoint)[1]); return( self); } #define LIGHT_BROWN 127./255, 63./255, 19./255 #define MEDIUM_BROWN 102./255, 51./255, 15./255 #define BROWN 77./255, 39./255, 12./255 #define DARK_BROWN 46./255, 23./255, 7./255 #define GRAY 102./255, 102./255, 102./255 #define LIGHT_GRAY 153./255, 153./255, 153./255 #define DARK_GRAY 50./255, 50./255, 50./255 - drawModel: (MATRIX)aTransform : (NXRect *)clip; { POINT distance; counterWidth = 1.0, counterDepth = .4; counterHeight = .3; shelfOriginY = .1, shelfOriginZ = .4, shelfHeight = .2; shelfWidth = .1, shelfDepth = .9; transform = aTransform; // X infinity distance[0] = -1000; distance[1] = 0; distance[2] = 0; distance[3] = 1; map( transform, &distance); project( &distance); // draw horizon PSmoveto( -10, distance[1] + .5); PSrlineto( 20, 0); PSsetlinewidth( 1); PSsetrgbcolor( 0, 1, 1); PSstroke(); PSsetrgbcolor( GRAY); // DK Brown [self drawPlane: 0 : 0 : 0 width: counterWidth : 0 : counterHeight]; PSsetrgbcolor( DARK_GRAY); [self drawPlane: counterWidth : 0 : 0 width: 0 : counterDepth : counterHeight]; PSsetrgbcolor( LIGHT_GRAY); [self drawPlane: 0 : 0 : counterHeight width: counterWidth : counterDepth : 0]; PSsetrgbcolor( MEDIUM_BROWN); [self drawPlane: 0 : shelfOriginY + shelfDepth : shelfOriginZ width: shelfWidth : 0 : shelfHeight]; PSsetrgbcolor( DARK_BROWN); [self drawPlane: 0 : shelfOriginY : shelfOriginZ width: shelfWidth : shelfDepth : 0]; PSsetrgbcolor( DARK_BROWN); [self drawPlane: 0 : shelfOriginY : shelfOriginZ width: 0 : shelfDepth : shelfHeight]; PSsetrgbcolor( LIGHT_BROWN); [self drawPlane: 0 : shelfOriginY : shelfOriginZ + shelfHeight width: shelfWidth : shelfDepth : 0]; PSsetrgbcolor( MEDIUM_BROWN); [self drawPlane: 0 : shelfOriginY : shelfOriginZ width: shelfWidth : 0 : shelfHeight]; return( self); } // draw lines from key points // to infinite axis points - drawVanishingPoints: (MATRIX)aTransform : (NXRect *)clip; { POINT distance; POINT aPoint; // X infinity distance[0] = -1000; distance[1] = 0; distance[2] = 0; distance[3] = 1; map( transform, &distance); project( &distance); aPoint[0] = 0; aPoint[1] = 0; aPoint[2] = 0; aPoint[3] = 1; PSmoveto( distance[0], distance[1]); [self drawLineTo: &aPoint]; aPoint[0] = 0; aPoint[1] = counterDepth; aPoint[2] = counterHeight; aPoint[3] = 1; PSmoveto( distance[0], distance[1]); [self drawLineTo: &aPoint]; aPoint[0] = 0; aPoint[1] = 0; aPoint[2] = counterHeight; aPoint[3] = 1; PSmoveto( distance[0], distance[1]); [self drawLineTo: &aPoint]; aPoint[0] = 0; aPoint[1] = shelfOriginY; aPoint[2] = shelfOriginZ; aPoint[3] = 1; PSmoveto( distance[0], distance[1]); [self drawLineTo: &aPoint]; aPoint[0] = 0; aPoint[1] = shelfOriginY; aPoint[2] = shelfOriginZ + shelfHeight; aPoint[3] = 1; PSmoveto( distance[0], distance[1]); [self drawLineTo: &aPoint]; PSsetrgbcolor( 1, 0, 0); PSsetlinewidth(0); PSstroke(); // Y infinity distance[0] = 0; distance[1] = 1000; distance[2] = 0; distance[3] = 1; map( transform, &distance); project( &distance); aPoint[0] = counterWidth; aPoint[1] = counterDepth; aPoint[2] = 0; aPoint[3] = 1; PSmoveto( distance[0], distance[1]); [self drawLineTo: &aPoint]; aPoint[0] = counterWidth; aPoint[1] = counterDepth; aPoint[2] = counterHeight; aPoint[3] = 1; PSmoveto( distance[0], distance[1]); [self drawLineTo: &aPoint]; aPoint[0] = 0; aPoint[1] = shelfOriginY + shelfDepth; aPoint[2] = shelfOriginZ; aPoint[3] = 1; PSmoveto( distance[0], distance[1]); [self drawLineTo: &aPoint]; aPoint[0] = 0; aPoint[1] = shelfOriginY + shelfDepth; aPoint[2] = shelfOriginZ + shelfHeight; aPoint[3] = 1; PSmoveto( distance[0], distance[1]); [self drawLineTo: &aPoint]; aPoint[0] = shelfWidth; aPoint[1] = shelfOriginY + shelfDepth; aPoint[2] = shelfOriginZ; aPoint[3] = 1; PSmoveto( distance[0], distance[1]); [self drawLineTo: &aPoint]; PSsetrgbcolor( 1, 0, 0); PSsetlinewidth(0); PSstroke(); return( self); } // draw a spatial plane, given // its origin in 3-space and // the widths of its dimensions // (One width must be 0) - drawPlane: (float)x : (float)y : (float)z width: (float)wx :(float)wy : (float)wz { POINT space; POINT mapped; space[0] = x; space[1] = y; space[2] = z; space[3] = 1; pointCopy( &mapped, &space); map( transform, &mapped); project( &mapped); PSmoveto( mapped[0], mapped[1]); pointCopy( &mapped, &space); if ( wx EQ 0.0 ) { mapped[1] += wy; [self drawLineTo: &mapped]; pointCopy( &mapped, &space); mapped[1] += wy; mapped[2] += wz; [self drawLineTo: &mapped]; pointCopy( &mapped, &space); mapped[2] += wz; [self drawLineTo: &mapped]; } else if ( wy EQ 0.0 ) { mapped[0] += wx; [self drawLineTo: &mapped]; pointCopy( &mapped, &space); mapped[0] += wx; mapped[2] += wz; [self drawLineTo: &mapped]; pointCopy( &mapped, &space); mapped[2] += wz; [self drawLineTo: &mapped]; } else { mapped[0] += wx; [self drawLineTo: &mapped]; pointCopy( &mapped, &space); mapped[0] += wx; mapped[1] += wy; [self drawLineTo: &mapped]; pointCopy( &mapped, &space); mapped[1] += wy; [self drawLineTo: &mapped]; } PSclosepath(); PSfill(); return( self); } @end #ifdef _LOG /* * $Log: Kitchen.m,v $ Revision 1.1 93/09/15 12:35:00 pkron Created. */ #endif
These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.