Coder Social home page Coder Social logo

osgopenvrviewer's People

Contributors

chrisdenham avatar mbehensky avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

osgopenvrviewer's Issues

Missed frames on nvidia 390 with ubuntu 16.04

Good day!
I used your app and found some stuttering in rendering to Vive with GTX 970 and latest SteamVR, OpenVR and OSG from git. hellovr_opengl example works fine without missed frames.
Also I found that at line 715 in hellovr_opengl_main.cpp there is some hack with glFinish();
maybe we need to insert this hack to osgopenvrviewer.

You can add as an example ?

You can add as an example ? Add Controllers and Buttons.....

void OpenVRDevice::updatePose()
{
vr::VRCompositor()->SetTrackingSpace(vr::TrackingUniverseSeated);

vr::TrackedDevicePose_t poses[vr::k_unMaxTrackedDeviceCount];
for (int i = 0; i < vr::k_unMaxTrackedDeviceCount; ++i) poses[i].bPoseIsValid = false;
vr::VRCompositor()->WaitGetPoses(poses, vr::k_unMaxTrackedDeviceCount, NULL, 0);

// Not sure why, but the openvr hellovr_opengl example only seems interested in the
// pose transform from the first pose tracking device in the array.
// i.e. this seems to be the only one that is used to affect the view transform matrix.
// So, here we do the same.

m_position.clear();
m_orientation.clear();
for (int i = 0; i < vr::k_unMaxTrackedDeviceCount; i++)
{
    const vr::TrackedDevicePose_t& pose = poses[i];
    if (pose.bPoseIsValid)
    {

        if ((m_vrSystem->GetTrackedDeviceClass( i ) != vr::TrackedDeviceClass_HMD ) && (m_vrSystem->GetTrackedDeviceClass( i ) != vr::TrackedDeviceClass_Controller )) continue;

        osg::Matrix matrix = convertMatrix34(pose.mDeviceToAbsoluteTracking);



        /*
        pose.mDeviceToAbsoluteTracking
        vr::HmdMatrix34_t
        you'll get the position from the [0][3], [1][3] and [2][3] matrix positions.
        */
        osg::Vec3 __pos (pose.mDeviceToAbsoluteTracking.m[0][3],pose.mDeviceToAbsoluteTracking.m[1][3],pose.mDeviceToAbsoluteTracking.m[2][3]);
        m_position.push_back ( __pos );

        osg::Matrix poseTransform = osg::Matrix::inverse(matrix);
        //m_position.push_back ( poseTransform.getTrans() * m_worldUnitsPerMetre );
        m_orientation.push_back ( poseTransform.getRotate());
    }
}


ButtonsAndAnalog.clear();


// Process SteamVR controller state
for (vr::TrackedDeviceIndex_t unDevice = 0; unDevice < vr::k_unMaxTrackedDeviceCount; unDevice++)
{
    if (m_vrSystem->GetTrackedDeviceClass( unDevice ) != vr::TrackedDeviceClass_Controller ) continue;

    buttons_and_analog temp;
    temp.k_EButton_ApplicationMenu=false;
    temp.k_EButton_Grip=false;
    temp.k_EButton_SteamVR_Touchpad=false;
    temp.k_EButton_SteamVR_Trigger=false;
    temp.TrackPad_x=0;
    temp.TrackPad_y=0;
    temp.Joystick_x=0;
    temp.Joystick_y=0;
    temp.Trigger_x=0;
    temp.Trigger_y=0;

    vr::VRControllerState_t state;
    if (m_vrSystem->GetControllerState(unDevice, &state))
    {
        if (state.ulButtonPressed & vr::ButtonMaskFromId(vr::k_EButton_ApplicationMenu)) temp.k_EButton_ApplicationMenu = true;
        if (state.ulButtonPressed & vr::ButtonMaskFromId(vr::k_EButton_SteamVR_Trigger))  temp.k_EButton_SteamVR_Trigger = true;
        if (state.ulButtonPressed & vr::ButtonMaskFromId(vr::k_EButton_Grip)) temp.k_EButton_Grip = true;
        if (state.ulButtonTouched & vr::ButtonMaskFromId(vr::k_EButton_SteamVR_Touchpad)) temp.k_EButton_SteamVR_Touchpad = true;


        // Convert the axes
        for (int j = 0; j < vr::k_unControllerStateAxisCount; j++)
        {
            vr::ETrackedDeviceProperty prop = (vr::ETrackedDeviceProperty)(vr::Prop_Axis0Type_Int32 + j);
            vr::EVRControllerAxisType type = (vr::EVRControllerAxisType)vr::VRSystem()->GetInt32TrackedDeviceProperty(unDevice, prop);
            vr::VRControllerAxis_t axis = state.rAxis[j];

            if (type == vr::k_eControllerAxis_TrackPad)
            {
                temp.TrackPad_x = axis.x ;
                temp.TrackPad_y = axis.y ;
            }

            if (type == vr::k_eControllerAxis_Trigger)
            {
                temp.Trigger_x = axis.x ;
                temp.Trigger_y = axis.y ;
            }

            if (type == vr::k_eControllerAxis_Joystick)
            {
                temp.Joystick_x = axis.x ;
                temp.Joystick_y = axis.y ;
            }
        }

        //
    }

    ButtonsAndAnalog.push_back(temp);
}

class buttons_and_analog
{
public:
bool k_EButton_ApplicationMenu;
bool k_EButton_SteamVR_Trigger;
bool k_EButton_Grip;
bool k_EButton_SteamVR_Touchpad;

float TrackPad_x;
float TrackPad_y;

float Trigger_x;
float Trigger_y;

float Joystick_x;
float Joystick_y;

};

std::vector osg::Vec3 position() const { return m_position; }
std::vector osg::Quat orientation() const { return m_orientation; }
std::vector <buttons_and_analog> buttonsAndAnalogs() const { return ButtonsAndAnalog; }

Integration with osgearth

Hello Chris,

this is an exciting development.

I am trying to integrate openvrviewer with osgearth viewer ... can you help me in this regard ?

thanks ,
Jai

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.