00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef __GEO_IORib_h__
00022 #define __GEO_IORib_h__
00023
00024 #include "GEO_API.h"
00025 #include "GEO_IOTranslator.h"
00026 #include "GEO_IORibExt.h"
00027
00028 #include <UT/UT_BitArray.h>
00029 #include <UT/UT_IntArray.h>
00030 #include <UT/UT_PtrArray.h>
00031
00032 class GEO_Detail;
00033 class GEO_Primitive;
00034 class GEO_PrimPoly;
00035 class GEO_PointRefArray;
00036 class GEO_Vertex;
00037 class GEO_IORibXlate;
00038 class GEO_IORibPrinter;
00039 class GEO_PrimParticle;
00040 class GB_PrimitiveGroup;
00041 class UT_Matrix4;
00042 class TS_MetaExpression;
00043 class TS_MetaPrimitive;
00044
00045 #define GEO_RIB_MAX_SEGMENTS 5
00046
00047 class GEO_API GEO_IORib : public GEO_IOTranslator {
00048 public:
00049 GEO_IORib();
00050 virtual ~GEO_IORib();
00051
00052 virtual const char *formatName() const;
00053
00054 virtual int checkExtension(const char *name);
00055 virtual int checkMagicNumber(unsigned magic);
00056
00057 virtual int fileSave(const GEO_Detail *gdp, ostream &);
00058 virtual bool fileLoad(GEO_Detail *, UT_IStream &, int);
00059
00060
00061
00062 void setMBGeo(const GEO_Detail *gdp) { myGdps[1] = gdp; }
00063
00064 void addMBGeo(const GEO_Detail *gdp);
00065 void setMBParticle(int onoff) { myBlurParticle = onoff; }
00066 void setOutputPrimGroup( const GB_PrimitiveGroup *grp )
00067 {
00068 myOutPrimGroup = grp;
00069 }
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079 void setVersion(const char *renderer,
00080 int major=3, int minor=6)
00081 {
00082 myExtensions.setRenderer(renderer, major, minor);
00083 }
00084
00085
00086
00087 void setForIFD(int onoff=1) { myIFDFlag = onoff; }
00088
00089 void setCurveBasis(const char *basis);
00090 void setPolySubdivide(int on);
00091 void setPoints(int on, float size=1);
00092
00093
00094 void setShutterSpeed(float shutter=1)
00095 {
00096 myShutterTime = shutter;
00097 }
00098
00099
00100
00101 static void outputQuadricAttributes(GEO_IORibPrinter &,
00102 const GEO_Primitive *, const GEO_Vertex *,
00103 int dup = 4, float pscale = 1);
00104
00105 static int outputParticleAttributes(GEO_IORibPrinter &out,
00106 const GEO_PrimParticle *part,
00107 float pscale=1, int dup=1,
00108 int allow_N=0);
00109
00110 private:
00111 int isBlurred() const { return myGdps[1] != 0; }
00112 int hasExtension(int ext)
00113 {
00114 return myExtensions.hasExtension(ext);
00115 }
00116
00117 const GEO_Detail *myGdps[GEO_RIB_MAX_SEGMENTS];
00118 int mySegments;
00119 int ptVel;
00120 int myBlurParticle;
00121
00122 unsigned myGeoFlag;
00123 float myPointSize;
00124 float myShutterTime;
00125
00126 const GB_PrimitiveGroup *myOutPrimGroup;
00127
00128 #if 0
00129 int myParticleIndex;
00130 UT_PtrArray<GEO_Detail*> *myParticleDetails;
00131 UT_PtrArray<GEO_Detail*> *myParticleMBDetails;
00132 #endif
00133
00134 void outputPolysAttrib(GEO_IORibPrinter &, const GEO_Detail *,
00135 const UT_BitArray &, const GEO_IORibXlate *,
00136 const UT_IntArray *group);
00137 void outputBlobbyAttrib(GEO_IORibPrinter &, const GEO_Detail *,
00138 const GEO_IORibXlate *,
00139 UT_PtrArray<TS_MetaPrimitive *> &prims);
00140 void outputCurvesAttrib(GEO_IORibPrinter &, const GEO_Detail *,
00141 const GEO_IORibXlate *,
00142 const char *curve_interp,
00143 int curve_step);
00144
00145 void outputParticleLinePosition(GEO_IORibPrinter &out,
00146 const GEO_PrimParticle *part,
00147 int veloff, float vscale);
00148 void outputMatrix (GEO_IORibPrinter &out, const UT_Matrix4 &xform);
00149 void outputBlobbies(GEO_IORibPrinter &out, int nblobs,
00150 const GEO_Detail *gdp);
00151 int outputPolys(GEO_IORibPrinter &out, const GEO_Detail *gdp);
00152 void outputSubDivs(GEO_IORibPrinter &out);
00153 void outputSubDivGroup(GEO_IORibPrinter &out,
00154 const GEO_Detail *gdp,
00155 UT_IntArray &group,
00156 const GEO_PointRefArray &ptRefArray,
00157 bool first_time);
00158 int outputPolyCurves(GEO_IORibPrinter &out, const GEO_Detail *gdp,
00159 const char *curve_interp, int curve_step);
00160 void outputNURBSCurves(GEO_IORibPrinter &out, const GEO_Detail *gdp);
00161 void outputMesh (GEO_IORibPrinter &out, const GEO_Primitive *prim);
00162 void outputNURBS (GEO_IORibPrinter &out, const GEO_Primitive *prim);
00163 void outputBezier (GEO_IORibPrinter &out, const GEO_Primitive *prim);
00164 void outputSphere (GEO_IORibPrinter &out, const GEO_Primitive *p[]);
00165 void outputTube (GEO_IORibPrinter &out, const GEO_Primitive *p[]);
00166 void outputCircle (GEO_IORibPrinter &out, const GEO_Primitive *p[]);
00167 void outputPoints (GEO_IORibPrinter &out, const GEO_Detail *gdp);
00168 void outputParticles(GEO_IORibPrinter &out,
00169 const GEO_Primitive *prim);
00170 void outputParticlePoints(GEO_IORibPrinter &out,
00171 const GEO_PrimParticle *part,
00172 int veloff, float vscale, float pscale);
00173 void outputParticleLines(GEO_IORibPrinter &out,
00174 const GEO_PrimParticle *part,
00175 float pscale);
00176
00177 int isOutputPrim( const GEO_Primitive *prim );
00178
00179
00180 static void outputExpressionBlobbies(GEO_IORibPrinter &out,
00181 const TS_MetaExpression *expr,
00182 int &floatAddr, int &exprNum);
00183
00184 GEO_IORibExt myExtensions;
00185 UT_PtrArray<GEO_IORibXlate *> myTranslators;
00186
00187 int myIFDFlag;
00188 };
00189
00190
00191 class GEO_API GEO_IORibPrinter {
00192 public:
00193 GEO_IORibPrinter(ostream &os);
00194 ~GEO_IORibPrinter();
00195
00196 void print(const char *fmt, ...);
00197 void print(const UT_Matrix4 &mat);
00198
00199 ostream &getStream();
00200 void flush();
00201 private:
00202 static const int theBufferSize;
00203 static const int theBlockSize;
00204
00205 ostream &myStream;
00206 unsigned mySize;
00207 unsigned myLineLen;
00208 char *myFreeStart;
00209 char *myFileBuffer;
00210 };
00211
00212
00213 #endif