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
ControllablePhysObj.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\ControllablePhysObj.cpp
Girar
Efecto
Propiedad
Historial
#include "ControllablePhysObj.h" #include "GameScene.h" const Real ControllablePhysObj::lowestSpeed = 0.1f/60.0f;//0.1 meters per second const Real ControllablePhysObj::skinWidthRatio = 1.0f/50.0f; // the ratio of skinWidth to the radius NxUserAllocatorDefault* ControllablePhysObj::memAllocator = NULL; NxControllerManager* ControllablePhysObj::controllerManager = NULL; ControllablePhysObj::ControllablePhysObj(Real radius, Real height, VisualObject* visualObject) :mPhysController(NULL), PhysicalObject(visualObject){ if (controllerManager==NULL){ //NxUserAllocator memAllocator = new NxUserAllocatorDefault(); controllerManager = NxCreateControllerManager(memAllocator); myassert(controllerManager!=NULL); } mHeight = height + 2*radius; mDisplacementVector = Vec3(0,0,mHeight/2); NxCapsuleControllerDesc desc; desc.upDirection = NX_Z; //desc.climbingMode = NxCapsuleClimbingMode::CLIMB_EASY; desc.height = height; desc.radius = radius; desc.skinWidth = radius * skinWidthRatio; desc.slopeLimit = 0; desc.stepOffset = 0.1f; desc.interactionFlag = NxCCTInteractionFlag::NXIF_INTERACTION_INCLUDE; desc.callback = this; Vec3 startPosition = mVisualObject->GetPosition(); desc.position = NxExtendedVec3(startPosition.x,startPosition.y,startPosition.z); mPhysController = controllerManager->createController(GameScene::GetSingleton()->GetPhysicsScnene(),desc); myassert(mPhysController!=NULL); mPhysController->reportSceneChanged(); mPhysController->setCollision(true); //mPhysController->getActor()->setGroup(5); mPhysController->getActor()->setContactReportFlags(NxContactPairFlag::NX_NOTIFY_FORCES | NxContactPairFlag::NX_NOTIFY_ON_START_TOUCH ); } ControllablePhysObj::~ControllablePhysObj(){ mPhysController->getActor()->userData = NULL; controllerManager->releaseController(*mPhysController); } void ControllablePhysObj::SetMovement(const Vec3& movingVector){ //if (movingVector.length()>0){ // int aa=0; //} NxU32 collisionFlags; mPhysController->move(movingVector,1,lowestSpeed,collisionFlags); } void ControllablePhysObj::FrameMove(Real elapsedTime){ mVisualObject->SetPosition(GetPosition());//only set position, because it does not have orientation NxU32 collisionFlags; mPhysController->move(Vec3(0,0,GameScene::GravityValue*elapsedTime),1,lowestSpeed,collisionFlags); } inline void ControllablePhysObj::RegisterPhysicalEventHandler(PhysicalEventHandler* physicalEventHandler){ myassert(mPhysController->getActor()->userData == NULL);//register one time only mPhysController->getActor()->userData = physicalEventHandler; } void ControllablePhysObj::SetCollisionEnable(bool enabled){ mPhysController->setCollision(enabled); if (!enabled){ mPhysController->setInteraction(NxCCTInteractionFlag::NXIF_INTERACTION_EXCLUDE); mPhysController->getActor()->putToSleep(); } } NxControllerAction ControllablePhysObj::onShapeHit (const NxControllerShapeHit &hit){ if (hit.shape->getActor().userData!=NULL){ static_cast
(this->mPhysController->getActor()->userData)->IsCollided( static_cast
(hit.shape->getActor().userData),hit.worldPos,hit.worldNormal); } return NxControllerAction::NX_ACTION_NONE; } NxControllerAction ControllablePhysObj::onControllerHit (const NxControllersHit &hit) { return NxControllerAction::NX_ACTION_NONE; }
ControllablePhysObj.cpp
Dirección de la página
Dirección del archivo
Anterior
11/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.