x
Yes
No
Do you want to visit DriveHQ English website?
首页
产品服务
价格
免费试用
下载客户端
关于我们
云文件服务
|
云备份服务
|
FTP服务
|
企业邮箱服务
|
网站托管
|
客户端软件
云文件服务
云备份服务
FTP服务
企业级邮箱服务
网站托管
客户端软件
SkinnedEntity.cpp - Hosted on DriveHQ Cloud IT Platform
返回上层目录
上传
下载
共享
发布
新建文件夹
新建文件
复制
剪切
删除
粘贴
评论
升级服务
路径: \\game3dprogramming\materials\GameFactory\GameFactoryDemo\GameFactory\SkinnedEntity.cpp
旋转
特效
属性
历史版本
#include "SkinnedEntity.h" SkinnedEntity::SkinnedEntity(const String& resourceName, const String& mainActorName, const Real& radius, const Real& height): isMoving(false),isRotating(false),mMovingSpeed(1.0f){ mSkinnedVisObj = new SkinnedVisObj(resourceName); mControllablePhysObj = new ControllableCompoundPhysObj(radius,height,resourceName,mainActorName,mSkinnedVisObj); mVisualObj = mSkinnedVisObj; mPhysicalObj = mControllablePhysObj; _enableToRayCast(); } SkinnedEntity::~SkinnedEntity(){ mControllablePhysObj = NULL; mSkinnedVisObj = NULL; } void SkinnedEntity::FrameMove(Real elapsedTime){ GameEntity::FrameMove(elapsedTime); //static bool mybool = false; if (isMoving) movingTo(elapsedTime,movingTarget); else{ //if (!mybool){ // mybool = true; // SetRagdollMode(true); //} } if (isRotating) rotatingTo(elapsedTime,rotatingTarget); } void SkinnedEntity::SetRagdollMode(bool enabled, const Vec3& direction){ if (enabled){ mControllablePhysObj->SetMode(ControllableCompoundPhysObj::Mode::CompoundMode, direction); SetNoAnimation(); mSkinnedVisObj->SetManualControl(true);//must be placed after SetMode for the ReBinding to work }else{ myassert(false);//not yet implemented } } void SkinnedEntity::SetOrientation(const GFQuat& q){ mVisualObj->SetOrientation(q); } void SkinnedEntity::MoveTo(const Vec3& position){ isMoving = true; movingTarget = position; RotateTo(position); } bool SkinnedEntity::isAt(const Vec3& pos) const{ return (this->GetPosition()-pos).length()<0.2f; } void SkinnedEntity::movingTo(Real elapsedTime, const Vec3& position){ Vec3 pos = position; //pos.z=0.0f; Vec3 movingVector = (pos - this->GetPosition()).normalisedCopy(); mControllablePhysObj->SetMovement(movingVector*mMovingSpeed*elapsedTime); if (isAt(position)){ isMoving = false; isRotating = false; Stop(); } } void SkinnedEntity::RotateTo(Real angleRadian){ isRotating = true; rotatingTarget = angleRadian; } void SkinnedEntity::RotateTo(const Vec3& position){ Vec3 pos = position; pos.z=0.0f; Vec3 movingVector = (pos - this->GetPosition()).normalisedCopy(); Real angle; if (movingVector.x==0){ if (movingVector.y>0) angle = 3.14159/2; else angle = -3.14159/2; }else{ angle = atanf(movingVector.y/movingVector.x); if (movingVector.x<0) angle+=3.14159; } angle+=3*3.14159/2;//to make this angle identical to character angle if (angle>3.14159*2) angle-=3.14159*2;//make sure it is not greater than 360 degrees RotateTo(angle); } void SkinnedEntity::rotatingTo(Real elapsedTime, Real angleRadian){ RotateTo(movingTarget); Real curAngle = this->GetOrientation().getRoll().valueRadians(); if (curAngle<0) curAngle+=3.14159*2; Real distPlus,distMinus,dist; if (angleRadian>curAngle){ distPlus = abs(angleRadian-curAngle); distMinus = abs(3.14159*2-angleRadian+curAngle); if (distPlus
3.14159/180*2) SetOrientation(Quaternion(Radian(curAngle+dist*elapsedTime*4.0f),Vector3::UNIT_Z)); //else // isRotating = false; }
SkinnedEntity.cpp
网页地址
文件地址
上一页
50/55
下一页
下载
( 3 KB )
Comments
Total ratings:
0
Average rating:
无评论
of 10
Would you like to comment?
Join now
, or
Logon
if you are already a member.