Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
MPEG-Public
PCC
V-PCC_decoder
Commits
e1d061d6
Commit
e1d061d6
authored
May 15, 2020
by
Vlad Zakharchenko
Browse files
Added PC controls for navigation
parent
696a7f95
Changes
7
Hide whitespace changes
Inline
Side-by-side
src/VPCCContext.h
View file @
e1d061d6
...
...
@@ -12,8 +12,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#pragma once
#include
"VPCCCommon.h"
#pragma once
#include
"VPCCCommon.h"
#include
"VPCCCodec.h"
#define VPCC_NAL_BUFFER_SIZE 8
...
...
@@ -21,27 +21,27 @@
/*!
* This class stores global context data
*/
class
VPCCContext
{
class
VPCCContext
{
public:
/** Construct VPCC context */
/** Construct VPCC context */
VPCCContext
();
/** The VPCC header */
/** The VPCC header */
VPCCHeader
vpccHeader
;
/** The VPCC sequence data */
/** The VPCC sequence data */
Vec
<
VPCCSequenceData
*>
sequenceData
;
/** The VPCC codec utility class */
VPCCCodec
*
vpccCodec
;
/** The VPCC codec utility class */
VPCCCodec
*
vpccCodec
;
Queue
<
VideoData
*>
attributeVideoData
,
/**< The attribute video data */
geometryVideoData
,
/**< The geometry video data */
occupancyVideoData
;
/**< The occupancy video data */
occupancyVideoData
;
/**< The occupancy video data */
Queue
<
ImageData
*>
blockToPatchImages
,
/**< The block to patch images queue */
occupancyImages
,
/**< The decoded occupancy images queue */
attributeImages
,
/**< The decoded attribute images queue */
geometryImages
;
/**< The decoded geometry images queue */
geometryImages
;
/**< The decoded geometry images queue */
glm
::
vec3
bounds
[
2
],
/**< The bounds of the VPCC point cloud */
rot
;
/**< The global rotation to apply to the VPCC point cloud */
bool
enableAR
;
/**< Enable/Disable augmented reality support */
rot
;
/**< The global rotation to apply to the VPCC point cloud */
bool
enableAR
;
/**< Enable/Disable augmented reality support */
};
src/VPCCRenderer.cpp
View file @
e1d061d6
...
...
@@ -210,19 +210,26 @@ void VPCCRenderer::onUpdate() {
//Update UI
updateUI
();
}
void
VPCCRenderer
::
onInput
(
InputType
type
,
InputEvent
*
event
)
{
#ifdef __ANDROID__
void
VPCCRenderer
::
onInput
(
InputType
type
,
InputEvent
*
event
)
{
//If AR enabled, pass input event to AR module
if
(
ctx
.
enableAR
)
ar
.
onInput
(
type
,
event
);
#endif
}
#else
void
VPCCRenderer
::
onInput
(
InputType
type
,
int
code
,
InputValue
value
)
{
camera
.
onInput
(
type
,
code
,
value
);
}
#endif
void
VPCCRenderer
::
run
()
{
//Initialize graphics context
gfx
.
init
(
"VPCC Renderer"
,
windowWidth
,
windowHeight
,
this
);
//Initialize input
#ifdef __ANDROID__
input
.
init
(
std
::
bind
(
&
VPCCRenderer
::
onInput
,
this
,
_1
,
_2
));
#else
input
.
init
(
this
);
#endif
//Initialize FPS counter
fpsCounter
.
init
();
#ifdef __ANDROID__
...
...
src/VPCCRenderer.h
View file @
e1d061d6
...
...
@@ -29,7 +29,7 @@ using namespace input;
/*!
* This class provides support for rendering the VPCC point cloud
*/
class
VPCCRenderer
:
public
GFXListener
{
class
VPCCRenderer
:
public
GFXListener
,
InputListener
{
public:
/** Construct the VPCC renderer */
VPCCRenderer
(
VPCCContext
&
ctx
);
...
...
@@ -41,7 +41,11 @@ public:
glm
::
vec3
mRotate
=
glm
::
vec3
(
0.0
f
),
mScale
=
glm
::
vec3
(
1.0
f
);
private:
void
init
();
#ifdef __ANDROID__
virtual
void
onInput
(
InputType
type
,
InputEvent
*
event
);
#else
virtual
void
onInput
(
InputType
type
,
int
code
,
InputValue
value
);
#endif
virtual
void
onDisplay
();
virtual
void
onUpdate
();
void
renderPointCloud
();
...
...
src/gfx/Camera.cpp
View file @
e1d061d6
...
...
@@ -15,9 +15,49 @@
#include
"gfx/Camera.h"
#include
"glm/gtx/transform.hpp"
#include
"glm/gtx/euler_angles.hpp"
#include
"input/Input.h"
using
namespace
input
;
using
namespace
gfx
;
using
namespace
glm
;
void
Camera
::
onInput
(
InputType
type
,
int
code
,
InputValue
value
)
{
static
bool
mouseMiddlePressed
=
false
,
altPressed
=
false
,
ctrlPressed
=
false
;
switch
(
type
)
{
case
InputType
::
KEYBOARD
:
switch
(
code
)
{
case
KEY
(
RIGHT_ALT
):
altPressed
=
(
value
==
InputValue
::
DOWN
);
break
;
case
KEY
(
RIGHT_CONTROL
):
ctrlPressed
=
(
value
==
InputValue
::
DOWN
);
}
break
;
case
InputType
::
MOUSE
:
switch
(
code
)
{
case
InputMouseCode
::
MIDDLE
:
mouseMiddlePressed
=
(
value
==
InputValue
::
DOWN
);
break
;
case
InputMouseCode
::
WHEEL_UP
:
zoom
+=
(
altPressed
)
?
0.05
f
:
0.2
f
;
break
;
case
InputMouseCode
::
WHEEL_DOWN
:
zoom
-=
(
altPressed
)
?
0.05
f
:
0.2
f
;
break
;
}
break
;
default:
break
;
case
InputType
::
REL_X
:
if
(
altPressed
&&
mouseMiddlePressed
)
{
panX
+=
code
/
800.0
f
;
}
else
if
(
mouseMiddlePressed
)
{
yaw
+=
code
;
}
break
;
case
InputType
::
REL_Y
:
if
(
altPressed
&&
mouseMiddlePressed
)
{
panY
+=
-
code
/
800.0
f
;
}
else
if
(
ctrlPressed
&&
mouseMiddlePressed
)
{
roll
+=
code
;
}
else
if
(
mouseMiddlePressed
)
{
pitch
+=
code
;
}
break
;
}
}
void
Camera
::
update
()
{
viewMat
=
translate
(
vec3
(
panX
,
panY
,
0
))
*
translate
(
vec3
(
0
,
0
,
zoom
))
*
...
...
src/gfx/Camera.h
View file @
e1d061d6
...
...
@@ -14,22 +14,25 @@
*/
#pragma once
#include
"glm/glm.hpp"
#include
"input/Input.h"
using
namespace
input
;
namespace
gfx
{
/*!
* This class provides support for an orbital camera
*/
class
Camera
{
/*!
* This class provides support for an orbital camera
*/
class
Camera
{
public:
/** Update the camera matrix */
/** Update the camera matrix */
void
onInput
(
InputType
type
,
int
code
,
InputValue
value
);
void
update
();
float
zoom
=
0.0
f
,
/**< The camera zoom */
zoom
=
0.0
f
,
/**< The camera zoom */
yaw
=
0.0
f
,
/**< The camera yaw (degrees) */
pitch
=
0.0
f
,
/**< The camera pitch (degrees) */
roll
=
0.0
f
,
/**< The camera roll (degrees) */
pitch
=
0.0
f
,
/**< The camera pitch (degrees) */
roll
=
0.0
f
,
/**< The camera roll (degrees) */
panX
=
0.0
f
,
/**< The camera x pan */
panY
=
0.0
f
;
/**< The camera y pan */
panY
=
0.0
f
;
/**< The camera y pan */
glm
::
mat4
viewMat
;
/**< The camera view matrix */
};
};
};
src/input/Input.h
View file @
e1d061d6
...
...
@@ -25,15 +25,29 @@
*/
namespace
input
{
#ifdef __ANDROID__
enum
InputType
{
TOUCH
};
#else
enum
InputType
{
KEYBOARD
,
MOUSE
,
TOUCH
,
REL_X
,
REL_Y
};
enum
InputValue
{
DOWN
,
UP
,
NONE
};
enum
InputMouseCode
{
LEFT
,
MIDDLE
,
RIGHT
,
WHEEL_UP
,
WHEEL_DOWN
};
#endif
struct
InputEvent
{};
struct
TouchEvent
:
public
InputEvent
{
int
action
,
pointerCount
,
*
x
,
*
y
;
};
typedef
std
::
function
<
void
(
InputType
type
,
InputEvent
*
event
)
>
InputCallback
;
class
InputListener
{
public:
virtual
void
onInput
(
InputType
type
,
int
code
,
InputValue
value
)
=
0
;
};
class
Input
{
public:
#ifdef __ANDROID__
void
init
(
InputCallback
cb
);
#else
void
init
(
InputListener
*
inputListener
);
#endif
};
};
src/input/Input_GLFW.cpp
View file @
e1d061d6
...
...
@@ -20,6 +20,7 @@
#include
<map>
using
namespace
input
;
extern
GLFWwindow
*
glfwWindow
;
#ifdef __ANDROID__
static
InputCallback
inputCallback
;
static
void
onKeyboard
(
GLFWwindow
*
window
,
int
key
,
int
scancode
,
int
action
,
int
mods
)
{
...
...
@@ -31,9 +32,47 @@ static void onCursorPos(GLFWwindow* window, double x, double y) {}
static
void
onMouseButton
(
GLFWwindow
*
window
,
int
button
,
int
action
,
int
mods
)
{}
static
void
onScroll
(
GLFWwindow
*
window
,
double
x
,
double
y
)
{}
#else
static
InputListener
*
inputListener
;
static
void
onKeyboard
(
GLFWwindow
*
window
,
int
key
,
int
scancode
,
int
action
,
int
mods
)
{
if
(
action
==
GLFW_REPEAT
)
return
;
inputListener
->
onInput
(
InputType
::
KEYBOARD
,
key
,
(
action
==
GLFW_PRESS
)
?
InputValue
::
DOWN
:
InputValue
::
UP
);
}
static
void
onCursorPos
(
GLFWwindow
*
window
,
double
x
,
double
y
)
{
int
ix
=
int
(
x
),
iy
=
int
(
y
);
static
int
px
=
-
1
,
py
=
-
1
;
if
(
px
==
-
1
)
px
=
ix
;
if
(
py
==
-
1
)
py
=
iy
;
inputListener
->
onInput
(
InputType
::
REL_X
,
ix
-
px
,
InputValue
::
NONE
);
inputListener
->
onInput
(
InputType
::
REL_Y
,
iy
-
py
,
InputValue
::
NONE
);
px
=
x
;
py
=
y
;
}
static
void
onMouseButton
(
GLFWwindow
*
window
,
int
button
,
int
action
,
int
mods
)
{
static
std
::
map
<
int
,
InputMouseCode
>
buttonMap
=
{
{
GLFW_MOUSE_BUTTON_LEFT
,
InputMouseCode
::
LEFT
},
{
GLFW_MOUSE_BUTTON_MIDDLE
,
InputMouseCode
::
MIDDLE
},
{
GLFW_MOUSE_BUTTON_RIGHT
,
InputMouseCode
::
RIGHT
}
};
if
(
buttonMap
.
find
(
button
)
==
buttonMap
.
end
())
{
LOG
(
"WARNING: button: %d not supported"
,
button
);
return
;
}
inputListener
->
onInput
(
InputType
::
MOUSE
,
buttonMap
.
at
(
button
),
(
action
==
GLFW_PRESS
)
?
InputValue
::
DOWN
:
InputValue
::
UP
);
}
static
void
onScroll
(
GLFWwindow
*
window
,
double
x
,
double
y
)
{
InputMouseCode
code
=
(
y
<
0
)
?
InputMouseCode
::
WHEEL_DOWN
:
InputMouseCode
::
WHEEL_UP
;
inputListener
->
onInput
(
InputType
::
MOUSE
,
code
,
InputValue
::
NONE
);
}
#endif
#ifdef __ANDROID__
void
Input
::
init
(
InputCallback
cb
)
{
inputCallback
=
cb
;
#else
void
Input
::
init
(
InputListener
*
listener
)
{
inputListener
=
listener
;
#endif
glfwSetMouseButtonCallback
(
glfwWindow
,
onMouseButton
);
glfwSetCursorPosCallback
(
glfwWindow
,
onCursorPos
);
glfwSetScrollCallback
(
glfwWindow
,
onScroll
);
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment