00001
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #ifndef NL_PS_ATTRIB_MAKER_BIN_OP_H
00027 #define NL_PS_ATTRIB_MAKER_BIN_OP_H
00028
00029 #include "nel/misc/types_nl.h"
00030 #include "ps_attrib_maker.h"
00031 #include "ps_plane_basis.h"
00032 #include "nel/misc/rgba.h"
00033 #include <memory>
00034
00035 namespace NL3D {
00036
00037
00039 struct CPSBinOp
00040 {
00041 enum BinOp
00042 {
00043 selectArg1 = 0,
00044 selectArg2,
00045 modulate,
00046 add,
00047 subtract,
00048 last
00049 };
00050 };
00051
00053 const uint PSBinOpBufSize = 1024;
00054
00063 template <class T> class CPSAttribMakerBinOp : public CPSAttribMaker<T>
00064 {
00065 public:
00067
00068
00072 CPSAttribMakerBinOp();
00073
00075 CPSAttribMakerBinOp(const CPSAttribMakerBinOp &other);
00076
00078 virtual ~CPSAttribMakerBinOp();
00079
00080
00081
00083
00085
00086 virtual T get (CPSLocated *loc, uint32 index);
00087 virtual void *make (CPSLocated *loc,
00088 uint32 startIndex,
00089 void *tab,
00090 uint32 stride,
00091 uint32 numAttrib,
00092 bool allowNoCopy = false,
00093 uint32 srcStep = (1 << 16)
00094 ) const;
00095
00096 virtual void make4 (CPSLocated *loc,
00097 uint32 startIndex,
00098 void *tab,
00099 uint32 stride,
00100 uint32 numAttrib,
00101 uint32 srcStep = (1 << 16)
00102 ) const;
00103
00104 virtual void makeN (CPSLocated *loc,
00105 uint32 startIndex,
00106 void *tab,
00107 uint32 stride,
00108 uint32 numAttrib,
00109 uint32 nbReplicate,
00110 uint32 srcStep = (1 << 16)
00111 ) const;
00112
00113 virtual void serial (NLMISC::IStream &f) throw(NLMISC::EStream);
00114 virtual void deleteElement (uint32 index);
00115 virtual void newElement (CPSLocated *emitterLocated, uint32 emitterIndex);
00116 virtual void resize (uint32 capacity, uint32 nbPresentElements);
00118
00120
00121
00125 void setArg(uint argNb, CPSAttribMaker<T> *arg)
00126 {
00127 nlassert(argNb < 2);
00128 delete _Arg[argNb];
00129 _Arg[argNb] = arg;
00130 if (arg->hasMemory())
00131 {
00132 arg->resize(_MaxSize, _Size);
00133 }
00134 }
00135
00139 CPSAttribMaker<T> *getArg(uint argNb)
00140 {
00141 nlassert(argNb < 2);
00142 return _Arg[argNb];
00143 }
00144
00148 const CPSAttribMaker<T> *getArg(uint argNb) const
00149 {
00150 nlassert(argNb < 2);
00151 return _Arg[argNb];
00152 }
00154
00156
00157
00160 void setOp(CPSBinOp::BinOp op)
00161 {
00162 nlassert(supportOp(op));
00163 _Op = op;
00164 }
00165
00167 bool supportOp(CPSBinOp::BinOp op) { return true; }
00168
00170 CPSBinOp::BinOp getOp(void) const { return _Op; }
00172
00173
00174 virtual T getMinValue(void) const { return T() ; }
00175 virtual T getMaxValue(void) const { return T() ; }
00176
00177 protected:
00178 void *makePrivate (T *buf1,
00179 T *buf2,
00180 CPSLocated *loc,
00181 uint32 startIndex,
00182 void *tab,
00183 uint32 stride,
00184 uint32 numAttrib,
00185 bool allowNoCopy = false,
00186 uint32 srcStep = (1 << 16)
00187 ) const;
00188
00189 void make4Private (T *buf1,
00190 T *buf2,
00191 CPSLocated *loc,
00192 uint32 startIndex,
00193 void *tab,
00194 uint32 stride,
00195 uint32 numAttrib,
00196 uint32 srcStep = (1 << 16)
00197 ) const;
00198
00199 void makeNPrivate (T *buf1,
00200 T *buf2,
00201 CPSLocated *loc,
00202 uint32 startIndex,
00203 void *tab,
00204 uint32 stride,
00205 uint32 numAttrib,
00206 uint32 nbReplicate,
00207 uint32 srcStep = (1 << 16)
00208 ) const;
00209
00210 CPSBinOp::BinOp _Op;
00211 CPSAttribMaker<T> *_Arg[2];
00212 void clean(void);
00213 uint32 _Size, _MaxSize;
00214 };
00215
00216
00217 }
00218
00219 #include "3d/ps_attrib_maker_bin_op_inline.h"
00220
00221
00222 #endif // NL_PS_ATTRIB_MAKER_BIN_OP_H
00223
00224