Rigs of Rods 2023.09
Soft-body Physics Simulation
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Loading...
Searching...
No Matches
GUI_DirectionArrow.cpp
Go to the documentation of this file.
1/*
2 This source file is part of Rigs of Rods
3 Copyright 2005-2012 Pierre-Michel Ricordel
4 Copyright 2007-2012 Thomas Fischer
5 Copyright 2013-2020 Petr Ohlidal
6
7 For more information, see http://www.rigsofrods.org/
8
9 Rigs of Rods is free software: you can redistribute it and/or modify
10 it under the terms of the GNU General Public License version 3, as
11 published by the Free Software Foundation.
12
13 Rigs of Rods is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with Rigs of Rods. If not, see <http://www.gnu.org/licenses/>.
20*/
21
22
23#include "GUI_DirectionArrow.h"
24
25#include "Actor.h"
26#include "AppContext.h"
27#include "GfxActor.h"
28#include "GfxScene.h"
29#include "Language.h"
30#include "GUIManager.h"
31
32#include <Overlay/OgreOverlayManager.h>
33#include <fmt/core.h>
34
35using namespace RoR;
36using namespace GUI;
37
39{
40 // Load overlay from .overlay file
41 m_overlay = Ogre::OverlayManager::getSingleton().getByName("tracks/DirectionArrow");
42
43 // openGL fix
44 m_overlay->show();
45 m_overlay->hide();
46
47 this->CreateArrow();
48}
49
51{
52 // setup direction arrow
53 Ogre::Entity* arrow_entity = App::GetGfxScene()->GetSceneManager()->createEntity("arrow2.mesh");
54 arrow_entity->setRenderQueueGroup(Ogre::RENDER_QUEUE_OVERLAY);
55
56 // Add entity to the scene node
57 m_node = new Ogre::SceneNode(App::GetGfxScene()->GetSceneManager());
58 m_node->attachObject(arrow_entity);
59 m_node->setVisible(false);
60 m_node->setScale(0.1, 0.1, 0.1);
61 m_node->setPosition(Ogre::Vector3(-0.6, +0.4, -1));
62 m_node->setFixedYawAxis(true, Ogre::Vector3::UNIT_Y);
63 m_overlay->add3D(m_node);
64}
65
67{
69
71 {
72 // Set visible
73 m_node->setVisible(true);
74 m_overlay->show();
75
76 // Update arrow direction
77 m_node->lookAt(data.simbuf_dir_arrow_target, Ogre::Node::TS_WORLD, Ogre::Vector3::UNIT_Y);
78 }
79 else
80 {
81 m_node->setVisible(false);
82 m_overlay->hide();
83 }
84}
85
86// Only effective in main menu, simulation visibility is set in `Update()`
88{
89 if (m_node && m_overlay)
90 {
91 m_node->setVisible(value);
92 if (value)
93 m_overlay->show();
94 else
95 m_overlay->hide();
96 }
97}
System integration layer; inspired by OgreBites::ApplicationContext.
Race direction arrow and text info (using OGRE Overlay)
Manager for all visuals belonging to a single actor.
void Update(RoR::GfxActor *player)
void CreateArrow()
Must be called again after OGRE scenemanager is cleared.
void SetVisible(bool value)
Only effective in main menu, simulation visibility is set in Update()
void LoadOverlay()
Must be called after meshes+overlays were loaded.
Ogre::SceneManager * GetSceneManager()
Definition GfxScene.h:83
GameContextSB & GetSimDataBuffer()
Definition GfxScene.h:80
GfxScene * GetGfxScene()
bool simbuf_dir_arrow_visible
Definition SimBuffers.h:218
Ogre::Vector3 simbuf_dir_arrow_target
Definition SimBuffers.h:216