|
|
|
|
Documentation |
|
Main Page Namespace List Class Hierarchy Alphabetical List Compound List File List Namespace Members Compound Members File Members Related Pages Search
NL3D::CRenderTrav Class ReferenceThe Render traversal.
More...
#include <render_trav.h>
Inheritance diagram for NL3D::CRenderTrav:
List of all members.
Render Lighting Setup. FOR OBSERVERS ONLY. |
enum | { MaxVPLight = 4
} |
void | resetLightSetup () |
| reset the lighting setup in the driver (all lights are disabled). More...
|
void | changeLightSetup (CLightContribution *lightContribution, bool useLocalAttenuation) |
| setup the driver to the given lightContribution. More...
|
void | beginVPLightSetup (uint ctStart, bool supportSpecular, const CMatrix &invObjectWM) |
| setup the driver VP constants to get info from current LightSetup. More...
|
void | changeVPLightSetupMaterial (const CMaterial &mat, bool excludeStrongest) |
| change the driver VP LightSetup constants which depends on material. More...
|
const CLight & | getDriverLight (sint index) const |
| This returns a reference to a driver light, by its index. More...
|
sint | getStrongestLightIndex () const |
| return an index to the current strongest settuped light (or -1 if there's none). More...
|
void | getStrongestLightColors (NLMISC::CRGBA &diffuse, NLMISC::CRGBA &specular) |
| Get current color, diffuse and specular of the strongest light in the scene. More...
|
uint | getNumVPLights () const |
| return the number of VP lights currently activated (sunlight included) Value correct after beginVPLightSetup() only. More...
|
std::string | getLightVPFragment (uint numActivePointLights, uint ctStart, bool supportSpecular, bool normalize) |
| tool to get a VP fragment which compute lighting with following rules: IN: R5 vertex in objectSpace (ie untransformed) R6 normal in objectSpace (ie untransformed) OUT: R6 normal normalized o[COL0] and o[COL1] are setuped. More...
|
Render Lighting Setup. |
void | setSunDirection (const CVector &dir) |
const CVector | getSunDirection () const |
bool | LightingSystemEnabled |
NLMISC::CRGBA | AmbientGlobal |
NLMISC::CRGBA | SunAmbient |
NLMISC::CRGBA | SunDiffuse |
NLMISC::CRGBA | SunSpecular |
Public Types |
Public Methods |
| CRenderTrav () |
| Constructor. More...
|
void | setDriver (IDriver *drv) |
IDriver * | getDriver () |
void | setViewport (const CViewport &viewport) |
CViewport | getViewport () const |
bool | isCurrentPassOpaque () |
void | setLayersRenderingOrder (bool directOrder=true) |
| Set the order or rendering for transparent objects. More...
|
bool | getLayersRenderingOrder () const |
void | setMeshSkinManager (CMeshSkinManager *msm) |
| Set/Replace the MeshSkinManager. More...
|
CMeshSkinManager * | getMeshSkinManager () const |
| get the MeshSkinManager. More...
|
|
IObs * | createDefaultObs () const |
| This method must create a default observer for this traversal. More...
|
NLMISC::CClassId | getClassId () const |
| This function must return the Unique Ident for this traversal class. More...
|
sint | getRenderOrder () const |
| Return the order of the traversal. More...
|
void | traverse () |
| First traverse the root (if any), then render the render list. More...
|
|
void | clearRenderList () |
| Clear the list of rendered observers. More...
|
void | addRenderObs (IBaseRenderObs *o) |
| Add an observer to the list of rendered observers. More...
|
Public Attributes |
|
CMeshBlockManager | MeshBlockManager |
| The manager of meshBlock. Used to add instances. More...
|
Private Attributes |
std::vector< IBaseRenderObs * > | RenderList |
COrderingTable< IBaseRenderObs > | OrderOpaqueList |
CLayeredOrderingTable< IBaseRenderObs > | OrderTransparentList |
IDriver * | Driver |
CViewport | _Viewport |
bool | _CurrentPassOpaque |
bool | _LayersRenderingOrder |
CMeshSkinManager * | _MeshSkinManager |
| The manager of skin. NULL by default. More...
|
|
CLightContribution * | _CacheLightContribution |
bool | _LastLocalAttenuation |
uint | _NumLightEnabled |
uint | _LastSunFactor |
NLMISC::CRGBA | _LastSunAmbient |
CPointLight * | _LastPointLight [NL3D_MAX_LIGHT_CONTRIBUTION] |
uint8 | _LastPointLightFactor [NL3D_MAX_LIGHT_CONTRIBUTION] |
bool | _LastPointLightLocalAttenuation [NL3D_MAX_LIGHT_CONTRIBUTION] |
CVector | _SunDirection |
CLight | _DriverLight [NL3D_MAX_LIGHT_CONTRIBUTION+1] |
uint | _StrongestLightIndex |
bool | _StrongestLightTouched |
uint | _VPCurrentCtStart |
uint | _VPNumLights |
bool | _VPSupportSpecular |
NLMISC::CRGBAF | _VPFinalAmbient |
NLMISC::CRGBAF | _VPLightDiffuse [MaxVPLight] |
NLMISC::CRGBAF | _VPLightSpecular [MaxVPLight] |
NLMISC::CRGBA | _StrongestLightDiffuse |
NLMISC::CRGBA | _StrongestLightSpecular |
bool | _VPMaterialCacheDirty |
uint32 | _VPMaterialCacheEmissive |
uint32 | _VPMaterialCacheAmbient |
uint32 | _VPMaterialCacheDiffuse |
uint32 | _VPMaterialCacheSpecular |
float | _VPMaterialCacheShininess |
Detailed Description
The Render traversal.
The purpose of this traversal is to render a list of models. This traversals is tightly linked to the cliptraversal. The clipTraversals insert directly the observers with CRenderTrav::addRenderObs(obs). The traverse() method should render all the render observer with IDriver.
This traversal is an exception since it is not designed to have a graph of observers. But this behavior is permitted, and the root (if any) is traversed.
USER RULES: Before using traverse() on a render traversal, you should:
NB: see CScene for 3d conventions (orthonormal basis...)
-
See also:
-
CScene IBaseRenderObs
-
Author:
-
Lionel Berenguier , Nevrax France
-
Date:
-
2000
Definition at line 88 of file render_trav.h.
Member Enumeration Documentation
Constructor & Destructor Documentation
NL3D::CRenderTrav::CRenderTrav |
( |
|
) |
|
|
|
Constructor.
Definition at line 60 of file render_trav.cpp.
References _CacheLightContribution, _CurrentPassOpaque, _LayersRenderingOrder, _MeshSkinManager, _StrongestLightTouched, _SunDirection, AmbientGlobal, Driver, LightingSystemEnabled, OrderOpaqueList, OrderTransparentList, RenderList, SunAmbient, SunDiffuse, and SunSpecular. |
Member Function Documentation
|
Add an observer to the list of rendered observers.
DOESN'T CHECK if already inserted. NB: only CTransform renderObs can be inserted!! asserted in the render() method
Definition at line 263 of file render_trav.cpp.
References RenderList. |
void NL3D::CRenderTrav::beginVPLightSetup |
( |
uint |
ctStart, |
|
|
bool |
supportSpecular, |
|
|
const CMatrix & |
invObjectWM |
|
) |
|
|
|
setup the driver VP constants to get info from current LightSetup.
Only 0..3 Light + SunLights are supported. The VP do NOT support distance/Spot attenuation Also it does not handle World Matrix with non uniform scale correctly since lighting is made in ObjectSpace -
Parameters:
-
ctStart |
the program use ctes from ctStart to ctStart+NumCtes. |
supportSpecular |
asitsounds. PointLights and dirLight are localViewer |
invObjectWM |
the inverse of object matrix: lights are mul by this. Vp compute in object space. |
Definition at line 525 of file render_trav.cpp.
References _DriverLight, _NumLightEnabled, _VPCurrentCtStart, _VPFinalAmbient, _VPLightDiffuse, _VPLightSpecular, _VPMaterialCacheDirty, _VPNumLights, _VPSupportSpecular, AmbientGlobal, NL3D::ITravCameraScene::CamPos, Driver, MaxVPLight, min, and nlassert. |
void NL3D::CRenderTrav::changeLightSetup |
( |
CLightContribution * |
lightContribution, |
|
|
bool |
useLocalAttenuation |
|
) |
|
|
|
setup the driver to the given lightContribution.
if lightContribution==NULL, then all currently enabled lights are disabled. NB: lightContribution is cached, so if same than preceding, no-op. cache cleared at each frame with resetLightSetup(). NB: models which are sticked or skinned on a skeleton have same lightContribution because lightSetup is made on the skeleton only. Hence the interest of this cache. -
Parameters:
-
useLocalAttenuation |
if true, use Hardware Attenuation, else use global one (attenuation with AttFactor) |
Definition at line 360 of file render_trav.cpp.
References _CacheLightContribution, _DriverLight, _LastLocalAttenuation, _LastPointLight, _LastPointLightFactor, _LastPointLightLocalAttenuation, _LastSunAmbient, _LastSunFactor, _NumLightEnabled, _StrongestLightTouched, _SunDirection, NLMISC::CRGBA::A, Driver, LightingSystemEnabled, NLMISC::CRGBA::modulateFromuiRGBOnly, NL3D_MAX_LIGHT_CONTRIBUTION, SunAmbient, SunDiffuse, and SunSpecular. |
void NL3D::CRenderTrav::changeVPLightSetupMaterial |
( |
const CMaterial & |
mat, |
|
|
bool |
excludeStrongest |
|
) |
|
|
|
change the driver VP LightSetup constants which depends on material.
-
Parameters:
-
excludeStrongest |
This remove the strongest light from the setup. The typical use is to have it computed by using perpixel lighting. |
Definition at line 621 of file render_trav.cpp.
References _StrongestLightDiffuse, _StrongestLightSpecular, _VPCurrentCtStart, _VPFinalAmbient, _VPLightDiffuse, _VPLightSpecular, _VPMaterialCacheAmbient, _VPMaterialCacheDiffuse, _VPMaterialCacheDirty, _VPMaterialCacheEmissive, _VPMaterialCacheShininess, _VPMaterialCacheSpecular, _VPNumLights, _VPSupportSpecular, NLMISC::CRGBAF::A, Driver, getStrongestLightIndex, and NLMISC::CRGBA::set. |
void NL3D::CRenderTrav::clearRenderList |
( |
|
) |
|
|
IObs * NL3D::CRenderTrav::createDefaultObs |
( |
|
) |
const [virtual] |
|
|
This method must create a default observer for this traversal.
Any model which doesn't provide (by registerObs() or by inheritance) an observer for this view will be linked with this default observer.
Implements NL3D::ITrav.
Definition at line 85 of file render_trav.cpp. |
|
This function must return the Unique Ident for this traversal class.
Implements NL3D::ITrav.
Definition at line 98 of file render_trav.h. |
IDriver* NL3D::CRenderTrav::getDriver |
( |
void |
|
) |
[inline] |
|
const CLight& NL3D::CRenderTrav::getDriverLight |
( |
sint |
index |
) |
const [inline] |
|
bool NL3D::CRenderTrav::getLayersRenderingOrder |
( |
|
) |
const [inline] |
|
std::string NL3D::CRenderTrav::getLightVPFragment |
( |
uint |
numActivePointLights, |
|
|
uint |
ctStart, |
|
|
bool |
supportSpecular, |
|
|
bool |
normalize |
|
) |
[static] |
|
|
tool to get a VP fragment which compute lighting with following rules: IN: R5 vertex in objectSpace (ie untransformed) R6 normal in objectSpace (ie untransformed) OUT: R6 normal normalized o[COL0] and o[COL1] are setuped.
- * - * - * - NB: BF0 and BF1 not computed/setuped. Scratch:
For information, constant mapping is (add ctStart):
== Strongest light included ==
if !supportSpecular:
- 0: AmbientColor.
- 1..4: DiffuseColor of 4 lights.
- 5: - (directional Light direction) in objectSpace
- 6..8: light position (3 pointLihgts) in objectSpace
- 9: material Diffuse Alpha copied to output. cte is: {0,0, 1, alphaMat} TOTAL: 10 constants used. if supportSpecular:
- 0: AmbientColor.
- 1..4: DiffuseColor of 4 lights.
- 5..8: SpecularColor of 4 lights. NB: SpecularColor[5].w get the specular exponent of the material
- 9: - (directional Light direction) in objectSpace
- 10: material Diffuse Alpha copied to output. cte is: {0,0, 1, alphaMat}
- 11: eye position in objectSpace
- 12..14: light position (3 pointLihgts) in objectSpace TOTAL: 15 constants used.
NB: the number of active light does not change the number of constantes used. But the VP code returned is modified accordingly.-
Parameters:
-
numActivePoinLights |
tells how many point light from 0 to 3 this VP must handle. NB: the Sun directionnal is not option NB: nlassert(numActiveLights<=MaxVPLight-1). |
Definition at line 932 of file render_trav.cpp.
References NL3D::LightingVPFragmentNormalize, NL3D::LightingVPFragmentNoSpecular_Begin, NL3D::LightingVPFragmentNoSpecular_End, NL3D::LightingVPFragmentNoSpecular_PL, NL3D::LightingVPFragmentSpecular_Begin, NL3D::LightingVPFragmentSpecular_End, NL3D::LightingVPFragmentSpecular_PL, MaxVPLight, nlassert, and NL3D::strReplaceAll. |
uint NL3D::CRenderTrav::getNumVPLights |
( |
|
) |
const [inline] |
|
sint NL3D::CRenderTrav::getRenderOrder |
( |
|
) |
const [inline, virtual] |
|
|
Return the order of the traversal.
This is usefull for CScene::render() method. It indicate when the traversal is called. Order for basic traversal are:
Implements NL3D::ITravScene.
Definition at line 99 of file render_trav.h. |
sint NL3D::CRenderTrav::getStrongestLightIndex |
( |
|
) |
const |
|
|
return an index to the current strongest settuped light (or -1 if there's none).
Definition at line 729 of file render_trav.cpp.
References _NumLightEnabled, _StrongestLightTouched, _VPLightDiffuse, _VPLightSpecular, NLMISC::CRGBAF::A, NLMISC::CRGBAF::B, NLMISC::CRGBAF::G, MaxVPLight, min, and NLMISC::CRGBAF::R.
Referenced by changeVPLightSetupMaterial, and getStrongestLightColors. |
const CVector NL3D::CRenderTrav::getSunDirection |
( |
|
) |
const [inline] |
|
CViewport NL3D::CRenderTrav::getViewport |
( |
|
) |
const [inline] |
|
bool NL3D::CRenderTrav::isCurrentPassOpaque |
( |
|
) |
[inline] |
|
void NL3D::CRenderTrav::resetLightSetup |
( |
|
) |
|
|
|
reset the lighting setup in the driver (all lights are disabled).
called at begining of traverse(). Must be called by any model (before and after rendering) that wish to use CDriver::setLight() instead of the standard behavior with changeLightSetup()
Definition at line 292 of file render_trav.cpp.
References _CacheLightContribution, _DriverLight, _LastPointLight, _LastSunAmbient, _LastSunFactor, _NumLightEnabled, _StrongestLightTouched, _SunDirection, AmbientGlobal, Driver, LightingSystemEnabled, NL3D_MAX_LIGHT_CONTRIBUTION, and NLMISC::CRGBA::set.
Referenced by traverse. |
void NL3D::CRenderTrav::setDriver |
( |
IDriver * |
drv |
) |
[inline] |
|
void NL3D::CRenderTrav::setLayersRenderingOrder |
( |
bool |
directOrder = true |
) |
[inline] |
|
|
Set the order or rendering for transparent objects.
In real case, with direct order, we have:
- Underwater is rendered.
- Water is rendered.
- Objects above water are rendered.
Definition at line 137 of file render_trav.h.
References _LayersRenderingOrder. |
|
Set/Replace the MeshSkinManager.
NULL by default => skinning is slower. The ptr is handled but not deleted. There should be one MeshSkinManager per driver.
Definition at line 278 of file render_trav.cpp.
References _MeshSkinManager. |
void NL3D::CRenderTrav::setSunDirection |
( |
const CVector & |
dir |
) |
|
|
void NL3D::CRenderTrav::setViewport |
( |
const CViewport & |
viewport |
) |
[inline] |
|
void NL3D::CRenderTrav::traverse |
( |
|
) |
[virtual] |
|
|
First traverse the root (if any), then render the render list.
NB: no Driver clear buffers (color or ZBuffer) are done.... -
Warning:
-
If an observer exist both in the graph and in the render list, it will be effectively traversed twice.
Implements NL3D::ITravScene.
Definition at line 90 of file render_trav.cpp.
References _CurrentPassOpaque, _LayersRenderingOrder, _MeshSkinManager, _Viewport, NL3D::ITravCameraScene::Bottom, NL3D::ITravCameraScene::CamPos, Driver, NL3D::ITravCameraScene::Far, getDriver, H_AUTO, NL3D::ITravCameraScene::Left, MeshBlockManager, min, NL3D::ITravCameraScene::Near, NL3D_MESH_SKIN_MANAGER_MAXVERTICES, NL3D_MESH_SKIN_MANAGER_VERTEXFORMAT, NL3D::OptFastFloor, NL3D::OptFastFloorBegin, NL3D::OptFastFloorEnd, OrderOpaqueList, OrderTransparentList, NL3D::ITravCameraScene::Perspective, RenderList, resetLightSetup, NL3D::ITravCameraScene::Right, NL3D::ITrav::Root, NL3D::ITravScene::Scene, NL3D::ITravCameraScene::Top, and NL3D::ITravCameraScene::ViewMatrix. |
Member Data Documentation
bool NL3D::CRenderTrav::_CurrentPassOpaque [private]
|
|
CLight NL3D::CRenderTrav::_DriverLight[NL3D_MAX_LIGHT_CONTRIBUTION+1] [private]
|
|
bool NL3D::CRenderTrav::_LastLocalAttenuation [private]
|
|
CPointLight* NL3D::CRenderTrav::_LastPointLight[NL3D_MAX_LIGHT_CONTRIBUTION] [private]
|
|
uint8 NL3D::CRenderTrav::_LastPointLightFactor[NL3D_MAX_LIGHT_CONTRIBUTION] [private]
|
|
bool NL3D::CRenderTrav::_LastPointLightLocalAttenuation[NL3D_MAX_LIGHT_CONTRIBUTION] [private]
|
|
uint NL3D::CRenderTrav::_LastSunFactor [private]
|
|
bool NL3D::CRenderTrav::_LayersRenderingOrder [private]
|
|
uint NL3D::CRenderTrav::_NumLightEnabled [private]
|
|
NLMISC::CRGBA NL3D::CRenderTrav::_StrongestLightDiffuse [private]
|
|
uint NL3D::CRenderTrav::_StrongestLightIndex [private]
|
|
NLMISC::CRGBA NL3D::CRenderTrav::_StrongestLightSpecular [private]
|
|
bool NL3D::CRenderTrav::_StrongestLightTouched [private]
|
|
CVector NL3D::CRenderTrav::_SunDirection [private]
|
|
CViewport NL3D::CRenderTrav::_Viewport [private]
|
|
uint NL3D::CRenderTrav::_VPCurrentCtStart [private]
|
|
NLMISC::CRGBAF NL3D::CRenderTrav::_VPLightDiffuse[MaxVPLight] [private]
|
|
NLMISC::CRGBAF NL3D::CRenderTrav::_VPLightSpecular[MaxVPLight] [private]
|
|
uint32 NL3D::CRenderTrav::_VPMaterialCacheAmbient [private]
|
|
uint32 NL3D::CRenderTrav::_VPMaterialCacheDiffuse [private]
|
|
bool NL3D::CRenderTrav::_VPMaterialCacheDirty [private]
|
|
uint32 NL3D::CRenderTrav::_VPMaterialCacheEmissive [private]
|
|
float NL3D::CRenderTrav::_VPMaterialCacheShininess [private]
|
|
uint32 NL3D::CRenderTrav::_VPMaterialCacheSpecular [private]
|
|
uint NL3D::CRenderTrav::_VPNumLights [private]
|
|
bool NL3D::CRenderTrav::_VPSupportSpecular [private]
|
|
IDriver* NL3D::CRenderTrav::Driver [private]
|
|
bool NL3D::CRenderTrav::LightingSystemEnabled
|
|
The documentation for this class was generated from the following files:
|
|