mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-07-24 00:43:51 +02:00
Merge branch 'master' of https://github.com/highfidelity/hifi into atp
This commit is contained in:
commit
61f23f6a5e
20 changed files with 323 additions and 284 deletions
24
cmake/externals/polyvox/CMakeLists.txt
vendored
24
cmake/externals/polyvox/CMakeLists.txt
vendored
|
@ -3,8 +3,8 @@ set(EXTERNAL_NAME polyvox)
|
||||||
include(ExternalProject)
|
include(ExternalProject)
|
||||||
ExternalProject_Add(
|
ExternalProject_Add(
|
||||||
${EXTERNAL_NAME}
|
${EXTERNAL_NAME}
|
||||||
URL http://hifi-public.s3.amazonaws.com/dependencies/polyvox.zip
|
URL http://hifi-public.s3.amazonaws.com/dependencies/polyvox-master-2015-7-15.zip
|
||||||
URL_MD5 904b840328278c9b36fa7a14be730c34
|
URL_MD5 9ec6323b87e849ae36e562ae1c7494a9
|
||||||
CMAKE_ARGS -DENABLE_EXAMPLES=OFF -DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR>
|
CMAKE_ARGS -DENABLE_EXAMPLES=OFF -DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR>
|
||||||
BINARY_DIR ${EXTERNAL_PROJECT_PREFIX}/build
|
BINARY_DIR ${EXTERNAL_PROJECT_PREFIX}/build
|
||||||
LOG_DOWNLOAD 1
|
LOG_DOWNLOAD 1
|
||||||
|
@ -24,7 +24,16 @@ if (APPLE)
|
||||||
${EXTERNAL_NAME}
|
${EXTERNAL_NAME}
|
||||||
change-install-name
|
change-install-name
|
||||||
COMMENT "Calling install_name_tool on libraries to fix install name for dylib linking"
|
COMMENT "Calling install_name_tool on libraries to fix install name for dylib linking"
|
||||||
COMMAND ${CMAKE_COMMAND} -DINSTALL_NAME_LIBRARY_DIR=${INSTALL_NAME_LIBRARY_DIR} -P ${EXTERNAL_PROJECT_DIR}/OSXInstallNameChange.cmake
|
COMMAND ${CMAKE_COMMAND} -DINSTALL_NAME_LIBRARY_DIR=${INSTALL_NAME_LIBRARY_DIR}/Debug -P ${EXTERNAL_PROJECT_DIR}/OSXInstallNameChange.cmake
|
||||||
|
DEPENDEES install
|
||||||
|
WORKING_DIRECTORY <SOURCE_DIR>
|
||||||
|
LOG 1
|
||||||
|
)
|
||||||
|
ExternalProject_Add_Step(
|
||||||
|
${EXTERNAL_NAME}
|
||||||
|
change-install-name
|
||||||
|
COMMENT "Calling install_name_tool on libraries to fix install name for dylib linking"
|
||||||
|
COMMAND ${CMAKE_COMMAND} -DINSTALL_NAME_LIBRARY_DIR=${INSTALL_NAME_LIBRARY_DIR}/Release -P ${EXTERNAL_PROJECT_DIR}/OSXInstallNameChange.cmake
|
||||||
DEPENDEES install
|
DEPENDEES install
|
||||||
WORKING_DIRECTORY <SOURCE_DIR>
|
WORKING_DIRECTORY <SOURCE_DIR>
|
||||||
LOG 1
|
LOG 1
|
||||||
|
@ -48,12 +57,15 @@ endif ()
|
||||||
|
|
||||||
|
|
||||||
if (WIN32)
|
if (WIN32)
|
||||||
set(${EXTERNAL_NAME_UPPER}_CORE_LIBRARY ${INSTALL_DIR}/PolyVoxCore/lib/PolyVoxCore.lib CACHE FILEPATH "polyvox core library")
|
set(${EXTERNAL_NAME_UPPER}_CORE_LIBRARY_DEBUG ${INSTALL_DIR}/PolyVoxCore/lib/Debug/PolyVoxCore.lib CACHE FILEPATH "polyvox core library")
|
||||||
|
set(${EXTERNAL_NAME_UPPER}_CORE_LIBRARY_RELEASE ${INSTALL_DIR}/PolyVoxCore/lib/Release/PolyVoxCore.lib CACHE FILEPATH "polyvox core library")
|
||||||
# set(${EXTERNAL_NAME_UPPER}_UTIL_LIBRARY ${INSTALL_DIR}/PolyVoxUtil/lib/PolyVoxUtil.lib CACHE FILEPATH "polyvox util library")
|
# set(${EXTERNAL_NAME_UPPER}_UTIL_LIBRARY ${INSTALL_DIR}/PolyVoxUtil/lib/PolyVoxUtil.lib CACHE FILEPATH "polyvox util library")
|
||||||
elseif (APPLE)
|
elseif (APPLE)
|
||||||
set(${EXTERNAL_NAME_UPPER}_CORE_LIBRARY ${INSTALL_DIR}/lib/libPolyVoxCore.dylib CACHE FILEPATH "polyvox core library")
|
set(${EXTERNAL_NAME_UPPER}_CORE_LIBRARY_DEBUG ${INSTALL_DIR}/lib/Debug/libPolyVoxCore.dylib CACHE FILEPATH "polyvox core library")
|
||||||
|
set(${EXTERNAL_NAME_UPPER}_CORE_LIBRARY_RELEASE ${INSTALL_DIR}/lib/Release/libPolyVoxCore.dylib CACHE FILEPATH "polyvox core library")
|
||||||
# set(${EXTERNAL_NAME_UPPER}_UTIL_LIBRARY ${INSTALL_DIR}/lib/libPolyVoxUtil.dylib CACHE FILEPATH "polyvox util library")
|
# set(${EXTERNAL_NAME_UPPER}_UTIL_LIBRARY ${INSTALL_DIR}/lib/libPolyVoxUtil.dylib CACHE FILEPATH "polyvox util library")
|
||||||
else ()
|
else ()
|
||||||
set(${EXTERNAL_NAME_UPPER}_CORE_LIBRARY ${INSTALL_DIR}/lib/libPolyVoxCore.so CACHE FILEPATH "polyvox core library")
|
set(${EXTERNAL_NAME_UPPER}_CORE_LIBRARY_DEBUG ${INSTALL_DIR}/lib/Debug/libPolyVoxCore.so CACHE FILEPATH "polyvox core library")
|
||||||
|
set(${EXTERNAL_NAME_UPPER}_CORE_LIBRARY_RELEASE ${INSTALL_DIR}/lib/Release/libPolyVoxCore.so CACHE FILEPATH "polyvox core library")
|
||||||
# set(${EXTERNAL_NAME_UPPER}_UTIL_LIBRARY ${INSTALL_DIR}/lib/libPolyVoxUtil.so CACHE FILEPATH "polyvox util library")
|
# set(${EXTERNAL_NAME_UPPER}_UTIL_LIBRARY ${INSTALL_DIR}/lib/libPolyVoxUtil.so CACHE FILEPATH "polyvox util library")
|
||||||
endif ()
|
endif ()
|
||||||
|
|
|
@ -24,9 +24,12 @@ hifi_library_search_hints("polyvox")
|
||||||
find_path(POLYVOX_CORE_INCLUDE_DIRS PolyVoxCore/SimpleVolume.h PATH_SUFFIXES include include/PolyVoxCore HINTS ${POLYVOX_SEARCH_DIRS})
|
find_path(POLYVOX_CORE_INCLUDE_DIRS PolyVoxCore/SimpleVolume.h PATH_SUFFIXES include include/PolyVoxCore HINTS ${POLYVOX_SEARCH_DIRS})
|
||||||
# find_path(POLYVOX_UTIL_INCLUDE_DIRS PolyVoxUtil/Serialization.h PATH_SUFFIXES include include/PolyVoxUtil HINTS ${POLYVOX_SEARCH_DIRS})
|
# find_path(POLYVOX_UTIL_INCLUDE_DIRS PolyVoxUtil/Serialization.h PATH_SUFFIXES include include/PolyVoxUtil HINTS ${POLYVOX_SEARCH_DIRS})
|
||||||
|
|
||||||
find_library(POLYVOX_CORE_LIBRARY NAMES PolyVoxCore PATH_SUFFIXES lib HINTS ${POLYVOX_SEARCH_DIRS})
|
find_library(POLYVOX_CORE_LIBRARY_DEBUG NAMES PolyVoxCore PATH_SUFFIXES lib/Debug HINTS ${POLYVOX_SEARCH_DIRS})
|
||||||
|
find_library(POLYVOX_CORE_LIBRARY_RELEASE NAMES PolyVoxCore PATH_SUFFIXES lib/Release lib HINTS ${POLYVOX_SEARCH_DIRS})
|
||||||
# find_library(POLYVOX_UTIL_LIBRARY NAMES PolyVoxUtil PATH_SUFFIXES lib HINTS ${POLYVOX_SEARCH_DIRS})
|
# find_library(POLYVOX_UTIL_LIBRARY NAMES PolyVoxUtil PATH_SUFFIXES lib HINTS ${POLYVOX_SEARCH_DIRS})
|
||||||
|
|
||||||
|
include(SelectLibraryConfigurations)
|
||||||
|
select_library_configurations(POLYVOX_CORE)
|
||||||
|
|
||||||
# if (WIN32)
|
# if (WIN32)
|
||||||
# find_path(POLYVOX_DLL_PATH polyvox.dll PATH_SUFFIXES bin HINTS ${POLYVOX_SEARCH_DIRS})
|
# find_path(POLYVOX_DLL_PATH polyvox.dll PATH_SUFFIXES bin HINTS ${POLYVOX_SEARCH_DIRS})
|
||||||
|
|
|
@ -656,8 +656,10 @@ function mouseMove(event) {
|
||||||
|
|
||||||
function handleIdleMouse() {
|
function handleIdleMouse() {
|
||||||
idleMouseTimerId = null;
|
idleMouseTimerId = null;
|
||||||
|
if (isActive) {
|
||||||
highlightEntityUnderCursor(lastMousePosition, true);
|
highlightEntityUnderCursor(lastMousePosition, true);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function highlightEntityUnderCursor(position, accurateRay) {
|
function highlightEntityUnderCursor(position, accurateRay) {
|
||||||
var pickRay = Camera.computePickRay(position.x, position.y);
|
var pickRay = Camera.computePickRay(position.x, position.y);
|
||||||
|
|
|
@ -130,10 +130,10 @@
|
||||||
var others = Entities.findEntities(this.properties.position, this.properties.dimensions.y);
|
var others = Entities.findEntities(this.properties.position, this.properties.dimensions.y);
|
||||||
|
|
||||||
for (var i = 0; i < others.length; i++) {
|
for (var i = 0; i < others.length; i++) {
|
||||||
var piece = others[i];
|
var pieceID = others[i];
|
||||||
|
|
||||||
if (piece.id != this.entityID) {
|
if (pieceID != this.entityID) {
|
||||||
var properties = Entities.getEntityProperties(piece);
|
var properties = Entities.getEntityProperties(pieceID);
|
||||||
|
|
||||||
var isWhite = properties.modelURL.search("White") !== -1;
|
var isWhite = properties.modelURL.search("White") !== -1;
|
||||||
var type = (properties.modelURL.search("King") !== -1) ? 4 :
|
var type = (properties.modelURL.search("King") !== -1) ? 4 :
|
||||||
|
@ -147,7 +147,7 @@
|
||||||
if (myPos.i === piecePos.i && myPos.j === piecePos.j && type !== -2) {
|
if (myPos.i === piecePos.i && myPos.j === piecePos.j && type !== -2) {
|
||||||
var position = this.getAbsolutePosition((isWhite) ? { i: type, j: -1 } : { i: 7 - type, j: 8 },
|
var position = this.getAbsolutePosition((isWhite) ? { i: type, j: -1 } : { i: 7 - type, j: 8 },
|
||||||
properties.dimensions.y / 2.0);
|
properties.dimensions.y / 2.0);
|
||||||
Entities.editEntity(piece, {
|
Entities.editEntity(pieceID, {
|
||||||
position: position
|
position: position
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
|
|
420
examples/grab.js
420
examples/grab.js
|
@ -10,97 +10,13 @@
|
||||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
//
|
//
|
||||||
|
|
||||||
var MOVE_TIMESCALE = 0.1;
|
|
||||||
var INV_MOVE_TIMESCALE = 1.0 / MOVE_TIMESCALE;
|
|
||||||
var MAX_SOLID_ANGLE = 0.01; // objects that appear smaller than this can't be grabbed
|
var MAX_SOLID_ANGLE = 0.01; // objects that appear smaller than this can't be grabbed
|
||||||
var CLOSE_ENOUGH = 0.001;
|
|
||||||
var ZERO_VEC3 = {x: 0, y: 0, z: 0};
|
var ZERO_VEC3 = {x: 0, y: 0, z: 0};
|
||||||
var ANGULAR_DAMPING_RATE = 0.40;
|
var IDENTITY_QUAT = {x: 0, y: 0, z: 0, w: 0};
|
||||||
|
|
||||||
// NOTE: to improve readability global variable names start with 'g'
|
|
||||||
var gIsGrabbing = false;
|
|
||||||
var gGrabbedEntity = null;
|
|
||||||
var gActionID = null;
|
|
||||||
var gEntityProperties;
|
|
||||||
var gStartPosition;
|
|
||||||
var gStartRotation;
|
|
||||||
var gCurrentPosition;
|
|
||||||
var gOriginalGravity = ZERO_VEC3;
|
|
||||||
var gPlaneNormal = ZERO_VEC3;
|
|
||||||
|
|
||||||
// gMaxGrabDistance is a function of the size of the object.
|
|
||||||
var gMaxGrabDistance;
|
|
||||||
|
|
||||||
// gGrabMode defines the degrees of freedom of the grab target positions
|
|
||||||
// relative to gGrabStartPosition options include:
|
|
||||||
// xzPlane (default)
|
|
||||||
// verticalCylinder (SHIFT)
|
|
||||||
// rotate (CONTROL)
|
|
||||||
// Modes to eventually support?:
|
|
||||||
// xyPlane
|
|
||||||
// yzPlane
|
|
||||||
// polar
|
|
||||||
// elevationAzimuth
|
|
||||||
var gGrabMode = "xzplane";
|
|
||||||
|
|
||||||
// gGrabOffset allows the user to grab an object off-center. It points from the object's center
|
|
||||||
// to the point where the ray intersects the grab plane (at the moment the grab is initiated).
|
|
||||||
// Future target positions of the ray intersection are on the same plane, and the offset is subtracted
|
|
||||||
// to compute the target position of the object's center.
|
|
||||||
var gGrabOffset = { x: 0, y: 0, z: 0 };
|
|
||||||
|
|
||||||
var gTargetPosition;
|
|
||||||
var gTargetRotation;
|
|
||||||
var gLiftKey = false; // SHIFT
|
|
||||||
var gRotateKey = false; // CONTROL
|
|
||||||
|
|
||||||
var gInitialMouse = { x: 0, y: 0 };
|
|
||||||
var gPreviousMouse = { x: 0, y: 0 };
|
|
||||||
var gMouseCursorLocation = { x: 0, y: 0 };
|
|
||||||
var gMouseAtRotateStart = { x: 0, y: 0 };
|
|
||||||
|
|
||||||
var gBeaconHeight = 0.10;
|
|
||||||
|
|
||||||
// var gAngularVelocity = ZERO_VEC3;
|
|
||||||
|
|
||||||
// TODO: play sounds again when we aren't leaking AudioInjector threads
|
|
||||||
// var grabSound = SoundCache.getSound("https://hifi-public.s3.amazonaws.com/eric/sounds/CloseClamp.wav");
|
|
||||||
// var releaseSound = SoundCache.getSound("https://hifi-public.s3.amazonaws.com/eric/sounds/ReleaseClamp.wav");
|
|
||||||
// var VOLUME = 0.0;
|
|
||||||
|
|
||||||
var gBeaconHeight = 0.10;
|
|
||||||
var BEACON_COLOR = {
|
|
||||||
red: 200,
|
|
||||||
green: 200,
|
|
||||||
blue: 200
|
|
||||||
};
|
|
||||||
var BEACON_WIDTH = 2;
|
|
||||||
|
|
||||||
|
|
||||||
var gBeacon = Overlays.addOverlay("line3d", {
|
// helper function
|
||||||
color: BEACON_COLOR,
|
function mouseIntersectionWithPlane(pointOnPlane, planeNormal, event, maxDistance) {
|
||||||
alpha: 1,
|
|
||||||
visible: false,
|
|
||||||
lineWidth: BEACON_WIDTH
|
|
||||||
});
|
|
||||||
|
|
||||||
function updateDropLine(position) {
|
|
||||||
Overlays.editOverlay(gBeacon, {
|
|
||||||
visible: true,
|
|
||||||
start: {
|
|
||||||
x: position.x,
|
|
||||||
y: position.y + gBeaconHeight,
|
|
||||||
z: position.z
|
|
||||||
},
|
|
||||||
end: {
|
|
||||||
x: position.x,
|
|
||||||
y: position.y - gBeaconHeight,
|
|
||||||
z: position.z
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function mouseIntersectionWithPlane(pointOnPlane, planeNormal, event) {
|
|
||||||
var cameraPosition = Camera.getPosition();
|
var cameraPosition = Camera.getPosition();
|
||||||
var localPointOnPlane = Vec3.subtract(pointOnPlane, cameraPosition);
|
var localPointOnPlane = Vec3.subtract(pointOnPlane, cameraPosition);
|
||||||
var distanceFromPlane = Vec3.dot(localPointOnPlane, planeNormal);
|
var distanceFromPlane = Vec3.dot(localPointOnPlane, planeNormal);
|
||||||
|
@ -117,7 +33,7 @@ function mouseIntersectionWithPlane(pointOnPlane, planeNormal, event) {
|
||||||
var useMaxForwardGrab = false;
|
var useMaxForwardGrab = false;
|
||||||
if (Math.abs(dirDotNorm) > MIN_RAY_PLANE_DOT) {
|
if (Math.abs(dirDotNorm) > MIN_RAY_PLANE_DOT) {
|
||||||
var distanceToIntersection = distanceFromPlane / dirDotNorm;
|
var distanceToIntersection = distanceFromPlane / dirDotNorm;
|
||||||
if (distanceToIntersection > 0 && distanceToIntersection < gMaxGrabDistance) {
|
if (distanceToIntersection > 0 && distanceToIntersection < maxDistance) {
|
||||||
// ray points into the plane
|
// ray points into the plane
|
||||||
localIntersection = Vec3.multiply(pickRay.direction, distanceFromPlane / dirDotNorm);
|
localIntersection = Vec3.multiply(pickRay.direction, distanceFromPlane / dirDotNorm);
|
||||||
} else {
|
} else {
|
||||||
|
@ -134,52 +50,160 @@ function mouseIntersectionWithPlane(pointOnPlane, planeNormal, event) {
|
||||||
// we re-route the intersection to be in front at max distance.
|
// we re-route the intersection to be in front at max distance.
|
||||||
var rayDirection = Vec3.subtract(pickRay.direction, Vec3.multiply(planeNormal, dirDotNorm));
|
var rayDirection = Vec3.subtract(pickRay.direction, Vec3.multiply(planeNormal, dirDotNorm));
|
||||||
rayDirection = Vec3.normalize(rayDirection);
|
rayDirection = Vec3.normalize(rayDirection);
|
||||||
localIntersection = Vec3.multiply(rayDirection, gMaxGrabDistance);
|
localIntersection = Vec3.multiply(rayDirection, maxDistance);
|
||||||
localIntersection = Vec3.sum(localIntersection, Vec3.multiply(planeNormal, distanceFromPlane));
|
localIntersection = Vec3.sum(localIntersection, Vec3.multiply(planeNormal, distanceFromPlane));
|
||||||
}
|
}
|
||||||
var worldIntersection = Vec3.sum(cameraPosition, localIntersection);
|
var worldIntersection = Vec3.sum(cameraPosition, localIntersection);
|
||||||
return worldIntersection;
|
return worldIntersection;
|
||||||
}
|
}
|
||||||
|
|
||||||
function computeNewGrabPlane() {
|
// Mouse class stores mouse click and drag info
|
||||||
if (!gIsGrabbing) {
|
Mouse = function() {
|
||||||
|
this.current = {x: 0, y: 0 };
|
||||||
|
this.previous = {x: 0, y: 0 };
|
||||||
|
this.rotateStart = {x: 0, y: 0 };
|
||||||
|
this.cursorRestore = {x: 0, y: 0};
|
||||||
|
}
|
||||||
|
|
||||||
|
Mouse.prototype.startDrag = function(position) {
|
||||||
|
this.current = {x: position.x, y: position.y};
|
||||||
|
this.startRotateDrag();
|
||||||
|
}
|
||||||
|
|
||||||
|
Mouse.prototype.updateDrag = function(position) {
|
||||||
|
this.current = {x: position.x, y: position.y };
|
||||||
|
}
|
||||||
|
|
||||||
|
Mouse.prototype.startRotateDrag = function() {
|
||||||
|
this.previous = {x: this.current.x, y: this.current.y};
|
||||||
|
this.rotateStart = {x: this.current.x, y: this.current.y};
|
||||||
|
this.cursorRestore = { x: Window.getCursorPositionX(), y: Window.getCursorPositionY() };
|
||||||
|
}
|
||||||
|
|
||||||
|
Mouse.prototype.getDrag = function() {
|
||||||
|
var delta = {x: this.current.x - this.previous.x, y: this.current.y - this.previous.y};
|
||||||
|
this.previous = {x: this.current.x, y: this.current.y};
|
||||||
|
return delta;
|
||||||
|
}
|
||||||
|
|
||||||
|
Mouse.prototype.restoreRotateCursor = function() {
|
||||||
|
Window.setCursorPosition(this.cursorRestore.x, this.cursorRestore.y);
|
||||||
|
this.current = {x: this.rotateStart.x, y: this.rotateStart.y};
|
||||||
|
}
|
||||||
|
|
||||||
|
var mouse = new Mouse();
|
||||||
|
|
||||||
|
|
||||||
|
// Beacon class stores info for drawing a line at object's target position
|
||||||
|
Beacon = function() {
|
||||||
|
this.height = 0.10;
|
||||||
|
this.overlayID = Overlays.addOverlay("line3d", {
|
||||||
|
color: {red: 200, green: 200, blue: 200},
|
||||||
|
alpha: 1,
|
||||||
|
visible: false,
|
||||||
|
lineWidth: 2
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
Beacon.prototype.enable = function() {
|
||||||
|
Overlays.editOverlay(this.overlayID, { visible: true });
|
||||||
|
}
|
||||||
|
|
||||||
|
Beacon.prototype.disable = function() {
|
||||||
|
Overlays.editOverlay(this.overlayID, { visible: false });
|
||||||
|
}
|
||||||
|
|
||||||
|
Beacon.prototype.updatePosition = function(position) {
|
||||||
|
Overlays.editOverlay(this.overlayID, {
|
||||||
|
visible: true,
|
||||||
|
start: {
|
||||||
|
x: position.x,
|
||||||
|
y: position.y + this.height,
|
||||||
|
z: position.z
|
||||||
|
},
|
||||||
|
end: {
|
||||||
|
x: position.x,
|
||||||
|
y: position.y - this.height,
|
||||||
|
z: position.z
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
var beacon = new Beacon();
|
||||||
|
|
||||||
|
|
||||||
|
// TODO: play sounds again when we aren't leaking AudioInjector threads
|
||||||
|
// var grabSound = SoundCache.getSound("https://hifi-public.s3.amazonaws.com/eric/sounds/CloseClamp.wav");
|
||||||
|
// var releaseSound = SoundCache.getSound("https://hifi-public.s3.amazonaws.com/eric/sounds/ReleaseClamp.wav");
|
||||||
|
// var VOLUME = 0.0;
|
||||||
|
|
||||||
|
|
||||||
|
// Grabber class stores and computes info for grab behavior
|
||||||
|
Grabber = function() {
|
||||||
|
this.isGrabbing = false;
|
||||||
|
this.entityID = null;
|
||||||
|
this.actionID = null;
|
||||||
|
this.startPosition = ZERO_VEC3;
|
||||||
|
this.lastRotation = IDENTITY_QUAT;
|
||||||
|
this.currentPosition = ZERO_VEC3;
|
||||||
|
this.planeNormal = ZERO_VEC3;
|
||||||
|
|
||||||
|
this.originalGravity = ZERO_VEC3;
|
||||||
|
// maxDistance is a function of the size of the object.
|
||||||
|
this.maxDistance;
|
||||||
|
|
||||||
|
// mode defines the degrees of freedom of the grab target positions
|
||||||
|
// relative to startPosition options include:
|
||||||
|
// xzPlane (default)
|
||||||
|
// verticalCylinder (SHIFT)
|
||||||
|
// rotate (CONTROL)
|
||||||
|
this.mode = "xzplane";
|
||||||
|
|
||||||
|
// offset allows the user to grab an object off-center. It points from the object's center
|
||||||
|
// to the point where the ray intersects the grab plane (at the moment the grab is initiated).
|
||||||
|
// Future target positions of the ray intersection are on the same plane, and the offset is subtracted
|
||||||
|
// to compute the target position of the object's center.
|
||||||
|
this.offset = {x: 0, y: 0, z: 0 };
|
||||||
|
|
||||||
|
this.targetPosition;
|
||||||
|
this.targetRotation;
|
||||||
|
|
||||||
|
this.liftKey = false; // SHIFT
|
||||||
|
this.rotateKey = false; // CONTROL
|
||||||
|
}
|
||||||
|
|
||||||
|
Grabber.prototype.computeNewGrabPlane = function() {
|
||||||
|
if (!this.isGrabbing) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var maybeResetMousePosition = false;
|
var modeWasRotate = (this.mode == "rotate");
|
||||||
if (gGrabMode !== "rotate") {
|
this.mode = "xzPlane";
|
||||||
gMouseAtRotateStart = gMouseCursorLocation;
|
this.planeNormal = {x: 0, y: 1, z: 0 };
|
||||||
|
if (this.rotateKey) {
|
||||||
|
this.mode = "rotate";
|
||||||
|
mouse.startRotateDrag();
|
||||||
} else {
|
} else {
|
||||||
maybeResetMousePosition = true;
|
if (modeWasRotate) {
|
||||||
|
// we reset the mouse screen position whenever we stop rotating
|
||||||
|
mouse.restoreRotateCursor();
|
||||||
}
|
}
|
||||||
gGrabMode = "xzPlane";
|
if (this.liftKey) {
|
||||||
gPlaneNormal = { x: 0, y: 1, z: 0 };
|
this.mode = "verticalCylinder";
|
||||||
if (gLiftKey) {
|
// NOTE: during verticalCylinder mode a new planeNormal will be computed each move
|
||||||
if (!gRotateKey) {
|
|
||||||
gGrabMode = "verticalCylinder";
|
|
||||||
// a new planeNormal will be computed each move
|
|
||||||
}
|
}
|
||||||
} else if (gRotateKey) {
|
|
||||||
gGrabMode = "rotate";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
gPointOnPlane = Vec3.sum(gCurrentPosition, gGrabOffset);
|
this.pointOnPlane = Vec3.sum(this.currentPosition, this.offset);
|
||||||
var xzOffset = Vec3.subtract(gPointOnPlane, Camera.getPosition());
|
var xzOffset = Vec3.subtract(this.pointOnPlane, Camera.getPosition());
|
||||||
xzOffset.y = 0;
|
xzOffset.y = 0;
|
||||||
gXzDistanceToGrab = Vec3.length(xzOffset);
|
this.xzDistanceToGrab = Vec3.length(xzOffset);
|
||||||
|
|
||||||
if (gGrabMode !== "rotate" && maybeResetMousePosition) {
|
|
||||||
// we reset the mouse position whenever we stop rotating
|
|
||||||
Window.setCursorPosition(gMouseAtRotateStart.x, gMouseAtRotateStart.y);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function mousePressEvent(event) {
|
Grabber.prototype.pressEvent = function(event) {
|
||||||
if (!event.isLeftButton) {
|
if (!event.isLeftButton) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
gInitialMouse = {x: event.x, y: event.y };
|
|
||||||
gPreviousMouse = {x: event.x, y: event.y };
|
|
||||||
|
|
||||||
var pickRay = Camera.computePickRay(event.x, event.y);
|
var pickRay = Camera.computePickRay(event.x, event.y);
|
||||||
var pickResults = Entities.findRayIntersection(pickRay, true); // accurate picking
|
var pickResults = Entities.findRayIntersection(pickRay, true); // accurate picking
|
||||||
|
@ -193,150 +217,172 @@ function mousePressEvent(event) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mouse.startDrag(event);
|
||||||
|
|
||||||
var clickedEntity = pickResults.entityID;
|
var clickedEntity = pickResults.entityID;
|
||||||
var entityProperties = Entities.getEntityProperties(clickedEntity)
|
var entityProperties = Entities.getEntityProperties(clickedEntity)
|
||||||
gStartPosition = entityProperties.position;
|
this.startPosition = entityProperties.position;
|
||||||
gStartRotation = entityProperties.rotation;
|
this.lastRotation = entityProperties.rotation;
|
||||||
var cameraPosition = Camera.getPosition();
|
var cameraPosition = Camera.getPosition();
|
||||||
|
|
||||||
gBeaconHeight = Vec3.length(entityProperties.dimensions);
|
var objectBoundingDiameter = Vec3.length(entityProperties.dimensions);
|
||||||
gMaxGrabDistance = gBeaconHeight / MAX_SOLID_ANGLE;
|
beacon.height = objectBoundingDiameter;
|
||||||
if (Vec3.distance(gStartPosition, cameraPosition) > gMaxGrabDistance) {
|
this.maxDistance = objectBoundingDiameter / MAX_SOLID_ANGLE;
|
||||||
|
if (Vec3.distance(this.startPosition, cameraPosition) > this.maxDistance) {
|
||||||
// don't allow grabs of things far away
|
// don't allow grabs of things far away
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Entities.editEntity(clickedEntity, { gravity: ZERO_VEC3 });
|
Entities.editEntity(clickedEntity, { gravity: ZERO_VEC3 });
|
||||||
gIsGrabbing = true;
|
this.isGrabbing = true;
|
||||||
|
|
||||||
gGrabbedEntity = clickedEntity;
|
this.entityID = clickedEntity;
|
||||||
gCurrentPosition = entityProperties.position;
|
this.currentPosition = entityProperties.position;
|
||||||
gOriginalGravity = entityProperties.gravity;
|
this.originalGravity = entityProperties.gravity;
|
||||||
gTargetPosition = gStartPosition;
|
this.targetPosition = {x: this.startPosition.x, y: this.startPosition.y, z: this.startPosition.z};
|
||||||
|
|
||||||
// compute the grab point
|
// compute the grab point
|
||||||
var nearestPoint = Vec3.subtract(gStartPosition, cameraPosition);
|
var nearestPoint = Vec3.subtract(this.startPosition, cameraPosition);
|
||||||
var distanceToGrab = Vec3.dot(nearestPoint, pickRay.direction);
|
var distanceToGrab = Vec3.dot(nearestPoint, pickRay.direction);
|
||||||
nearestPoint = Vec3.multiply(distanceToGrab, pickRay.direction);
|
nearestPoint = Vec3.multiply(distanceToGrab, pickRay.direction);
|
||||||
gPointOnPlane = Vec3.sum(cameraPosition, nearestPoint);
|
this.pointOnPlane = Vec3.sum(cameraPosition, nearestPoint);
|
||||||
|
|
||||||
// compute the grab offset (points from object center to point of grab)
|
// compute the grab offset (points from object center to point of grab)
|
||||||
gGrabOffset = Vec3.subtract(gPointOnPlane, gStartPosition);
|
this.offset = Vec3.subtract(this.pointOnPlane, this.startPosition);
|
||||||
|
|
||||||
computeNewGrabPlane();
|
this.computeNewGrabPlane();
|
||||||
|
|
||||||
updateDropLine(gStartPosition);
|
beacon.updatePosition(this.startPosition);
|
||||||
|
|
||||||
// TODO: play sounds again when we aren't leaking AudioInjector threads
|
// TODO: play sounds again when we aren't leaking AudioInjector threads
|
||||||
//Audio.playSound(grabSound, { position: entityProperties.position, volume: VOLUME });
|
//Audio.playSound(grabSound, { position: entityProperties.position, volume: VOLUME });
|
||||||
}
|
}
|
||||||
|
|
||||||
function mouseReleaseEvent() {
|
Grabber.prototype.releaseEvent = function() {
|
||||||
if (gIsGrabbing) {
|
if (this.isGrabbing) {
|
||||||
if (Vec3.length(gOriginalGravity) != 0) {
|
if (Vec3.length(this.originalGravity) != 0) {
|
||||||
Entities.editEntity(gGrabbedEntity, { gravity: gOriginalGravity });
|
Entities.editEntity(this.entityID, { gravity: this.originalGravity});
|
||||||
}
|
}
|
||||||
|
|
||||||
gIsGrabbing = false
|
this.isGrabbing = false
|
||||||
Entities.deleteAction(gGrabbedEntity, gActionID);
|
Entities.deleteAction(this.entityID, this.actionID);
|
||||||
gActionID = null;
|
this.actionID = null;
|
||||||
|
|
||||||
Overlays.editOverlay(gBeacon, { visible: false });
|
beacon.disable();
|
||||||
|
|
||||||
// TODO: play sounds again when we aren't leaking AudioInjector threads
|
// TODO: play sounds again when we aren't leaking AudioInjector threads
|
||||||
//Audio.playSound(releaseSound, { position: entityProperties.position, volume: VOLUME });
|
//Audio.playSound(releaseSound, { position: entityProperties.position, volume: VOLUME });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function mouseMoveEvent(event) {
|
Grabber.prototype.moveEvent = function(event) {
|
||||||
if (!gIsGrabbing) {
|
if (!this.isGrabbing) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
mouse.updateDrag(event);
|
||||||
|
|
||||||
// see if something added/restored gravity
|
// see if something added/restored gravity
|
||||||
var entityProperties = Entities.getEntityProperties(gGrabbedEntity);
|
var entityProperties = Entities.getEntityProperties(this.entityID);
|
||||||
if (Vec3.length(entityProperties.gravity) != 0) {
|
if (Vec3.length(entityProperties.gravity) != 0) {
|
||||||
gOriginalGravity = entityProperties.gravity;
|
this.originalGravity = entityProperties.gravity;
|
||||||
}
|
}
|
||||||
gCurrentPosition = entityProperties.position;
|
this.currentPosition = entityProperties.position;
|
||||||
|
|
||||||
var actionArgs = {};
|
var actionArgs = {};
|
||||||
|
|
||||||
if (gGrabMode === "rotate") {
|
if (this.mode === "rotate") {
|
||||||
var deltaMouse = { x: 0, y: 0 };
|
var drag = mouse.getDrag();
|
||||||
var dx = event.x - gInitialMouse.x;
|
|
||||||
var dy = event.y - gInitialMouse.y;
|
|
||||||
var orientation = Camera.getOrientation();
|
var orientation = Camera.getOrientation();
|
||||||
var dragOffset = Vec3.multiply(dx, Quat.getRight(orientation));
|
var dragOffset = Vec3.multiply(drag.x, Quat.getRight(orientation));
|
||||||
dragOffset = Vec3.sum(dragOffset, Vec3.multiply(-dy, Quat.getUp(orientation)));
|
dragOffset = Vec3.sum(dragOffset, Vec3.multiply(-drag.y, Quat.getUp(orientation)));
|
||||||
var axis = Vec3.cross(dragOffset, Quat.getFront(orientation));
|
var axis = Vec3.cross(dragOffset, Quat.getFront(orientation));
|
||||||
axis = Vec3.normalize(axis);
|
axis = Vec3.normalize(axis);
|
||||||
var ROTATE_STRENGTH = 0.4; // magic number tuned by hand
|
var ROTATE_STRENGTH = 0.4; // magic number tuned by hand
|
||||||
var angle = ROTATE_STRENGTH * Math.sqrt((dx * dx) + (dy * dy));
|
var angle = ROTATE_STRENGTH * Math.sqrt((drag.x * drag.x) + (drag.y * drag.y));
|
||||||
var deltaQ = Quat.angleAxis(angle, axis);
|
var deltaQ = Quat.angleAxis(angle, axis);
|
||||||
// var qZero = entityProperties.rotation;
|
// var qZero = entityProperties.rotation;
|
||||||
var qZero = gStartRotation;
|
//var qZero = this.lastRotation;
|
||||||
var qOne = Quat.multiply(deltaQ, qZero);
|
this.lastRotation = Quat.multiply(deltaQ, this.lastRotation);
|
||||||
actionArgs = {targetRotation: qOne, angularTimeScale: 0.1};
|
actionArgs = {targetRotation: this.lastRotation, angularTimeScale: 0.1};
|
||||||
} else {
|
} else {
|
||||||
var newTargetPosition;
|
var newPointOnPlane;
|
||||||
if (gGrabMode === "verticalCylinder") {
|
if (this.mode === "verticalCylinder") {
|
||||||
// for this mode we recompute the plane based on current Camera
|
// for this mode we recompute the plane based on current Camera
|
||||||
var planeNormal = Quat.getFront(Camera.getOrientation());
|
var planeNormal = Quat.getFront(Camera.getOrientation());
|
||||||
planeNormal.y = 0;
|
planeNormal.y = 0;
|
||||||
planeNormal = Vec3.normalize(planeNormal);
|
planeNormal = Vec3.normalize(planeNormal);
|
||||||
var pointOnCylinder = Vec3.multiply(planeNormal, gXzDistanceToGrab);
|
var pointOnCylinder = Vec3.multiply(planeNormal, this.xzDistanceToGrab);
|
||||||
pointOnCylinder = Vec3.sum(Camera.getPosition(), pointOnCylinder);
|
pointOnCylinder = Vec3.sum(Camera.getPosition(), pointOnCylinder);
|
||||||
newTargetPosition = mouseIntersectionWithPlane(pointOnCylinder, planeNormal, event);
|
this.pointOnPlane = mouseIntersectionWithPlane(pointOnCylinder, planeNormal, mouse.current, this.maxDistance);
|
||||||
gPointOnPlane = Vec3.sum(newTargetPosition, gGrabOffset);
|
newPointOnPlane = {x: this.pointOnPlane.x, y: this.pointOnPlane.y, z: this.pointOnPlane.z};
|
||||||
} else {
|
} else {
|
||||||
var cameraPosition = Camera.getPosition();
|
var cameraPosition = Camera.getPosition();
|
||||||
newTargetPosition = mouseIntersectionWithPlane(gPointOnPlane, gPlaneNormal, event);
|
newPointOnPlane = mouseIntersectionWithPlane(this.pointOnPlane, this.planeNormal, mouse.current, this.maxDistance);
|
||||||
var relativePosition = Vec3.subtract(newTargetPosition, cameraPosition);
|
var relativePosition = Vec3.subtract(newPointOnPlane, cameraPosition);
|
||||||
var distance = Vec3.length(relativePosition);
|
var distance = Vec3.length(relativePosition);
|
||||||
if (distance > gMaxGrabDistance) {
|
if (distance > this.maxDistance) {
|
||||||
// clamp distance
|
// clamp distance
|
||||||
relativePosition = Vec3.multiply(relativePosition, gMaxGrabDistance / distance);
|
relativePosition = Vec3.multiply(relativePosition, this.maxDistance / distance);
|
||||||
newTargetPosition = Vec3.sum(relativePosition, cameraPosition);
|
newPointOnPlane = Vec3.sum(relativePosition, cameraPosition);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
gTargetPosition = Vec3.subtract(newTargetPosition, gGrabOffset);
|
this.targetPosition = Vec3.subtract(newPointOnPlane, this.offset);
|
||||||
actionArgs = {targetPosition: gTargetPosition, linearTimeScale: 0.1};
|
actionArgs = {targetPosition: this.targetPosition, linearTimeScale: 0.1};
|
||||||
}
|
|
||||||
gPreviousMouse = { x: event.x, y: event.y };
|
|
||||||
gMouseCursorLocation = { x: Window.getCursorPositionX(), y: Window.getCursorPositionY() };
|
|
||||||
|
|
||||||
if (!gActionID) {
|
beacon.updatePosition(this.targetPosition);
|
||||||
gActionID = Entities.addAction("spring", gGrabbedEntity, actionArgs);
|
}
|
||||||
|
|
||||||
|
if (!this.actionID) {
|
||||||
|
this.actionID = Entities.addAction("spring", this.entityID, actionArgs);
|
||||||
} else {
|
} else {
|
||||||
Entities.updateAction(gGrabbedEntity, gActionID, actionArgs);
|
Entities.updateAction(this.entityID, this.actionID, actionArgs);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
updateDropLine(gTargetPosition);
|
Grabber.prototype.keyReleaseEvent = function(event) {
|
||||||
}
|
|
||||||
|
|
||||||
function keyReleaseEvent(event) {
|
|
||||||
if (event.text === "SHIFT") {
|
if (event.text === "SHIFT") {
|
||||||
gLiftKey = false;
|
this.liftKey = false;
|
||||||
}
|
}
|
||||||
if (event.text === "CONTROL") {
|
if (event.text === "CONTROL") {
|
||||||
gRotateKey = false;
|
this.rotateKey = false;
|
||||||
}
|
}
|
||||||
computeNewGrabPlane();
|
this.computeNewGrabPlane();
|
||||||
|
}
|
||||||
|
|
||||||
|
Grabber.prototype.keyPressEvent = function(event) {
|
||||||
|
if (event.text === "SHIFT") {
|
||||||
|
this.liftKey = true;
|
||||||
|
}
|
||||||
|
if (event.text === "CONTROL") {
|
||||||
|
this.rotateKey = true;
|
||||||
|
}
|
||||||
|
this.computeNewGrabPlane();
|
||||||
|
}
|
||||||
|
|
||||||
|
var grabber = new Grabber();
|
||||||
|
|
||||||
|
function pressEvent(event) {
|
||||||
|
grabber.pressEvent(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
function moveEvent(event) {
|
||||||
|
grabber.moveEvent(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
function releaseEvent(event) {
|
||||||
|
grabber.releaseEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
function keyPressEvent(event) {
|
function keyPressEvent(event) {
|
||||||
if (event.text === "SHIFT") {
|
grabber.keyPressEvent(event);
|
||||||
gLiftKey = true;
|
|
||||||
}
|
|
||||||
if (event.text === "CONTROL") {
|
|
||||||
gRotateKey = true;
|
|
||||||
}
|
|
||||||
computeNewGrabPlane();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Controller.mouseMoveEvent.connect(mouseMoveEvent);
|
function keyReleaseEvent(event) {
|
||||||
Controller.mousePressEvent.connect(mousePressEvent);
|
grabber.keyReleaseEvent(event);
|
||||||
Controller.mouseReleaseEvent.connect(mouseReleaseEvent);
|
}
|
||||||
|
|
||||||
|
Controller.mousePressEvent.connect(pressEvent);
|
||||||
|
Controller.mouseMoveEvent.connect(moveEvent);
|
||||||
|
Controller.mouseReleaseEvent.connect(releaseEvent);
|
||||||
Controller.keyPressEvent.connect(keyPressEvent);
|
Controller.keyPressEvent.connect(keyPressEvent);
|
||||||
Controller.keyReleaseEvent.connect(keyReleaseEvent);
|
Controller.keyReleaseEvent.connect(keyReleaseEvent);
|
||||||
|
|
|
@ -1571,7 +1571,9 @@ void Application::mouseMoveEvent(QMouseEvent* event, unsigned int deviceID) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (deviceID == 0) {
|
||||||
_keyboardMouseDevice.mouseMoveEvent(event, deviceID);
|
_keyboardMouseDevice.mouseMoveEvent(event, deviceID);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1592,7 +1594,9 @@ void Application::mousePressEvent(QMouseEvent* event, unsigned int deviceID) {
|
||||||
|
|
||||||
|
|
||||||
if (activeWindow() == _window) {
|
if (activeWindow() == _window) {
|
||||||
|
if (deviceID == 0) {
|
||||||
_keyboardMouseDevice.mousePressEvent(event);
|
_keyboardMouseDevice.mousePressEvent(event);
|
||||||
|
}
|
||||||
|
|
||||||
if (event->button() == Qt::LeftButton) {
|
if (event->button() == Qt::LeftButton) {
|
||||||
_mouseDragStarted = getTrueMouse();
|
_mouseDragStarted = getTrueMouse();
|
||||||
|
@ -1632,7 +1636,9 @@ void Application::mouseReleaseEvent(QMouseEvent* event, unsigned int deviceID) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (activeWindow() == _window) {
|
if (activeWindow() == _window) {
|
||||||
|
if (deviceID == 0) {
|
||||||
_keyboardMouseDevice.mouseReleaseEvent(event);
|
_keyboardMouseDevice.mouseReleaseEvent(event);
|
||||||
|
}
|
||||||
|
|
||||||
if (event->button() == Qt::LeftButton) {
|
if (event->button() == Qt::LeftButton) {
|
||||||
_mousePressed = false;
|
_mousePressed = false;
|
||||||
|
|
|
@ -523,7 +523,7 @@ void Avatar::render(RenderArgs* renderArgs, const glm::vec3& cameraPosition, boo
|
||||||
|
|
||||||
auto cameraMode = Application::getInstance()->getCamera()->getMode();
|
auto cameraMode = Application::getInstance()->getCamera()->getMode();
|
||||||
if (!isMyAvatar() || cameraMode != CAMERA_MODE_FIRST_PERSON) {
|
if (!isMyAvatar() || cameraMode != CAMERA_MODE_FIRST_PERSON) {
|
||||||
renderDisplayName(batch, *renderArgs->_viewFrustum);
|
renderDisplayName(batch, *renderArgs->_viewFrustum, renderArgs->_viewport);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -674,7 +674,7 @@ glm::vec3 Avatar::getDisplayNamePosition() const {
|
||||||
return namePosition;
|
return namePosition;
|
||||||
}
|
}
|
||||||
|
|
||||||
Transform Avatar::calculateDisplayNameTransform(const ViewFrustum& frustum, float fontSize) const {
|
Transform Avatar::calculateDisplayNameTransform(const ViewFrustum& frustum, float fontSize, const glm::ivec4& viewport) const {
|
||||||
Transform result;
|
Transform result;
|
||||||
// We assume textPosition is whithin the frustum
|
// We assume textPosition is whithin the frustum
|
||||||
glm::vec3 textPosition = getDisplayNamePosition();
|
glm::vec3 textPosition = getDisplayNamePosition();
|
||||||
|
@ -693,12 +693,7 @@ Transform Avatar::calculateDisplayNameTransform(const ViewFrustum& frustum, floa
|
||||||
glm::vec4 p0 = viewProj * glm::vec4(testPoint0, 1.0);
|
glm::vec4 p0 = viewProj * glm::vec4(testPoint0, 1.0);
|
||||||
glm::vec4 p1 = viewProj * glm::vec4(testPoint1, 1.0);
|
glm::vec4 p1 = viewProj * glm::vec4(testPoint1, 1.0);
|
||||||
|
|
||||||
// TODO REMOVE vvv
|
float windowSizeY = viewport.w;
|
||||||
GLint viewportMatrix[4];
|
|
||||||
glGetIntegerv(GL_VIEWPORT, viewportMatrix);
|
|
||||||
glm::dmat4 modelViewMatrix;
|
|
||||||
float windowSizeY = viewportMatrix[3] - viewportMatrix[1];
|
|
||||||
// TODO REMOVE ^^^
|
|
||||||
|
|
||||||
const float DESIRED_HIGHT_ON_SCREEN = 20; // In pixels (this is double on retinas)
|
const float DESIRED_HIGHT_ON_SCREEN = 20; // In pixels (this is double on retinas)
|
||||||
|
|
||||||
|
@ -731,7 +726,7 @@ Transform Avatar::calculateDisplayNameTransform(const ViewFrustum& frustum, floa
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Avatar::renderDisplayName(gpu::Batch& batch, const ViewFrustum& frustum) const {
|
void Avatar::renderDisplayName(gpu::Batch& batch, const ViewFrustum& frustum, const glm::ivec4& viewport) const {
|
||||||
bool shouldShowReceiveStats = DependencyManager::get<AvatarManager>()->shouldShowReceiveStats() && !isMyAvatar();
|
bool shouldShowReceiveStats = DependencyManager::get<AvatarManager>()->shouldShowReceiveStats() && !isMyAvatar();
|
||||||
|
|
||||||
// If we have nothing to draw, or it's tottaly transparent, return
|
// If we have nothing to draw, or it's tottaly transparent, return
|
||||||
|
@ -773,7 +768,7 @@ void Avatar::renderDisplayName(gpu::Batch& batch, const ViewFrustum& frustum) co
|
||||||
(_displayNameAlpha / DISPLAYNAME_ALPHA) * DISPLAYNAME_BACKGROUND_ALPHA);
|
(_displayNameAlpha / DISPLAYNAME_ALPHA) * DISPLAYNAME_BACKGROUND_ALPHA);
|
||||||
|
|
||||||
// Compute display name transform
|
// Compute display name transform
|
||||||
auto textTransform = calculateDisplayNameTransform(frustum, renderer->getFontSize());
|
auto textTransform = calculateDisplayNameTransform(frustum, renderer->getFontSize(), viewport);
|
||||||
batch.setModelTransform(textTransform);
|
batch.setModelTransform(textTransform);
|
||||||
|
|
||||||
DependencyManager::get<DeferredLightingEffect>()->bindSimpleProgram(batch, false, true, true, true);
|
DependencyManager::get<DeferredLightingEffect>()->bindSimpleProgram(batch, false, true, true, true);
|
||||||
|
|
|
@ -234,8 +234,8 @@ protected:
|
||||||
float getPelvisFloatingHeight() const;
|
float getPelvisFloatingHeight() const;
|
||||||
glm::vec3 getDisplayNamePosition() const;
|
glm::vec3 getDisplayNamePosition() const;
|
||||||
|
|
||||||
Transform calculateDisplayNameTransform(const ViewFrustum& frustum, float fontSize) const;
|
Transform calculateDisplayNameTransform(const ViewFrustum& frustum, float fontSize, const glm::ivec4& viewport) const;
|
||||||
void renderDisplayName(gpu::Batch& batch, const ViewFrustum& frustum) const;
|
void renderDisplayName(gpu::Batch& batch, const ViewFrustum& frustum, const glm::ivec4& viewport) const;
|
||||||
virtual void renderBody(RenderArgs* renderArgs, ViewFrustum* renderFrustum, bool postLighting, float glowLevel = 0.0f);
|
virtual void renderBody(RenderArgs* renderArgs, ViewFrustum* renderFrustum, bool postLighting, float glowLevel = 0.0f);
|
||||||
virtual bool shouldRenderHead(const RenderArgs* renderArgs) const;
|
virtual bool shouldRenderHead(const RenderArgs* renderArgs) const;
|
||||||
virtual void fixupModelsInScene();
|
virtual void fixupModelsInScene();
|
||||||
|
|
|
@ -121,7 +121,7 @@ void SkeletonModel::simulate(float deltaTime, bool fullUpdate) {
|
||||||
hand->getLeftRightPalmIndices(leftPalmIndex, rightPalmIndex);
|
hand->getLeftRightPalmIndices(leftPalmIndex, rightPalmIndex);
|
||||||
|
|
||||||
const float HAND_RESTORATION_RATE = 0.25f;
|
const float HAND_RESTORATION_RATE = 0.25f;
|
||||||
if (leftPalmIndex == -1 || rightPalmIndex == -1) {
|
if (leftPalmIndex == -1 && rightPalmIndex == -1) {
|
||||||
// palms are not yet set, use mouse
|
// palms are not yet set, use mouse
|
||||||
if (_owningAvatar->getHandState() == HAND_STATE_NULL) {
|
if (_owningAvatar->getHandState() == HAND_STATE_NULL) {
|
||||||
restoreRightHandPosition(HAND_RESTORATION_RATE, PALM_PRIORITY);
|
restoreRightHandPosition(HAND_RESTORATION_RATE, PALM_PRIORITY);
|
||||||
|
@ -138,8 +138,16 @@ void SkeletonModel::simulate(float deltaTime, bool fullUpdate) {
|
||||||
restoreLeftHandPosition(HAND_RESTORATION_RATE, PALM_PRIORITY);
|
restoreLeftHandPosition(HAND_RESTORATION_RATE, PALM_PRIORITY);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
if (leftPalmIndex != -1) {
|
||||||
applyPalmData(geometry.leftHandJointIndex, hand->getPalms()[leftPalmIndex]);
|
applyPalmData(geometry.leftHandJointIndex, hand->getPalms()[leftPalmIndex]);
|
||||||
|
} else {
|
||||||
|
restoreLeftHandPosition(HAND_RESTORATION_RATE, PALM_PRIORITY);
|
||||||
|
}
|
||||||
|
if (rightPalmIndex != -1) {
|
||||||
applyPalmData(geometry.rightHandJointIndex, hand->getPalms()[rightPalmIndex]);
|
applyPalmData(geometry.rightHandJointIndex, hand->getPalms()[rightPalmIndex]);
|
||||||
|
} else {
|
||||||
|
restoreRightHandPosition(HAND_RESTORATION_RATE, PALM_PRIORITY);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_isFirstPerson) {
|
if (_isFirstPerson) {
|
||||||
|
@ -791,19 +799,24 @@ void SkeletonModel::renderBoundingCollisionShapes(gpu::Batch& batch, float alpha
|
||||||
transform.setTranslation(endPoint);
|
transform.setTranslation(endPoint);
|
||||||
batch.setModelTransform(transform);
|
batch.setModelTransform(transform);
|
||||||
auto geometryCache = DependencyManager::get<GeometryCache>();
|
auto geometryCache = DependencyManager::get<GeometryCache>();
|
||||||
geometryCache->renderSphere(batch, _boundingShape.getRadius(), BALL_SUBDIVISIONS, BALL_SUBDIVISIONS, glm::vec4(0.6f, 0.6f, 0.8f, alpha));
|
geometryCache->renderSphere(batch, _boundingShape.getRadius(), BALL_SUBDIVISIONS, BALL_SUBDIVISIONS,
|
||||||
|
glm::vec4(0.6f, 0.6f, 0.8f, alpha));
|
||||||
|
|
||||||
// draw a yellow sphere at the capsule startpoint
|
// draw a yellow sphere at the capsule startpoint
|
||||||
glm::vec3 startPoint;
|
glm::vec3 startPoint;
|
||||||
_boundingShape.getStartPoint(startPoint);
|
_boundingShape.getStartPoint(startPoint);
|
||||||
startPoint = startPoint - _translation;
|
startPoint = startPoint - _translation;
|
||||||
glm::vec3 axis = endPoint - startPoint;
|
glm::vec3 axis = endPoint - startPoint;
|
||||||
glTranslatef(-axis.x, -axis.y, -axis.z);
|
Transform axisTransform = Transform();
|
||||||
geometryCache->renderSphere(_boundingShape.getRadius(), BALL_SUBDIVISIONS, BALL_SUBDIVISIONS, glm::vec4(0.8f, 0.8f, 0.6f, alpha));
|
axisTransform.setTranslation(-axis);
|
||||||
|
batch.setModelTransform(axisTransform);
|
||||||
|
geometryCache->renderSphere(batch, _boundingShape.getRadius(), BALL_SUBDIVISIONS, BALL_SUBDIVISIONS,
|
||||||
|
glm::vec4(0.8f, 0.8f, 0.6f, alpha));
|
||||||
|
|
||||||
// draw a green cylinder between the two points
|
// draw a green cylinder between the two points
|
||||||
glm::vec3 origin(0.0f);
|
glm::vec3 origin(0.0f);
|
||||||
Avatar::renderJointConnectingCone(batch, origin, axis, _boundingShape.getRadius(), _boundingShape.getRadius(), glm::vec4(0.6f, 0.8f, 0.6f, alpha));
|
Avatar::renderJointConnectingCone(batch, origin, axis, _boundingShape.getRadius(), _boundingShape.getRadius(),
|
||||||
|
glm::vec4(0.6f, 0.8f, 0.6f, alpha));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SkeletonModel::hasSkeleton() {
|
bool SkeletonModel::hasSkeleton() {
|
||||||
|
|
|
@ -244,14 +244,6 @@ void SixenseManager::update(float deltaTime) {
|
||||||
palm->setTrigger(data->trigger);
|
palm->setTrigger(data->trigger);
|
||||||
palm->setJoystick(data->joystick_x, data->joystick_y);
|
palm->setJoystick(data->joystick_x, data->joystick_y);
|
||||||
|
|
||||||
handleButtonEvent(data->buttons, numActiveControllers - 1);
|
|
||||||
handleAxisEvent(data->joystick_x, data->joystick_y, data->trigger, numActiveControllers - 1);
|
|
||||||
|
|
||||||
// Emulate the mouse so we can use scripts
|
|
||||||
if (Menu::getInstance()->isOptionChecked(MenuOption::SixenseMouseInput) && !_controllersAtBase) {
|
|
||||||
emulateMouse(palm, numActiveControllers - 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
// NOTE: Sixense API returns pos data in millimeters but we IMMEDIATELY convert to meters.
|
// NOTE: Sixense API returns pos data in millimeters but we IMMEDIATELY convert to meters.
|
||||||
glm::vec3 position(data->pos[0], data->pos[1], data->pos[2]);
|
glm::vec3 position(data->pos[0], data->pos[1], data->pos[2]);
|
||||||
position *= METERS_PER_MILLIMETER;
|
position *= METERS_PER_MILLIMETER;
|
||||||
|
@ -260,6 +252,15 @@ void SixenseManager::update(float deltaTime) {
|
||||||
const float CONTROLLER_AT_BASE_DISTANCE = 0.075f;
|
const float CONTROLLER_AT_BASE_DISTANCE = 0.075f;
|
||||||
if (glm::length(position) < CONTROLLER_AT_BASE_DISTANCE) {
|
if (glm::length(position) < CONTROLLER_AT_BASE_DISTANCE) {
|
||||||
numControllersAtBase++;
|
numControllersAtBase++;
|
||||||
|
palm->setActive(false);
|
||||||
|
} else {
|
||||||
|
handleButtonEvent(data->buttons, numActiveControllers - 1);
|
||||||
|
handleAxisEvent(data->joystick_x, data->joystick_y, data->trigger, numActiveControllers - 1);
|
||||||
|
|
||||||
|
// Emulate the mouse so we can use scripts
|
||||||
|
if (Menu::getInstance()->isOptionChecked(MenuOption::SixenseMouseInput) && !_controllersAtBase) {
|
||||||
|
emulateMouse(palm, numActiveControllers - 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Transform the measured position into body frame.
|
// Transform the measured position into body frame.
|
||||||
|
|
|
@ -197,7 +197,6 @@ void ApplicationCompositor::displayOverlayTexture(RenderArgs* renderArgs) {
|
||||||
updateTooltips();
|
updateTooltips();
|
||||||
|
|
||||||
auto deviceSize = qApp->getDeviceSize();
|
auto deviceSize = qApp->getDeviceSize();
|
||||||
glViewport(0, 0, deviceSize.width(), deviceSize.height());
|
|
||||||
|
|
||||||
//Handle fading and deactivation/activation of UI
|
//Handle fading and deactivation/activation of UI
|
||||||
gpu::Batch batch;
|
gpu::Batch batch;
|
||||||
|
|
|
@ -33,8 +33,6 @@ void Cube3DOverlay::render(RenderArgs* args) {
|
||||||
const float MAX_COLOR = 255.0f;
|
const float MAX_COLOR = 255.0f;
|
||||||
glm::vec4 cubeColor(color.red / MAX_COLOR, color.green / MAX_COLOR, color.blue / MAX_COLOR, alpha);
|
glm::vec4 cubeColor(color.red / MAX_COLOR, color.green / MAX_COLOR, color.blue / MAX_COLOR, alpha);
|
||||||
|
|
||||||
//glDisable(GL_LIGHTING);
|
|
||||||
|
|
||||||
// TODO: handle registration point??
|
// TODO: handle registration point??
|
||||||
glm::vec3 position = getPosition();
|
glm::vec3 position = getPosition();
|
||||||
glm::vec3 center = getCenter();
|
glm::vec3 center = getCenter();
|
||||||
|
|
|
@ -86,7 +86,7 @@ public:
|
||||||
// Then by the inverse of the ViewTransform from world space to eye space
|
// Then by the inverse of the ViewTransform from world space to eye space
|
||||||
// finaly projected into the clip space by the projection transform
|
// finaly projected into the clip space by the projection transform
|
||||||
// WARNING: ViewTransform transform from eye space to world space, its inverse is composed
|
// WARNING: ViewTransform transform from eye space to world space, its inverse is composed
|
||||||
// with the ModelTransformu to create the equivalent of the glModelViewMatrix
|
// with the ModelTransform to create the equivalent of the gl ModelViewMatrix
|
||||||
void setModelTransform(const Transform& model);
|
void setModelTransform(const Transform& model);
|
||||||
void setViewTransform(const Transform& view);
|
void setViewTransform(const Transform& view);
|
||||||
void setProjectionTransform(const Mat4& proj);
|
void setProjectionTransform(const Mat4& proj);
|
||||||
|
|
|
@ -433,8 +433,6 @@ void GeometryCache::renderGrid(gpu::Batch& batch, int x, int y, int width, int h
|
||||||
}
|
}
|
||||||
// Draw vertical grid lines
|
// Draw vertical grid lines
|
||||||
for (int i = cols + 1; --i >= 0; ) {
|
for (int i = cols + 1; --i >= 0; ) {
|
||||||
//glVertex2i(tx, y);
|
|
||||||
//glVertex2i(tx, y + height);
|
|
||||||
*(vertex++) = tx;
|
*(vertex++) = tx;
|
||||||
*(vertex++) = y;
|
*(vertex++) = y;
|
||||||
|
|
||||||
|
|
|
@ -55,10 +55,6 @@
|
||||||
#include "model_lightmap_specular_map_frag.h"
|
#include "model_lightmap_specular_map_frag.h"
|
||||||
#include "model_translucent_frag.h"
|
#include "model_translucent_frag.h"
|
||||||
|
|
||||||
|
|
||||||
#define GLBATCH( call ) batch._##call
|
|
||||||
//#define GLBATCH( call ) call
|
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
static int modelPointerTypeId = qRegisterMetaType<QPointer<Model> >();
|
static int modelPointerTypeId = qRegisterMetaType<QPointer<Model> >();
|
||||||
|
@ -1850,22 +1846,6 @@ void Model::deleteGeometry() {
|
||||||
_blendedBlendshapeCoefficients.clear();
|
_blendedBlendshapeCoefficients.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Model::setupBatchTransform(gpu::Batch& batch, RenderArgs* args) {
|
|
||||||
|
|
||||||
// Capture the view matrix once for the rendering of this model
|
|
||||||
if (_transforms.empty()) {
|
|
||||||
_transforms.push_back(Transform());
|
|
||||||
}
|
|
||||||
|
|
||||||
// We should be able to use the Frustum viewpoint onstead of the "viewTransform"
|
|
||||||
// but it s still buggy in some cases, so let's s wait and fix it...
|
|
||||||
_transforms[0] = _viewState->getViewTransform();
|
|
||||||
|
|
||||||
_transforms[0].preTranslate(-_translation);
|
|
||||||
|
|
||||||
batch.setViewTransform(_transforms[0]);
|
|
||||||
}
|
|
||||||
|
|
||||||
AABox Model::getPartBounds(int meshIndex, int partIndex) {
|
AABox Model::getPartBounds(int meshIndex, int partIndex) {
|
||||||
|
|
||||||
if (meshIndex < _meshStates.size()) {
|
if (meshIndex < _meshStates.size()) {
|
||||||
|
@ -2000,7 +1980,7 @@ void Model::renderPart(RenderArgs* args, int meshIndex, int partIndex, bool tran
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isSkinned) {
|
if (isSkinned) {
|
||||||
GLBATCH(glUniformMatrix4fv)(locations->clusterMatrices, state.clusterMatrices.size(), false,
|
batch._glUniformMatrix4fv(locations->clusterMatrices, state.clusterMatrices.size(), false,
|
||||||
(const float*)state.clusterMatrices.constData());
|
(const float*)state.clusterMatrices.constData());
|
||||||
_transforms[0] = Transform();
|
_transforms[0] = Transform();
|
||||||
_transforms[0].preTranslate(_translation);
|
_transforms[0].preTranslate(_translation);
|
||||||
|
@ -2021,7 +2001,7 @@ void Model::renderPart(RenderArgs* args, int meshIndex, int partIndex, bool tran
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mesh.colors.isEmpty()) {
|
if (mesh.colors.isEmpty()) {
|
||||||
GLBATCH(glColor4f)(1.0f, 1.0f, 1.0f, 1.0f);
|
batch._glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
// guard against partially loaded meshes
|
// guard against partially loaded meshes
|
||||||
|
@ -2077,7 +2057,7 @@ void Model::renderPart(RenderArgs* args, int meshIndex, int partIndex, bool tran
|
||||||
if (!part.emissiveTexture.transform.isIdentity()) {
|
if (!part.emissiveTexture.transform.isIdentity()) {
|
||||||
part.emissiveTexture.transform.getMatrix(texcoordTransform[1]);
|
part.emissiveTexture.transform.getMatrix(texcoordTransform[1]);
|
||||||
}
|
}
|
||||||
GLBATCH(glUniformMatrix4fv)(locations->texcoordMatrices, 2, false, (const float*) &texcoordTransform);
|
batch._glUniformMatrix4fv(locations->texcoordMatrices, 2, false, (const float*) &texcoordTransform);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!mesh.tangents.isEmpty()) {
|
if (!mesh.tangents.isEmpty()) {
|
||||||
|
@ -2102,7 +2082,7 @@ void Model::renderPart(RenderArgs* args, int meshIndex, int partIndex, bool tran
|
||||||
// assert(locations->emissiveParams >= 0); // we should have the emissiveParams defined in the shader
|
// assert(locations->emissiveParams >= 0); // we should have the emissiveParams defined in the shader
|
||||||
float emissiveOffset = part.emissiveParams.x;
|
float emissiveOffset = part.emissiveParams.x;
|
||||||
float emissiveScale = part.emissiveParams.y;
|
float emissiveScale = part.emissiveParams.y;
|
||||||
GLBATCH(glUniform2f)(locations->emissiveParams, emissiveOffset, emissiveScale);
|
batch._glUniform2f(locations->emissiveParams, emissiveOffset, emissiveScale);
|
||||||
|
|
||||||
NetworkTexture* emissiveMap = networkPart.emissiveTexture.data();
|
NetworkTexture* emissiveMap = networkPart.emissiveTexture.data();
|
||||||
batch.setResourceTexture(locations->emissiveTextureUnit, (!emissiveMap || !emissiveMap->isLoaded()) ?
|
batch.setResourceTexture(locations->emissiveTextureUnit, (!emissiveMap || !emissiveMap->isLoaded()) ?
|
||||||
|
@ -2210,12 +2190,12 @@ void Model::pickPrograms(gpu::Batch& batch, RenderMode mode, bool translucent, f
|
||||||
batch.setPipeline((*pipeline).second._pipeline);
|
batch.setPipeline((*pipeline).second._pipeline);
|
||||||
|
|
||||||
if ((locations->alphaThreshold > -1) && (mode != RenderArgs::SHADOW_RENDER_MODE)) {
|
if ((locations->alphaThreshold > -1) && (mode != RenderArgs::SHADOW_RENDER_MODE)) {
|
||||||
GLBATCH(glUniform1f)(locations->alphaThreshold, alphaThreshold);
|
batch._glUniform1f(locations->alphaThreshold, alphaThreshold);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((locations->glowIntensity > -1) && (mode != RenderArgs::SHADOW_RENDER_MODE)) {
|
if ((locations->glowIntensity > -1) && (mode != RenderArgs::SHADOW_RENDER_MODE)) {
|
||||||
const float DEFAULT_GLOW_INTENSITY = 1.0f; // FIXME - glow is removed
|
const float DEFAULT_GLOW_INTENSITY = 1.0f; // FIXME - glow is removed
|
||||||
GLBATCH(glUniform1f)(locations->glowIntensity, DEFAULT_GLOW_INTENSITY);
|
batch._glUniform1f(locations->glowIntensity, DEFAULT_GLOW_INTENSITY);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -407,7 +407,6 @@ private:
|
||||||
|
|
||||||
// helper functions used by render() or renderInScene()
|
// helper functions used by render() or renderInScene()
|
||||||
|
|
||||||
void setupBatchTransform(gpu::Batch& batch, RenderArgs* args);
|
|
||||||
static void pickPrograms(gpu::Batch& batch, RenderArgs::RenderMode mode, bool translucent, float alphaThreshold,
|
static void pickPrograms(gpu::Batch& batch, RenderArgs::RenderMode mode, bool translucent, float alphaThreshold,
|
||||||
bool hasLightmap, bool hasTangents, bool hasSpecular, bool isSkinned, bool isWireframe, RenderArgs* args,
|
bool hasLightmap, bool hasTangents, bool hasSpecular, bool isSkinned, bool isWireframe, RenderArgs* args,
|
||||||
Locations*& locations);
|
Locations*& locations);
|
||||||
|
|
|
@ -504,9 +504,6 @@ glm::vec2 Font::drawString(float x, float y, const QString & str,
|
||||||
_vao->release();
|
_vao->release();
|
||||||
_texture->release(); // TODO: Brad & Sam, let's discuss this. Without this non-textured quads get their colors borked.
|
_texture->release(); // TODO: Brad & Sam, let's discuss this. Without this non-textured quads get their colors borked.
|
||||||
_program->release();
|
_program->release();
|
||||||
// FIXME, needed?
|
|
||||||
// glDisable(GL_TEXTURE_2D);
|
|
||||||
|
|
||||||
|
|
||||||
return advance;
|
return advance;
|
||||||
}
|
}
|
||||||
|
|
|
@ -110,9 +110,6 @@ const gpu::TexturePointer& TextureCache::getPermutationNormalTexture() {
|
||||||
|
|
||||||
_permutationNormalTexture = gpu::TexturePointer(gpu::Texture::create2D(gpu::Element(gpu::VEC3, gpu::UINT8, gpu::RGB), 256, 2));
|
_permutationNormalTexture = gpu::TexturePointer(gpu::Texture::create2D(gpu::Element(gpu::VEC3, gpu::UINT8, gpu::RGB), 256, 2));
|
||||||
_permutationNormalTexture->assignStoredMip(0, _blueTexture->getTexelFormat(), sizeof(data), data);
|
_permutationNormalTexture->assignStoredMip(0, _blueTexture->getTexelFormat(), sizeof(data), data);
|
||||||
|
|
||||||
// glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
|
||||||
// glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
|
||||||
}
|
}
|
||||||
return _permutationNormalTexture;
|
return _permutationNormalTexture;
|
||||||
}
|
}
|
||||||
|
@ -122,13 +119,6 @@ const unsigned char OPAQUE_GRAY[] = { 0x80, 0x80, 0x80, 0xFF };
|
||||||
const unsigned char OPAQUE_BLUE[] = { 0x80, 0x80, 0xFF, 0xFF };
|
const unsigned char OPAQUE_BLUE[] = { 0x80, 0x80, 0xFF, 0xFF };
|
||||||
const unsigned char OPAQUE_BLACK[] = { 0x00, 0x00, 0x00, 0xFF };
|
const unsigned char OPAQUE_BLACK[] = { 0x00, 0x00, 0x00, 0xFF };
|
||||||
|
|
||||||
/*
|
|
||||||
static void loadSingleColorTexture(const unsigned char* color) {
|
|
||||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, color);
|
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
const gpu::TexturePointer& TextureCache::getWhiteTexture() {
|
const gpu::TexturePointer& TextureCache::getWhiteTexture() {
|
||||||
if (!_whiteTexture) {
|
if (!_whiteTexture) {
|
||||||
_whiteTexture = gpu::TexturePointer(gpu::Texture::create2D(gpu::Element(gpu::VEC4, gpu::UINT8, gpu::RGBA), 1, 1));
|
_whiteTexture = gpu::TexturePointer(gpu::Texture::create2D(gpu::Element(gpu::VEC4, gpu::UINT8, gpu::RGBA), 1, 1));
|
||||||
|
|
|
@ -87,20 +87,20 @@ public:
|
||||||
const Vec3& getTranslation() const;
|
const Vec3& getTranslation() const;
|
||||||
void setTranslation(const Vec3& translation); // [new this] = [translation] * [this.rotation] * [this.scale]
|
void setTranslation(const Vec3& translation); // [new this] = [translation] * [this.rotation] * [this.scale]
|
||||||
void preTranslate(const Vec3& translation); // [new this] = [translation] * [this]
|
void preTranslate(const Vec3& translation); // [new this] = [translation] * [this]
|
||||||
void postTranslate(const Vec3& translation); // [new this] = [this] * [translation] equivalent to glTranslate
|
void postTranslate(const Vec3& translation); // [new this] = [this] * [translation] equivalent to:glTranslate
|
||||||
|
|
||||||
const Quat& getRotation() const;
|
const Quat& getRotation() const;
|
||||||
void setRotation(const Quat& rotation); // [new this] = [this.translation] * [rotation] * [this.scale]
|
void setRotation(const Quat& rotation); // [new this] = [this.translation] * [rotation] * [this.scale]
|
||||||
void preRotate(const Quat& rotation); // [new this] = [rotation] * [this]
|
void preRotate(const Quat& rotation); // [new this] = [rotation] * [this]
|
||||||
void postRotate(const Quat& rotation); // [new this] = [this] * [rotation] equivalent to glRotate
|
void postRotate(const Quat& rotation); // [new this] = [this] * [rotation] equivalent to:glRotate
|
||||||
|
|
||||||
const Vec3& getScale() const;
|
const Vec3& getScale() const;
|
||||||
void setScale(float scale);
|
void setScale(float scale);
|
||||||
void setScale(const Vec3& scale); // [new this] = [this.translation] * [this.rotation] * [scale]
|
void setScale(const Vec3& scale); // [new this] = [this.translation] * [this.rotation] * [scale]
|
||||||
void preScale(float scale);
|
void preScale(float scale);
|
||||||
void preScale(const Vec3& scale);
|
void preScale(const Vec3& scale);
|
||||||
void postScale(float scale); // [new this] = [this] * [scale] equivalent to glScale
|
void postScale(float scale); // [new this] = [this] * [scale] equivalent to:glScale
|
||||||
void postScale(const Vec3& scale); // [new this] = [this] * [scale] equivalent to glScale
|
void postScale(const Vec3& scale); // [new this] = [this] * [scale] equivalent to:glScale
|
||||||
|
|
||||||
bool isIdentity() const { return (_flags & ~Flags(FLAG_CACHE_INVALID_BITSET)).none(); }
|
bool isIdentity() const { return (_flags & ~Flags(FLAG_CACHE_INVALID_BITSET)).none(); }
|
||||||
bool isTranslating() const { return _flags[FLAG_TRANSLATION]; }
|
bool isTranslating() const { return _flags[FLAG_TRANSLATION]; }
|
||||||
|
|
Loading…
Reference in a new issue