# Home    # nevrax.com   
Nevrax
Nevrax.org
#News
#Mailing-list
#Documentation
#CVS
#Bugs
#License
Docs
 
Documentation  
Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages   Search  

ps_attrib_maker_bin_op.h

Go to the documentation of this file.
00001 
00007 /* Copyright, 2001 Nevrax Ltd.
00008  *
00009  * This file is part of NEVRAX NEL.
00010  * NEVRAX NEL is free software; you can redistribute it and/or modify
00011  * it under the terms of the GNU General Public License as published by
00012  * the Free Software Foundation; either version 2, or (at your option)
00013  * any later version.
00014 
00015  * NEVRAX NEL is distributed in the hope that it will be useful, but
00016  * WITHOUT ANY WARRANTY; without even the implied warranty of
00017  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
00018  * General Public License for more details.
00019 
00020  * You should have received a copy of the GNU General Public License
00021  * along with NEVRAX NEL; see the file COPYING. If not, write to the
00022  * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
00023  * MA 02111-1307, USA.
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 protected:
00174         void   *makePrivate     (T *buf1,
00175                                                  T *buf2,
00176                                                  CPSLocated *loc,
00177                                                  uint32 startIndex,
00178                                                  void *tab,
00179                                                  uint32 stride,
00180                                                  uint32 numAttrib,
00181                                                  bool allowNoCopy = false,
00182                                                  uint32 srcStep = (1 << 16)
00183                                                 ) const;
00184         
00185         void    make4Private    (T *buf1,
00186                                                          T *buf2,
00187                                                          CPSLocated *loc,
00188                                                          uint32 startIndex,
00189                                                          void *tab,
00190                                                          uint32 stride,
00191                                                          uint32 numAttrib,
00192                                                          uint32 srcStep = (1 << 16)
00193                                                         ) const;
00194 
00195         void    makeNPrivate  (T *buf1,
00196                                                    T *buf2,
00197                                                    CPSLocated *loc,
00198                                                    uint32 startIndex,
00199                                                    void *tab,
00200                                                    uint32 stride,
00201                                                    uint32 numAttrib,
00202                                                    uint32 nbReplicate,
00203                                                    uint32 srcStep = (1 << 16)
00204                                                   ) const;
00205         
00206         CPSBinOp::BinOp   _Op; // the operator being used
00207         CPSAttribMaker<T> *_Arg[2]; // the arguments for the binary operator            
00208         void clean(void);       
00209         uint32 _Size, _MaxSize;
00210 };
00211 
00212 
00213 } // NL3D
00214 
00215 #include "3d/ps_attrib_maker_bin_op_inline.h"
00216 
00217 
00218 #endif // NL_PS_ATTRIB_MAKER_BIN_OP_H
00219 
00220 /* End of ps_attrib_maker_bin_op.h */