mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-04 04:13:11 +02:00
refining the avatar display name rendering with different behavior if in HMD mode or not
This commit is contained in:
parent
c2adc6256e
commit
fc54ad93b8
3 changed files with 35 additions and 13 deletions
|
@ -2673,6 +2673,14 @@ void Application::queryOctree(NodeType_t serverType, PacketType packetType, Node
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Application::isHMDMode() const {
|
||||||
|
if (OculusManager::isConnected()) {
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////
|
||||||
// loadViewFrustum()
|
// loadViewFrustum()
|
||||||
//
|
//
|
||||||
|
|
|
@ -316,6 +316,11 @@ public:
|
||||||
|
|
||||||
void registerScriptEngineWithApplicationServices(ScriptEngine* scriptEngine);
|
void registerScriptEngineWithApplicationServices(ScriptEngine* scriptEngine);
|
||||||
|
|
||||||
|
// the isHMDmode is true whenever we use the interface from an HMD and not a standard flat display
|
||||||
|
// rendering of several elements depend on that
|
||||||
|
// TODO: carry that information on the Camera as a setting
|
||||||
|
bool isHMDMode() const;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
|
||||||
/// Fired when we're simulating; allows external parties to hook in.
|
/// Fired when we're simulating; allows external parties to hook in.
|
||||||
|
|
|
@ -655,7 +655,10 @@ void Avatar::renderDisplayName() {
|
||||||
if (_displayName.isEmpty() || _displayNameAlpha == 0.0f) {
|
if (_displayName.isEmpty() || _displayNameAlpha == 0.0f) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// which viewing mode?
|
||||||
|
bool inHMD = Application::getInstance()->isHMDMode();
|
||||||
|
|
||||||
glDisable(GL_LIGHTING);
|
glDisable(GL_LIGHTING);
|
||||||
|
|
||||||
glPushMatrix();
|
glPushMatrix();
|
||||||
|
@ -664,17 +667,17 @@ void Avatar::renderDisplayName() {
|
||||||
glTranslatef(textPosition.x, textPosition.y, textPosition.z);
|
glTranslatef(textPosition.x, textPosition.y, textPosition.z);
|
||||||
|
|
||||||
// we need "always facing camera": we must remove the camera rotation from the stack
|
// we need "always facing camera": we must remove the camera rotation from the stack
|
||||||
glm::quat rotation = Application::getInstance()->getCamera()->getRotation();
|
|
||||||
|
|
||||||
glm::vec3 frontAxis(1.f, 0.f, 0.f);
|
glm::vec3 frontAxis(0.f, 0.f, 1.f);
|
||||||
frontAxis = glm::rotate(rotation, frontAxis);
|
if (inHMD) {
|
||||||
frontAxis = glm::normalize(glm::vec3(frontAxis.x, 0.f, frontAxis.z));
|
glm::vec3 camPosition = Application::getInstance()->getCamera()->getPosition();
|
||||||
|
frontAxis = camPosition - textPosition;
|
||||||
// TODO : test this secodn solution which should be better wfor occulus
|
} else {
|
||||||
//glm::vec3 camPosition = Application::getInstance()->getCamera()->getPosition();
|
glm::quat rotation = Application::getInstance()->getCamera()->getRotation();
|
||||||
//glm::vec3 frontAxis = camPosition - textPosition;
|
frontAxis = glm::rotate(rotation, frontAxis);
|
||||||
//frontAxis = glm::normalize(glm::vec3(frontAxis.z, 0.f, -frontAxis.x));
|
}
|
||||||
|
|
||||||
|
frontAxis = glm::normalize(glm::vec3(frontAxis.z, 0.f, -frontAxis.x));
|
||||||
float angle = acos(frontAxis.x) * ((frontAxis.z < 0) ? 1.f : -1.f);
|
float angle = acos(frontAxis.x) * ((frontAxis.z < 0) ? 1.f : -1.f);
|
||||||
glRotatef(glm::degrees(angle), 0.0f, 1.0f, 0.0f);
|
glRotatef(glm::degrees(angle), 0.0f, 1.0f, 0.0f);
|
||||||
|
|
||||||
|
@ -706,10 +709,16 @@ void Avatar::renderDisplayName() {
|
||||||
|
|
||||||
if (success) {
|
if (success) {
|
||||||
double textWindowHeight = abs(result1[1] - result0[1]);
|
double textWindowHeight = abs(result1[1] - result0[1]);
|
||||||
float scaleFactor = Application::getInstance()->getRenderResolutionScale() * // Scale compensate for the resolution
|
// need to scale to compensate for the font resolution due to the device
|
||||||
QApplication::desktop()->windowHandle()->devicePixelRatio() * // And the device pixel ratio
|
float scaleFactor = QApplication::desktop()->windowHandle()->devicePixelRatio() *
|
||||||
((textWindowHeight > EPSILON) ? 1.0f / textWindowHeight : 1.0f);
|
((textWindowHeight > EPSILON) ? 1.0f / textWindowHeight : 1.0f);
|
||||||
glScalef(scaleFactor, scaleFactor, 1.0);
|
if (inHMD) {
|
||||||
|
const float HMDMODE_NAME_SCALE = 0.65f;
|
||||||
|
scaleFactor *= HMDMODE_NAME_SCALE;
|
||||||
|
} else {
|
||||||
|
scaleFactor *= Application::getInstance()->getRenderResolutionScale();
|
||||||
|
}
|
||||||
|
glScalef(scaleFactor, scaleFactor, 1.0);
|
||||||
|
|
||||||
glScalef(1.0f, -1.0f, 1.0f); // TextRenderer::draw paints the text upside down in y axis
|
glScalef(1.0f, -1.0f, 1.0f); // TextRenderer::draw paints the text upside down in y axis
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue