CWindStateMgr class
The CWindStateMgr class is declared and defined in Include/SpeedTree/Core/SpeedTreeWind.h.
Read time 3 minutesLast updated 2 hours ago
As highlighted in yellow in the figure below, feeds state information into a wind-enabled vertex shader through shader constants. The state is defined by an artist in the Modeler application when the wind behavior is tuned.
CWindStateMgr
CWindStateMgrCWindStateMgrSWindInputRuntimeSdk::m_sStatem_sStateSWindStateRuntimeSdkInclude/SpeedTree/Core/SpeedTreeWind.hstruct SWindBranchStateRuntimeSdk{ float3 m_vNoisePosTurbulence; float m_fIndependence; float m_fBend; float m_fOscillation; float m_fTurbulence; float m_fFlexibility;};struct SWindRippleStateRuntimeSdk{ float3 m_vNoisePosTurbulence; float m_fIndependence; float m_fPlanar; float m_fDirectional; float m_fFlexibility; float m_fShimmer;};struct SWindStateRuntimeSdk{ float3 m_vWindDirection; float m_fWindStrength; float3 m_vBoundingBoxMin; float m_fSharedHeightStart; float3 m_vBoundingBoxMax; float m_fBranch1StretchLimit; SWindBranchStateRuntimeSdk m_sShared; SWindBranchStateRuntimeSdk m_sBranch1; SWindBranchStateRuntimeSdk m_sBranch2; SWindRippleStateRuntimeSdk m_sRipple; float m_fBranch2StretchLimit;};
Initialization
Each instantiation of a object (which represents a base tree model) has its own object. has a series of overloading functions, one of which takes a . contains all of the wind behavior parameters set by the artist in the Modeler. When an .stsdk file is loaded via , the object embedded in that object is automatically initialized with the -related data embedded in the .stsdk file.
CCoreCWindStateMgrCWindStateMgrConfigure()SConfigRuntimeSdkSConfigRuntimeSdkCCore::LoadTree()CWindStateMgrCCoreSConfigRuntimeSdkThe relationship between and is that contains a complete definition of the wind profile set in the Modeler whereas houses the data the wind shader functions need at a particular snapshot in time.
SConfigRuntimeSdkSWindStateRuntimeSdkSConfigRuntimeSdkSWindStateRuntimeSdkForest library wind functions
The class provides convenience functions for controlling the wind for a set of base trees without having to access each tree separately. The functions include the following:
CForestFunction | Description |
|---|---|
| This is an initialization-level function and shouldn't be called to enable/disable the wind while the rendering loop is active. If wind is to be supported, call this function once during initialization. |
| Advances the wind simulation for all of the base tree objects in the forest. The second parameter, time, is in seconds and represents time since the beginning of the simulation, not the time since the last call or frame. Not free in terms of CPU but not expensive. |
| A convenience function for bypassing the start-up state of the wind simulation. It's common to use a 10-second or so pre-roll. |
| Updates the strength of all of the base trees in the forest. |
| Updates the direction of all of the base trees in the forest. |
You can still set an individual base tree's wind parameters by querying the object of a and setting its parameters directly. All of the instances of a share this wind object. Each will have its own slight variation of the wind, as provided by the wind shader's usage of the tree's position as a unique numerical identifier. However, all of the wind parameters set for the base tree in the Modeler application will remain the same across all its instances.
CWindCTreeCTree