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 );

 

 

 

先展示下效果 https://pan.quark.cn/s/5061241daffd 在使用Apache HttpClient库发起HTTP请求的过程中,有可能遇到`HttpClient`返回`response`为`null`的现象,这通常暗示着请求未能成功执行或部分资源未能得到妥善处理。 在本文中,我们将详细研究该问题的成因以及应对策略。 我们需要掌握`HttpClient`的运作机制。 `HttpClient`是一个功能强大的Java库,用于发送HTTP请求并接收响应。 它提供了丰富的API,能够处理多种HTTP方法(例如GET、POST等),支持重试机制、连接池管理以及自定义请求头等特性。 然而,一旦`response`对象为`null`,可能涉及以下几种情形:1. **连接故障**:网络连接未成功建立或在请求期间中断。 需要检查网络配置,确保服务器地址准确且可访问。 2. **超时配置**:若请求超时,`HttpClient`可能不会返回`response`。 应检查连接和读取超时设置,并根据实际需求进行适当调整。 3. **服务器故障**:服务器可能返回了错误状态码(如500内部服务器错误),`HttpClient`无法解析该响应。 建议查看服务器日志以获取更多详细信息。 4. **资源管理**:在某些情况下,如果请求的响应实体未被正确关闭,可能导致连接被提前释放,进而使后续的`response`对象为`null`。 在使用`HttpClient 3.x`版本时,必须手动调用`HttpMethod.releaseConnection()`来释放连接。 而在`HttpClient 4.x`及以上版本中,推荐采用`EntityUtils.consumeQuietly(respons...
actor palette 是在多个软件和框架中用于管理和操作 actor(执行单元)的工具集。这种功能常见于分布式系统、图形界面开发、游戏引擎以及建模工具中,尤其是在涉及并发和异步处理的场景下。actor 模型是一种并发模型,其中 actor 是独立的计算实体,它们通过消息传递进行通信[^1]。 ### 功能 1. **Actor 创建与管理** actor palette 提供了创建、配置和管理 actor 的能力。用户可以定义 actor 的行为、状态以及消息传递机制。例如,在某些系统中,可以通过拖放的方式将 actor 添加到工作区,并设置其属性。 2. **消息传递机制** actor palette 支持定义 actor 之间的通信方式,包括同步和异步消息传递。这些工具通常提供可视化接口来配置消息队列、端口绑定以及消息处理逻辑[^2]。 3. **可视化编程支持** 在某些开发环境中,actor palette 以图形化方式呈现,允许用户通过连接不同的 actor 来构建复杂的工作流。这种方式降低了并发编程的复杂性,使得开发者可以更专注于业务逻辑的设计[^3]。 4. **调试与监控** actor palette 还可能包含调试和监控功能,帮助开发者追踪 actor 的状态变化、消息流动以及资源使用情况。这对于优化系统性能和排查错误至关重要。 ### 工具 1. **Akka Toolkit** Akka 是一个用于构建高并发、分布式、容错系统的工具包,广泛应用于 Scala 和 Java 开发中。Akka 提供了强大的 actor 模型实现,并通过其 API 和工具链支持 actor 的创建、管理和通信[^4]。 2. **LabVIEW Actor Framework** LabVIEW 是一种图形化编程语言,广泛应用于测试、测量和控制系统。LabVIEW 的 Actor Framework 提供了 actor palette,允许用户通过图形化界面构建基于 actor 的并发应用程序[^5]。 3. **Unity DOTS (Data-Oriented Tech Stack)** Unity 是一个流行的游戏引擎,其 DOTS 技术栈中引入了基于 actor 的并发模型。开发者可以使用 Unity 的 ECS(Entity Component System)架构和 Job System 来实现高效的并发处理。 4. **Erlang OTP** Erlang 是一种专为并发和分布式系统设计的编程语言。其 OTP(Open Telecom Platform)框架提供了丰富的 actor 模型支持,允许开发者构建高度可靠的系统[^6]。 ### 使用场景 1. **游戏开发** 在游戏开发中,actor palette 被用来管理游戏中的角色、AI 行为以及事件处理。通过 actor 模型,开发者可以轻松实现复杂的交互逻辑和并发任务[^7]。 2. **物联网 (IoT)** IoT 系统通常涉及大量的设备和传感器,actor palette 可以帮助开发者管理这些设备之间的通信和数据处理。actor 模型的异步特性非常适合处理 IoT 中的高并发请求[^8]。 3. **实时数据分析** 在实时数据分析系统中,actor palette 可以用于构建数据流处理管道。每个 actor 可以负责处理特定类型的数据,并通过消息传递与其他 actor 协作,从而实现高效的实时分析[^9]。 4. **金融交易系统** 金融交易系统需要处理大量的并发请求,并且对系统的可靠性和性能有极高的要求。actor palette 提供的并发模型和容错机制非常适合用于构建这样的系统[^10]。 ### 示例代码(Akka) 以下是一个简单的 Akka 示例,展示了如何创建 actor 并发送消息: ```scala import akka.actor.{Actor, ActorSystem, Props} class MyActor extends Actor { def receive = { case "hello" => println("Hello from actor!") case _ => println("Unknown message") } } object Main extends App { val system = ActorSystem("MySystem") val myActor = system.actorOf(Props[MyActor], "myActor") myActor ! "hello" // Send a message to the actor } ``` 该示例创建了一个简单的 actor,并向其发送了一条消息。Akka 的 actor 模型通过 `!` 操作符实现异步消息传递。 ---
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值