本文整理汇总了C++中Hud类的典型用法代码示例。如果您正苦于以下问题:C++ Hud类的具体用法?C++ Hud怎么用?C++ Hud使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Hud类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: servo_out_handler
void servo_out_handler(const lcm_recv_buf_t *rbuf, const char* channel, const lcmt_deltawing_u *msg, void *user) {
Hud *hud = (Hud*)user;
hud->SetServoCommands((msg->throttle - 1100) * 100/797, (msg->elevonL-1000)/10.0, (msg->elevonR-1000)/10.0);
hud->SetAutonomous(msg->is_autonomous);
}
示例2: main
int main(int argc, char *argv[])
{
Q_INIT_RESOURCE(basicdrawing);
QApplication app(argc, argv);
Hud window;
window.show();
return app.exec();
}
示例3: log_size_handler
void log_size_handler(const lcm_recv_buf_t *rbuf, const char* channel, const lcmt_log_size *msg, void *user) {
Hud *hud = (Hud*)user;
// plane number is the last character of the channel name
char last_char = channel[strlen(channel)-1];
int plane_number = last_char - '0'; // this converts a single character to an integer
// and is standards conforming C
hud->SetPlaneNumber(plane_number);
hud->SetLogNumber(msg->log_number);
}
示例4: startHoverTest
void RealTimeTest::run() {
game.initialize();
game.getPopupHelpScreen()->hide();
Hud *testingHud = game.getHudsManager()->createHud(HudAlignment::RIGHT);
testingHud->setText("TESTING...");
std::thread startHoverTest(RealTimeTest::hover);
std::thread startMaxSpeadTest(RealTimeTest::maxSpead);
game.run();
startHoverTest.join();
startMaxSpeadTest.join();
delete testingHud;
}
示例5: dc
void RealTimeTest::maxSpead() {
Hud *maxSpeadTestingHud = game.getHudsManager()->createHud(HudAlignment::RIGHT);
maxSpeadTestingHud->setText("MAX SPEAD TESTING STARTED...");
DelayCommand dc(15);
dc.execute();
Helicopter *helicopter = game.getHelicopter();
JoystickMoveForward jmf(helicopter->getJoystick());
RotorNeutral rn(helicopter->getMainRotor());
float oldV = 0;
float newV = 0;
std::cout << "\nmaxSpead test started:" << std::endl;
game.getConfiguration()->activateFriction();
helicopter->reset();
helicopter->setPosistion(osg::Vec3f(0, 0, 600));
jmf.execute();
rn.execute();
do {
oldV = newV;
dc.execute();
newV = helicopter->getVelocity().x();
} while (oldV < newV);
// viscous resistance = v * (6 * WORLD_PI * 0.001 * 4)
// if joystick(theta = 15, phi = 0) and throttle(9.8), then
// ax = sin15 * 9.8 = 0.2588 * 9.8 = 2.53624
// viscous resistance should be equal 2.53624
// v * (6 * WORLD_PI * 0.001 * 4) = 2.53624 <= now solve for v
// v = 2.53624 / (6 * WORLD_PI * 0.001 * 4)
// v = 33.6379
Assert(33.6379, helicopter->getVelocity().x(), 0.01);
std::cout << "maxSpead test passed" << std::endl;
std::cout << "maxSpead test results:" << std::endl;
std::cout << "vx = " << helicopter->getVelocity().x() << std::endl;
maxSpeadTestingHud->setText("HOVER TESTING PASSED...");
}
示例6: Hud
Hud* HudsManager::createHud(HudAlignment hudAlignment) {
Hud *hud = new Hud();
unsigned long hudPosition;
hud->initializeHudText();
if (hudAlignment == HudAlignment::LEFT) {
this->leftHuds.push_back(hud);
hud->setPosition(osg::Vec3(10, this->initial_Y_Position, 0));
} else {
this->rightHuds.push_back(hud);
hud->setPosition(osg::Vec3(900, this->initial_Y_Position, 0));
}
hud->setText("");
osg::Camera *hudCamera = hud->getHudCamera();
game->getRoot()->addChild(hudCamera);
// update huds positions
hudPosition = this->leftHuds.size();
for (Hud* h : this->leftHuds)
h->setPosition(osg::Vec3(h->getPosition().x(), ((hudPosition--) * 25) + this->initial_Y_Position + 10, 0));
hudPosition = this->rightHuds.size();
for (Hud* h : this->rightHuds)
h->setPosition(osg::Vec3(h->getPosition().x(), ((hudPosition--) * 25) + this->initial_Y_Position + 10, 0));
return hud;
}
示例7: mav_pose_t_handler
void mav_pose_t_handler(const lcm_recv_buf_t *rbuf, const char* channel, const mav_pose_t *msg, void *user) {
Hud *hud = (Hud*)user;
hud->SetAltitude(msg->pos[2]);
hud->SetOrientation(msg->orientation[0], msg->orientation[1], msg->orientation[2], msg->orientation[3]);
hud->SetAcceleration(msg->accel[0], msg->accel[1], msg->accel[2]);
hud->SetAirspeed(msg->vel[0]);
hud->SetTimestamp(msg->utime);
}
示例8: main
int main(int argc, char *argv[])
{
// get input arguments
string configFile = "";
string video_file_left = "", video_file_right = "", video_directory = "";
int starting_frame_number = 0;
bool enable_gamma = false;
float random_results = -1.0;
int last_frame_number = -1;
int last_playback_frame_number = -2;
ConciseArgs parser(argc, argv);
parser.add(configFile, "c", "config", "Configuration file containing camera GUIDs, etc.", true);
parser.add(show_display, "d", "show-dispaly", "Enable for visual debugging display. Will reduce framerate significantly.");
parser.add(show_display_wait, "w", "show-display-wait", "Optional argument to decrease framerate for lower network traffic when forwarding the display.");
parser.add(show_unrectified, "u", "show-unrectified", "When displaying images, do not apply rectification.");
parser.add(disable_stereo, "s", "disable-stereo", "Disable online stereo processing.");
parser.add(force_brightness, "b", "force-brightness", "Force a brightness setting.");
parser.add(force_exposure, "e", "force-exposure", "Force an exposure setting.");
parser.add(quiet_mode, "q", "quiet", "Reduce text output.");
parser.add(video_file_left, "l", "video-file-left", "Do not use cameras, instead use this video file (also requires a right video file).");
parser.add(video_file_right, "t", "video-file-right", "Right video file, only for use with the -l option.");
parser.add(video_directory, "i", "video-directory", "Directory to search for videos in (for playback).");
parser.add(starting_frame_number, "f", "starting-frame", "Frame to start at when playing back videos.");
parser.add(display_hud, "v", "hud", "Overlay HUD on display images.");
parser.add(record_hud, "x", "record-hud", "Record the HUD display.");
parser.add(file_frame_skip, "p", "skip", "Number of frames skipped in recording (for playback).");
parser.add(enable_gamma, "g", "enable-gamma", "Turn gamma on for both cameras.");
parser.add(random_results, "R", "random-results", "Number of random points to produce per frame. Can be a float in which case we'll take a random sample to decide if to produce the last one. Disables real stereo processing. Only for debugging / analysis!");
parser.add(publish_all_images, "P", "publish-all-images", "Publish all images to LCM");
parser.parse();
// parse the config file
if (ParseConfigFile(configFile, &stereoConfig) != true)
{
fprintf(stderr, "Failed to parse configuration file, quitting.\n");
return -1;
}
if (video_file_left.length() > 0
&& video_file_right.length() <= 0) {
fprintf(stderr, "Error: for playback you must specify both "
"a right and left video file. (Only got a left one.)\n");
return -1;
}
if (video_file_left.length() <= 0
&& video_file_right.length() > 0) {
fprintf(stderr, "Error: for playback you must specify both "
"a right and left video file. (Only got a right one.)\n");
return -1;
}
recording_manager.Init(stereoConfig);
// attempt to load video files / directories
if (video_file_left.length() > 0) {
if (recording_manager.LoadVideoFiles(video_file_left, video_file_right) != true) {
// don't have videos, bail out.
return -1;
}
}
if (video_directory.length() > 0) {
if (recording_manager.SetPlaybackVideoDirectory(video_directory) != true) {
// bail
return -1;
}
}
recording_manager.SetQuietMode(quiet_mode);
recording_manager.SetPlaybackFrameNumber(starting_frame_number);
uint64 guid = stereoConfig.guidLeft;
uint64 guid2 = stereoConfig.guidRight;
// start up LCM
lcm_t * lcm;
lcm = lcm_create (stereoConfig.lcmUrl.c_str());
unsigned long elapsed;
Hud hud;
// --- setup control-c handling ---
struct sigaction sigIntHandler;
sigIntHandler.sa_handler = control_c_handler;
sigemptyset(&sigIntHandler.sa_mask);
//.........这里部分代码省略.........
示例9: mav_gps_data_t_handler
void mav_gps_data_t_handler(const lcm_recv_buf_t *rbuf, const char* channel, const mav_gps_data_t *msg, void *user) {
Hud *hud = (Hud*)user;
hud->SetGpsSpeed(msg->speed);
hud->SetGpsHeading(msg->heading);
}
示例10: IndieLib
int IndieLib()
{
// ----- IndieLib intialization -----
CIndieLib *mI = CIndieLib::instance();
if (!mI->init()) return 0;
// ----- Get Window Dimensions
int winWidth = mI->_window->getWidth();
int winHeight = mI->_window->getHeight();
srand(static_cast<unsigned int>(time(0)));
// ----- Surface loading -----
IND_Surface *mSurfaceBack = IND_Surface::newSurface();
if (!mI->_surfaceManager->add(mSurfaceBack, "../SpaceGame/resources/Backgrounds/18.jpg", IND_OPAQUE, IND_32)) return 0;
/*IND_Animation* mTestA = IND_Animation::newAnimation();
if (!mI->_animationManager->addToSurface(mTestA, "resources/animations/dust.xml", IND_ALPHA, IND_32, 255, 0, 255)) return 0;
mTestA->getActualFramePos(0);*/
// Loading 2D Entities
// Background
IND_Entity2d* mBack = IND_Entity2d::newEntity2d();
mI->_entity2dManager->add(mBack);
mBack->setSurface(mSurfaceBack);
mBack->setScale((float)winWidth / mSurfaceBack->getWidth(), (float)winHeight / mSurfaceBack->getHeight());
Controls* controls = new Controls();
controls->loadSettings();
ErrorHandler* error = new ErrorHandler();
error->initialize(mI);
Hud* mHud = new Hud();
mHud->createHud(mI);
Menu* mMenu = new Menu();
mMenu->createMenu(mI);
Save* quickSave = new Save();
if (!SoundEngine::initialize())
{
error->writeError(200, 100, "Error", "SoundEngine");
}
vector<Planet*> mPlanets;
Ship* mShip = NULL;
bool loadSave = false;
float mDelta = 0.0f;
IND_Timer* mTimer = new IND_Timer;
mTimer->start();
while (!mI->_input->onKeyPress(IND_ESCAPE) && !mI->_input->quit() && !mMenu->isExit())
{
// get delta time
mDelta = mI->_render->getFrameTime() / 1000.0f;
if (mI->_input->isKeyPressed(controls->getMenu()))
{
mMenu->show();
SoundEngine::getSoundEngine()->setAllSoundsPaused(true);
}
if (!mMenu->isHidden())
{
mMenu->updateMenu(mHud, quickSave, mPlanets, mShip);
loadSave = mHud->getLoadingText()->isShow();
}
else
{
if (loadSave)
{
mDelta = 0.0;
loadSave = false;
SoundEngine::getSoundEngine()->setAllSoundsPaused(true);
mHud->getLoadingText()->setShow(false);
quickSave->loadSave(mI, mShip, mPlanets);
mHud->showHud();
}
if (mShip != NULL)
{
if (mI->_input->onKeyPress(controls->getQuickSave()))
{
quickSave->makeSave(mI, mShip, mPlanets);
}
mHud->updateHud(mShip);
if (mI->_input->onKeyPress(controls->getQuickLoad()))
{
deleteObjects(mHud, mShip, mPlanets);
loadSave = true;
}
//.........这里部分代码省略.........
示例11: HudsManager
void Game::initializePopupHelpScreen() {
if (popupHelpScreen)
delete popupHelpScreen;
this->popupHelpScreen = new HudsManager(this, this->configuration->getScreenHeight() / 2);
Hud *titleHud = popupHelpScreen->createHud(HudAlignment::LEFT);
Hud *mouseHud;
Hud *movementHud;
if (this->configuration->isMouseControl())
mouseHud = popupHelpScreen->createHud(HudAlignment::LEFT);
else
movementHud = popupHelpScreen->createHud(HudAlignment::LEFT);
Hud *resetJoystickHud = popupHelpScreen->createHud(HudAlignment::LEFT);
Hud *zeroRotorSpeedHud = popupHelpScreen->createHud(HudAlignment::LEFT);
Hud *increase_decreaseRotorSpeedHud = popupHelpScreen->createHud(HudAlignment::LEFT);
Hud *neutralRotorModeHud = popupHelpScreen->createHud(HudAlignment::LEFT);
Hud *rotationHud = popupHelpScreen->createHud(HudAlignment::LEFT);
Hud *fireHud = popupHelpScreen->createHud(HudAlignment::LEFT);
Hud *increment_decrementInclinationAngleHud = popupHelpScreen->createHud(HudAlignment::LEFT);
Hud *increment_decrementMissileInitialSpeedHud = popupHelpScreen->createHud(HudAlignment::LEFT);
Hud *frictionEnable_DisableHud = popupHelpScreen->createHud(HudAlignment::LEFT);
Hud *startLoggingHud = popupHelpScreen->createHud(HudAlignment::LEFT);
Hud *stopLoggingHud = popupHelpScreen->createHud(HudAlignment::LEFT);
Hud *updateHud = popupHelpScreen->createHud(HudAlignment::LEFT);
Hud *showHelpHud = popupHelpScreen->createHud(HudAlignment::LEFT);
Hud *hideHelpHud = popupHelpScreen->createHud(HudAlignment::LEFT);
titleHud->setText("Settings");
if (this->configuration->isMouseControl())
mouseHud->setText("Mouse contorl the joystick");
else {
movementHud->setText(
std::string(1, this->configuration->getKeySettings().movingForward) + ", " +
std::string(1, this->configuration->getKeySettings().movingRight) + ", " +
std::string(1, this->configuration->getKeySettings().movingLeft) + ", " +
std::string(1, this->configuration->getKeySettings().movingBackward) +
": moving forward, left, right, backward"
);
}
resetJoystickHud->setText(
std::string(1, this->configuration->getKeySettings().resetJoystick) + ": reset joystick");
zeroRotorSpeedHud->setText(
std::string(1, this->configuration->getKeySettings().zeroRotorSpeed) + ": zero rotor speed");
increase_decreaseRotorSpeedHud->setText(
std::string(1, this->configuration->getKeySettings().increaseRotorSpeed) + "/" +
std::string(1, this->configuration->getKeySettings().decreaseRotorSpeed) + ": +/- rotor speed");
neutralRotorModeHud->setText(
std::string(1, this->configuration->getKeySettings().neutralRotorMode) + ": neutral rotor mode");
rotationHud->setText(
std::string(1, this->configuration->getKeySettings().rotateLeft) + "/" +
std::string(1, this->configuration->getKeySettings().rotateRight) + ": rotate left/right");
fireHud->setText(
std::string(1, this->configuration->getKeySettings().fire) + ": fire");
increment_decrementInclinationAngleHud->setText(
std::string(1, this->configuration->getKeySettings().incrementInclinationAngle) + "/" +
std::string(1, this->configuration->getKeySettings().decrementInclinationAngle) +
": +/- inclination angle");
increment_decrementMissileInitialSpeedHud->setText(
std::string(1, this->configuration->getKeySettings().incrementMissileInitialSpeed) + "/" +
std::string(1, this->configuration->getKeySettings().decrementMissileInitialSpeed) +
+ ": +/- increment missile initial speed");
frictionEnable_DisableHud->setText(
std::string(1, this->configuration->getKeySettings().frictionEnable) + "/" +
std::string(1, this->configuration->getKeySettings().frictionDisable) +
+ ": enable/disable friction");
startLoggingHud->setText(
std::string(1, this->configuration->getKeySettings().startLogging) + ": start logging");
stopLoggingHud->setText(
std::string(1, this->configuration->getKeySettings().stopLogging) + ": stop logging");
updateHud->setText(
std::string(1, this->configuration->getKeySettings().updateKeySettings) + ": updste key settings");
showHelpHud->setText(
std::string(1, this->configuration->getKeySettings().showPopupHelpScreen) + ": show help screen");
hideHelpHud->setText(
std::string(1, this->configuration->getKeySettings().hidePopupHelpScreen) + ": hide help screen");
}
示例12: Register
void ScreenOverlay::Register(Hud& _hud)
{
_hud.RegisterElement(*this);
}
示例13: starfield
Level::Level( int which ) {
Starfield starfield( 350 );
Hud hud;
Timer *timer = Timer::Instance();
Video *video = Video::Instance();
SpriteList *spriteList = SpriteList::Instance();
Ship *player = new Ship(); // the player sprite
bool quit = false;
SDL_Event event;
camera = Camera::Instance();
camera->Follow( player );
player->UseAI( false );
player->IsPlayer( true );
player->SetThrust( 5. );
// add player
spriteList->Add( player );
Ship *test = new Ship( 15, 15 );
spriteList->Add( test );
if( SDL_Init( SDL_INIT_JOYSTICK ) != 0 )
cout << "massive joystick error" << endl; // move to an input class
timer->Reset();
hud.Message( HUD_MSG_COMMAND, "Good morning, pilot." );
while( !quit ) {
// erase
video->Blank();
// update
// get user input
while( SDL_PollEvent( &event ) ) {
switch( event.type ) {
case SDL_QUIT:
quit = true;
break;
case SDL_JOYAXISMOTION:
cout << "joystick motion!" << endl;
if(event.jaxis.which == 0)
player->Turn( (float)-20 * 0.15f );
break;
case SDL_KEYDOWN:
switch( event.key.keysym.sym ) {
case SDLK_ESCAPE:
quit = true;
break;
case SDLK_w:
player->ThrottleUp();
break;
case SDLK_s:
player->ThrottleDown();
break;
default:
break;
}
break;
case SDL_MOUSEMOTION:
if(( event.motion.xrel ) && ( event.motion.xrel != 160 )) {
if( abs(event.motion.xrel) > 20 )
if(event.motion.xrel < 0)
player->Turn( (float)-20 * 0.15f );
else
player->Turn( (float)20 * 0.15f );
else
player->Turn( (float)event.motion.xrel * 0.15f );
}
break;
case SDL_MOUSEBUTTONDOWN:
if( event.button.button == 1) player->Fire();
if( event.button.button == 4) player->ThrottleUp();
if( event.button.button == 5) player->ThrottleDown();
break;
default:
break;
}
}
for( int n = timer->GetLoops(); n ; --n ) {
// update various systems
camera->Update();
starfield.Update();
spriteList->Update();
hud.Update();
}
// draw
starfield.Draw();
spriteList->Draw();
hud.Draw();
video->Update();
//.........这里部分代码省略.........
示例14: main
int main(int argc, char ** argv)
{
SDL_Surface * psdlsScreen = NULL;
SDL_Surface * psdlsWMIcon = NULL;
int nVideoMode = MODE_WINDOWED;
bool bDone = false;
char szFilename[512] = {"default.lvl\0"};
Level level("fuckyou");
Cursor cursor(0, 0);
Hud hud;
// deal with command line shit
if(argc > 2)
{
ShowUsage();
exit(1);
}
if(argc == 2)
{
if(!strcmp("--help", argv[1]) || !strcmp("-h", argv[1]) || !strcmp("-help", argv[1]))
{
ShowUsage();
exit(0);
}
sprintf(szFilename, "%s", argv[1]);
if(!level.ReadFromFile(szFilename))
fprintf(stderr, "Couldn't read level from: %s, assuming file doesn't exist yet\n", szFilename);
else
fprintf(stderr, "Level read successfully from: %s\n", szFilename);
}
else
fprintf(stderr, "No file name specified, using: %s\n", szFilename);
InitSDL();
// SetVideoMode(psdlsScreen, nVideoMode);
fprintf(stderr, "Setting window icon... ");
psdlsWMIcon = SDL_LoadBMP(LoadResource("bomn32.bmp", RESOURCE_GRAPHIC));
if(psdlsWMIcon)
{
Uint32 colorkey;
colorkey = SDL_MapRGB(psdlsWMIcon->format, 0, 0, 0);
SDL_SetColorKey(psdlsWMIcon, SDL_SRCCOLORKEY, colorkey);
SDL_WM_SetIcon(psdlsWMIcon, NULL);
fprintf(stderr, "Success!\n");
}
else
fprintf(stderr, "AW JUNK! Something fishy happened...\n");
// can't fucking use SetVideoMode here, for SOME REASON
fprintf(stderr, "Setting video mode to 800x600 %s mode... ", (nVideoMode == MODE_WINDOWED ? "windowed" : "fullscreen"));
SDL_WM_SetCaption("Bomns for Linux Level Editor", "Bomns for Linux Level Editor");
if(nVideoMode == MODE_WINDOWED)
psdlsScreen = SDL_SetVideoMode(800, 600, 0, SDL_HWSURFACE | SDL_DOUBLEBUF);
else if(nVideoMode == MODE_FULLSCREEN)
psdlsScreen = SDL_SetVideoMode(800, 600, 0, SDL_HWSURFACE | SDL_DOUBLEBUF | SDL_FULLSCREEN);
else
QuitWithError("Que?\n");
if(!psdlsScreen)
QuitWithError("Error setting GODDAM VIDEO MODE... for some fucking reason!\n");
else
fprintf(stderr, "Success!\n");
SDL_ShowCursor(false);
// do this here so the surfaces can read the display format
cursor.CreateSurfaces();
hud.CreateSurfaces();
level.CreateSurfaces();
// main input loop
while(!bDone)
{
SDL_Event sdleEvent;
Uint8 * anKeyState = NULL;
Uint8 nMouseState = 0;
while(SDL_PollEvent(&sdleEvent))
{
if(sdleEvent.type == SDL_QUIT)
bDone = true;
// TODO: use relative mouse motion so it doesn't jump around
if(sdleEvent.type == SDL_MOUSEMOTION)
cursor.SetPosition(sdleEvent.motion.x / 10, sdleEvent.motion.y / 10);
// process mouse input
nMouseState = SDL_GetMouseState(NULL, NULL);
if(nMouseState & SDL_BUTTON_LMASK)
cursor.StampCurrentObject(&level);
if(nMouseState & SDL_BUTTON_RMASK)
cursor.DeleteUnderCursor(&level);
if(sdleEvent.type == SDL_MOUSEBUTTONDOWN)
{
switch(sdleEvent.button.button)
{
case SDL_BUTTON_WHEELUP:
cursor.ForwardObject();
//.........这里部分代码省略.........
示例15: baro_airspeed_handler
void baro_airspeed_handler(const lcm_recv_buf_t *rbuf, const char* channel, const lcmt_baro_airspeed *msg, void *user) {
Hud *hud = (Hud*)user;
hud->SetAirspeed(msg->airspeed);
}