Actor

西昌.何雨锋 

 

actor

1、动物,actor,可以从TVA文件中读取。而TVA文件由mdl文件转换而来,转换时最好把坐标也变了,同时,在变化后的
bmp文件压缩成jpg,然后再修改成bmp扩展名.
2、建立:
                  man1=new CTVActor();
 man1=scene1->CreateActor("man1");
 man1->LoadTVA("..//..//media//rancor_Final.tva",false,false);
 man1->SetAnimationID(3);
 man1->PlayAnimation(1);
 man1->SetScale(10,10,10);
3、如何将有alpha背景的mdl文件变成去掉颜色背景的TVA文件?
                 没有一个直接的函数来做到这一点,最直接的方法就是将modelconvert时产生的纹理文件,用ps打开,删除其alpha图层,
然后利用其颜色图层建立出一个alpha图层,然后存为DDS格式,再把DDS文件改名为bmp即可覆盖原纹理文件,然后再程序中使用:
 act1->SetBlendingMode(cTV_BLEND_ALPHA);
 act1->SetAlphaTest(true,128,true);
这样就可以让有颜色的部分变来没颜色。

3、其他函数:
                  void SetPath(CTVPath* pPath);
 void SetPathSpeed(float fSpeed, bool bConstantSpeed = false);

 // generic loading
 bool Load(const char* datasource);
 
 // specific loading
 bool LoadTVA(const char* datasource, bool bLoadTextures = true, bool bLoadShaders = true);
 bool LoadXFile(const char* datasource, bool bLoadTextures = true, bool bLoadMaterials = true);
 bool SaveTVA(const char* datasource);

 void SetAnimationID(int iAnimationID);
 void PlayAnimation(float speed = 1.0f);
 void StopAnimation();
 void PauseAnimation();
 void BlendAnimationTo(int iNewAnimation, float fTransitionLengthSec = 1.0f); 

 void SetMaterial(int matid, int group = -1);
 int GetMaterial(int group = 0);

 // rendering updating
 void Update();
 void Render(bool bUpdate = true);

 void SetIndex(int iIndex);
 int GetIndex() ;

 // bone manipulating.
 void SetBoneRotation(int iBone, float aRotateX, float aRotateY, float aRotateZ, bool bRelative);
 void SetBoneRotationMatrix(int iBone, cTV_3DMATRIX* mRotateMatrix, bool bRelative);
 void SetBoneMatrix(int iBone, cTV_3DMATRIX* mMatrix, bool bRelative = true, bool bModelSpace = false);
 void SetBoneTranslation(int iBone, float fTranslationX, float fTranslationY, float fTranslationZ, bool bRelative = false);
 void SetBoneScale(int iBone, float fScaleX, float fScaleY, float fScaleZ);
 void SetBoneGlobalMatrix(int iBone, cTV_3DMATRIX* mMatrix);

 cTV_3DMATRIX GetBoneMatrix(int iBone, bool bModelSpace = false);
 cTV_3DVECTOR GetBonePosition(int iBone, bool bLocal = false);

 int GetBoneParent(int iBone);
 int GetBoneCount();
 char* GetBoneName(int iBone);
 int GetBoneID(const char* sBoneName);


 // entity.
 void RotateZ( float fAngleZ, bool bRelative =true);
 void RotateY( float fAngleY, bool bRelative =true) ;
 void RotateX( float fAngleX, bool bRelative = true);
 void SetMatrix( cTV_3DMATRIX* mMatrix);
 void SetRotationMatrix( cTV_3DMATRIX* mMatrix);
 void SetScale( float fScaleX, float fScaleY, float fScaleZ);
 void SetRotation( float fAngleX, float fAngleY, float fAngleZ);
 void SetPosition( float x, float y, float z);
 
 cTV_3DMATRIX GetRotationMatrix();
 cTV_3DMATRIX GetMatrix();
 cTV_3DVECTOR GetPosition();
 cTV_3DVECTOR GetScale();
 cTV_3DVECTOR GetRotation();

 // new
 void SetActorMode(cCONST_TV_ACTORMODE eActorMode);
                  cTV_ACTORMODE_SHADER = 0,
 cTV_ACTORMODE_BLENDING = 1,
 cTV_ACTORMODE_CPU = 2,
 cTV_ACTORMODE_FASTEST = 3
 void SetTexture(int iTexture, int iGroup = -1);

 void SetTextureEx(int iLayer, int iTexture, int iGroup = -1);

 void SetLightingMode(cCONST_TV_LIGHTINGMODE eLightMode, int iMaxDirLight = -1, int iMaxPointLights = -1);

 //
 void Destroy();

 void SetShadowCast(bool bEnable, bool bUseAdditiveShadows, bool bFastShadow = false);

 void SetCullMode(cCONST_TV_CULLING eCullMode);
    CTVActor* Duplicate(const char* sNewActorName = NULL);

 int GetGroupCount();
 void SetCollisionEnable(bool bEnableColision, int iActorGroup = -1, cCONST_TV_TESTTYPE eDefaultTestType = cTV_TESTTYPE_DEFAULT);
 
 int GetCurrentAnimation();
 char* GetAnimationName(int iAnimationID);
 int GetAnimationCount();
 float GetAnimationLength(int iAnimationID);

 char* GetName();
 void SetName(const char* sNewName);
 
 bool IsAnimationFinished();
 void SetAnimationLoop(bool bLooped);

 void SetAnimationByName(const char* sAnimationName);
 float GetKeyFrame();
 void SetKeyFrame(float fKeyFrame);
 void GetBoundingBox(cTV_3DVECTOR* retBoxMin, cTV_3DVECTOR* retBoxMax, bool bLocal = false);
 void GetBoundingSphere(cTV_3DVECTOR* retSphereCenter, float* retRadius, bool bLocal = false);

 void SetAlphaTest(bool bEnable, int iAlphaRef = 128, bool bWriteToDepthBuffer = true);
 void Enable(bool bEnable);
 bool IsEnabled();
 bool IsVisible();

 int GetTexture(int iGroup = -1);
                  //得到某组现在的纹理
 int GetTextureEx(int iLayer, int iGroup = -1 );
 
 void MorphTargetCompiler_Clear();
 void MorphTargetCompiler_AddMorphTargetMesh(const char* sName, CTVMesh* pMesh, bool bReference = false);
 void MorphTargetCompiler_DeleteMorphTargetMesh(const char* sName);
 void MorphTargetCompiler_Compile();

 void MorphTarget_Enable(bool bEnable, bool bDynamic = false);
 void MorphTarget_SetWeight(int iPose, float fWeight);
 void MorphTarget_SetWeightByName(const char* sMorphTarget, float fWeight);
 char* MorphTarget_GetName(int iPose);
 float MorphTarget_GetWeight(int iPose);
 int MorphTarget_GetCount();

 int GetTriangleCount();
 int GetVertexCount();

 void ComputeNormals();
 int GetAnimationIDByName(const char* sName);
 void ShowBoundingBox(bool bShow, int cColor = -1, bool bShowHitBoxes = false);

 int AddAnimationRange(int iAnimationSource, float fStartFrame, float fEndFrame, const char* sNewAnimationName = NULL);
 void SetAnimationRange(int iAnimationSource, float fStartFrame, float fEndFrame);
                  //设置动画范围
 void SetCustomAnimation(float fStartFrame, float fEndFrame);
                  //设置定制动画:起-止
// void SetAnimationSpeed(int iAnimation, float fAnimationSpeed);

 void SetTag(const char* sTag);
 char* GetTag();

 void SetUserData(int i32bitsData);
 int GetUserData();

 void AttachTo(cCONST_TV_NODETYPE eObjectType, int iObjectIndex, int iSubIndex, bool bKeepMatrix = true, bool bRemoveScale = false);
                  //粘到什么上面:(被粘类型,被粘索引,子索引,保持矩阵不变吗,可否同步放缩)
                 第1参数列表
                  cTV_NODETYPE_NODE = 0,
 cTV_NODETYPE_MESH = 1,
 cTV_NODETYPE_ACTOR = 2,
 cTV_NODETYPE_CAMERA = 3,
 cTV_NODETYPE_LIGHT = 4,
 cTV_NODETYPE_PARTICLEEMITTER = 5,

 cTV_NODETYPE_NONE = 99
 void SetParent(cCONST_TV_NODETYPE eObjectType, int iObjectIndex, int iSubIndex);
 void SetParentEx(cCONST_TV_NODETYPE eObjectType, int iObjectIndex, int iSubIndex, float fTranslationOffsetX = 0.0f, float fTranslationOffsetY = 0.0f, float fTranslationOffsetZ = 0.0f, float fRotationOffsetX = 0.0f, float fRotationOffsetY = 0.0f, float fRotationOffsetZ = 0.0f, bool bRemoveScale = false);
  void LookAtPoint(cTV_3DVECTOR* vPoint, bool bOnlyRotationY = false);
                  //看向某个点
 void GetBasisVectors(cTV_3DVECTOR* retDirection, cTV_3DVECTOR* retUp, cTV_3DVECTOR* retSide);
 void SetQuaternion(cTV_3DQUATERNION* qQuat);
                   //四元组
 cTV_3DQUATERNION GetQuaternion();

 void SetGroupEnable(int iGroup, bool bEnable);
                 //一般组都分为躯干body、头顶helmet、头head、背部gear,可以用这个函数让某部分无效

 bool GetGroupEnable(int iGroup);
                  //得到某一组是否被允许
 void ExportAnimations(const char* sDatasource, int iSpecificAnimation = -1);
 bool ImportAnimations(const char* sDatasource, bool bAppendAnimations = true);

 void MoveRelative(float fFront = 0.0f, float fUp = 0.0f, float fRight = 0.0f);
                   //移动关系
 void SetShader( CTVShader* sShader );
 void SetShaderEx( CTVShader* sShader, bool bMatchActorFormat, int iGroupIndex);

 void SetMaxUpdateFrequency(bool bEnableLimit, int iMaxUpdateFPS);
                  //设置最大更新频率
 void RenameAnimation(int iAnimationID, const char* sNewName);
 void InvertNormals();
 int GetEntityIndex();
                 //得到实体索引
 void SetBlendingModeEx(cCONST_TV_BLENDEX eSourceBlend, cCONST_TV_BLENDEX eDestBlend);
 void SetBlendingMode(cCONST_TV_BLENDINGMODE eBlending);

 void SetColor(int cColor, bool bForLighting = false);
 void SetAttachMode(bool bRemoveParentScale , bool bOnlyPosition );

 char* GetGroupName(int iGroup);
                 //根据组号得到组名
 void SetGroupName(int iGroup, char* sGroupName);
                  //重新设置某组的名称
 int GetGroupByName(char* sGroup);
                //根据名称得到组号
 void EnableMotionBlur(bool bEnable);
                
 void SetBlendedAnimationID(int iAnimationID, float fWeight = 1.0f, int iBlendedAnimationLayer = 0);
 void SetBlendedAnimationByName(char* sAnimationName, float fWeight = 1.0f, int iBlendedAnimationLayer = 0);
 void PlayBlendedAnimation(float fAnimationSpeed, int iBlendedAnimationLayer = 0);
 void PauseBlendedAnimation(int iBlendedAnimationLayer = 0);
 void StopBlendedAnimation(int iBlendedAnimationLayer = 0);
 void SetBlendedAnimationWeight(float fWeight, int iBlendedAnimationLayer = 0 );
 void SetBlendedAnimationLoop(bool bLooping, int iBlendedAnimationLayer = 0);

 bool GetParent(int* retNodeType, int* retObjectIndex, int* retSubIndex);
 void ResetPath(float fNodeKey = 0.0f);
 void SetOverlay(bool bOverlayEnable);
                  //设置覆盖允许,则看起来有点半透明
 void ForceMatrixUpdate();

 void SetClamping(bool bEnable);
                
 int GetAnimationID();
 int GetBlendedAnimationID(int iBlendedAnimationLayer);
 void SetBoneEnable(int iBoneId, bool bEnable);
                 //设置某骨骼允许,若不允许,则其子骨骼将被放在0,0点不动
 bool IsBoneEnabled(int iBoneId);
 
 void SetBlendedAnimationKeyFrame(float fKeyFrame, int iBlendedAnimationLayer = 0);
 float GetBlendedAnimationKeyFrame(int iBlendedAnimationLayer = 0);

 void OptimizeAnimations();
                
 bool AdvancedCollision(cTV_3DVECTOR* vStartRay, cTV_3DVECTOR* vEndRay, cTV_COLLISIONRESULT* pRetCollResult, cCONST_TV_TESTTYPE eCollisionType = cTV_TESTTYPE_DEFAULT);
                  //高级碰撞,注意cTV_COLLISIONRESULT是一个结构,可不是CTV_Collision类,结构如下:
 typedef struct cTV_COLLISIONRESULT {
      
        cTV_3DVECTOR vCollisionNormal;
        cTV_3DVECTOR vCollisionImpact;    //碰撞位置
        float fDistance;                                    //与起点距离
        float fU;
        float fV;
        int iFaceindex;                                     //碰撞面的index
        int iGroupIndex;                                  //碰撞组的index
        bool bHasCollided;                             //是否已碰撞过了
        cCONST_TV_OBJECT_TYPE eCollidedObjectType;      //碰撞物体类型
        int iEntityID;                                        //物理id
        int iMeshID;                                        //meshid
        int iLandscapeID;                              //陆地id
        int iBoneID;                                       //骨骼id
  float fTexU;
  float fTexV;
    } cTV_COLLISIONRESULT;
   碰撞类型:
typedef enum cCONST_TV_OBJECT_TYPE {
  cTV_OBJECT_ALL = 0,
  cTV_OBJECT_MESH = 1,
  cTV_OBJECT_LANDSCAPE = 2,
  cTV_OBJECT_OCTREE = 4,
  cTV_OBJECT_ACTOR = 8,
  cTV_OBJECT_NOCOLLISION = 256,
  cTV_OBJECT_FORCE_DWORD = 0x7fffffff // to have a int enumeration (delphi)
 } cCONST_TV_OBJECT_TYPE;

 bool Collision(cTV_3DVECTOR* vStartRay, cTV_3DVECTOR* vEndRay, cCONST_TV_TESTTYPE eCollisionType = cTV_TESTTYPE_DEFAULT);
 void SetGroupRenderOrder(bool bRenderOrderEnable,int iNumGroupToRender, int* pGroupOrderArray);
                  //设置某些部分可以显示,某些部分不能显示。
                  第二个参数为显示多少,如一个只有4部分的模型,如果设置为3则不显示最后一个部分。
                  第三个参数为一个一维数组,一般只有为0,1,2,3时才能正常显示,为其他值要么益出,要么不显示,达不到换模型与纹理的效果。                 

 CTVMesh* GetDeformedMesh();
 cTV_3DVECTOR GetWorldPosition(cTV_3DVECTOR* vLocalPosition);
 CTVShader* GetShader(int iGroup = -1);
 void DeleteAnimationRange(int iAnimationIDRange);
 bool GetAnimationRangeInfo(int iAnimationID, int* iSourceAnimation, float* fStartKeyFrame, float* fEndKeyFrame);
 void SetAnimationRangeInfo(int iAnimationID, int iSourceAnimation, float fStartKeyFrame, float fEndKeyFrame);
 void BindToActor(CTVActor* pParentActor);
 void BindToActorEx(CTVActor* pParentActor, int iNumMatchingBones, int* pMatchingBonesArray);
 void ResetTime();
 float GetPathCurrentNode();
 void WeldVertices();

 bool IsBlendedAnimationFinished(int iBlendAnimationLayer);
 void UpdateEx(float fElapsedTime);

 void GetAlphaTest(bool* retbEnableAlphaTest, int* retRefValue, bool* retbWriteToZBuffer);
 void GetAlphaBlendingEx(bool* retbEnable, cCONST_TV_BLENDEX* reteSrcBlend, cCONST_TV_BLENDEX* reteDestBlend);

 void SetTangentParameters(float fMaxAngleForSharedNormals, float fMaxAngleForSharedTangents,  bool bUseAdjacency = true );

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值