# 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  

NL3D::CMeshVPPerPixelLight Class Reference

This vertex program is used to perform perpixel lighting with meshs. More...

#include <meshvp_per_pixel_light.h>

Inheritance diagram for NL3D::CMeshVPPerPixelLight:

NL3D::IMeshVertexProgram NLMISC::IStreamable NLMISC::CRefCount NLMISC::IClassable List of all members.

Public Methods

 CMeshVPPerPixelLight ()
IMeshVertexProgram implementation
virtual void initInstance (CMeshBaseInstance *mbi)
 Called at creation of an instance, to setup some information directly in the CMeshBaseInstance. More...

virtual bool begin (IDriver *drv, CScene *scene, CMeshBaseInstance *mbi, const NLMISC::CMatrix &invertedModelMat, const NLMISC::CVector &viewerPos)
 Called to setup constant / activate VertexProgram. More...

virtual void end (IDriver *drv)
 Typically disable the VertexProgram, or do some uninit. More...

virtual void serial (NLMISC::IStream &f) throw (NLMISC::EStream)
virtual void setupForMaterial (const CMaterial &mat, IDriver *drv, CScene *scene, CVertexBuffer *vb)
 Setup this shader for the given material. More...

virtual void setupForMaterial (const CMaterial &mat, IDriver *drv, CScene *scene, IVertexBufferHard *vb)
 The same as setupForMaterial, but with a hard vb. More...

virtual bool needTangentSpace () const
 NLMISC_DECLARE_CLASS (CMeshVPPerPixelLight)

Public Attributes

bool SpecularLighting
 true if want Specular Lighting. More...


Private Types

enum  { NumVp = 8 }

Private Methods

void enable (bool enabled, IDriver *drv)
virtual bool setupForMaterial (const CMaterial &mat, IDriver *drv, CScene *scene)

Private Attributes

bool _Enabled
bool _IsPointLight

Static Private Attributes

std::auto_ptr< CVertexProgram_VertexProgram [NumVp]

Detailed Description

This vertex program is used to perform perpixel lighting with meshs.

Its ouputs are :

Coord Tex 0 : duplicate the tex Coord 0 set from the v.b. Coord Tex 1 : The light vector in tangent space. Coord Tex 2 : The half-angle vector in tangent space.

This is designed to work with material that got a 'PerPixelLighting' shader. Note that no bump is used with this shader.

It requires that the input mesh has its tangent space first column vector encoded in the 2nd texture coordinate. Other stages are not supported for now.

Note that this can be mixed with gouraud rendered light (the gouraud diffuse and specular component are still computed)

Author:
Nicolas Vizerie , Nevrax France
Date:
2002

Definition at line 58 of file meshvp_per_pixel_light.h.


Member Enumeration Documentation

anonymous enum [private]
 

Enumeration values:
NumVp 

Definition at line 99 of file meshvp_per_pixel_light.h.


Constructor & Destructor Documentation

NL3D::CMeshVPPerPixelLight::CMeshVPPerPixelLight   [inline]
 

Definition at line 64 of file meshvp_per_pixel_light.h.

References _Enabled, and SpecularLighting.


Member Function Documentation

bool NL3D::CMeshVPPerPixelLight::begin IDriver   drv,
CScene   scene,
CMeshBaseInstance   mbi,
const NLMISC::CMatrix   invertedModelMat,
const NLMISC::CVector   viewerPos
[virtual]
 

Called to setup constant / activate VertexProgram.

(called before activate of the VB). The result tells wether the vertex program will be used in the given context. If this is the case, a call to setupMaterial must be done for each material being rendered with this V.P. After all primitive have been rendered, end() must be called.

Parameters:
drv  driver where to setup VP.
scene  retrieve some useFull scene info (windPower, time ...)
mbi  the mesh instance to retrieve some instance setup.
mat  the matrix to use (may not be the one of mbi)
viewerPos  position of the viewer in world space.

Implements NL3D::IMeshVertexProgram.

Definition at line 433 of file meshvp_per_pixel_light.cpp.

References _IsPointLight, enable, NLMISC::CMatrix::mulVector, and SpecularLighting.

void NL3D::CMeshVPPerPixelLight::enable bool    enabled,
IDriver   drv
[private]
 

Definition at line 517 of file meshvp_per_pixel_light.cpp.

References _Enabled, _IsPointLight, _VertexProgram, nlassert, and SpecularLighting.

Referenced by begin, end, and setupForMaterial.

void NL3D::CMeshVPPerPixelLight::end IDriver   drv [virtual]
 

Typically disable the VertexProgram, or do some uninit.

Implements NL3D::IMeshVertexProgram.

Definition at line 502 of file meshvp_per_pixel_light.cpp.

References enable.

void NL3D::CMeshVPPerPixelLight::initInstance CMeshBaseInstance   mbi [virtual]
 

Called at creation of an instance, to setup some information directly in the CMeshBaseInstance.

Implements NL3D::IMeshVertexProgram.

Definition at line 371 of file meshvp_per_pixel_light.cpp.

References _VertexProgram, nlassert, nlwarning, NumVp, CVPParser::parse, NL3D::PPLightingDirectionnalNoSpecVPCodeBegin, NL3D::PPLightingDirectionnalNoSpecVPNormalizeCodeBegin, NL3D::PPLightingDirectionnalVPCodeBegin, NL3D::PPLightingDirectionnalVPNormalizeCodeBegin, NL3D::PPLightingNoSpecVPCodeBegin, NL3D::PPLightingVPCodeBegin, NL3D::PPLightingVPCodeEnd, NL3D::PPLightingVPNormalizeCodeBegin, NL3D::PPLightingVPNormalizeNoSpecCodeBegin, and CVPParser::TProgram.

virtual bool NL3D::CMeshVPPerPixelLight::needTangentSpace   const [inline, virtual]
 

Reimplemented from NL3D::IMeshVertexProgram.

Definition at line 84 of file meshvp_per_pixel_light.h.

NL3D::CMeshVPPerPixelLight::NLMISC_DECLARE_CLASS CMeshVPPerPixelLight   
 

void NL3D::CMeshVPPerPixelLight::serial NLMISC::IStream   f throw (NLMISC::EStream) [virtual]
 

Implements NLMISC::IStreamable.

Definition at line 509 of file meshvp_per_pixel_light.cpp.

bool NL3D::CMeshVPPerPixelLight::setupForMaterial const CMaterial   mat,
IDriver   drv,
CScene   scene
[private, virtual]
 

Definition at line 544 of file meshvp_per_pixel_light.cpp.

References _Enabled, and enable.

void NL3D::CMeshVPPerPixelLight::setupForMaterial const CMaterial   mat,
IDriver   drv,
CScene   scene,
IVertexBufferHard   vb
[virtual]
 

The same as setupForMaterial, but with a hard vb.

Implements NL3D::IMeshVertexProgram.

Definition at line 577 of file meshvp_per_pixel_light.cpp.

References setupForMaterial.

void NL3D::CMeshVPPerPixelLight::setupForMaterial const CMaterial   mat,
IDriver   drv,
CScene   scene,
CVertexBuffer   vb
[virtual]
 

Setup this shader for the given material.

This may disable the shader if necessary. This is why the vertex buffer is needed : when disabling the v.p we may need to reactivate it

Implements NL3D::IMeshVertexProgram.

Definition at line 564 of file meshvp_per_pixel_light.cpp.

Referenced by setupForMaterial.


Member Data Documentation

bool NL3D::CMeshVPPerPixelLight::_Enabled [private]
 

Definition at line 96 of file meshvp_per_pixel_light.h.

Referenced by CMeshVPPerPixelLight, enable, and setupForMaterial.

bool NL3D::CMeshVPPerPixelLight::_IsPointLight [private]
 

Definition at line 97 of file meshvp_per_pixel_light.h.

Referenced by begin, and enable.

std::auto_ptr< CVertexProgram > NL3D::CMeshVPPerPixelLight::_VertexProgram [static, private]
 

Definition at line 44 of file meshvp_per_pixel_light.cpp.

Referenced by enable, and initInstance.

bool NL3D::CMeshVPPerPixelLight::SpecularLighting
 

true if want Specular Lighting.

Definition at line 62 of file meshvp_per_pixel_light.h.

Referenced by begin, CMeshVPPerPixelLight, and enable.


The documentation for this class was generated from the following files: