00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef __VRAY_Volume__
00020 #define __VRAY_Volume__
00021
00022 #include "VRAY_API.h"
00023 #include <SYS/SYS_Types.h>
00024
00025 template <class T> class UT_RefArray;
00026
00027
00028
00029 #include <UT/UT_VoxelArray.h>
00030
00031 class UT_StringArray;
00032 class UT_IntArray;
00033 class UT_FloatArray;
00034 class UT_BoundingBox;
00035 class UT_Vector3;
00036 class UT_Matrix4;
00037 class UT_Filter;
00038 class VEX_LateBinding;
00039 class GEO_Primitive;
00040 class GEO_Vertex;
00041 class VRAY_Octree;
00042
00043 class VRAY_API VRAY_Volume {
00044 public:
00045 VRAY_Volume();
00046 virtual ~VRAY_Volume();
00047
00048
00049
00050
00051 virtual GEO_Primitive *getGeoPrimitive() const { return 0; }
00052 virtual GEO_Vertex *getGeoVertex() const { return 0; }
00053
00054
00055
00056
00057 virtual void getXform(UT_Matrix4 &xform) const;
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071 virtual void getWeightedBoxes(UT_RefArray<UT_BoundingBox> &boxes,
00072 UT_FloatArray &weights,
00073 fpreal radius,
00074 fpreal dbound) const = 0;
00075
00076
00077
00078
00079
00080
00081 virtual void getAttributeBinding(UT_StringArray &names,
00082 UT_IntArray &sizes) const = 0;
00083
00084
00085
00086 virtual void evaluate(const UT_Vector3 &pos,
00087 const UT_Filter &filter,
00088 fpreal radius, fpreal time,
00089 int idx, fpreal *data) const = 0;
00090
00091
00092
00093
00094 virtual bool evaluateInterval(const UT_BoundingBox &box,
00095 const UT_Filter &filter,
00096 fpreal radius,
00097 fpreal time, int idx,
00098 fpreal *minval,
00099 fpreal *maxval) const
00100 {
00101 return false;
00102 }
00103
00104
00105
00106 virtual UT_Vector3 gradient(const UT_Vector3 &pos,
00107 const UT_Filter &filter,
00108 fpreal radius, fpreal time,
00109 int idx) const;
00110
00111
00112 virtual fpreal getGradientDelta() const { return 1e-3F; }
00113
00114
00115
00116 virtual int getNormalAttribute() const { return 0; }
00117
00118
00119 virtual fpreal getVoxelSize() const { return 0; }
00120
00121 public:
00122 void bumpRef(int dir)
00123 {
00124 myRefCount += dir;
00125 if (myRefCount == 0)
00126 delete this;
00127 }
00128
00129
00130 VRAY_Octree *getTree() const { return myTree; }
00131 void setTree(VRAY_Octree *tree) { myTree = tree; }
00132 VRAY_Octree *getDisplaceTree() const { return myTree; }
00133 void setDisplaceTree(VRAY_Octree *tree) { myTree = tree; }
00134
00135
00136 void fillBinding(VEX_LateBinding &bind) const;
00137
00138 protected:
00139
00140
00141 static void addVoxelBoxes(UT_VoxelArrayF &voxels,
00142 UT_RefArray<UT_BoundingBox> &boxes,
00143 UT_FloatArray &weights,
00144 fpreal radius, fpreal dbound);
00145
00146 private:
00147 VRAY_Octree *myTree;
00148 VRAY_Octree *myDisplaceTree;
00149 int myRefCount;
00150 };
00151
00152 #endif