Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Jeremie Garcia
Trajectoires
Commits
fdb6945f
Commit
fdb6945f
authored
Dec 04, 2015
by
Jérémie Garcia
Browse files
update
parent
ff492b9c
Changes
8
Hide whitespace changes
Inline
Side-by-side
WOB/server/interfaces/css/speaker_icon 2.png
0 → 100644
View file @
fdb6945f
2.12 KB
WOB/server/interfaces/css/speaker_icon.png
View replaced file @
ff492b9c
View file @
fdb6945f
2.12 KB
|
W:
|
H:
604 Bytes
|
W:
|
H:
2-up
Swipe
Onion skin
WOB/server/interfaces/js/OSC.js
View file @
fdb6945f
...
...
@@ -112,9 +112,8 @@ Traj.OSC = {
Traj
.
OSC
.
sendMessage
(
Traj
.
OSC
.
record_address
,
msg
);
},
// orientation_rate : 0, //used to send orientaiton events one time over the rate
sendOrientation
:
function
(
msg
){
Traj
.
OSC
.
sendSpatMessage
([
'
source
'
,
Traj
.
Manager
.
currentSource
,
'
yaw
'
,
msg
[
0
]]);
sendOrientation
:
function
(
sourceNB
,
msg
){
Traj
.
OSC
.
sendSpatMessage
([
'
source
'
,
sourceNB
,
'
yaw
'
,
msg
[
0
]]);
//Traj.OSC.sendSpatMessage(['source', Traj.Manager.currentSource, 'pitch', msg[1]]);
//Traj.OSC.sendSpatMessage(['source', Traj.Manager.currentSource, 'roll', msg[2]]);
},
...
...
@@ -138,7 +137,12 @@ Traj.OSC = {
streamCurvePoint
:
function
(
curve
,
index
)
{
//ussing Spat formatting source ID xyz x y z
Traj
.
OSC
.
sendSpatMessage
(
[
'
source
'
,
curve
.
sourceNumber
,
'
xyz
'
,
curve
.
X
[
index
],
curve
.
Y
[
index
],
curve
.
Z
[
index
]]);
Traj
.
OSC
.
streamPoint
(
curve
.
sourceNumber
,
[
curve
.
X
[
index
],
curve
.
Y
[
index
],
curve
.
Z
[
index
]]);
},
streamPoint
:
function
(
sourceNb
,
coords
){
//ussing Spat formatting source ID xyz x y z
Traj
.
OSC
.
sendSpatMessage
(
[
'
source
'
,
sourceNb
,
'
xyz
'
,
coords
[
0
],
coords
[
1
],
coords
[
2
]]);
},
sendCurveOSC
:
function
(
curve
,
id
)
{
...
...
WOB/server/interfaces/js/Player.js
View file @
fdb6945f
...
...
@@ -24,6 +24,7 @@ Traj.Player = {
yOld
=
curve
.
Y
[
0
],
z
=
curve
.
Z
[
0
],
counter
=
0
,
orientation
=
[
0
,
0
,
0
],
idx
=
0
;
Traj
.
OSC
.
sendPlay
(
"
start
"
);
...
...
@@ -58,18 +59,15 @@ Traj.Player = {
x
=
pointCoord
[
0
];
y
=
pointCoord
[
1
];
z
=
pointCoord
[
2
];
orientation
=
pointCoord
[
4
];
if
(
!
isNaN
(
x
)
&&!
isNaN
(
y
))
{
//ussing Spat formatting source ID xyz x y z
Traj
.
OSC
.
sendSpatMessage
(
[
'
source
'
,
pointCoord
[
0
],
'
xyz
'
,
pointCoord
[
1
],
pointCoord
[
2
],
pointCoord
[
3
]]);
//Traj.OSC.sendPosxyzMsg(pointCoord);
// send osc point
//}
// clear dyn canvas = large point
Traj
.
OSC
.
streamPoint
(
curve
.
sourceNumber
,[
x
,
y
,
z
]);
Traj
.
OSC
.
sendOrientation
(
curve
.
sourceNumber
,
orientation
);
// Traj.OSC.sendSpatMessage( ['source', pointCoord[0], 'xyz',pointCoord[1], pointCoord[2], pointCoord[3]]);
Traj
.
View
.
dyn_repaint
();
Traj
.
Player
.
repaintPoint
(
curve
,[
x
,
y
]);
// paint point
// Traj.Player.repaintPoint(curve,[x,y]); // paint point
Traj
.
Player
.
repaintPointWithOrientation
(
curve
,[
x
,
y
],
orientation
);
// paint point
Traj
.
Player
.
repaintCurve
(
curve
,
idx
,
idx
-
1
);
// paint large curve
...
...
@@ -352,16 +350,17 @@ Traj.Player = {
var
curveIdx
=
Traj
.
Manager
.
currentCurveIndex
,
curve
=
Traj
.
Manager
.
trajectories
[
curveIdx
];
Traj
.
View
.
dyn_ctx
.
lineWidth
=
5
;
Traj
.
View
.
dyn_ctx
.
fillStyle
=
curve
.
color
;
Traj
.
View
.
dyn_ctx
.
strokeStyle
=
curve
.
color
;
Traj
.
View
.
dyn_ctx
.
globalAlpha
=
Traj
.
View
.
CURVE_ACTIVE_ALPHA
;
if
(
typeof
curve
!=
'
undefined
'
){
Traj
.
View
.
dyn_ctx
.
lineWidth
=
5
;
Traj
.
View
.
dyn_ctx
.
fillStyle
=
curve
.
color
;
Traj
.
View
.
dyn_ctx
.
strokeStyle
=
curve
.
color
;
Traj
.
View
.
dyn_ctx
.
globalAlpha
=
Traj
.
View
.
CURVE_ACTIVE_ALPHA
;
Traj
.
View
.
traj_ctx
.
lineWidth
=
Traj
.
View
.
CURVE_ACTIVE_STROKE_SIZE
*
2.5
;
Traj
.
View
.
traj_ctx
.
strokeStyle
=
curve
.
color
;
this
.
playCurve
(
curveIdx
);
Traj
.
View
.
traj_ctx
.
lineWidth
=
Traj
.
View
.
CURVE_ACTIVE_STROKE_SIZE
*
2.5
;
Traj
.
View
.
traj_ctx
.
strokeStyle
=
curve
.
color
;
this
.
playCurve
(
curveIdx
);
}
},
stopCurrentCurve
:
function
()
{
...
...
@@ -395,6 +394,19 @@ Traj.Player = {
}
},
repaintPointWithOrientation
:
function
(
curve
,
point
,
orientation
)
{
var
dyn_ctx
=
Traj
.
View
.
dyn_ctx
;
dyn_ctx
.
strokeStyle
=
curve
.
color
;
if
(
point
&&
orientation
)
{
var
pos
=
Traj
.
Utils
.
convertUnitsIntoCanvasPos
(
point
);
Traj
.
View
.
drawOrientationForPoint
(
dyn_ctx
,
point
,
orientation
);
//draw large point
Traj
.
View
.
drawPoint
(
dyn_ctx
,
pos
,
18
);
}
},
repaintCurve
:
function
(
curve
,
index
,
lastIndex
)
{
var
dyn_ctx
=
Traj
.
View
.
dyn_ctx
,
pos
,
...
...
WOB/server/interfaces/js/TimedCurve.js
View file @
fdb6945f
...
...
@@ -24,15 +24,27 @@ TimedCurve.prototype.addTimedPoint = function (x, y, z, t) {
this
.
Y
.
push
(
y
);
this
.
Z
.
push
(
z
);
this
.
t
.
push
(
Math
.
floor
(
t
))
this
.
orientation
.
push
([
270
,
0
,
0
]);
this
.
orientation
.
push
([
null
,
null
,
null
]);
}
// write points into currentCurve object
TimedCurve
.
prototype
.
setOrientationAtIndex
=
function
(
orientation
,
idx
)
{
this
.
orientation
[
idx
]
=
orientation
;
}
TimedCurve
.
prototype
.
hasOrientation
=
function
(){
for
(
var
i
=
0
;
i
<
this
.
orientation
.
length
;
i
++
)
{
if
(
this
.
orientation
[
i
][
0
]
!=
null
){
return
true
;
}
}
return
false
;
}
TimedCurve
.
prototype
.
getOrientationAtIndex
=
function
(
idx
){
return
this
.
orientation
[
idx
];
}
TimedCurve
.
prototype
.
spaceScale
=
function
(
factor
)
{
for
(
var
k
=
0
;
k
<
this
.
X
.
length
;
k
++
)
{
this
.
X
[
k
]
=
factor
*
this
.
X
[
k
];
...
...
WOB/server/interfaces/js/Utils.js
View file @
fdb6945f
...
...
@@ -192,7 +192,55 @@ Traj.Utils = {
var
idx
=
Traj
.
Utils
.
findPointIdx
(
now
,
curve
);
}
var
lastTime
=
curve
.
t
[
idx
],
nextTime
=
0
,
x
,
y
,
z
;
nextTime
=
0
,
orientation
=
[
0
,
0
,
0
],
x
,
y
,
z
;
//process orientation find previous and next orientation if it is defined
if
(
curve
.
hasOrientation
()){
var
prev_orientation
=
curve
.
orientation
[
idx
],
prev_orientation_time
=
curve
.
t
[
idx
],
next_orientation
=
curve
.
orientation
[
idx
+
1
],
next_orientation_time
=
curve
.
t
[
idx
+
1
];
if
(
prev_orientation
[
0
]
==
null
){
//set value to the previously defined points with orientation and the time
for
(
var
i
=
idx
-
1
;
i
>=
0
;
i
--
)
{
if
(
curve
.
orientation
[
i
][
0
]
!=
null
){
prev_orientation
=
curve
.
orientation
[
i
];
prev_orientation_time
=
curve
.
t
[
i
];
break
;
}
}
}
if
(
typeof
(
next_orientation
)
==
'
undefined
'
||
next_orientation
[
0
]
==
null
){
//set value to the previously defined points with orientation and the time
for
(
var
j
=
idx
+
2
;
j
<
curve
.
orientation
.
lentgh
;
j
++
)
{
if
(
curve
.
orientation
[
j
][
0
]
!=
null
){
next_orientation
=
curve
.
orientation
[
j
];
next_orientation_time
=
curve
.
t
[
j
];
break
;
}
}
}
if
(
prev_orientation
[
0
]
==
null
){
prev_orientation
=
next_orientation
;
prev_orientation_time
=
0
;
}
if
(
typeof
(
next_orientation
)
==
'
undefined
'
||
next_orientation
[
0
]
==
null
){
next_orientation
=
prev_orientation
;
next_orientation_time
=
curve
.
t
[
curve
.
t
.
lentgh
-
1
];
}
var
orientation_diffTime
=
next_orientation_time
-
prev_orientation_time
;
orientation
[
0
]
=
prev_orientation
[
0
]
*
(
next_orientation_time
-
now
)
/
orientation_diffTime
+
next_orientation
[
0
]
*
(
now
-
prev_orientation_time
)
/
orientation_diffTime
;
orientation
[
1
]
=
prev_orientation
[
1
]
*
(
next_orientation_time
-
now
)
/
orientation_diffTime
+
next_orientation
[
1
]
*
(
now
-
prev_orientation_time
)
/
orientation_diffTime
;
orientation
[
2
]
=
prev_orientation
[
2
]
*
(
next_orientation_time
-
now
)
/
orientation_diffTime
+
next_orientation
[
2
]
*
(
now
-
prev_orientation_time
)
/
orientation_diffTime
;
}
if
(
curve
.
t
[
idx
+
1
]
!==
undefined
)
{
nextTime
=
curve
.
t
[
idx
+
1
]
...
...
@@ -210,7 +258,8 @@ Traj.Utils = {
pointCoord
.
push
(
x
);
pointCoord
.
push
(
y
);
pointCoord
.
push
(
z
);
pointCoord
.
push
(
now
);
pointCoord
.
push
(
now
)
pointCoord
.
push
(
orientation
);
return
pointCoord
;
},
...
...
WOB/server/interfaces/js/View.js
View file @
fdb6945f
...
...
@@ -153,19 +153,32 @@ Traj.View = {
},
speaker_image
:
new
Image
(),
speaker_image_width
:
26
,
drawOrientationForCurve
:
function
(
ctx
,
curve
,
index
,
linewidth
,
alpha
,
withPoint
)
{
var
width
=
26
;
drawOrientationForCurve
:
function
(
ctx
,
curve
)
{
for
(
var
i
=
0
;
i
<
curve
.
orientation
.
length
;
i
++
)
{
var
orientation
=
curve
.
orientation
[
i
],
alpha
=
orientation
[
0
]
*
Math
.
PI
/
180
,
pos
=
Traj
.
Utils
.
convertUnitsIntoCanvasPos
([
curve
.
X
[
i
],
curve
.
Y
[
i
]]);
ctx
.
save
();
ctx
.
translate
(
pos
[
0
]
-
width
/
2
,
pos
[
1
]
-
width
/
2
);
ctx
.
rotate
(
alpha
);
ctx
.
drawImage
(
this
.
speaker_image
,
0
,
0
,
width
,
width
);
ctx
.
restore
();
};
var
orientation
=
curve
.
getOrientationAtIndex
(
i
);
Traj
.
View
.
drawOrientationForPoint
(
ctx
,[
curve
.
X
[
i
],
curve
.
Y
[
i
]],
orientation
);
};
},
//the position needs to be in the space units, not the canvas.
drawOrientationForPoint
:
function
(
ctx
,
position
,
orientation
){
console
.
log
(
ctx
+
"
"
+
position
+
"
"
+
orientation
);
if
(
orientation
[
0
]
!=
null
){
var
alpha
=
orientation
[
0
]
*
Math
.
PI
/
180
,
pos
=
Traj
.
Utils
.
convertUnitsIntoCanvasPos
(
position
),
offset_angle
=
Math
.
atan2
(
position
[
1
],
position
[
0
]),
w
=
Traj
.
View
.
speaker_image_width
;
ctx
.
save
();
ctx
.
translate
(
pos
[
0
],
pos
[
1
]);
ctx
.
rotate
(
alpha
-
offset_angle
+
Math
.
PI
);
ctx
.
drawImage
(
this
.
speaker_image
,
-
w
/
2
,
-
w
/
2
,
w
,
w
);
ctx
.
restore
();
}
},
//////////////////////////////////
...
...
@@ -456,7 +469,9 @@ Traj.View = {
var
curve
=
Traj
.
Manager
.
trajectories
[
currentCurveIndex
];
if
(
typeof
(
curve
)
!=
'
undefined
'
)
{
this
.
drawCurve
(
this
.
current_ctx
,
curve
,
currentCurveIndex
,
this
.
CURVE_ACTIVE_STROKE_SIZE
,
this
.
CURVE_ACTIVE_ALPHA
,
true
);
this
.
drawOrientationForCurve
(
this
.
current_ctx
,
curve
,
currentCurveIndex
,
this
.
CURVE_ACTIVE_STROKE_SIZE
,
this
.
CURVE_ACTIVE_ALPHA
,
true
);
//if(curve.hasOrientation()){
this
.
drawOrientationForCurve
(
this
.
current_ctx
,
curve
);
//}
}
},
...
...
WOB/server/interfaces/js/events.js
View file @
fdb6945f
...
...
@@ -362,7 +362,6 @@ Traj.Events = {
var
dir
=
event
.
alpha
;
//put with correct offset for android
dir
=
(
360
-
dir
)
%
360
;
console
.
log
(
dir
);
if
(
Traj
.
Events
.
orientation_calibrated
){
//put with the offset
dir
=
(
dir
-
Traj
.
Events
.
orientation_offset
+
360
)
%
360
;
...
...
@@ -372,9 +371,10 @@ Traj.Events = {
&&
Traj
.
Manager
.
hasSelectedCurve
()){
var
curve
=
Traj
.
Manager
.
getCurrentCurve
();
curve
.
setOrientationAtIndex
(
Traj
.
Events
.
orientation
,
Traj
.
Events
.
recordingOrientationIdx
);
Traj
.
View
.
setFeedbackDisplay
(
"
Setting Orientation of point
"
+
Traj
.
Events
.
recordingOrientationIdx
+
"
to
"
+
Traj
.
Events
.
orientation
);
Traj
.
View
.
setFeedbackDisplay
(
"
Setting Orientation of point
"
+
Traj
.
Events
.
recordingOrientationIdx
+
"
to
"
+
Traj
.
Events
.
orientation
);
}
Traj
.
OSC
.
sendOrientation
(
Traj
.
Events
.
orientation
);
Traj
.
OSC
.
sendOrientation
(
Traj
.
Manager
.
currentSource
,
Traj
.
Events
.
orientation
);
}
else
if
(
!
Traj
.
Events
.
orientation_calibrated
){
Traj
.
Events
.
calibrateOrientation
(
dir
);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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