mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 23:36:44 +02:00
Fixing typo and review comments
This commit is contained in:
parent
07c13f4d66
commit
b90af1a1ce
2 changed files with 54 additions and 90 deletions
|
@ -11,17 +11,17 @@
|
||||||
|
|
||||||
|
|
||||||
function makeSphere(color) {
|
function makeSphere(color) {
|
||||||
var SPHERE_SIZE = 0.05;
|
var SPHERE_SIZE = 0.05;
|
||||||
var sphere = Overlays.addOverlay("sphere", {
|
var sphere = Overlays.addOverlay("sphere", {
|
||||||
position: { x: 0, y: 0, z: 0 },
|
position: { x: 0, y: 0, z: 0 },
|
||||||
size: SPHERE_SIZE,
|
size: SPHERE_SIZE,
|
||||||
color: color,
|
color: color,
|
||||||
alpha: 1.0,
|
alpha: 1.0,
|
||||||
solid: true,
|
solid: true,
|
||||||
visible: true,
|
visible: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
return sphere;
|
return sphere;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -34,104 +34,67 @@ var COLORS = [ { red: 255, green: 0, blue: 0 }, { red: 0, green: 0, blue: 255 }
|
||||||
|
|
||||||
|
|
||||||
function index(handNum, indexNum) {
|
function index(handNum, indexNum) {
|
||||||
return handNum * NUM_HANDS + indexNum;
|
return handNum * NUM_HANDS + indexNum;
|
||||||
}
|
}
|
||||||
|
|
||||||
var app = {};
|
var app = {};
|
||||||
|
|
||||||
|
|
||||||
function setup() {
|
function setup() {
|
||||||
app.spheres = new Array();
|
app.spheres = new Array();
|
||||||
|
|
||||||
for (var h = 0; h < NUM_HANDS; h++) {
|
for (var h = 0; h < NUM_HANDS; h++) {
|
||||||
for (var s = 0; s < NUM_SPHERES_PER_HAND; s++) {
|
for (var s = 0; s < NUM_SPHERES_PER_HAND; s++) {
|
||||||
var i = index(h, s);
|
var i = index(h, s);
|
||||||
app.spheres[i] = makeSphere(COLORS[h]);
|
app.spheres[i] = makeSphere(COLORS[h]);
|
||||||
print("Added Sphere num " + i + " = " + JSON.stringify(app.spheres[i]));
|
print("Added Sphere num " + i + " = " + JSON.stringify(app.spheres[i]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateHand(handNum, deltaTime) {
|
function updateHand(handNum, deltaTime) {
|
||||||
var pose;
|
var pose;
|
||||||
var handName = "right";
|
var handName = "right";
|
||||||
if (handNum == LEFT_HAND) {
|
if (handNum == LEFT_HAND) {
|
||||||
pose = MyAvatar.getLeftHandPose();
|
pose = MyAvatar.getLeftHandPose();
|
||||||
handName = "left";
|
handName = "left";
|
||||||
} else {
|
} else {
|
||||||
pose = MyAvatar.getRightHandPose();
|
pose = MyAvatar.getRightHandPose();
|
||||||
handName = "right";
|
handName = "right";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pose.valid) {
|
if (pose.valid) {
|
||||||
//print(handName + " hand moving" + JSON.stringify(pose));
|
//print(handName + " hand moving" + JSON.stringify(pose));
|
||||||
Overlays.editOverlay(app.spheres[index(handNum, 0)], {
|
Overlays.editOverlay(app.spheres[index(handNum, 0)], {
|
||||||
position: pose.translation,
|
position: pose.translation,
|
||||||
visible: true,
|
visible: true,
|
||||||
});
|
});
|
||||||
var vpos = Vec3.sum(Vec3.multiply(10 * deltaTime, pose.velocity), pose.translation);
|
var vpos = Vec3.sum(Vec3.multiply(10 * deltaTime, pose.velocity), pose.translation);
|
||||||
Overlays.editOverlay(app.spheres[index(handNum, 1)], {
|
Overlays.editOverlay(app.spheres[index(handNum, 1)], {
|
||||||
position: vpos,
|
position: vpos,
|
||||||
visible: true,
|
visible: true,
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
Overlays.editOverlay(app.spheres[index(handNum, 0)], {
|
Overlays.editOverlay(app.spheres[index(handNum, 0)], {
|
||||||
visible: false
|
visible: false
|
||||||
});
|
});
|
||||||
|
|
||||||
Overlays.editOverlay(app.spheres[index(handNum, 1)], {
|
Overlays.editOverlay(app.spheres[index(handNum, 1)], {
|
||||||
visible: false
|
visible: false
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
function updateHydra(handNum, deltaTime) {
|
|
||||||
var pose;
|
|
||||||
var handName = "right";
|
|
||||||
if (handNum == LEFT_HAND) {
|
|
||||||
pose = Controller.getPoseValue(Controller.Hardware.Hydra.LeftHand);
|
|
||||||
handName = "left";
|
|
||||||
} else {
|
|
||||||
pose = Controller.getPoseValue(Controller.Hardware.Hydra.RightHand);
|
|
||||||
handName = "right";
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pose.valid) {
|
|
||||||
//print(handName + " hand moving" + JSON.stringify(pose));
|
|
||||||
var wpos = Vec3.sum(MyAvatar.getPosition(), pose.translation);
|
|
||||||
|
|
||||||
Overlays.editOverlay(app.spheres[index(handNum, 0)], {
|
|
||||||
position: pose.translation,
|
|
||||||
visible: true,
|
|
||||||
});
|
|
||||||
/*var vpos = Vec3.sum(Vec3.multiply(10 * deltaTime, pose.velocity), pose.translation);
|
|
||||||
Overlays.editOverlay(app.spheres[index(handNum, 1)], {
|
|
||||||
position: vpos,
|
|
||||||
visible: true,
|
|
||||||
});*/
|
|
||||||
} else {
|
|
||||||
Overlays.editOverlay(app.spheres[index(handNum, 0)], {
|
|
||||||
visible: false
|
|
||||||
});
|
|
||||||
|
|
||||||
Overlays.editOverlay(app.spheres[index(handNum, 1)], {
|
|
||||||
visible: false
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function update(deltaTime) {
|
function update(deltaTime) {
|
||||||
//updateHand(LEFT_HAND, deltaTime);
|
updateHand(LEFT_HAND, deltaTime);
|
||||||
//updateHand(RIGHT_HAND, deltaTime);
|
updateHand(RIGHT_HAND, deltaTime);
|
||||||
updateHydra(LEFT_HAND, deltaTime);
|
|
||||||
updateHydra(RIGHT_HAND, deltaTime);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function scriptEnding() {
|
function scriptEnding() {
|
||||||
print("Removing spheres = " + JSON.stringify(app.spheres));
|
print("Removing spheres = " + JSON.stringify(app.spheres));
|
||||||
for (var i = 0; i < app.spheres.length; i++) {
|
for (var i = 0; i < app.spheres.length; i++) {
|
||||||
Overlays.deleteOverlay(app.spheres[i]);
|
Overlays.deleteOverlay(app.spheres[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
setup();
|
setup();
|
||||||
|
|
|
@ -40,6 +40,7 @@ public:
|
||||||
|
|
||||||
void addInputVariant(QString name, ReadLambda& lambda);
|
void addInputVariant(QString name, ReadLambda& lambda);
|
||||||
|
|
||||||
|
protected:
|
||||||
QVector<NamedReadLambda> _namedReadLambdas;
|
QVector<NamedReadLambda> _namedReadLambdas;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue