home *** CD-ROM | disk | FTP | other *** search
/ Stone Design / Stone Design.iso / Stone_Friends / Wave / WavesWorld / Source / IBPalettes / WW3DKit / RIBMotionBegin.m < prev    next >
Encoding:
Text File  |  1995-03-22  |  2.1 KB  |  122 lines

  1. // copyright 1993 Michael B. Johnson; some portions copyright 1994, MIT
  2. // see COPYRIGHT for reuse legalities
  3. //
  4.  
  5. #import "RIBMotionBegin.h"
  6.  
  7. @implementation RIBMotionBegin
  8.  
  9.  
  10. + initialize { return [RIBMotionBegin setVersion:1], self; }
  11.  
  12. - init
  13. {
  14.   [super init];
  15.  
  16.   nTimes = 0;
  17.   times = NULL;
  18.   
  19.   return self;
  20. }
  21.  
  22. - awake
  23. {
  24.   [super awake];
  25.  
  26.   nTimes = 0;
  27.   times = NULL;
  28.   
  29.   return self;
  30.  
  31. }
  32.  
  33. - free
  34. {
  35.   if (nTimes) {  free(times); }
  36.   return [super free];
  37. }
  38.  
  39. - setNTimes:(RtInt)newNTimes timeVector:(RtFloat *)timeVector
  40. {
  41.   nTimes = newNTimes;
  42.   times = timeVector;
  43.   return self;
  44. }
  45.  
  46. - (RtInt)nTimes { return nTimes; }
  47. - (float *)times { return times; }
  48.  
  49. - renderSelf:(WW3DCamera *)camera startingAt:(RtFloat)shutterOpenTime endingAt:(RtFloat)shutterCloseTime
  50. {
  51.   RiMotionBeginV(n, times);
  52.  
  53.   return self;
  54. }
  55.  
  56. - (unsigned long int)maxSampleBandwidth {  return ([super maxSampleBandwidth] + (unsigned long int)(sizeof(RtInt) + (nTimes * sizeof(RtFloat)))); }
  57.  
  58.  
  59. - writeEve:(NXStream *)stream atTabLevel:(int)tab
  60. {
  61.    int  i;
  62.  
  63.  
  64.    for (i = 0; i < tab; i++)
  65.    {  NXPrintf(stream, "\t");
  66.    }
  67.    NXPrintf(stream, "MotionBegin {"); 
  68.    for (i = 0; i < nTimes; i++)
  69.    {  NXPrintf(stream, "%f ", times[i]);
  70.    }
  71.    NXPrintf(stream, "};"); 
  72.    return self;
  73. }
  74.  
  75. #define typeVector "d"
  76. #define typeValues &nTimes
  77.  
  78. - read:(NXTypedStream*)stream 
  79. {
  80.     int version, i;
  81.     [super read:stream];
  82.  
  83.     version = NXTypedStreamClassVersion(stream,"RIBMotionBegin");
  84.     if (version == 0) NXReadTypes(stream, "i", &version), version=1;
  85.     if (version == 1)
  86.     {  NXReadTypes(stream, typeVector, typeValues);
  87.        if (nTimes)
  88.        {  times = (float *)malloc(sizeof(float)*nTimes);
  89.           for (i = 0; i < nTimes; i++)
  90.           NXReadTypes(stream, "f", times[i]);
  91.        }
  92.        else
  93.        {  times = NULL;
  94.        }
  95.     } 
  96.     else 
  97.     {
  98.     }
  99.     return self;
  100. }
  101.  
  102. - write:(NXTypedStream*)stream 
  103. {
  104.     int  i;
  105.  
  106.  
  107.     [super write:stream];
  108.  
  109.     NXWriteTypes(stream, typeVector, typeValues);
  110.     if (nTimes)
  111.     {  for (i = 0; i < nTimes; i++)
  112.        NXWriteTypes(stream, "f", times[i]);
  113.     }
  114.     else
  115.     {  times = NULL;
  116.     }
  117.  
  118.     return self;
  119. }
  120.  
  121. @end
  122.