mirror of
https://github.com/overte-org/overte.git
synced 2025-04-25 17:35:45 +02:00
Moved sixense laser stuff to MyAvatar
This commit is contained in:
parent
2cee5992a0
commit
c6bda4bf16
6 changed files with 52 additions and 57 deletions
|
@ -2807,6 +2807,9 @@ void Application::displaySide(Camera& whichCamera, bool selfAvatarOnly) {
|
|||
PerformanceTimer perfTimer("avatars");
|
||||
|
||||
_avatarManager.renderAvatars(mirrorMode ? Avatar::MIRROR_RENDER_MODE : Avatar::NORMAL_RENDER_MODE, selfAvatarOnly);
|
||||
|
||||
//Render the sixense lasers
|
||||
_myAvatar->renderLaserPointers();
|
||||
}
|
||||
|
||||
if (!selfAvatarOnly) {
|
||||
|
|
|
@ -1849,3 +1849,43 @@ void MyAvatar::applyCollision(const glm::vec3& contactPoint, const glm::vec3& pe
|
|||
}
|
||||
}
|
||||
|
||||
//Renders sixense laser pointers for UI selection with controllers
|
||||
void MyAvatar::renderLaserPointers() {
|
||||
const float PALM_TIP_ROD_RADIUS = 0.002f;
|
||||
|
||||
//If the Oculus is enabled, we will draw a blue cursor ray
|
||||
|
||||
for (size_t i = 0; i < getHand()->getNumPalms(); ++i) {
|
||||
PalmData& palm = getHand()->getPalms()[i];
|
||||
if (palm.isActive()) {
|
||||
glColor4f(0, 1, 1, 1);
|
||||
glm::vec3 tip = getLaserPointerTipPosition(&palm);
|
||||
glm::vec3 root = palm.getPosition();
|
||||
|
||||
//Scale the root vector with the avatar scale
|
||||
scaleVectorRelativeToPosition(root);
|
||||
|
||||
Avatar::renderJointConnectingCone(root, tip, PALM_TIP_ROD_RADIUS, PALM_TIP_ROD_RADIUS);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Gets the tip position for the laser pointer
|
||||
glm::vec3 MyAvatar::getLaserPointerTipPosition(const PalmData* palm) {
|
||||
const ApplicationOverlay& applicationOverlay = Application::getInstance()->getApplicationOverlay();
|
||||
const float PALM_TIP_ROD_LENGTH_MULT = 40.0f;
|
||||
|
||||
glm::vec3 direction = glm::normalize(palm->getTipPosition() - palm->getPosition());
|
||||
|
||||
glm::vec3 position = palm->getPosition();
|
||||
//scale the position with the avatar
|
||||
scaleVectorRelativeToPosition(position);
|
||||
|
||||
|
||||
glm::vec3 result;
|
||||
if (applicationOverlay.calculateRayUICollisionPoint(position, direction, result)) {
|
||||
return result;
|
||||
}
|
||||
|
||||
return palm->getPosition();
|
||||
}
|
||||
|
|
|
@ -127,6 +127,9 @@ public:
|
|||
|
||||
void applyCollision(const glm::vec3& contactPoint, const glm::vec3& penetration);
|
||||
|
||||
/// Renders a laser pointer for UI picking
|
||||
void renderLaserPointers();
|
||||
glm::vec3 getLaserPointerTipPosition(const PalmData* palm);
|
||||
public slots:
|
||||
void goHome();
|
||||
void increaseSize();
|
||||
|
|
|
@ -463,51 +463,3 @@ QSize OculusManager::getRenderTargetSize() {
|
|||
return QSize(100, 100);
|
||||
#endif
|
||||
}
|
||||
|
||||
//Renders sixense laser pointers for UI selection in the oculus
|
||||
void OculusManager::renderLaserPointers() {
|
||||
#ifdef HAVE_LIBOVR
|
||||
const float PALM_TIP_ROD_RADIUS = 0.002f;
|
||||
|
||||
MyAvatar* myAvatar = Application::getInstance()->getAvatar();
|
||||
|
||||
//If the Oculus is enabled, we will draw a blue cursor ray
|
||||
|
||||
for (size_t i = 0; i < myAvatar->getHand()->getNumPalms(); ++i) {
|
||||
PalmData& palm = myAvatar->getHand()->getPalms()[i];
|
||||
if (palm.isActive()) {
|
||||
glColor4f(0, 1, 1, 1);
|
||||
glm::vec3 tip = getLaserPointerTipPosition(&palm);
|
||||
glm::vec3 root = palm.getPosition();
|
||||
|
||||
//Scale the root vector with the avatar scale
|
||||
myAvatar->scaleVectorRelativeToPosition(root);
|
||||
|
||||
Avatar::renderJointConnectingCone(root, tip, PALM_TIP_ROD_RADIUS, PALM_TIP_ROD_RADIUS);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
//Gets the tip position for the laser pointer
|
||||
glm::vec3 OculusManager::getLaserPointerTipPosition(const PalmData* palm) {
|
||||
#ifdef HAVE_LIBOVR
|
||||
const ApplicationOverlay& applicationOverlay = Application::getInstance()->getApplicationOverlay();
|
||||
const float PALM_TIP_ROD_LENGTH_MULT = 40.0f;
|
||||
|
||||
glm::vec3 direction = glm::normalize(palm->getTipPosition() - palm->getPosition());
|
||||
|
||||
glm::vec3 position = palm->getPosition();
|
||||
//scale the position with the avatar
|
||||
Application::getInstance()->getAvatar()->scaleVectorRelativeToPosition(position);
|
||||
|
||||
|
||||
glm::vec3 result;
|
||||
if (applicationOverlay.calculateRayUICollisionPoint(position, direction, result)) {
|
||||
return result;
|
||||
}
|
||||
|
||||
return palm->getPosition();
|
||||
#endif
|
||||
return glm::vec3(0.0f);
|
||||
}
|
||||
|
|
|
@ -43,10 +43,6 @@ public:
|
|||
static void getEulerAngles(float& yaw, float& pitch, float& roll);
|
||||
static QSize getRenderTargetSize();
|
||||
|
||||
/// Renders a laser pointer for UI picking
|
||||
static void renderLaserPointers();
|
||||
static glm::vec3 getLaserPointerTipPosition(const PalmData* palm);
|
||||
|
||||
private:
|
||||
#ifdef HAVE_LIBOVR
|
||||
static void generateDistortionMesh();
|
||||
|
|
|
@ -64,6 +64,7 @@ void ApplicationOverlay::renderOverlay(bool renderToTexture) {
|
|||
|
||||
_textureFov = Menu::getInstance()->getOculusUIAngularSize() * RADIANS_PER_DEGREE;
|
||||
|
||||
|
||||
Application* application = Application::getInstance();
|
||||
|
||||
Overlays& overlays = application->getOverlays();
|
||||
|
@ -272,7 +273,7 @@ QPoint ApplicationOverlay::getOculusPalmClickLocation(const PalmData *palm) cons
|
|||
QGLWidget* glWidget = application->getGLWidget();
|
||||
MyAvatar* myAvatar = application->getAvatar();
|
||||
|
||||
glm::vec3 tip = OculusManager::getLaserPointerTipPosition(palm);
|
||||
glm::vec3 tip = myAvatar->getLaserPointerTipPosition(palm);
|
||||
glm::vec3 eyePos = myAvatar->getHead()->calculateAverageEyePosition();
|
||||
glm::quat orientation = glm::inverse(myAvatar->getOrientation());
|
||||
glm::vec3 dir = orientation * glm::normalize(application->getCamera()->getPosition() - tip); //direction of ray goes towards camera
|
||||
|
@ -340,7 +341,7 @@ void ApplicationOverlay::displayOverlayTextureOculus(Camera& whichCamera) {
|
|||
MyAvatar* myAvatar = application->getAvatar();
|
||||
|
||||
//Render the sixense lasers
|
||||
OculusManager::renderLaserPointers();
|
||||
myAvatar->renderLaserPointers();
|
||||
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
|
||||
|
@ -700,7 +701,7 @@ void ApplicationOverlay::renderPointersOculus(const glm::vec3& eyePos) {
|
|||
|
||||
PalmData& palm = myAvatar->getHand()->getPalms()[i];
|
||||
if (palm.isActive()) {
|
||||
glm::vec3 tip = OculusManager::getLaserPointerTipPosition(&palm);
|
||||
glm::vec3 tip = myAvatar->getLaserPointerTipPosition(&palm);
|
||||
glm::vec3 tipPos = (tip - eyePos);
|
||||
|
||||
float length = glm::length(eyePos - tip);
|
||||
|
|
Loading…
Reference in a new issue