Ejemplo n.º 1
0
void CharacterObject::createActor(const glm::vec2& size)
{
	if(physCharacter) {
		destroyActor();
	}
	
	// Don't create anything without a valid model.
	if(model) {
		btTransform tf;
		tf.setIdentity();
		tf.setOrigin(btVector3(position.x, position.y, position.z));

		physObject = new btPairCachingGhostObject;
		physObject->setUserPointer(this);
		physObject->setWorldTransform(tf);
		physShape = new btCapsuleShapeZ(size.x, size.y);
		physObject->setCollisionShape(physShape);
		physObject->setCollisionFlags(btCollisionObject::CF_KINEMATIC_OBJECT);
		physCharacter = new btKinematicCharacterController(physObject, physShape, 0.30f, 2);
		physCharacter->setFallSpeed(20.f);
		physCharacter->setUseGhostSweepTest(true);
		physCharacter->setVelocityForTimeInterval(btVector3(1.f, 1.f, 1.f), 1.f);
		physCharacter->setGravity(engine->dynamicsWorld->getGravity().length());
		physCharacter->setJumpSpeed(5.f);

		engine->dynamicsWorld->addCollisionObject(physObject, btBroadphaseProxy::KinematicFilter,
												  btBroadphaseProxy::StaticFilter|btBroadphaseProxy::SensorTrigger);
		engine->dynamicsWorld->addAction(physCharacter);
	}
}
Ejemplo n.º 2
0
CharacterObject::~CharacterObject()
{
	destroyActor();
	if( currentVehicle )
	{
		currentVehicle->setOccupant(getCurrentSeat(), nullptr);
	}
}
Ejemplo n.º 3
0
void CharacterObject::setCurrentVehicle(VehicleObject *value, size_t seat)
{
	currentVehicle = value;
	currentSeat = seat;
	if(currentVehicle == nullptr && physCharacter == nullptr) {
		createActor();
	}
	else if(currentVehicle) {
		destroyActor();
	}
}
Ejemplo n.º 4
0
//-----------------------------------------------------------------------
void ActorObject::destroyRenderInstance(void)
{
    if (mActor)
    {
        destroyActor();
    }

    if (mProxy)
    {
        delete mProxy;
        mProxy = NULL;
    }

    PlacementObject::destroyRenderInstance();
}
Ejemplo n.º 5
0
//-----------------------------------------------------------------------
void ActorObject::setActorName(const Ogre::String& actorName)
{
    if (mActorName != actorName)
    {
        if (mActor)
        {
            destroyActor();
        }

        mActorName = actorName;

        if (mProxy && !mActorName.empty())
        {
            // i assume we only call this function in FairyEditor, so I set the parameter "editable" to false
            createActor();
        }
    }
}