00001
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #ifndef NL_MESHVP_PER_PIXEL_LIGHT_H
00027 #define NL_MESHVP_PER_PIXEL_LIGHT_H
00028
00029 #include "nel/misc/types_nl.h"
00030 #include "3d/mesh_vertex_program.h"
00031 #include "3d/vertex_program.h"
00032
00033
00034 #include <memory>
00035
00036
00037 namespace NL3D {
00038
00039
00058 class CMeshVPPerPixelLight : public IMeshVertexProgram
00059 {
00060 public:
00062 bool SpecularLighting;
00063 public:
00064 CMeshVPPerPixelLight() : SpecularLighting(true), _Enabled(false) {}
00066
00067 virtual void initInstance(CMeshBaseInstance *mbi);
00068 virtual bool begin(IDriver *drv,
00069 CScene *scene,
00070 CMeshBaseInstance *mbi,
00071 const NLMISC::CMatrix &invertedModelMat,
00072 const NLMISC::CVector &viewerPos);
00073 virtual void end(IDriver *drv);
00074 virtual void serial(NLMISC::IStream &f) throw(NLMISC::EStream);
00075 virtual void setupForMaterial(const CMaterial &mat,
00076 IDriver *drv,
00077 CScene *scene,
00078 CVertexBuffer *vb
00079 );
00080 virtual void setupForMaterial(const CMaterial &mat,
00081 IDriver *drv,
00082 CScene *scene,
00083 IVertexBufferHard *vb);
00084 virtual bool needTangentSpace() const { return true; }
00085 NLMISC_DECLARE_CLASS(CMeshVPPerPixelLight);
00086
00087 private:
00088
00089 void enable(bool enabled, IDriver *drv);
00090 private:
00091
00092 virtual bool setupForMaterial(const CMaterial &mat,
00093 IDriver *drv,
00094 CScene *scene
00095 );
00096 bool _Enabled;
00097 bool _IsPointLight;
00098
00099 enum { NumVp = 8};
00100 static std::auto_ptr<CVertexProgram> _VertexProgram[NumVp];
00101 };
00102
00103 }
00104
00105
00106 #endif // NL_MESHVP_PER_PIXEL_LIGHT_H
00107
00108