mirror of
https://github.com/Armored-Dragon/overte.git
synced 2025-03-11 16:13:16 +01:00
Merge branch 'master' of https://github.com/highfidelity/hifi into animenu
This commit is contained in:
commit
03abad4f20
7 changed files with 34 additions and 26 deletions
|
@ -8,6 +8,10 @@
|
|||
// This is an example script that demonstrates use of the Controller and MyAvatar classes to implement
|
||||
// avatar flying through the hydra/controller joysticks
|
||||
//
|
||||
// The joysticks (on hydra) will drive the avatar much like a playstation controller.
|
||||
//
|
||||
// Pressing the '4' or the 'FWD' button and moving/banking the hand will allow you to move and fly.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
@ -15,8 +19,8 @@
|
|||
var damping = 0.9;
|
||||
var position = { x: MyAvatar.position.x, y: MyAvatar.position.y, z: MyAvatar.position.z };
|
||||
var joysticksCaptured = false;
|
||||
var THRUST_CONTROLLER = 0;
|
||||
var VIEW_CONTROLLER = 1;
|
||||
var THRUST_CONTROLLER = 1;
|
||||
var VIEW_CONTROLLER = 0;
|
||||
var INITIAL_THRUST_MULTPLIER = 1.0;
|
||||
var THRUST_INCREASE_RATE = 1.05;
|
||||
var MAX_THRUST_MULTIPLIER = 75.0;
|
||||
|
@ -46,9 +50,12 @@ var JOYSTICK_PITCH_MAG = PITCH_MAG * 0.5;
|
|||
|
||||
|
||||
var LEFT_PALM = 0;
|
||||
var LEFT_BUTTON_4 = 4;
|
||||
var LEFT_BUTTON_4 = 5;
|
||||
var LEFT_BUTTON_FWD = 5;
|
||||
var RIGHT_PALM = 2;
|
||||
var RIGHT_BUTTON_4 = 10;
|
||||
var RIGHT_BUTTON_FWD = 11;
|
||||
|
||||
|
||||
|
||||
function printVector(text, v, decimals) {
|
||||
|
@ -57,6 +64,15 @@ function printVector(text, v, decimals) {
|
|||
|
||||
var debug = false;
|
||||
|
||||
function getJoystickPosition(palm) {
|
||||
// returns CONTROLLER_ID position in avatar local frame
|
||||
var invRotation = Quat.inverse(MyAvatar.orientation);
|
||||
var palmWorld = Controller.getSpatialControlPosition(palm);
|
||||
var palmRelative = Vec3.subtract(palmWorld, MyAvatar.position);
|
||||
var palmLocal = Vec3.multiplyQbyV(invRotation, palmRelative);
|
||||
return palmLocal;
|
||||
}
|
||||
|
||||
// Used by handleGrabBehavior() for managing the grab position changes
|
||||
function getAndResetGrabDelta() {
|
||||
var HAND_GRAB_SCALE_DISTANCE = 2.0;
|
||||
|
@ -75,19 +91,19 @@ function getGrabRotation() {
|
|||
// When move button is pressed, process results
|
||||
function handleGrabBehavior(deltaTime) {
|
||||
// check for and handle grab behaviors
|
||||
grabbingWithRightHand = Controller.isButtonPressed(RIGHT_BUTTON_4);
|
||||
grabbingWithLeftHand = Controller.isButtonPressed(LEFT_BUTTON_4);
|
||||
grabbingWithRightHand = Controller.isButtonPressed(RIGHT_BUTTON_FWD) || Controller.isButtonPressed(RIGHT_BUTTON_4);
|
||||
grabbingWithLeftHand = Controller.isButtonPressed(LEFT_BUTTON_FWD) || Controller.isButtonPressed(LEFT_BUTTON_4);
|
||||
stoppedGrabbingWithLeftHand = false;
|
||||
stoppedGrabbingWithRightHand = false;
|
||||
|
||||
if (grabbingWithRightHand && !wasGrabbingWithRightHand) {
|
||||
// Just starting grab, capture starting rotation
|
||||
grabStartRotation = Controller.getSpatialControlRawRotation(RIGHT_PALM);
|
||||
grabStartPosition = Controller.getSpatialControlPosition(RIGHT_PALM);
|
||||
grabStartPosition = getJoystickPosition(RIGHT_PALM);
|
||||
if (debug) printVector("start position", grabStartPosition, 3);
|
||||
}
|
||||
if (grabbingWithRightHand) {
|
||||
grabDelta = Vec3.subtract(Controller.getSpatialControlPosition(RIGHT_PALM), grabStartPosition);
|
||||
grabDelta = Vec3.subtract(getJoystickPosition(RIGHT_PALM), grabStartPosition);
|
||||
grabCurrentRotation = Controller.getSpatialControlRawRotation(RIGHT_PALM);
|
||||
}
|
||||
if (!grabbingWithRightHand && wasGrabbingWithRightHand) {
|
||||
|
@ -99,12 +115,12 @@ function handleGrabBehavior(deltaTime) {
|
|||
if (grabbingWithLeftHand && !wasGrabbingWithLeftHand) {
|
||||
// Just starting grab, capture starting rotation
|
||||
grabStartRotation = Controller.getSpatialControlRawRotation(LEFT_PALM);
|
||||
grabStartPosition = Controller.getSpatialControlPosition(LEFT_PALM);
|
||||
grabStartPosition = getJoystickPosition(LEFT_PALM);
|
||||
if (debug) printVector("start position", grabStartPosition, 3);
|
||||
}
|
||||
|
||||
if (grabbingWithLeftHand) {
|
||||
grabDelta = Vec3.subtract(Controller.getSpatialControlPosition(LEFT_PALM), grabStartPosition);
|
||||
grabDelta = Vec3.subtract(getJoystickPosition(LEFT_PALM), grabStartPosition);
|
||||
grabCurrentRotation = Controller.getSpatialControlRawRotation(LEFT_PALM);
|
||||
}
|
||||
if (!grabbingWithLeftHand && wasGrabbingWithLeftHand) {
|
||||
|
@ -122,23 +138,20 @@ function handleGrabBehavior(deltaTime) {
|
|||
var front = Quat.getFront(headOrientation);
|
||||
var right = Quat.getRight(headOrientation);
|
||||
var up = Quat.getUp(headOrientation);
|
||||
|
||||
grabDelta = Vec3.multiplyQbyV(MyAvatar.orientation, Vec3.multiply(grabDelta, -1));
|
||||
|
||||
if (debug) {
|
||||
printVector("grabDelta: ", grabDelta, 3);
|
||||
}
|
||||
|
||||
var THRUST_GRAB_SCALING = 0.0;
|
||||
var THRUST_GRAB_SCALING = 300000.0;
|
||||
|
||||
var thrustFront = Vec3.multiply(front, MyAvatar.scale * grabDelta.z * THRUST_GRAB_SCALING * deltaTime);
|
||||
var thrustFront = Vec3.multiply(front, MyAvatar.scale * -grabDelta.z * THRUST_GRAB_SCALING * deltaTime);
|
||||
MyAvatar.addThrust(thrustFront);
|
||||
var thrustRight = Vec3.multiply(right, MyAvatar.scale * grabDelta.x * THRUST_GRAB_SCALING * deltaTime);
|
||||
MyAvatar.addThrust(thrustRight);
|
||||
var thrustUp = Vec3.multiply(up, MyAvatar.scale * grabDelta.y * THRUST_GRAB_SCALING * deltaTime);
|
||||
MyAvatar.addThrust(thrustUp);
|
||||
|
||||
|
||||
// add some rotation...
|
||||
var deltaRotation = getGrabRotation();
|
||||
var PITCH_SCALING = 2.0;
|
||||
|
|
|
@ -236,7 +236,7 @@ function checkControllerSide(whichSide) {
|
|||
|
||||
debugPrint("modelRadius=" +modelRadius);
|
||||
|
||||
newModel = Models.addModel(properties);
|
||||
//newModel = Models.addModel(properties);
|
||||
|
||||
print("just added model... newModel=" + newModel.creatorTokenID);
|
||||
print("properties.animationURL=" + properties.animationURL);
|
||||
|
|
|
@ -1476,10 +1476,10 @@ void Application::importVoxels() {
|
|||
}
|
||||
|
||||
if (!_voxelImporter->exec()) {
|
||||
qDebug() << "[DEBUG] Import succeeded." << endl;
|
||||
qDebug() << "Import succeeded." << endl;
|
||||
_importSucceded = true;
|
||||
} else {
|
||||
qDebug() << "[DEBUG] Import failed." << endl;
|
||||
qDebug() << "Import failed." << endl;
|
||||
if (_sharedVoxelSystem.getTree() == _voxelImporter->getVoxelTree()) {
|
||||
_sharedVoxelSystem.killLocalVoxels();
|
||||
_sharedVoxelSystem.changeTree(&_clipboard);
|
||||
|
|
|
@ -40,18 +40,17 @@ void LocalVoxelsList::addPersistantTree(QString treeName, VoxelTree* tree) {
|
|||
StrongVoxelTreePointer treePtr(tree, doNothing);
|
||||
_persistantTrees.push_back(treePtr);
|
||||
_trees.insert(treeName, treePtr);
|
||||
qDebug() << "[DEBUG] LocalVoxelsList : added persistant tree (" << treeName << ")";
|
||||
}
|
||||
|
||||
void LocalVoxelsList::insert(QString treeName, StrongVoxelTreePointer& tree) {
|
||||
// If the key don't already exist or the value is null
|
||||
if (!_trees.contains(treeName) || !_trees.value(treeName)) {
|
||||
_trees.insert(treeName, tree);
|
||||
qDebug() << "[DEBUG] LocalVoxelsList : added local tree (" << treeName << ")";
|
||||
qDebug() << "LocalVoxelsList : added local tree (" << treeName << ")";
|
||||
} else {
|
||||
// if not we replace the tree created by the user with the existing one
|
||||
tree = _trees.value(treeName);
|
||||
qDebug() << "[DEBUG] LocalVoxelsList : local tree already exist (" << treeName << ")";
|
||||
qDebug() << "[WARNING] LocalVoxelsList : local tree already exist (" << treeName << ")";
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -59,9 +58,6 @@ void LocalVoxelsList::remove(QString treeName) {
|
|||
// if the tree is not used anymore (no strong pointer)
|
||||
if (!_trees.value(treeName)) {
|
||||
// then remove it from the list
|
||||
qDebug() << "[DEBUG] LocalVoxelsList : removed unused tree (" << treeName << ")";
|
||||
_trees.remove(treeName);
|
||||
} else {
|
||||
qDebug() << "[DEBUG] LocalVoxelsList : tree still in use (" << treeName << ")";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -186,7 +186,7 @@ int retrieveData(std::string filename, std::stringstream &ss) {
|
|||
return ret;
|
||||
}
|
||||
|
||||
std::cerr << "[DEBUG] Schematic compression type not recognize : " << type << std::endl;
|
||||
std::cerr << "[ERROR] Schematic compression type not recognize : " << type << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
|
@ -359,7 +359,7 @@ bool VoxelTree::readFromSchematicFile(const char *fileName) {
|
|||
|
||||
for (int x = 0; x < schematics.getWidth(); ++x) {
|
||||
if (_stopImport) {
|
||||
qDebug("[DEBUG] Canceled import at %d voxels.", count);
|
||||
qDebug("Canceled import at %d voxels.", count);
|
||||
_stopImport = false;
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -107,7 +107,6 @@ DeleteVoxelCommand::DeleteVoxelCommand(VoxelTree* tree, VoxelDetail& voxel, Voxe
|
|||
_voxel.blue = element->getColor()[2];
|
||||
} else {
|
||||
_voxel.s = 0.0f;
|
||||
qDebug() << "No element for delete.";
|
||||
}
|
||||
_tree->unlock();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue