mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 13:18:38 +02:00
Added sound effects and removing voxels with VR controllers
This commit is contained in:
parent
ab57e191a5
commit
412ca8657d
1 changed files with 43 additions and 12 deletions
|
@ -64,6 +64,9 @@ EditVoxels = function() {
|
|||
that.triggeredHand = NO_HAND;
|
||||
that.pressedHand = NO_HAND;
|
||||
|
||||
var soundAdd = SoundCache.getSound(Script.resourcesPath() + "sounds/Button05.wav");
|
||||
var soundDelete = SoundCache.getSound(Script.resourcesPath() + "sounds/Tab03.wav");
|
||||
|
||||
that.setActive = function(active) {
|
||||
isActive = (active === true);
|
||||
}
|
||||
|
@ -177,7 +180,12 @@ EditVoxels = function() {
|
|||
print("floorVector(toDrawPosition): " + JSON.stringify(floorVector(toDrawPosition)));
|
||||
}
|
||||
oldEditPosition = floorVector(toDrawPosition);
|
||||
return Entities.setVoxel(entityID, oldEditPosition, lastEditValue);
|
||||
if (Entities.setVoxel(entityID, oldEditPosition, lastEditValue)){
|
||||
Audio.playSystemSound((lastEditValue === 255) ? soundAdd : soundDelete);
|
||||
return true;
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (editSpheres) {
|
||||
var toDrawPosition = intersectionLocation;
|
||||
|
@ -189,7 +197,12 @@ EditVoxels = function() {
|
|||
oldEditPosition = floorVector(Vec3.sum(voxelPosition, Vec3.multiply(pickRayDirInVoxelSpace, 0.1)));
|
||||
}
|
||||
oldEditPosition = floorVector(Vec3.sum(voxelPosition, Vec3.multiply(pickRayDirInVoxelSpace, 0.1)));
|
||||
return Entities.setVoxelSphere(entityID, floorVector(toDrawPosition), editSphereRadius, lastEditValue);
|
||||
if (Entities.setVoxelSphere(entityID, floorVector(toDrawPosition), editSphereRadius, lastEditValue)){
|
||||
Audio.playSystemSound((lastEditValue === 255) ? soundAdd : soundDelete);
|
||||
return true;
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -247,11 +260,21 @@ EditVoxels = function() {
|
|||
return;
|
||||
}
|
||||
|
||||
if (event.isLeftButton || event.isMiddleButton){
|
||||
if (event.isMiddleButton){
|
||||
inverseOperation = true;
|
||||
}else{
|
||||
inverseOperation = false;
|
||||
}
|
||||
}else{
|
||||
inverseOperation = false;
|
||||
if(that.triggeredHand === Controller.Standard.RightHand && Controller.getValue(Controller.Standard.RightGrip) > 0.5){
|
||||
inverseOperation = true;
|
||||
}
|
||||
if(that.triggeredHand === Controller.Standard.LeftHand && Controller.getValue(Controller.Standard.LeftGrip) > 0.5){
|
||||
inverseOperation = true;
|
||||
}
|
||||
}
|
||||
|
||||
var pickRay = generalComputePickRay(event.x, event.y);
|
||||
var intersection = Entities.findRayIntersection(pickRay, true); // accurate picking
|
||||
|
@ -442,8 +465,16 @@ EditVoxels = function() {
|
|||
print("directionMultiplier: " + JSON.stringify(directionMultiplier) + " pickRay.direction: " + JSON.stringify(pickRay.direction) + " pickRayDirInVoxelSpace: " + JSON.stringify(pickRayDirInVoxelSpace) + " voxelPickRayOrigin: " + JSON.stringify(voxelPickRayOrigin) + " editPlane: " + JSON.stringify(editPlane));
|
||||
}
|
||||
|
||||
if (editSingleVoxels) {
|
||||
if (Entities.setVoxel(editedVoxelEntity, newEditPosition, lastEditValue)){
|
||||
oldEditPosition = newEditPosition;
|
||||
Audio.playSystemSound((lastEditValue === 255) ? soundAdd : soundDelete);
|
||||
}
|
||||
}else if (editSpheres){
|
||||
if (Entities.setVoxel(editedVoxelEntity, newEditPosition, lastEditValue)){
|
||||
oldEditPosition = newEditPosition;
|
||||
Audio.playSystemSound((lastEditValue === 255) ? soundAdd : soundDelete);
|
||||
}
|
||||
}
|
||||
//TODO: add spheres
|
||||
|
||||
|
|
Loading…
Reference in a new issue