x
Yes
No
Do you want to visit DriveHQ English website?
Inicio
Características
Precios
Prueba gratuita
Software cliente
Acerca de nosotros
Servidor de archivos
|
Solución de copias de seguridad
|
Servidor FTP
|
Servidor de correo electrónico
|
Alojamiento web
|
Software cliente
Servidor de archivos
Solución de copia de seguridad
Servidor FTP
Servidor de correo electrónico
Alojamiento web
Software cliente
SkinnedEntity.cpp - Hosted on DriveHQ Cloud IT Platform
Arriba
Subir
Descargar
Compartir
Publicar
Nueva carpeta
Nuevo archivo
Copiar
Cortar
Eliminar
Pegar
Clasificación
Actualizar
Ruta de la carpeta: \\game3dprogramming\materials\GameFactory\GameFactoryDemo\GameFactory\SkinnedEntity.cpp
Girar
Efecto
Propiedad
Historial
#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
Dirección de la página
Dirección del archivo
Anterior
50/55
Siguiente
Descargar
( 3 KB )
Comments
Total ratings:
0
Average rating:
No clasificado
of 10
Would you like to comment?
Join now
, or
Logon
if you are already a member.