home *** CD-ROM | disk | FTP | other *** search
/ NeXTSTEP 3.2 (Developer) / NS_dev_3.2.iso / NextDeveloper / Headers / 3Dkit / N3DShape.h < prev    next >
Text File  |  1993-01-08  |  4KB  |  149 lines

  1. /*
  2.     Copyright (c) 1991, 1992 by NeXT Computer, Inc as an unpublished work.
  3.     All rights reserved.
  4. */
  5.  
  6. #import <objc/Object.h>
  7. #import <ri/ri.h>
  8. #import <ri/slo.h>
  9. #import <appkit/graphics.h>
  10. #import "next3d.h"
  11.  
  12. @class N3DCamera;
  13.  
  14. typedef struct {
  15.     char    id[6];    /* self, encoded to 6 non-0 bytes */
  16.     char    name;    /* optional visible name */
  17. } N3DShapeName;
  18.  
  19. /* flags for CTM and inverse dirty bits */
  20. #define N3D_BOTH_CLEAN        0
  21. #define N3D_CTM_DIRTY        1
  22. #define N3D_CTM_INVERSE_DIRTY    2
  23. #define N3D_CTM_BOTH_DIRTY    3
  24.  
  25. @interface N3DShape : Object
  26. {
  27.     RtMatrix    transform; /* The matrix that's catenated at this node */
  28.     RtMatrix    compositeTransform; /* The CTM */
  29.     RtMatrix    inverseCompositeTransform; /* The CTM^-1 */
  30.     RtBound    boundingBox;    /* bounds in 3D */
  31.     N3DShapeName *shapeName;
  32.     N3DSurfaceType surfaceType;
  33.  
  34.     /* Pointers to each kind of shader available */
  35.     id        surfaceShader;
  36.     id        displacementShader;
  37.     id        lightShader;
  38.     id        imagerShader;
  39.     id        volumeShader;
  40.     id        transformationShader;
  41.     
  42.  
  43.     struct {
  44.     unsigned int    selectable:1; /* can you select this N3DShape? */
  45.     unsigned int    visible:1; /* self and descendants are invisible */
  46.     unsigned int    ancestorChanged:1; /* need to update bounds, etc. */
  47.     unsigned int    compositeDirty:2; /* flags for CTM & inverse */
  48.     unsigned int    drawAsBox:1; /* draw the bbox */
  49.     unsigned int    isInstance:1; /* is this an instance of another? */
  50.     unsigned int    hasShader:1; /* are there any shaders? */
  51.     unsigned int    _emitTransform:1;
  52.     unsigned int    _emitSurfaceType:1;
  53.     unsigned int    filler:24;
  54.     } shapeFlags;
  55.  
  56.     /* The following are links to other DAGNodes.  Really the DAG allows
  57.        traversal to a nextPeer or descendant; the prev and ancestor pointers
  58.        are here for back-linking.
  59.      */
  60.     id        nextPeer;
  61.     id        previousPeer;  /* back link */
  62.     id        descendant;
  63.     id        ancestor;  /* back link */
  64.     
  65.     id        renderDelegate; /* set if this Object is an instance */
  66.     
  67.     void    *_CTMRel;
  68.     char    *_rnm;
  69.     void    *_N3Dprivate;
  70. }
  71.  
  72. - init;
  73.  
  74. - linkPeer:aPeer;
  75. - nextPeer;
  76. - previousPeer;
  77. - firstPeer;
  78. - lastPeer;
  79.  
  80. - linkDescendant:aDescendant;
  81. - descendant;
  82. - lastDescendant;
  83.  
  84. - linkAncestor:anAncestor;
  85. - ancestor;
  86. - firstAncestor;
  87.  
  88. - unlink;
  89. - group:toShape;
  90. - ungroup;
  91.  
  92. - (BOOL)isWorld;
  93.  
  94. - setSurfaceType:(N3DSurfaceType)surfaceType andDescendants:(BOOL)flag;
  95. - (N3DSurfaceType)surfaceType;
  96.  
  97. - setShader:aShader;
  98. - shaderType:(SLO_TYPE)type;
  99.  
  100. - getBoundingBox:(RtBound *)bbox;
  101. - setDrawAsBox:(BOOL)flag;
  102. - (BOOL)doesDrawAsBox;
  103. - getBounds:(NXRect *)sRect inCamera:camera;
  104. - convertObjectPoints:(RtPoint *)points count:(int)n toCamera:camera;
  105. - convertPoints:(RtPoint *)points count:(int)n fromAncestor:(N3DShape *)aShape;
  106. - convertPoints:(RtPoint *)points count:(int)n toAncestor:(N3DShape *)aShape;
  107.  
  108. - setSelectable:(BOOL)flag;
  109. - (BOOL)isSelectable;
  110. - setVisible:(BOOL)flag;
  111. - (BOOL)isVisible;
  112.  
  113. - setShapeName:(const char *)aName;
  114. - (const char *)shapeName;
  115.  
  116. - setRenderDelegate:anObject;
  117. - removeRenderDelegate;
  118. - renderDelegate;
  119.  
  120. - setTransformMatrix:(RtMatrix)tm;
  121. - getTransformMatrix:(RtMatrix)tm;
  122. - concatTransformMatrix:(RtMatrix)ctm premultiply:(BOOL)flag;
  123. - getCompositeTransformMatrix:(RtMatrix)ctm
  124.     relativeToAncestor:(N3DShape *)aShape;
  125. - getInverseCompositeTransformMatrix:(RtMatrix)ictm
  126.     relativeToAncestor:(N3DShape *)aShape;
  127.  
  128. - rotateAngle:(float)ang axis:(RtPoint)anAxis;
  129. - preRotateAngle:(float)ang axis:(RtPoint)anAxis;
  130. - scale:(float)sx :(float)sy :(float)sz;
  131. - preScale:(float)sx :(float)sy :(float)sz;
  132. - scaleUniformly:(float)s;
  133. - preScaleUniformly:(float)s;
  134. - translate:(float)tx :(float)ty :(float)tz;
  135. - preTranslate:(float)tx :(float)ty :(float)tz;
  136.  
  137. - render:(N3DCamera *)camera;
  138. - renderSelf:(N3DCamera *)camera;
  139. - renderSelfAsBox:(N3DCamera *)camera;
  140.  
  141. - free;
  142. - freeAll;
  143.  
  144. - awake;
  145. - read:(NXTypedStream *)stream;
  146. - write:(NXTypedStream *)stream;
  147.  
  148. @end
  149.