@@ -13,23 +13,21 @@ import java.util.function.Supplier
13
13
import kotlin.concurrent.thread
14
14
15
15
class DefaultKinects <CTX >(
16
- private val program : Program ,
17
- private val manager : KinectsManager <CTX >
16
+ private val program : Program ,
17
+ private val manager : KinectsManager <CTX >
18
18
) : Kinects<CTX> {
19
19
20
+ private inner class Destroyer : Thread () {
21
+ override fun run () {
22
+ manager.shutdown()
23
+ }
24
+ }
25
+
20
26
init {
21
27
manager.initialize()
22
28
// as we don't have explicit shutdown mechanism in OPENRNDR
23
29
// we need to install a shutdown hook for now
24
- Runtime .getRuntime().addShutdownHook(
25
- thread(
26
- name = " ${manager.javaClass.simpleName} -closer" ,
27
- start = false ,
28
- isDaemon = false
29
- ) {
30
- manager.shutdown()
31
- }
32
- )
30
+ Runtime .getRuntime().addShutdownHook(Destroyer ())
33
31
}
34
32
35
33
override fun countDevices (): Int {
@@ -65,8 +63,8 @@ interface KinectCommandsExecutor<CTX> {
65
63
}
66
64
67
65
class DefaultKinectDevice <CTX >(
68
- override val depthCamera : DefaultKinectDepthCamera ,
69
- private val commandsExecutor : KinectCommandsExecutor <CTX >
66
+ override val depthCamera : DefaultKinectDepthCamera ,
67
+ private val commandsExecutor : KinectCommandsExecutor <CTX >
70
68
) : KinectDevice<CTX> {
71
69
override var enabled: Boolean = true
72
70
override fun beforeDraw (drawer : Drawer , program : Program ) {
@@ -79,13 +77,13 @@ class DefaultKinectDevice<CTX>(
79
77
}
80
78
81
79
class DefaultKinectDepthCamera (
82
- override val width : Int ,
83
- override val height : Int ,
84
- depthScale : Double ,
85
- private val enabler : KinectFeatureEnabler ,
86
- private val bytesSupplier : Supplier <ByteBuffer ?>
80
+ override val width : Int ,
81
+ override val height : Int ,
82
+ depthScale : Double ,
83
+ private val enabler : KinectFeatureEnabler ,
84
+ private val bytesSupplier : Supplier <ByteBuffer ?>
87
85
) :
88
- KinectDepthCamera , UpdatableKinectCamera {
86
+ KinectDepthCamera , UpdatableKinectCamera {
89
87
90
88
override var enabled: Boolean
91
89
get() = enabler.enabled
@@ -94,16 +92,16 @@ class DefaultKinectDepthCamera(
94
92
}
95
93
96
94
private val rawBuffer: ColorBuffer = colorBuffer(
97
- width,
98
- height,
99
- format = ColorFormat .R ,
100
- type = ColorType .UINT16 // it would be perfect if we could use isampler in the shader
95
+ width,
96
+ height,
97
+ format = ColorFormat .R ,
98
+ type = ColorType .UINT16 // it would be perfect if we could use isampler in the shader
101
99
)
102
100
override val currentFrame: ColorBuffer = colorBuffer(
103
- width,
104
- height,
105
- format = ColorFormat .R ,
106
- type = ColorType .FLOAT16 // in the future we might want to choose the precision here
101
+ width,
102
+ height,
103
+ format = ColorFormat .R ,
104
+ type = ColorType .FLOAT16 // in the future we might want to choose the precision here
107
105
)
108
106
109
107
private val depthMapper = KinectRawDataToDepthMapper ()
@@ -132,15 +130,21 @@ class DefaultKinectDepthCamera(
132
130
133
131
override var mirror: Boolean
134
132
get() = depthMapper.mirror
135
- set(value) { depthMapper.mirror = value }
133
+ set(value) {
134
+ depthMapper.mirror = value
135
+ }
136
136
137
137
}
138
138
139
139
private class KinectRawDataToDepthMapper :
140
- Filter (filterShaderFromUrl(
141
- resourceUrl(" kinect-raw-to-depth.frag" ,
142
- DefaultKinects ::class .java))
143
- ) {
140
+ Filter (
141
+ filterShaderFromUrl(
142
+ resourceUrl(
143
+ " kinect-raw-to-depth.frag" ,
144
+ DefaultKinects ::class .java
145
+ )
146
+ )
147
+ ) {
144
148
var depthScale: Double by parameters
145
149
var mirror: Boolean by parameters
146
150
var resolution: Vector2 by parameters
0 commit comments