Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
lava-vr
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
lava
lava-vr
Commits
078da71f
Commit
078da71f
authored
6 years ago
by
Christian Mattes
Browse files
Options
Downloads
Patches
Plain Diff
Can now disable individual hands in the RopeLocomotion.
parent
497564db
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/lava-vr/RopeLocomotion.cc
+26
-30
26 additions, 30 deletions
src/lava-vr/RopeLocomotion.cc
src/lava-vr/RopeLocomotion.hh
+2
-0
2 additions, 0 deletions
src/lava-vr/RopeLocomotion.hh
with
28 additions
and
30 deletions
src/lava-vr/RopeLocomotion.cc
+
26
−
30
View file @
078da71f
#include
"RopeLocomotion.hh"
#include
<openvr.h>
#include
<glm/gtc/matrix_transform.hpp>
#include
<glm/gtx/string_cast.hpp>
#include
<glm/gtx/transform.hpp>
...
...
@@ -8,30 +9,27 @@
#include
<lava-extras/openvr/OpenVRControllerInput.hh>
#include
<lava-extras/openvr/OpenVRHmd.hh>
#include
<lava-extras/openvr/OpenVRTypes.hh>
#include
<openvr.h>
namespace
lava
{
namespace
vr
{
RopeLocomotion
::
RopeLocomotion
(
const
lava
::
openvr
::
SharedOpenVRHmd
&
output
)
:
mOpenVR
(
output
),
mPressed
({{
false
,
false
}})
{}
namespace
lava
{
namespace
vr
{
RopeLocomotion
::
RopeLocomotion
(
const
lava
::
openvr
::
SharedOpenVRHmd
&
output
)
:
mOpenVR
(
output
),
mPressed
({{
false
,
false
}})
{}
glm
::
mat4
RopeLocomotion
::
updateMatrix
(
glm
::
mat4
old
)
{
static
auto
triggerMask
=
::
vr
::
ButtonMaskFromId
(
::
vr
::
EVRButtonId
::
k_EButton_SteamVR_Trigger
);
static
auto
touchpadMask
=
::
vr
::
ButtonMaskFromId
(
::
vr
::
EVRButtonId
::
k_EButton_SteamVR_Touchpad
);
glm
::
mat4
RopeLocomotion
::
updateMatrix
(
glm
::
mat4
old
)
{
static
auto
triggerMask
=
::
vr
::
ButtonMaskFromId
(
::
vr
::
EVRButtonId
::
k_EButton_SteamVR_Trigger
);
static
auto
touchpadMask
=
::
vr
::
ButtonMaskFromId
(
::
vr
::
EVRButtonId
::
k_EButton_SteamVR_Touchpad
);
std
::
array
<::
vr
::
ETrackedControllerRole
,
2
>
roles
=
{
::
vr
::
TrackedControllerRole_RightHand
,
::
vr
::
TrackedControllerRole_LeftHand
};
std
::
array
<::
vr
::
ETrackedControllerRole
,
2
>
roles
=
{
::
vr
::
TrackedControllerRole_RightHand
,
::
vr
::
TrackedControllerRole_LeftHand
};
auto
oldPoses
=
mLastPos
;
auto
oldPressed
=
mPressed
;
auto
touched
=
std
::
array
<
bool
,
2
>
{{
false
,
false
}};
auto
system
=
::
vr
::
VRSystem
();
for
(
size_t
i
=
0
;
i
<
2
;
i
++
)
{
for
(
size_t
i
=
0
;
i
<
2
;
i
++
)
{
auto
hand
=
system
->
GetTrackedDeviceIndexForControllerRole
(
roles
[
i
]);
if
(
hand
==
::
vr
::
k_unTrackedDeviceIndexInvalid
)
continue
;
...
...
@@ -42,14 +40,14 @@ glm::mat4 RopeLocomotion::updateMatrix(glm::mat4 old) {
::
vr
::
VRControllerState_t
state
;
system
->
GetControllerState
(
hand
,
&
state
,
sizeof
(
state
));
auto
mat
=
glm
::
transpose
(
lava
::
vrToGlm
(
pose
.
mDeviceToAbsoluteTracking
));
auto
mat
=
glm
::
transpose
(
lava
::
vrToGlm
(
pose
.
mDeviceToAbsoluteTracking
));
mLastPos
[
i
]
=
glm
::
vec3
(
mat
[
3
]);
mPressed
[
i
]
=
state
.
ulButtonPressed
&
triggerMask
;
mPressed
[
i
]
=
(
state
.
ulButtonPressed
&
triggerMask
)
&&
!
mConfig
.
disableHand
[
i
]
;
touched
[
i
]
=
state
.
ulButtonTouched
&
touchpadMask
;
}
if
(
mPressed
[
0
]
&&
mPressed
[
1
])
{
if
(
mPressed
[
0
]
&&
mPressed
[
1
])
{
auto
old_cog
=
0.5
f
*
(
oldPoses
[
0
]
+
oldPoses
[
1
]);
auto
new_cog
=
0.5
f
*
(
mLastPos
[
0
]
+
mLastPos
[
1
]);
...
...
@@ -59,24 +57,22 @@ glm::mat4 RopeLocomotion::updateMatrix(glm::mat4 old) {
auto
old_dir
=
glm
::
normalize
(
old_ray
);
auto
new_dir
=
glm
::
normalize
(
new_ray
);
auto
scale
=
(
mConfig
.
allowZoom
)
?
glm
::
length
(
new_ray
)
/
glm
::
length
(
old_ray
)
:
1.0
f
;
auto
scale
=
(
mConfig
.
allowZoom
)
?
glm
::
length
(
new_ray
)
/
glm
::
length
(
old_ray
)
:
1.0
f
;
auto
axis
=
glm
::
vec3
{
0.
f
,
1.
f
,
0.
f
};
auto
angle
=
(
mConfig
.
allowRotation
)
?
glm
::
orientedAngle
(
old_dir
,
new_dir
,
axis
)
:
0.0
f
;
auto
angle
=
(
mConfig
.
allowRotation
)
?
glm
::
orientedAngle
(
old_dir
,
new_dir
,
axis
)
:
0.0
f
;
auto
rot
=
glm
::
rotate
(
angle
,
axis
);
auto
combined
=
glm
::
translate
(
new_cog
)
*
rot
*
glm
::
scale
(
glm
::
vec3
{
scale
,
scale
,
scale
})
*
glm
::
translate
(
-
old_cog
);
auto
combined
=
glm
::
translate
(
new_cog
)
*
rot
*
glm
::
scale
(
glm
::
vec3
{
scale
,
scale
,
scale
})
*
glm
::
translate
(
-
old_cog
);
old
=
combined
*
old
;
}
else
if
(
mPressed
[
0
])
{
}
else
if
(
mPressed
[
0
])
{
old
[
3
]
+=
glm
::
vec4
(
mLastPos
[
0
]
-
oldPoses
[
0
],
0.
f
);
}
else
if
(
mPressed
[
1
])
{
}
else
if
(
mPressed
[
1
])
{
old
[
3
]
+=
glm
::
vec4
(
mLastPos
[
1
]
-
oldPoses
[
1
],
0.
f
);
}
...
...
This diff is collapsed.
Click to expand it.
src/lava-vr/RopeLocomotion.hh
+
2
−
0
View file @
078da71f
...
...
@@ -12,6 +12,8 @@ class RopeLocomotion {
struct
Config
{
bool
allowZoom
=
true
;
bool
allowRotation
=
true
;
bool
disableHand
[
2
]
=
{
false
,
false
};
};
RopeLocomotion
(
lava
::
openvr
::
SharedOpenVRHmd
const
&
output
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment