Updated examples

It is now possible to pause the animation in AnimatedMesh demo with the
P key


Former-commit-id: 98d1b5196007dd524e2257157d6e7fd3171fb070
This commit is contained in:
Lynix 2012-10-04 09:36:56 +02:00
parent 41bfaf6941
commit defbb0f1a6
2 changed files with 13 additions and 7 deletions

View File

@ -247,6 +247,7 @@ int main()
// Quelques variables // Quelques variables
bool camMode = true; bool camMode = true;
bool paused = false;
bool thirdPerson = false; bool thirdPerson = false;
bool windowOpen = true; bool windowOpen = true;
@ -338,6 +339,8 @@ int main()
} }
else if (event.key.code == NzKeyboard::Escape) else if (event.key.code == NzKeyboard::Escape)
windowOpen = false; windowOpen = false;
else if (event.key.code == NzKeyboard::P)
paused = !paused;
break; break;
@ -433,7 +436,9 @@ int main()
drfreak.matrix = NzMatrix4f::Rotate(modelOrient) * NzMatrix4f::Translate(modelPos); drfreak.matrix = NzMatrix4f::Rotate(modelOrient) * NzMatrix4f::Translate(modelPos);
// Animation // Animation
if (!paused)
AnimateModel(drfreak, elapsedTime); AnimateModel(drfreak, elapsedTime);
updateClock.Restart(); updateClock.Restart();
} }

View File

@ -1,12 +1,13 @@
#include <Nazara/Audio.hpp> #include <Nazara/Audio.hpp>
#include <Nazara/Core/Clock.hpp> #include <Nazara/Core/Clock.hpp>
#include <Nazara/Core/Thread.hpp> // Thread::Sleep #include <Nazara/Core/Thread.hpp> // Thread::Sleep
#include <Nazara/Math/Vector3.hpp>
#include <Nazara/Utility/Keyboard.hpp> #include <Nazara/Utility/Keyboard.hpp>
#include <iostream> #include <iostream>
int main() int main()
{ {
// NzKeyboard ne nécessite pas l'initialisation d'Utility // NzKeyboard ne nécessite pas l'initialisation du module Utilitaire
NzInitializer<NzAudio> audio; NzInitializer<NzAudio> audio;
if (!audio) if (!audio)
{ {
@ -32,11 +33,11 @@ int main()
// On fait en sorte de répéter le son // On fait en sorte de répéter le son
sound.EnableLooping(true); sound.EnableLooping(true);
// La source du son se situe en (50, 0, 5) // La source du son se situe vers la gauche (Et un peu en avant)
sound.SetPosition(50, 0, 5); sound.SetPosition(NzVector3f::Left()*50.f + NzVector3f::Forward()*5.);
// Et possède une vitesse de -10 par seconde sur l'axe X // Et possède une vitesse de 10 par seconde vers la droite
sound.SetVelocity(-10, 0, 0); sound.SetVelocity(NzVector3f::Left()*-10.f);
// On joue le son // On joue le son
sound.Play(); sound.Play();
@ -58,7 +59,7 @@ int main()
std::cout << "Sound position: " << pos << std::endl; std::cout << "Sound position: " << pos << std::endl;
// Si la position de la source atteint une certaine position, ou si l'utilisateur appuie sur echap // Si la position de la source atteint une certaine position, ou si l'utilisateur appuie sur echap
if (pos.x < -50.f || NzKeyboard::IsKeyPressed(NzKeyboard::Escape)) if (pos.x > NzVector3f::Left().x*-50.f || NzKeyboard::IsKeyPressed(NzKeyboard::Escape))
sound.Stop(); // On arrête le son (Stoppant également la boucle) sound.Stop(); // On arrête le son (Stoppant également la boucle)
clock.Restart(); clock.Restart();