MCPcopy Create free account
hub / github.com/Prograda/Skybolt / updateState

Method updateState

src/SkyboltExamples/ExamplesCommon/HudSystem.cpp:155–220  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

153}
154
155void HudSystem::updateState()
156{
157 bool showHud = false;
158 if (mEntity && mEnabled)
159 {
160 osg::Viewport* viewport = mParentCamera->getViewport();
161 mHud->setAspectRatio(viewport->width() / viewport->height());
162
163 Node* node = mEntity->getFirstComponent<Node>().get();
164 Motion* motion = mEntity->getFirstComponent<Motion>().get();
165
166 if (node && motion)
167 {
168 showHud = true;
169 mHud->clear();
170
171 LatLonAlt lla = toLatLonAlt(GeocentricPosition(node->getPosition())).position;
172 Quaternion ltpOrientation = toLtpNed(GeocentricOrientation(node->getOrientation()), toLatLon(lla)).orientation;
173 Vector3 euler = math::eulerFromQuat(ltpOrientation);
174
175 mHeadingRibbon->draw(euler.z * math::radToDegD());
176
177 Quaternion uprightYawFrameOrientation = toGeocentric(LtpNedOrientation(glm::angleAxis(euler.z, Vector3(0, 0, 1))), toLatLon(lla)).orientation;
178 const Vector3 uprightLocalVel = glm::inverse(uprightYawFrameOrientation) * motion->linearVelocity;
179 const glm::vec2 uprightLocalVel2d(uprightLocalVel.x, uprightLocalVel.y);
180
181 if (glm::length(uprightLocalVel2d) < 10)
182 {
183 mHoverVelModel->draw(uprightLocalVel2d);
184 }
185
186 if (mPitchLadderVisible)
187 {
188 double verticalFov = mVerticalFovProvider();
189 mPitchLadder->setPitchGapHeight(2.0 * pitchLadderAngleIncrement / verticalFov);
190 mPitchLadder->draw(euler.y, euler.x);
191 }
192
193 mHud->drawText(glm::vec2(-0.4, 0.35), toIntString(glm::length(motion->linearVelocity) * metersPerSecToKnots));
194
195 mAltitudeBar->draw(lla.alt);
196 mHud->drawText(glm::vec2(0.4, 0.35), toIntString(lla.alt * metersToFeet));
197
198 mRollAngleRibbon->draw(euler.x * math::radToDegD());
199
200 drawVee(*mHud, glm::vec2(0));
201
202 ControlInputsComponent* controlInputsComponents = mEntity->getFirstComponent<ControlInputsComponent>().get();
203 if (controlInputsComponents)
204 {
205 drawControlInputs(*mHud, glm::vec2(-0.8), *controlInputsComponents);
206 }
207 }
208 }
209
210 if (showHud && !mInScene)
211 {
212 mParentCamera->addChild(mHud);

Callers

nothing calls this directly

Calls 15

GeocentricPositionClass · 0.85
toLtpNedFunction · 0.85
eulerFromQuatFunction · 0.85
radToDegDFunction · 0.85
LtpNedOrientationClass · 0.85
toIntStringFunction · 0.85
drawVeeFunction · 0.85
drawControlInputsFunction · 0.85
setPitchGapHeightMethod · 0.80
drawTextMethod · 0.80
toLatLonAltFunction · 0.50

Tested by

no test coverage detected