# 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::CVegetable Class Reference

A vegetable descriptor. More...

#include <vegetable.h>

List of all members.

Density Angle Factor

enum  TAngleType { AngleGround = 0, AngleCeiling, AngleWall }
void setAngleGround (float cosAngleMin)
 set an Angle setup such that max density is when normal== K, and 0 density is when normalAngle= cosAngleMin. More...

void setAngleCeiling (float cosAngleMax)
 set an Angle setup such that max density is when normal= -K, and 0 density is when normalAngle= cosAngleMax. More...

void setAngleWall (float cosAngleMin, float cosAngleMax)
 set an Angle setup such that max density is when normal is at (cosAngleMin+cosAngleMax)/2, and 0 density is when cosAngle= one of the cosAngleMin or cosAngleMax. More...

float getCosAngleMin () const
float getCosAngleMax () const
TAngleType getAngleType () const

Public Types

enum  TVegetableWater { AboveWater = 0, UnderWater, IntersectWater, VegetInfoLast }
 Micro vegetation position against Water. Above water is the default. More...


Public Methods

 CVegetable ()
void registerToManager (CVegetableManager *manager)
 register the vegetable to the vegetable manager. More...

void generateGroup (const CVector &posInWorld, const CVector &surfaceNormal, float area, uint vegetSeed, std::vector< CVector2f > &instances) const
 generate a list of instance to create on a small ground element, according to density and noise. More...

void generateGroupBiLinear (const CVector &posInWorld, const CVector posInWorldBorder[4], const CVector &surfaceNormal, float area, uint vegetSeed, std::vector< CVector2f > &instances) const
void reserveIgAddInstances (CVegetableInstanceGroupReserve &vegetIgReserve, TVegetableWater vegetWaterState, uint numInstances) const
 Fast allocation reservation: you must call this before generating all your instances in an Ig: Add N instances of Vegetable to the reservation system. More...

void generateInstance (CVegetableInstanceGroup *ig, const NLMISC::CMatrix &posInWorld, const NLMISC::CRGBAF &modulateAmbientColor, const NLMISC::CRGBAF &modulateDiffuseColor, float blendDistMax, TVegetableWater vegetWaterState, CVegetableUV8 dlmUV) const
 posInWorld should be a matrix of position + rotation (typically for surface alignement). More...

void serial (NLMISC::IStream &f)

Public Attributes

std::string ShapeName
 Name of the shape to use. More...

CNoiseValue Density
 Density== Number of instance to create / mē. More...

float MaxDensity
 the maximum density computed. if <0, no maximum. -1 by default. More...

CNoiseValue Sxy
 Random Scale. More...

CNoiseValue Sz
 Random Scale. More...

CNoiseValue Rx
 Random Orientation. More...

CNoiseValue Ry
 Random Orientation. More...

CNoiseValue Rz
 Random Orientation. More...

CNoiseValue BendFactor
 Random Bend factor. More...

CNoiseValue BendPhase
 Random Bend Phase. More...

float BendFrequencyFactor
 Fixed Bend FrequencyFactor. NB: rounded during addInstance to the nearest NL3D_VEGETABLE_FREQUENCY_FACTOR_PREC. More...

CNoiseColorGradient Color
 The color to modulate the instance. More...

uint32 DistType
 At which distance this vegetable will be rendered. More...


Private Methods

void generateGroupEx (float nbInst, const CVector &posInWorld, const CVector &surfaceNormal, uint vegetSeed, std::vector< CVector2f > &instances) const
 Do the generateGroup, but take nbInst unmodulated by normal. More...


Static Private Methods

float easeInEaseOut (float x)

Private Attributes

float _CosAngleMin
 density is multiplied by a function f(cos angle with verticalVector), such that f(CosAngleMiddle)==1, and f(CosAngleMin)==f(CosAngleMax)== 0. More...

float _CosAngleMax
 density is multiplied by a function f(cos angle with verticalVector), such that f(CosAngleMiddle)==1, and f(CosAngleMin)==f(CosAngleMax)== 0. More...

float _CosAngleMiddle
 density is multiplied by a function f(cos angle with verticalVector), such that f(CosAngleMiddle)==1, and f(CosAngleMin)==f(CosAngleMax)== 0. More...

float _OOCosAngleDist
 density is multiplied by a function f(cos angle with verticalVector), such that f(CosAngleMiddle)==1, and f(CosAngleMin)==f(CosAngleMax)== 0. More...

TAngleType _AngleType
 angle type setuped with setAngleMin etc... More...

CVegetableManager_Manager
 the manager. More...

CVegetableShape_VegetableShape
 shape in the manager. More...


Detailed Description

A vegetable descriptor.

Author:
Lionel Berenguier , Nevrax France
Date:
2001

Definition at line 54 of file vegetable.h.


Member Enumeration Documentation

enum NL3D::CVegetable::TAngleType
 

Enumeration values:
AngleGround 
AngleCeiling 
AngleWall 

Definition at line 90 of file vegetable.h.

Referenced by getAngleType.

enum NL3D::CVegetable::TVegetableWater
 

Micro vegetation position against Water. Above water is the default.

Enumeration values:
AboveWater 
UnderWater 
IntersectWater 
VegetInfoLast 

Definition at line 58 of file vegetable.h.


Constructor & Destructor Documentation

NL3D::CVegetable::CVegetable  
 

Definition at line 48 of file vegetable.cpp.

References _Manager, BendFactor, BendFrequencyFactor, DistType, MaxDensity, Rx, Ry, Rz, setAngleGround, Sxy, and Sz.


Member Function Documentation

float NL3D::CVegetable::easeInEaseOut float    x [inline, static, private]
 

Definition at line 189 of file vegetable.h.

References x, and y.

Referenced by generateGroupBiLinear.

void NL3D::CVegetable::generateGroup const CVector &    posInWorld,
const CVector &    surfaceNormal,
float    area,
uint    vegetSeed,
std::vector< CVector2f > &    instances
const
 

generate a list of instance to create on a small ground element, according to density and noise.

result is a list of instance to create, with random 2d position. 2d position are in range [0..1]. caller should scale, or use it to compute real world position, and then use generateInstance() to really compute the instances.

Warning! Use OptFastFloor()! So call must be enclosed with a OptFastFloorBegin()/OptFastFloorEnd().

Parameters:
posInWorld  center (approx) of the surface which generate group of vegetable
surfaceNormal  UNIT up vector of the surface to compare with (0,0,1), to modulate density
area  area of the surface, to know number of elements to generate for this surface
vegetSeed  "random" value which Should be different for all vegetables in the same area. usefull if lot of different vegetable generated in same area: positions won't be generated at same place.
instances  the generated position of instances.

Definition at line 176 of file vegetable.cpp.

References Density, generateGroupEx, MaxDensity, and min.

void NL3D::CVegetable::generateGroupBiLinear const CVector &    posInWorld,
const CVector    posInWorldBorder[4],
const CVector &    surfaceNormal,
float    area,
uint    vegetSeed,
std::vector< CVector2f > &    instances
const
 

Definition at line 190 of file vegetable.cpp.

References Density, easeInEaseOut, generateGroupEx, MaxDensity, min, NL3D::RandomGenerator, x, and y.

void NL3D::CVegetable::generateGroupEx float    nbInst,
const CVector &    posInWorld,
const CVector &    surfaceNormal,
uint    vegetSeed,
std::vector< CVector2f > &    instances
const [private]
 

Do the generateGroup, but take nbInst unmodulated by normal.

Definition at line 132 of file vegetable.cpp.

References _CosAngleMiddle, _OOCosAngleDist, NL3D::OptFastFloor, NL3D::RandomGenerator, and NLMISC::sqr.

Referenced by generateGroup, and generateGroupBiLinear.

void NL3D::CVegetable::generateInstance CVegetableInstanceGroup   ig,
const NLMISC::CMatrix   posInWorld,
const NLMISC::CRGBAF   modulateAmbientColor,
const NLMISC::CRGBAF   modulateDiffuseColor,
float    blendDistMax,
TVegetableWater    vegetWaterState,
CVegetableUV8    dlmUV
const
 

posInWorld should be a matrix of position + rotation (typically for surface alignement).

FinalPos= posInWorld * noiseMatrix(scale/rot) FinalAmbientColor= vegetManager->Ambient * modulateAmbientColor * randomColor. FinalDiffuseColor= vegetManager->Diffuse * modulateDiffuseColor * randomColor. If instance is in AlphaBlend/ZSort, blendDistMax is the distance where the instance is invisible (alpha==0). instance is added to the manager, under the instance group ig. This one must have been generated by the VegetableManager.

Parameters:
dlmUV  is the dynamic lightmap UV for this vegetable.

Definition at line 306 of file vegetable.cpp.

References _Manager, _VegetableShape, BendFactor, BendFrequencyFactor, BendPhase, Color, NLMISC::CMatrix::getPos, nlassert, Rx, Ry, Rz, Sxy, and Sz.

TAngleType NL3D::CVegetable::getAngleType   const [inline]
 

Definition at line 109 of file vegetable.h.

References _AngleType, and TAngleType.

float NL3D::CVegetable::getCosAngleMax   const [inline]
 

Definition at line 108 of file vegetable.h.

References _CosAngleMax.

float NL3D::CVegetable::getCosAngleMin   const [inline]
 

Definition at line 107 of file vegetable.h.

References _CosAngleMin.

void NL3D::CVegetable::registerToManager CVegetableManager   manager
 

register the vegetable to the vegetable manager.

do it first. used by generateInstance(). Manager will load the shape needed for this vegetable.

Definition at line 123 of file vegetable.cpp.

References _Manager, _VegetableShape, nlassert, and ShapeName.

void NL3D::CVegetable::reserveIgAddInstances CVegetableInstanceGroupReserve   vegetIgReserve,
TVegetableWater    vegetWaterState,
uint    numInstances
const
 

Fast allocation reservation: you must call this before generating all your instances in an Ig: Add N instances of Vegetable to the reservation system.

Parameters:
numInstances  number of instances to generate (as "returned" by generateGroup()).
See also:
CVegetableManager::reserveIgCompile().

Definition at line 296 of file vegetable.cpp.

References _Manager, _VegetableShape, and nlassert.

void NL3D::CVegetable::serial NLMISC::IStream   f
 

Definition at line 367 of file vegetable.cpp.

References _AngleType, _CosAngleMax, _CosAngleMiddle, _CosAngleMin, _OOCosAngleDist, BendFactor, BendFrequencyFactor, BendPhase, Color, Density, DistType, MaxDensity, Rx, Ry, Rz, NLMISC::IStream::serial, NLMISC::IStream::serialEnum, NLMISC::IStream::serialVersion, ShapeName, Sxy, and Sz.

void NL3D::CVegetable::setAngleCeiling float    cosAngleMax
 

set an Angle setup such that max density is when normal= -K, and 0 density is when normalAngle= cosAngleMax.

Parameters:
cosAngleMinLimit  should be a cosinus angle between -1 and 1.

Definition at line 91 of file vegetable.cpp.

References _AngleType, _CosAngleMax, _CosAngleMiddle, _CosAngleMin, _OOCosAngleDist, and AngleCeiling.

void NL3D::CVegetable::setAngleGround float    cosAngleMin
 

set an Angle setup such that max density is when normal== K, and 0 density is when normalAngle= cosAngleMin.

Parameters:
cosAngleMinLimit  should be a cosinus angle between -1 and 1.

Definition at line 75 of file vegetable.cpp.

References _AngleType, _CosAngleMax, _CosAngleMiddle, _CosAngleMin, _OOCosAngleDist, and AngleGround.

Referenced by CVegetable.

void NL3D::CVegetable::setAngleWall float    cosAngleMin,
float    cosAngleMax
 

set an Angle setup such that max density is when normal is at (cosAngleMin+cosAngleMax)/2, and 0 density is when cosAngle= one of the cosAngleMin or cosAngleMax.

Definition at line 107 of file vegetable.cpp.

References _AngleType, _CosAngleMax, _CosAngleMiddle, _CosAngleMin, _OOCosAngleDist, and AngleWall.


Member Data Documentation

TAngleType NL3D::CVegetable::_AngleType [private]
 

angle type setuped with setAngleMin etc...

Definition at line 175 of file vegetable.h.

Referenced by getAngleType, serial, setAngleCeiling, setAngleGround, and setAngleWall.

float NL3D::CVegetable::_CosAngleMax [private]
 

density is multiplied by a function f(cos angle with verticalVector), such that f(CosAngleMiddle)==1, and f(CosAngleMin)==f(CosAngleMax)== 0.

Definition at line 173 of file vegetable.h.

Referenced by getCosAngleMax, serial, setAngleCeiling, setAngleGround, and setAngleWall.

float NL3D::CVegetable::_CosAngleMiddle [private]
 

density is multiplied by a function f(cos angle with verticalVector), such that f(CosAngleMiddle)==1, and f(CosAngleMin)==f(CosAngleMax)== 0.

Definition at line 173 of file vegetable.h.

Referenced by generateGroupEx, serial, setAngleCeiling, setAngleGround, and setAngleWall.

float NL3D::CVegetable::_CosAngleMin [private]
 

density is multiplied by a function f(cos angle with verticalVector), such that f(CosAngleMiddle)==1, and f(CosAngleMin)==f(CosAngleMax)== 0.

Definition at line 173 of file vegetable.h.

Referenced by getCosAngleMin, serial, setAngleCeiling, setAngleGround, and setAngleWall.

CVegetableManager* NL3D::CVegetable::_Manager [private]
 

the manager.

Definition at line 179 of file vegetable.h.

Referenced by CVegetable, generateInstance, registerToManager, and reserveIgAddInstances.

float NL3D::CVegetable::_OOCosAngleDist [private]
 

density is multiplied by a function f(cos angle with verticalVector), such that f(CosAngleMiddle)==1, and f(CosAngleMin)==f(CosAngleMax)== 0.

Definition at line 173 of file vegetable.h.

Referenced by generateGroupEx, serial, setAngleCeiling, setAngleGround, and setAngleWall.

CVegetableShape* NL3D::CVegetable::_VegetableShape [private]
 

shape in the manager.

Definition at line 181 of file vegetable.h.

Referenced by generateInstance, registerToManager, and reserveIgAddInstances.

CNoiseValue NL3D::CVegetable::BendFactor
 

Random Bend factor.

Definition at line 72 of file vegetable.h.

Referenced by CVegetable, generateInstance, and serial.

float NL3D::CVegetable::BendFrequencyFactor
 

Fixed Bend FrequencyFactor. NB: rounded during addInstance to the nearest NL3D_VEGETABLE_FREQUENCY_FACTOR_PREC.

Definition at line 76 of file vegetable.h.

Referenced by CVegetable, generateInstance, and serial.

CNoiseValue NL3D::CVegetable::BendPhase
 

Random Bend Phase.

Definition at line 74 of file vegetable.h.

Referenced by generateInstance, and serial.

CNoiseColorGradient NL3D::CVegetable::Color
 

The color to modulate the instance.

Definition at line 78 of file vegetable.h.

Referenced by generateInstance, and serial.

CNoiseValue NL3D::CVegetable::Density
 

Density== Number of instance to create / mē.

Definition at line 64 of file vegetable.h.

Referenced by generateGroup, generateGroupBiLinear, and serial.

uint32 NL3D::CVegetable::DistType
 

At which distance this vegetable will be rendered.

NB: DistType is not managed by CVegetableManager, but by user (eg CLandscape).

Definition at line 82 of file vegetable.h.

Referenced by CVegetable, and serial.

float NL3D::CVegetable::MaxDensity
 

the maximum density computed. if <0, no maximum. -1 by default.

Definition at line 66 of file vegetable.h.

Referenced by CVegetable, generateGroup, generateGroupBiLinear, and serial.

CNoiseValue NL3D::CVegetable::Rx
 

Random Orientation.

Definition at line 70 of file vegetable.h.

Referenced by CVegetable, generateInstance, and serial.

CNoiseValue NL3D::CVegetable::Ry
 

Random Orientation.

Definition at line 70 of file vegetable.h.

Referenced by CVegetable, generateInstance, and serial.

CNoiseValue NL3D::CVegetable::Rz
 

Random Orientation.

Definition at line 70 of file vegetable.h.

Referenced by CVegetable, generateInstance, and serial.

std::string NL3D::CVegetable::ShapeName
 

Name of the shape to use.

Definition at line 62 of file vegetable.h.

Referenced by registerToManager, and serial.

CNoiseValue NL3D::CVegetable::Sxy
 

Random Scale.

Definition at line 68 of file vegetable.h.

Referenced by CVegetable, generateInstance, and serial.

CNoiseValue NL3D::CVegetable::Sz
 

Random Scale.

Definition at line 68 of file vegetable.h.

Referenced by CVegetable, generateInstance, and serial.


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