About the work record of displaying the handle in OSG+VR

brief:

Various detours, the matrix is ​​not very good. 

The osg's own bot has an impact on the camera, I didn't know it at first.

There are still some unsolved mysteries, such as how does the frame rate of 90 frames come from? What is provided by SteamVR?

The handle model still uses the surface drawing method, which is not good-looking, and does not know openGL, so there is no way.

TXT:

Found the code to load the controller:
error = vr::VRRenderModels()->LoadRenderModel_Async( pchRenderModelName, &pModel );//1: lh_basestation_vive 2:vr_controller_1_5
But there is source code in this function LoadRenderModel_Async

CGLRenderModel::Draw() RenderModel draws itself. The question is how to draw itself
. The method called inside is from glew.h

So, is it possible to draw in OSG with native OpenGL?

1>main.obj : error LNK2001: unresolved external symbol __imp__glewActiveTexture
1>main.obj : error LNK2001: unresolved external symbol __imp___glewBindVertexArray
1>MSVCRT.lib(crtexe.obj) : error LNK2001: unresolved external The symbol main
has an error that the main cannot be parsed because of the file SDL.h.
LNK2001 is a platform problem. The sample example uses Debug win32
. The difference between Debug and Release may not matter, because the Sample project is to load the Release version of the lib, but compile it with the Debug version
This Sample is in the OSG64 folder, but it is 32-bit
compiled and passed, now to load the dll
openvr108\samples\bin\win64 There is also a glew32.dll
that has stopped working, the error location is 0x0000 There is no error code

Without the foundation of OpenGL, I can't solve this error.

############################################################################################

If the display controller is the built-in api of SteamVR or HTC VIVE. Then, there is no model file.
However, in OpenGL, the performance of the controller is different from that in Unity. There is no trigger pressing process in OpenGL.
renderModelName and OpenGL The same as in: vr_controller_vive_1_5


############################################################################################

https://github.com/ValveSoftware/openvr/wiki/API-Documentation#initialization-and-cleanup
IVRSystem mapping of two eyes, tracking of helmet handle, event response
Compositor typesetting worker Used in updatePose WaitGetPoses
IVOverlay It is suspected that there are examples of APIs for displaying 2D images in 3D scenes, but the example is QT.
    If you want to do a model program, the existing VR scene must be able to run through
Screenshots. I guess it is a screenshot and a picture, the two sample projects are useless Here, I don't know what exactly


So, how is the projection of the desktop screen realized? How is the projection of the HMD realized? IVRSystem

Deduct the code and use it directly. The current requirement is to display the osg scene in VR, that's
all. After copying the OpenVRDll64 project again, there will be no header file conflict
    . function, can not be displayed normally
    now I want to encapsulate it into an inline function, all kinds of errors

####


In order to copy the handle model to get the code, it is necessary to add the directory glew32.lib of the imported header file. The
unresolved external symbol bool __cdecl CGLRenderModel::BInit
code has not been copied
. Copy the glew32.dll over. This dll can also be used under x64. .GetRenderModelCount
() The number of models retrieved by this function is 51, which is too many and is not affected by the device switch. It may be a constant
helloVR how to get the device name, how helloVR gets the device id
helloVR, Get the device name through the function GetTrackedDeviceString . The
device number of the handle is 3 or 4. 
The device name obtained from osg is: generic_controller and generic_hmd are 3 and 4 respectively. The
number of devices is only 4, and no more devices are found. vr::k_unTrackedDeviceIndex_Hmd is counted. The skipped one, the five have
to build global variables, but fortunately in the module, other modules can't call it.
It also needs to deal with the situation that the controller is turned off halfway or has no power.

The viewer cannot be obtained in openvrdevice, so drawing relies on external calls.

####
The 3 and 4 obtained are not the vr handle model, output all models, there is no previous
lh_basestation_vive 2:vr_controller_1_5 The
vr handle is outside the 16 models

Model name greater than 4: 5 : generic_tracker
Model name greater than 4: 6 : hard_bounds
Model name greater than 4: 7 : laser_pointer
Model name greater than 4: 8 : lh_basestation_01_boysandgirls
Model name greater than 4: 9 : lh_basestation_02_batman
Model name greater than 4 :10 : lh_basestation_03_robin
model name greater than 4: 11 : lh_basestation_vive
model name greater than 4: 12 : lighthouse_ufo
model name greater than 4: 13 : mptam_hmd_model
model name greater than 4: 14 : oculus_cv1_controller_left
model name greater than 4: 15 : oculus_cv1_controller_right

The handle model can be displayed, although it is not perfect
########################################## ##################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################

Now the movement of the handle does not match the reality.
Let's see how it is done in hellovr. RenderControllerAxes has processed
m_rmat4DevicePose and this data is also taken from mDeviceToAbsoluteTracking.

The rotation of the handle is messed up, is it a left-handed coordinate system?

Do the matrix test in line 1145 of hellovr_opengl_main.cpp.
Therefore, the last line of the matrix is ​​the coordinates. This line is not affected
. You can also see how the helmet moves.
The movement of the headset is also affected by the angle, but there is no problem. Yes A difference is that the headset acts on the camera, while the handle acts on the objects in the scene. The
environment is different, the matrix obtained in hellovr, the last row obtained does not change due to the change of angle.
The output of hellovr : 1.918463, 0.884200, 0.470154 , 1.000000
osg output: 0.179302, 0.00267851, 0.0541984, 1

################################################## ##################
Either learn to calculate, or find out why the coordinates are different
###################### #############################################
How is openvrdevices Brush frame to get device coordinates?
    updatePose is called in OpenVRUpdateSlaveCallback

Is there any difference in initialization parameters between osg and openGL?
    From openvrdevices, I can't see any parameters

Is there a parameter of 90 frames? No! So where is updateSlave called?
    There is a function called updateSlaveImplementation in the slave, which is an osg function, which may trigger the osg refresh,
    otherwise the osg only has 60 frames
    OpenVRUpdateSlaveCallback : public osg::View:: Slave::UpdateSlaveCallback
    uses OSG's standard
    m_view object only, there are two slave viewports
    gc->setSwapCallback(swapCallback); Does this sentence have any effect?
    ​​Finally, lost clues in swapBuffersImplementation
    
########## ################################################## ########
The code readability of the example is there, and the OpenVR documentation is there, but what should I do?
How to refresh the frame by the VR device, I can't find it, it can only be triggered by osg.
Then, first make a model program to see if you can get the frame refresh event callback function of the View.
    Just use the NodeCallback StackOverflow first, which is also the case


Now that the entire matrix array is output, it is found that m[0][3] ~ m[2][3] is OK.
Then why is Matrix44 not?

Build a few cubes as reference objects
    and follow the reference objects. The X and Z of the handle are no problem.
    The reference objects are .3 in size and z-direction.


1. For the handle, there is an axis that is reversed. Does the handle model need to be inverted or the coordinates should be inverted?
2. The camera's coordinate specification, but can the handle's specification be used ?


State 1: put on the table
.957936 .0671016 0
0.279027 -0.129168 0.969042 0.210413 0
-0.25627 -0.237603 .936947 0
-0.0621173 0.0138077 -0.157989 1 << Matrix44
State 2: put a chair
0.865644 0.010904 0.500541 0
-0.125182 0.972721 0.195301 0
-0.484757 -0.23172 0.843396 0
-1.19622 -0.439365 3.71773 1 <<Matrix44

State 3: chair by the window
.945089 .0206033 0.326164 0
-0.101473 .967185 0
.232931 -0.310661 -0.253237 .916166 0
.0451128 3.79893 -0.428728 Matrix44. 1 <<
Status 4: window chair from
0.956137 0.0306015 0.291316 0
-0.106346 0.962934 0.247889 0
-0.272932 -0.267997 0.923951 0
-2.19937 -0.433549 3.14582 1 <<Matrix44

Completed the model display of the switch status of the two handles
in 10 days

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325442005&siteId=291194637