mirror of
https://github.com/rwengine/openrw.git
synced 2024-11-26 04:12:41 +01:00
Jump test
This commit is contained in:
parent
dc32c9c6ce
commit
7cbebb89dd
@ -31,6 +31,8 @@ public:
|
|||||||
virtual void update(float dt);
|
virtual void update(float dt);
|
||||||
|
|
||||||
virtual glm::vec3 getTargetPosition();
|
virtual glm::vec3 getTargetPosition();
|
||||||
|
|
||||||
|
void jump();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -31,6 +31,9 @@ public:
|
|||||||
Walk,
|
Walk,
|
||||||
Run,
|
Run,
|
||||||
Crouch,
|
Crouch,
|
||||||
|
Jump,
|
||||||
|
Falling,
|
||||||
|
Landing,
|
||||||
VehicleDrive,
|
VehicleDrive,
|
||||||
VehicleSit,
|
VehicleSit,
|
||||||
KnockedDown,
|
KnockedDown,
|
||||||
@ -81,6 +84,8 @@ public:
|
|||||||
|
|
||||||
virtual bool takeDamage(const DamageInfo& damage);
|
virtual bool takeDamage(const DamageInfo& damage);
|
||||||
|
|
||||||
|
void jump();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Resets the Actor to the nearest AI Graph node
|
* Resets the Actor to the nearest AI Graph node
|
||||||
* (taking into account the current vehicle)
|
* (taking into account the current vehicle)
|
||||||
|
@ -62,6 +62,8 @@ void GTAPlayerAIController::enterNearestVehicle()
|
|||||||
|
|
||||||
void GTAPlayerAIController::update(float dt)
|
void GTAPlayerAIController::update(float dt)
|
||||||
{
|
{
|
||||||
|
if( character->currentActivity != GTACharacter::Jump )
|
||||||
|
{
|
||||||
if( glm::length(direction) > 0.001f ) {
|
if( glm::length(direction) > 0.001f ) {
|
||||||
character->changeAction(running ? GTACharacter::Run : GTACharacter::Walk);
|
character->changeAction(running ? GTACharacter::Run : GTACharacter::Walk);
|
||||||
}
|
}
|
||||||
@ -78,10 +80,17 @@ void GTAPlayerAIController::update(float dt)
|
|||||||
else if( glm::length(direction) > 0.001f ) {
|
else if( glm::length(direction) > 0.001f ) {
|
||||||
character->rotation = cameraRotation * glm::quat(glm::vec3(0.f, 0.f, -atan2(direction.x, direction.y)));
|
character->rotation = cameraRotation * glm::quat(glm::vec3(0.f, 0.f, -atan2(direction.x, direction.y)));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
glm::vec3 GTAPlayerAIController::getTargetPosition()
|
glm::vec3 GTAPlayerAIController::getTargetPosition()
|
||||||
{
|
{
|
||||||
return direction;
|
return direction;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GTAPlayerAIController::jump()
|
||||||
|
{
|
||||||
|
character->changeAction(GTACharacter::Jump);
|
||||||
|
character->jump();
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -119,7 +119,6 @@ void GTACharacter::tick(float dt)
|
|||||||
void GTACharacter::updateCharacter()
|
void GTACharacter::updateCharacter()
|
||||||
{
|
{
|
||||||
if(physCharacter) {
|
if(physCharacter) {
|
||||||
|
|
||||||
// Check to see if the character should be knocked down.
|
// Check to see if the character should be knocked down.
|
||||||
btManifoldArray manifoldArray;
|
btManifoldArray manifoldArray;
|
||||||
btBroadphasePairArray& pairArray = physObject->getOverlappingPairCache()->getOverlappingPairArray();
|
btBroadphasePairArray& pairArray = physObject->getOverlappingPairCache()->getOverlappingPairArray();
|
||||||
@ -163,12 +162,22 @@ void GTACharacter::updateCharacter()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(currentActivity == GTACharacter::Jump)
|
||||||
|
{
|
||||||
|
if(physCharacter->onGround())
|
||||||
|
{
|
||||||
|
changeAction(GTACharacter::Idle);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
glm::vec3 direction = rotation * animator->getRootTranslation();
|
glm::vec3 direction = rotation * animator->getRootTranslation();
|
||||||
physCharacter->setWalkDirection(btVector3(direction.x, direction.y, direction.z));
|
physCharacter->setWalkDirection(btVector3(direction.x, direction.y, direction.z));
|
||||||
|
|
||||||
btVector3 Pos = physCharacter->getGhostObject()->getWorldTransform().getOrigin();
|
btVector3 Pos = physCharacter->getGhostObject()->getWorldTransform().getOrigin();
|
||||||
position = glm::vec3(Pos.x(), Pos.y(), Pos.z());
|
position = glm::vec3(Pos.x(), Pos.y(), Pos.z());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GTACharacter::setPosition(const glm::vec3& pos)
|
void GTACharacter::setPosition(const glm::vec3& pos)
|
||||||
@ -245,6 +254,12 @@ bool GTACharacter::takeDamage(const GTAObject::DamageInfo& dmg)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GTACharacter::jump()
|
||||||
|
{
|
||||||
|
physCharacter->jump();
|
||||||
|
changeAction(GTACharacter::Jump);
|
||||||
|
}
|
||||||
|
|
||||||
void GTACharacter::resetToAINode()
|
void GTACharacter::resetToAINode()
|
||||||
{
|
{
|
||||||
auto nodes = engine->aigraph.nodes;
|
auto nodes = engine->aigraph.nodes;
|
||||||
|
@ -288,9 +288,14 @@ void handleInputEvent(sf::Event &event)
|
|||||||
switch(event.type) {
|
switch(event.type) {
|
||||||
case sf::Event::KeyPressed:
|
case sf::Event::KeyPressed:
|
||||||
switch (event.key.code) {
|
switch (event.key.code) {
|
||||||
case sf::Keyboard::Space:
|
case sf::Keyboard::LShift:
|
||||||
moveSpeed = 60.f;
|
moveSpeed = 60.f;
|
||||||
break;
|
break;
|
||||||
|
case sf::Keyboard::Space:
|
||||||
|
if(playerCharacter) {
|
||||||
|
playerCharacter->jump();
|
||||||
|
}
|
||||||
|
break;
|
||||||
case sf::Keyboard::M:
|
case sf::Keyboard::M:
|
||||||
mouseGrabbed = ! mouseGrabbed;
|
mouseGrabbed = ! mouseGrabbed;
|
||||||
break;
|
break;
|
||||||
@ -660,6 +665,7 @@ int main(int argc, char *argv[])
|
|||||||
cs.depthBits = 32;
|
cs.depthBits = 32;
|
||||||
window.create(sf::VideoMode(w, h), "GTA3 Viewer", sf::Style::Close, cs);
|
window.create(sf::VideoMode(w, h), "GTA3 Viewer", sf::Style::Close, cs);
|
||||||
window.setVerticalSyncEnabled(true);
|
window.setVerticalSyncEnabled(true);
|
||||||
|
window.setMouseCursorVisible(false);
|
||||||
|
|
||||||
init(argv[optind], loadWorld);
|
init(argv[optind], loadWorld);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user