📄 tsshapeinstance.h
字号:
Vector<TSThread*> mTransitionThreads;
/// @name Transition nodes
/// keep track of nodes that are involved in a transition
///
/// @note this only tracks nodes we're transitioning from...
/// nodes we're transitioning to are implicitly handled
/// (i.e., we don't need to keep track of them)
/// @{
TSIntegerSet mTransitionRotationNodes;
TSIntegerSet mTransitionTranslationNodes;
TSIntegerSet mTransitionScaleNodes;
/// @}
/// keep track of nodes with animation restrictions put on them
TSIntegerSet mMaskRotationNodes;
TSIntegerSet mMaskPosXNodes;
TSIntegerSet mMaskPosYNodes;
TSIntegerSet mMaskPosZNodes;
TSIntegerSet mDisableBlendNodes;
TSIntegerSet mHandsOffNodes; ///< Nodes that aren't animated through threads automatically
TSIntegerSet mCallbackNodes;
/// state variables
U32 mTriggerStates;
bool initGround();
void addPath(TSThread * gt, F32 start, F32 end, MatrixF * mat = NULL);
/// @name Render functions
/// @{
void setupTexturing(S32 dl, F32 intraDL);
bool twoPassEnvironmentMap();
bool twoPassDetailMap();
bool twoPassFog();
void renderEnvironmentMap();
void renderDetailMap();
void renderFog();
/// @}
/// @name DirectX render functions
/// @{
bool renderMeshesX(S32 ss, S32 od);
bool renderDecalsX(S32 ss, S32 od);
///@}
// skin modifier
/// @name skin modifier
/// @{
struct SkinModifier
{
StringTableEntry skinName;
TextureHandle hModTexture;
TextureHandle hBakTexture;
U32 nBakIndex;
};
SkinModifier mSkinModifiers[MaxSkinModifiers];
TextureHandle getSkinTexutre(StringTableEntry baseSkinName, StringTableEntry skinName);
/// @}
public:
bool fillVB();
TSShape* getShape() { return mShape; }
/// @name Statics
/// set non-rendering static variables used for accessing shape data
/// @{
void setStatics(S32 dl = 0, F32 interDL = 0.0f, const Point3F * shapeScale = NULL);
void clearStatics();
/// @}
TSMaterialList* getMaterialList() { return mMaterialList; }
void setMaterialList(TSMaterialList*); ///< we won't own the material list unless we clone it (see below)
void cloneMaterialList(); ///< call this to own the material list -- i.e., we'll make a copy of the currently
///< set material list and be responsible for deleting it...if we don't own the list,
///< then the application better not delete the set list out from under us (all this
///< is handled automatically when using the shape's original list).
bool ownMaterialList() const { return mOwnMaterialList; }
void reSkin(StringHandle& newBaseHandle);
// skin modifier
/// @name skin modifier
/// @{
void addSkinModifier(U32 slot, StringTableEntry skinName, StringTableEntry printName);
void removeSkinModifier(U32 slot);
void clearSkinModifiers();
void updateModifiers();
void updateModifier(U32 slot/*, TextureHandle* pTexture=NULL*/);
void updateModifier(StringTableEntry skinName/*, TextureHandle* pTexture=NULL*/);
TextureHandle getShapeSkinTexture(StringTableEntry skinName,U32* pRet=NULL);
/// @}
enum
{
MaskNodeRotation = 0x01,
MaskNodePosX = 0x02,
MaskNodePosY = 0x04,
MaskNodePosZ = 0x08,
MaskNodeBlend = 0x10,
MaskNodeAll = MaskNodeRotation|MaskNodePosX|MaskNodePosY|MaskNodePosZ|MaskNodeBlend,
MaskNodeAllButBlend = MaskNodeRotation|MaskNodePosX|MaskNodePosY|MaskNodePosZ,
MaskNodeAllButRotation = MaskNodePosX|MaskNodePosY|MaskNodePosZ|MaskNodeBlend,
MaskNodeAllButPosX = MaskNodeRotation|MaskNodePosY|MaskNodePosZ|MaskNodeBlend,
MaskNodeAllButPosY = MaskNodeRotation|MaskNodePosX|MaskNodePosZ|MaskNodeBlend,
MaskNodeAllButPosZ = MaskNodeRotation|MaskNodePosX|MaskNodePosY|MaskNodeBlend,
MaskNodeHandsOff = 0x20, ///< meaning, don't even set to default, programmer controls it (blend still applies)
MaskNodeCallback = 0x40 ///< meaning, get local transform via callback function (see setCallback)
///< callback data2 is node index, callback return value is pointer to local transform
///< Note: won't get this callback everytime you animate...application responsibility
///< to make sure matrix pointer continues to point to valid and updated local transform
};
/// @name Node Masking
/// set node masking...
/// @{
void setNodeAnimationState(S32 nodeIndex, U32 animationState);
U32 getNodeAnimationState(S32 nodeIndex);
/// @}
/// @name Trigger states
/// check trigger value
/// @{
bool getTriggerState(U32 stateNum, bool clearState = true);
void setTriggerState(U32 stateNum, bool on);
void setTriggerStateBit(U32 stateBit, bool on);
/// @}
/// @name Callback Functions
/// @{
typedef void (*CallbackFunction)(TSShapeInstance*, MatrixF*, S32 node, U32 data);
CallbackFunction mCallback;
U32 mCallbackData;
void setCallback(CallbackFunction cb, U32 data1) { mCallback = cb; mCallbackData = data1; }
/// @}
/// @name Debris Management
/// @{
void incDebrisRefCount();
void decDebrisRefCount();
U32 getDebrisRefCount();
/// @}
/// @name AlphaAlways
/// AlphaAlways allows the entire model to become translucent at the same value
/// @{
void setAlphaAlways(F32 value) { mAlphaAlways = (value<0.99f); mAlphaAlwaysValue = value; }
F32 getAlphaAlwaysValue() { return mAlphaAlways ? mAlphaAlwaysValue : 1.0f; }
bool getAlphaAlways() { return mAlphaAlways; }
/// @}
/// @name Ballooning
/// Blow up the model
/// @{
void setShapeBalloon(F32 value) { mBalloonShape = value > 1; mBalloonValue = value; }
F32 getBalloonValue() const { return mBalloonShape ? mBalloonValue : 1.0f; }
/// @}
/// @name Override Texture
/// @{
void setOverrideTexture(TextureHandle override) { mOverrideTexture = override; mUseOverrideTexture = true; }
void clearOverrideTexture() { mOverrideTexture = NULL; mUseOverrideTexture = false; }
/// @}
enum
{
NO_ENVIRONMENT_MAP, ///< don't render environment map
ENVIRONMENT_MAP_MULTI_1, ///< render with multi-texturing (+1 texture units), shape alpha = reflectance map
ENVIRONMENT_MAP_MULTI_3, ///< render with multi-texturing (+3 texture units), reflectance map separate texture
ENVIRONMENT_MAP_TWO_PASS, ///< render in two passes -- mAllowTwoPassEnvironmentMap must be true
///
/// @note if reflectance map is separate from shape texture then won't render unless card has 4 texture units
/// However, translucency won't work quite right if reflection map not separated -- probably ok though.
/// Bottom line: previous 2 items probably only used for special shapes...
NO_DETAIL_MAP,
DETAIL_MAP_MULTI_1,
DETAIL_MAP_MULTI_2,
DETAIL_MAP_TWO_PASS,
NO_FOG,
FOG_MULTI_1,
FOG_MULTI_1_TEXGEN,
FOG_TWO_PASS,
FOG_TWO_PASS_TEXGEN
};
const TextureHandle & getEnvironmentMap() { return mEnvironmentMap; }
F32 getEnvironmentMapAlpha() { return mEnvironmentMapAlpha; }
void setEnvironmentMap(const TextureHandle& map) { mEnvironmentMap = map; }
void setEnvironmentMapOn(bool on, F32 alpha = 0.25f) { mEnvironmentMapOn = on; mEnvironmentMapAlpha = alpha; }
//-------------------------------------------------------------------------------------
// private methods for setting up and affecting animation
//-------------------------------------------------------------------------------------
private:
/// @name Private animation methods
/// These are private methods for setting up and affecting animation
/// @{
void updateTransitions();
void handleDefaultScale(S32 a, S32 b, TSIntegerSet & scaleBeenSet);
void handleTransitionNodes(S32 a, S32 b);
void handleNodeScale(S32 a, S32 b);
void handleAnimatedScale(TSThread *, S32 a, S32 b, TSIntegerSet &);
void handleMaskedPositionNode(TSThread *, S32 nodeIndex, S32 offset);
void handleBlendSequence(TSThread *, S32 a, S32 b);
void checkScaleCurrentlyAnimated();
/// @}
//-------------------------------------------------------------------------------------
// animate, render, & detail control
//-------------------------------------------------------------------------------------
public:
struct RenderData
{
MatrixF * currentTransform;
S32 detailLevel;
F32 intraDetailLevel;
S32 environmentMapMethod;
S32 detailMapMethod;
S32 detailMapTE;
S32 environmentMapTE;
F32 environmentMapAlpha;
U32 environmentMapGLName;
S32 baseTE;
F32 detailTextureScale;
F32 detailMapAlpha;
bool fadeSet;
bool lightingOn;
bool alwaysAlpha;
F32 alwaysAlphaValue;
bool balloonShape;
F32 balloonValue;
U32 materialFlags;
S32 materialIndex;
const Point3F * objectScale;
bool fogOn;
S32 fogMethod;
S32 fogTE;
Point4F fogColor;
Point4F fogTexGenS;
Point4F fogTexGenT;
TextureHandle * fogMapHandle; ///< used by texgen fog
bool useOverride;
TextureHandle override;
bool textureMatrixPushed;
bool fogTexture;
GBitmap *fogBitmap;
TextureHandle *fogHandle;
bool renderDecals;
struct VertexAlpha
{
/// @name Vertex Data
/// Track various contributors to vertex alpha
/// @{
F32 vis;
F32 emap;
F32 fog;
F32 always;
/// @}
/// current result...
F32 current;
void init() { current=vis=emap=fog=always=1.0f; }
bool set() { F32 old = current; current =vis*emap*fog*always; return (mFabs(old-current)>0.001f); }
} vertexAlpha;
};
static RenderData smRenderData;
/// if true, skip these objects
static bool smNoRenderTranslucent;
static bool smNoRenderNonTranslucent;
/// when taking hiQuality snapshot, scale intermediate bitmaps up to this amount
static S32 smMaxSnapshotScale;
/// scale pixel size by this amount when selecting detail levels
static F32 smDetailAdjust;
/// a different error metrix used by newer shapes (screen error from hi detail)
static F32 smScreenError;
static bool smFogExemptionOn;
/// never choose detail level number below this value (except if
/// only way to get a visible detail)
static S32 smNumSkipRenderDetails;
static bool smSkipFirstFog;
static bool smSkipFog;
virtual void render(const Point3F * objectScale = NULL);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -