This commit is contained in:
Andrzej Kapolka 2014-12-10 15:23:27 -08:00
commit d402f767c1
10 changed files with 86 additions and 134 deletions

View file

@ -13,7 +13,6 @@ Script.include("libraries/globals.js");
var panelWall = false;
var orbShell = false;
var reticle = false;
var descriptionText = false;
var showText = false;
@ -24,8 +23,6 @@ var numberOfLines = 2;
var textMargin = 0.0625;
var lineHeight = (textHeight - (2 * textMargin)) / numberOfLines;
var lastMouseMove = 0;
var IDLE_HOVER_TIME = 2000; // if you haven't moved the mouse in 2 seconds, and in HMD mode, then we use reticle for hover
var avatarStickPosition = {};
var orbNaturalExtentsMin = { x: -1.230354, y: -1.22077, z: -1.210487 };
@ -58,13 +55,6 @@ var elevatorSound = SoundCache.getSound(HIFI_PUBLIC_BUCKET + "sounds/Lobby/eleva
var currentMuzakInjector = null;
var currentSound = null;
var inOculusMode = false;
function reticlePosition() {
var RETICLE_DISTANCE = 1;
return Vec3.sum(Camera.position, Vec3.multiply(Quat.getFront(Camera.orientation), RETICLE_DISTANCE));
}
function textOverlayPosition() {
var TEXT_DISTANCE_OUT = 6;
var TEXT_DISTANCE_DOWN = -2;
@ -72,6 +62,21 @@ function textOverlayPosition() {
Vec3.multiply(Quat.getUp(Camera.orientation), TEXT_DISTANCE_DOWN));
}
var panelLocationOrder = [
7, 8, 9, 10, 11, 12, 13,
0, 1, 2, 3, 4, 5, 6,
14, 15, 16, 17, 18, 19, 20
];
// Location index is 0-based
function locationIndexToPanelIndex(locationIndex) {
return panelLocationOrder.indexOf(locationIndex) + 1;
}
// Panel index is 1-based
function panelIndexToLocationIndex(panelIndex) {
return panelLocationOrder[panelIndex - 1];
}
var MAX_NUM_PANELS = 21;
var DRONE_VOLUME = 0.3;
@ -125,22 +130,6 @@ function drawLobby() {
panelWall = Overlays.addOverlay("model", panelWallProps);
orbShell = Overlays.addOverlay("model", orbShellProps);
descriptionText = Overlays.addOverlay("text3d", descriptionTextProps);
inOculusMode = Menu.isOptionChecked("Enable VR Mode");
// for HMD wearers, create a reticle in center of screen
if (inOculusMode) {
var CURSOR_SCALE = 0.025;
reticle = Overlays.addOverlay("billboard", {
url: HIFI_PUBLIC_BUCKET + "images/cursor.svg",
position: reticlePosition(),
ignoreRayIntersection: true,
isFacingAvatar: true,
alpha: 1.0,
scale: CURSOR_SCALE
});
}
// add an attachment on this avatar so other people see them in the lobby
MyAvatar.attach(HELMET_ATTACHMENT_URL, "Neck", {x: 0, y: 0, z: 0}, Quat.fromPitchYawRollDegrees(0, 0, 0), 1.15);
@ -169,7 +158,8 @@ function changeLobbyTextures() {
};
for (var j = 0; j < NUM_PANELS; j++) {
textureProp["textures"]["file" + (j + 1)] = "http:" + locations[j].thumbnail_url
var panelIndex = locationIndexToPanelIndex(j);
textureProp["textures"]["file" + panelIndex] = "http:" + locations[j].thumbnail_url;
};
Overlays.editOverlay(panelWall, textureProp);
@ -228,14 +218,8 @@ function cleanupLobby() {
Overlays.deleteOverlay(orbShell);
Overlays.deleteOverlay(descriptionText);
if (reticle) {
Overlays.deleteOverlay(reticle);
}
panelWall = false;
orbShell = false;
reticle = false;
Audio.stopInjector(currentDrone);
currentDrone = null;
@ -260,12 +244,13 @@ function actionStartEvent(event) {
var panelStringIndex = panelName.indexOf("Panel");
if (panelStringIndex != -1) {
var panelIndex = parseInt(panelName.slice(5)) - 1;
if (panelIndex < locations.length) {
var actionLocation = locations[panelIndex];
var panelIndex = parseInt(panelName.slice(5));
var locationIndex = panelIndexToLocationIndex(panelIndex);
if (locationIndex < locations.length) {
var actionLocation = locations[locationIndex];
print("Jumping to " + actionLocation.name + " at " + actionLocation.path
+ " in " + actionLocation.domain.name + " after click on panel " + panelIndex);
+ " in " + actionLocation.domain.name + " after click on panel " + panelIndex + " with location index " + locationIndex);
Window.location = actionLocation;
maybeCleanupLobby();
@ -309,9 +294,10 @@ function handleLookAt(pickRay) {
var panelName = result.extraInfo;
var panelStringIndex = panelName.indexOf("Panel");
if (panelStringIndex != -1) {
var panelIndex = parseInt(panelName.slice(5)) - 1;
if (panelIndex < locations.length) {
var actionLocation = locations[panelIndex];
var panelIndex = parseInt(panelName.slice(5));
var locationIndex = panelIndexToLocationIndex(panelIndex);
if (locationIndex < locations.length) {
var actionLocation = locations[locationIndex];
if (actionLocation.description == "") {
Overlays.editOverlay(descriptionText, { text: actionLocation.name, visible: showText });
@ -359,20 +345,6 @@ function handleLookAt(pickRay) {
function update(deltaTime) {
maybeCleanupLobby();
if (panelWall) {
if (reticle) {
Overlays.editOverlay(reticle, {
position: reticlePosition()
});
var nowDate = new Date();
var now = nowDate.getTime();
if (now - lastMouseMove > IDLE_HOVER_TIME) {
var pickRay = Camera.computeViewPickRay(0.5, 0.5);
handleLookAt(pickRay);
}
}
Overlays.editOverlay(descriptionText, { position: textOverlayPosition() });
// if the reticle is up then we may need to play the next muzak
@ -384,8 +356,6 @@ function update(deltaTime) {
function mouseMoveEvent(event) {
if (panelWall) {
var nowDate = new Date();
lastMouseMove = nowDate.getTime();
var pickRay = Camera.computePickRay(event.x, event.y);
handleLookAt(pickRay);
}

View file

@ -86,6 +86,7 @@ ChessGame.Board = (function(position, scale) {
modelURL: ChessGame.BOARD.modelURL,
position: this.position,
dimensions: this.dimensions,
rotation: ChessGame.BOARD.rotation,
userData: this.buildUserDataString()
}
this.entity = null;

View file

@ -167,8 +167,6 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) :
_raiseMirror(0.0f),
_lastMouseMove(usecTimestampNow()),
_lastMouseMoveWasSimulated(false),
_mouseHidden(false),
_seenMouseMove(false),
_touchAvgX(0.0f),
_touchAvgY(0.0f),
_isTouchPressed(false),
@ -1130,7 +1128,8 @@ void Application::keyPressEvent(QKeyEvent* event) {
if (!event->isAutoRepeat()) {
// this starts an HFActionEvent
HFActionEvent startActionEvent(HFActionEvent::startType(),
_myCamera.computeViewPickRay(0.5f, 0.5f));
_myCamera.computePickRay(getTrueMouseX(),
getTrueMouseY()));
sendEvent(this, &startActionEvent);
}
@ -1221,10 +1220,11 @@ void Application::keyReleaseEvent(QKeyEvent* event) {
case Qt::Key_Space: {
if (!event->isAutoRepeat()) {
// this ends the HFActionEvent
HFActionEvent endActionEvent(HFActionEvent::endType(), _myCamera.computeViewPickRay(0.5f, 0.5f));
HFActionEvent endActionEvent(HFActionEvent::endType(),
_myCamera.computePickRay(getTrueMouseX(),
getTrueMouseY()));
sendEvent(this, &endActionEvent);
}
break;
}
case Qt::Key_Escape: {
@ -1233,7 +1233,6 @@ void Application::keyReleaseEvent(QKeyEvent* event) {
HFBackEvent endBackEvent(HFBackEvent::endType());
sendEvent(this, &endBackEvent);
}
break;
}
default:
@ -1252,34 +1251,24 @@ void Application::focusOutEvent(QFocusEvent* event) {
}
void Application::mouseMoveEvent(QMouseEvent* event, unsigned int deviceID) {
bool showMouse = true;
// Used by application overlay to determine how to draw cursor(s)
_lastMouseMoveWasSimulated = deviceID > 0;
// If this mouse move event is emitted by a controller, dont show the mouse cursor
if (_lastMouseMoveWasSimulated) {
showMouse = false;
if (!_lastMouseMoveWasSimulated) {
_lastMouseMove = usecTimestampNow();
}
if (!_aboutToQuit) {
_entities.mouseMoveEvent(event, deviceID);
if (_aboutToQuit) {
return;
}
_entities.mouseMoveEvent(event, deviceID);
_controllerScriptingInterface.emitMouseMoveEvent(event, deviceID); // send events to any registered scripts
// if one of our scripts have asked to capture this event, then stop processing it
if (_controllerScriptingInterface.isMouseCaptured()) {
return;
}
_lastMouseMove = usecTimestampNow();
if (_mouseHidden && showMouse && !OculusManager::isConnected() && !TV3DManager::isConnected()) {
getGLWidget()->setCursor(Qt::ArrowCursor);
_mouseHidden = false;
_seenMouseMove = true;
}
}
void Application::mousePressEvent(QMouseEvent* event, unsigned int deviceID) {
@ -2111,13 +2100,7 @@ void Application::updateMouseRay() {
// make sure the frustum is up-to-date
loadViewFrustum(_myCamera, _viewFrustum);
// if the mouse pointer isn't visible, act like it's at the center of the screen
float x = 0.5f, y = 0.5f;
if (!_mouseHidden) {
x = getTrueMouseX() / (float)_glWidget->width();
y = getTrueMouseY() / (float)_glWidget->height();
}
PickRay pickRay = _myCamera.computeViewPickRay(x, y);
PickRay pickRay = _myCamera.computePickRay(getTrueMouseX(), getTrueMouseY());
_mouseRayOrigin = pickRay.origin;
_mouseRayDirection = pickRay.direction;
@ -2313,22 +2296,29 @@ void Application::updateCursor(float deltaTime) {
bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings);
PerformanceWarning warn(showWarnings, "Application::updateCursor()");
// watch mouse position, if it hasn't moved, hide the cursor
bool hideMouse = false;
bool underMouse = _glWidget->underMouse();
if (!_mouseHidden) {
quint64 now = usecTimestampNow();
int elapsed = now - _lastMouseMove;
const int HIDE_CURSOR_TIMEOUT = 1 * 1000 * 1000; // 1 second
if (elapsed > HIDE_CURSOR_TIMEOUT && (underMouse || !_seenMouseMove)) {
getGLWidget()->setCursor(Qt::BlankCursor);
_mouseHidden = true;
static const int HIDE_CURSOR_TIMEOUT = 3 * USECS_PER_SECOND; // 3 second
int elapsed = usecTimestampNow() - _lastMouseMove;
if ((elapsed > HIDE_CURSOR_TIMEOUT && underMouse) ||
(OculusManager::isConnected() && Menu::getInstance()->isOptionChecked(MenuOption::EnableVRMode))) {
hideMouse = true;
}
setCursorVisible(!hideMouse);
}
void Application::setCursorVisible(bool visible) {
if (visible) {
if (overrideCursor() != NULL) {
restoreOverrideCursor();
}
} else {
// if the mouse is hidden, but we're not inside our window, then consider ourselves to be moving
if (!underMouse && _seenMouseMove) {
_lastMouseMove = usecTimestampNow();
getGLWidget()->setCursor(Qt::ArrowCursor);
_mouseHidden = false;
if (overrideCursor() != NULL) {
changeOverrideCursor(Qt::BlankCursor);
} else {
setOverrideCursor(Qt::BlankCursor);
}
}
}
@ -2350,17 +2340,6 @@ void Application::update(float deltaTime) {
}
static QCursor cursor;
if (OculusManager::isConnected() &&
Menu::getInstance()->isOptionChecked(MenuOption::EnableVRMode)){
if (_window->cursor().shape() != Qt::BlankCursor) {
cursor = _window->cursor();
_window->setCursor(QCursor(Qt::BlankCursor));
}
} else if(_window->cursor().shape() == Qt::BlankCursor) {
_window->setCursor(cursor);
}
// Dispatch input events
_controllerScriptingInterface.updateInputControllers();
@ -2874,8 +2853,13 @@ void Application::updateShadowMap() {
// store view matrix without translation, which we'll use for precision-sensitive objects
updateUntranslatedViewMatrix();
// TODO: assign an equivalent viewTransform object to the application to match the current path which uses glMatrixStack
// setViewTransform(viewTransform);
// Equivalent to what is happening with _untranslatedViewMatrix and the _viewMatrixTranslation
// the viewTransofmr object is updatded with the correct values and saved,
// this is what is used for rendering the Entities and avatars
Transform viewTransform;
viewTransform.setRotation(rotation);
setViewTransform(viewTransform);
glEnable(GL_POLYGON_OFFSET_FILL);
glPolygonOffset(1.1f, 4.0f); // magic numbers courtesy http://www.eecs.berkeley.edu/~ravir/6160/papers/shadowmaps.ppt
@ -4372,14 +4356,6 @@ void Application::skipVersion(QString latestVersion) {
skipFile.write(latestVersion.toStdString().c_str());
}
void Application::setCursorVisible(bool visible) {
if (visible) {
restoreOverrideCursor();
} else {
setOverrideCursor(Qt::BlankCursor);
}
}
void Application::takeSnapshot() {
QMediaPlayer* player = new QMediaPlayer();
QFileInfo inf = QFileInfo(Application::resourcesPath() + "sounds/snap.wav");

View file

@ -211,7 +211,8 @@ public:
EntityTreeRenderer* getEntityClipboardRenderer() { return &_entityClipboardRenderer; }
Environment* getEnvironment() { return &_environment; }
bool isMousePressed() const { return _mousePressed; }
bool isMouseHidden() const { return _mouseHidden; }
bool isMouseHidden() const { return _glWidget->cursor().shape() == Qt::BlankCursor; }
void setCursorVisible(bool visible);
const glm::vec3& getMouseRayOrigin() const { return _mouseRayOrigin; }
const glm::vec3& getMouseRayDirection() const { return _mouseRayDirection; }
bool mouseOnScreen() const;
@ -309,8 +310,6 @@ public:
QStringList getRunningScripts() { return _scriptEnginesHash.keys(); }
ScriptEngine* getScriptEngine(QString scriptHash) { return _scriptEnginesHash.contains(scriptHash) ? _scriptEnginesHash[scriptHash] : NULL; }
void setCursorVisible(bool visible);
bool isLookingAtMyAvatar(Avatar* avatar);
@ -567,8 +566,6 @@ private:
int _mouseDragStartedY;
quint64 _lastMouseMove;
bool _lastMouseMoveWasSimulated;
bool _mouseHidden;
bool _seenMouseMove;
glm::vec3 _mouseRayOrigin;
glm::vec3 _mouseRayDirection;

View file

@ -132,8 +132,10 @@ void JoystickScriptingInterface::update() {
: HFActionEvent::endType();
// global action events fire in the center of the screen
HFActionEvent actionEvent(actionType,
Application::getInstance()->getCamera()->computeViewPickRay(0.5f, 0.5f));
Application* app = Application::getInstance();
PickRay pickRay = app->getCamera()->computePickRay(app->getTrueMouseX(),
app->getTrueMouseY());
HFActionEvent actionEvent(actionType, pickRay);
qApp->sendEvent(qApp, &actionEvent);
}

View file

@ -536,7 +536,7 @@ void ApplicationOverlay::renderPointers() {
glm::vec2 screenPos = sphericalToScreen(glm::vec2(yaw, -pitch));
position = QPoint(screenPos.x, screenPos.y);
QCursor::setPos(application->getGLWidget()->mapToGlobal(position));
application->getGLWidget()->cursor().setPos(application->getGLWidget()->mapToGlobal(position));
}
_reticlePosition[MOUSE] = position;

View file

@ -122,21 +122,21 @@ void FramelessDialog::mousePressEvent(QMouseEvent* mouseEvent) {
if (hitLeft || hitRight) {
_isResizing = true;
_resizeInitialWidth = size().width();
QApplication::setOverrideCursor(Qt::SizeHorCursor);
setCursor(Qt::SizeHorCursor);
}
} else {
bool hitTop = (_position == POSITION_TOP) && (abs(mouseEvent->pos().y() - size().height()) < RESIZE_HANDLE_WIDTH);
if (hitTop) {
_isResizing = true;
_resizeInitialWidth = size().height();
QApplication::setOverrideCursor(Qt::SizeHorCursor);
setCursor(Qt::SizeHorCursor);
}
}
}
}
void FramelessDialog::mouseReleaseEvent(QMouseEvent* mouseEvent) {
QApplication::restoreOverrideCursor();
unsetCursor();
_isResizing = false;
}

View file

@ -1542,7 +1542,7 @@ FBXGeometry extractFBXGeometry(const FBXNode& node, const QVariantHash& mapping,
}
} else {
std::string whatisthat = subobject.name;
if (whatisthat == "WTF") {
if (whatisthat == "Shape") {
}
}
#endif

View file

@ -44,7 +44,9 @@ bool ReceivedPacketProcessor::process() {
NetworkPacket& packet = _packets.front(); // get the oldest packet
NetworkPacket temporary = packet; // make a copy of the packet in case the vector is resized on us
_packets.erase(_packets.begin()); // remove the oldest packet
_nodePacketCounts[temporary.getNode()->getUUID()]--;
if (!temporary.getNode().isNull()) {
_nodePacketCounts[temporary.getNode()->getUUID()]--;
}
unlock(); // let others add to the packets
processPacket(temporary.getNode(), temporary.getByteArray()); // process our temporary copy
midProcess();

View file

@ -728,6 +728,10 @@ bool Octree::findRayIntersection(const glm::vec3& origin, const glm::vec3& direc
}
recurseTreeWithOperation(findRayIntersectionOp, &args);
if (args.found) {
args.distance *= (float)(TREE_SCALE); // scale back up to meters
}
if (gotLock) {
unlock();