mirror of
https://thingvellir.net/git/overte
synced 2025-03-27 23:52:03 +01:00
Merge branch 'master' of https://github.com/highfidelity/hifi into android
Conflicts: interface/src/avatar/Hand.cpp
This commit is contained in:
commit
4562c29be8
61 changed files with 1843 additions and 1643 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -3,7 +3,7 @@ CMakeCache.txt
|
|||
CMakeFiles/
|
||||
CMakeScripts/
|
||||
cmake_install.cmake
|
||||
build/
|
||||
build*/
|
||||
Makefile
|
||||
*.user
|
||||
|
||||
|
|
|
@ -14,23 +14,23 @@
|
|||
HIFI_PUBLIC_BUCKET = "http://s3.amazonaws.com/hifi-public/";
|
||||
|
||||
Script.include([
|
||||
"http://public.highfidelity.io/scripts/libraries/stringHelpers.js",
|
||||
"http://public.highfidelity.io/scripts/libraries/dataviewHelpers.js",
|
||||
"http://public.highfidelity.io/scripts/libraries/httpMultiPart.js",
|
||||
"http://public.highfidelity.io/scripts/libraries/modelUploader.js",
|
||||
"http://public.highfidelity.io/scripts/libraries/toolBars.js",
|
||||
"http://public.highfidelity.io/scripts/libraries/progressDialog.js",
|
||||
"libraries/stringHelpers.js",
|
||||
"libraries/dataviewHelpers.js",
|
||||
"libraries/httpMultiPart.js",
|
||||
"libraries/modelUploader.js",
|
||||
"libraries/toolBars.js",
|
||||
"libraries/progressDialog.js",
|
||||
|
||||
"http://public.highfidelity.io/scripts/libraries/entitySelectionTool.js",
|
||||
"http://public.highfidelity.io/scripts/libraries/ModelImporter.js",
|
||||
"libraries/entitySelectionTool.js",
|
||||
"libraries/ModelImporter.js",
|
||||
|
||||
"http://public.highfidelity.io/scripts/libraries/ExportMenu.js",
|
||||
"http://public.highfidelity.io/scripts/libraries/ToolTip.js",
|
||||
"libraries/ExportMenu.js",
|
||||
"libraries/ToolTip.js",
|
||||
|
||||
"http://public.highfidelity.io/scripts/libraries/entityPropertyDialogBox.js",
|
||||
"http://public.highfidelity.io/scripts/libraries/entityCameraTool.js",
|
||||
"http://public.highfidelity.io/scripts/libraries/gridTool.js",
|
||||
"http://public.highfidelity.io/scripts/libraries/entityList.js",
|
||||
"libraries/entityPropertyDialogBox.js",
|
||||
"libraries/entityCameraTool.js",
|
||||
"libraries/gridTool.js",
|
||||
"libraries/entityList.js",
|
||||
]);
|
||||
|
||||
var selectionDisplay = SelectionDisplay;
|
||||
|
@ -42,6 +42,7 @@ var cameraManager = new CameraManager();
|
|||
|
||||
var grid = Grid();
|
||||
gridTool = GridTool({ horizontalGrid: grid });
|
||||
gridTool.setVisible(false);
|
||||
|
||||
var entityListTool = EntityListTool();
|
||||
|
||||
|
@ -55,10 +56,17 @@ selectionManager.addEventListener(function() {
|
|||
// Open properties and model list, but force selection of model list tab
|
||||
propertiesTool.setVisible(false);
|
||||
entityListTool.setVisible(false);
|
||||
gridTool.setVisible(false);
|
||||
propertiesTool.setVisible(true);
|
||||
entityListTool.setVisible(true);
|
||||
gridTool.setVisible(true);
|
||||
hasShownPropertiesTool = true;
|
||||
}
|
||||
if (!selectionManager.hasSelection()) {
|
||||
toolBar.setActive(false);
|
||||
} else {
|
||||
toolBar.setActive(true);
|
||||
}
|
||||
});
|
||||
|
||||
var windowDimensions = Controller.getViewportDimensions();
|
||||
|
@ -126,11 +134,13 @@ var toolBar = (function () {
|
|||
function initialize() {
|
||||
toolBar = new ToolBar(0, 0, ToolBar.VERTICAL);
|
||||
|
||||
// Hide active button for now - this may come back, so not deleting yet.
|
||||
activeButton = toolBar.addTool({
|
||||
imageURL: toolIconUrl + "models-tool.svg",
|
||||
subImage: { x: 0, y: Tool.IMAGE_WIDTH, width: Tool.IMAGE_WIDTH, height: Tool.IMAGE_HEIGHT },
|
||||
width: toolWidth,
|
||||
height: toolHeight,
|
||||
// subImage: { x: 0, y: Tool.IMAGE_WIDTH, width: Tool.IMAGE_WIDTH, height: Tool.IMAGE_HEIGHT },
|
||||
subImage: { x: 0, y: Tool.IMAGE_WIDTH, width: 0, height: 0 },
|
||||
width: 0,//toolWidth,
|
||||
height: 0,//toolHeight,
|
||||
alpha: 0.9,
|
||||
visible: true
|
||||
}, true, false);
|
||||
|
@ -242,7 +252,6 @@ var toolBar = (function () {
|
|||
} else {
|
||||
hasShownPropertiesTool = false;
|
||||
cameraManager.enable();
|
||||
gridTool.setVisible(true);
|
||||
grid.setEnabled(true);
|
||||
}
|
||||
}
|
||||
|
@ -510,7 +519,7 @@ function mousePressEvent(event) {
|
|||
mouseHasMovedSincePress = false;
|
||||
mouseCapturedByTool = false;
|
||||
|
||||
if (toolBar.mousePressEvent(event) || progressDialog.mousePressEvent(event) || gridTool.mousePressEvent(event)) {
|
||||
if (toolBar.mousePressEvent(event) || progressDialog.mousePressEvent(event)) {
|
||||
mouseCapturedByTool = true;
|
||||
return;
|
||||
}
|
||||
|
@ -546,19 +555,16 @@ function mouseMoveEvent(event) {
|
|||
}
|
||||
|
||||
mouseHasMovedSincePress = true;
|
||||
if (isActive) {
|
||||
// allow the selectionDisplay and cameraManager to handle the event first, if it doesn't handle it, then do our own thing
|
||||
if (selectionDisplay.mouseMoveEvent(event) || cameraManager.mouseMoveEvent(event)) {
|
||||
return;
|
||||
}
|
||||
|
||||
lastMousePosition = { x: event.x, y: event.y };
|
||||
|
||||
highlightEntityUnderCursor(lastMousePosition, false);
|
||||
idleMouseTimerId = Script.setTimeout(handleIdleMouse, IDLE_MOUSE_TIMEOUT);
|
||||
} else {
|
||||
cameraManager.mouseMoveEvent(event);
|
||||
// allow the selectionDisplay and cameraManager to handle the event first, if it doesn't handle it, then do our own thing
|
||||
if (selectionDisplay.mouseMoveEvent(event) || cameraManager.mouseMoveEvent(event)) {
|
||||
return;
|
||||
}
|
||||
|
||||
lastMousePosition = { x: event.x, y: event.y };
|
||||
|
||||
highlightEntityUnderCursor(lastMousePosition, false);
|
||||
idleMouseTimerId = Script.setTimeout(handleIdleMouse, IDLE_MOUSE_TIMEOUT);
|
||||
}
|
||||
|
||||
function handleIdleMouse() {
|
||||
|
@ -611,7 +617,7 @@ function mouseReleaseEvent(event) {
|
|||
}
|
||||
|
||||
function mouseClickEvent(event) {
|
||||
if (!isActive) {
|
||||
if (!event.isRightButton) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -622,6 +628,7 @@ function mouseClickEvent(event) {
|
|||
}
|
||||
return;
|
||||
}
|
||||
toolBar.setActive(true);
|
||||
var pickRay = result.pickRay;
|
||||
var foundEntity = result.entityID;
|
||||
|
||||
|
@ -835,6 +842,8 @@ Controller.keyReleaseEvent.connect(function (event) {
|
|||
// since sometimes our menu shortcut keys don't work, trap our menu items here also and fire the appropriate menu items
|
||||
if (event.text == "BACKSPACE" || event.text == "DELETE") {
|
||||
deleteSelectedEntities();
|
||||
} else if (event.text == "ESC") {
|
||||
selectionManager.clearSelections();
|
||||
} else if (event.text == "TAB") {
|
||||
selectionDisplay.toggleSpaceMode();
|
||||
} else if (event.text == "f") {
|
||||
|
@ -1038,4 +1047,4 @@ PropertiesTool = function(opts) {
|
|||
};
|
||||
|
||||
propertiesTool = PropertiesTool();
|
||||
|
||||
toolBar.setActive(true);
|
||||
|
|
166
examples/html/gridControls.html
Normal file
166
examples/html/gridControls.html
Normal file
|
@ -0,0 +1,166 @@
|
|||
<html>
|
||||
<head>
|
||||
<link rel="stylesheet" type="text/css" href="style.css">
|
||||
<script>
|
||||
function loaded() {
|
||||
var gridColor = { red: 0, green: 0, blue: 0 };
|
||||
var gridColors = [
|
||||
{ red: 0, green: 0, blue: 0 },
|
||||
{ red: 255, green: 255, blue: 255 },
|
||||
{ red: 255, green: 0, blue: 0 },
|
||||
{ red: 0, green: 255, blue: 0},
|
||||
{ red: 0, green: 0, blue: 255 },
|
||||
];
|
||||
var gridColorIndex = 0;
|
||||
|
||||
elPosY = document.getElementById("horiz-y");
|
||||
elMinorSpacing = document.getElementById("minor-spacing");
|
||||
elMajorSpacing = document.getElementById("major-spacing");
|
||||
elSnapToGrid = document.getElementById("snap-to-grid");
|
||||
elHorizontalGridVisible = document.getElementById("horiz-grid-visible");
|
||||
elMoveToSelection = document.getElementById("move-to-selection");
|
||||
elMoveToAvatar = document.getElementById("move-to-avatar");
|
||||
|
||||
if (window.EventBridge !== undefined) {
|
||||
EventBridge.scriptEventReceived.connect(function(data) {
|
||||
data = JSON.parse(data);
|
||||
|
||||
if (data.origin) {
|
||||
var origin = data.origin;
|
||||
elPosY.value = origin.y.toFixed(2);
|
||||
}
|
||||
|
||||
if (data.minorGridSpacing !== undefined) {
|
||||
elMinorSpacing.value = data.minorGridSpacing;
|
||||
}
|
||||
|
||||
if (data.majorGridEvery !== undefined) {
|
||||
elMajorSpacing.value = data.majorGridEvery;
|
||||
}
|
||||
|
||||
if (data.gridColor) {
|
||||
gridColor = data.gridColor;
|
||||
}
|
||||
|
||||
if (data.snapToGrid !== undefined) {
|
||||
elSnapToGrid.checked = data.snapToGrid == true;
|
||||
}
|
||||
|
||||
if (data.visible !== undefined) {
|
||||
elHorizontalGridVisible.checked = data.visible == true;
|
||||
}
|
||||
});
|
||||
|
||||
function emitUpdate() {
|
||||
EventBridge.emitWebEvent(JSON.stringify({
|
||||
type: "update",
|
||||
origin: {
|
||||
y: elPosY.value,
|
||||
},
|
||||
minorGridSpacing: elMinorSpacing.value,
|
||||
majorGridEvery: elMajorSpacing.value,
|
||||
gridColor: gridColor,
|
||||
colorIndex: gridColorIndex,
|
||||
snapToGrid: elSnapToGrid.checked,
|
||||
visible: elHorizontalGridVisible.checked,
|
||||
}));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
elPosY.addEventListener("change", emitUpdate);
|
||||
elMinorSpacing.addEventListener("change", emitUpdate);
|
||||
elMajorSpacing.addEventListener("change", emitUpdate);
|
||||
elSnapToGrid.addEventListener("change", emitUpdate);
|
||||
elHorizontalGridVisible.addEventListener("change", emitUpdate);
|
||||
|
||||
elMoveToAvatar.addEventListener("click", function() {
|
||||
EventBridge.emitWebEvent(JSON.stringify({
|
||||
type: "action",
|
||||
action: "moveToAvatar",
|
||||
}));
|
||||
});
|
||||
elMoveToSelection.addEventListener("click", function() {
|
||||
EventBridge.emitWebEvent(JSON.stringify({
|
||||
type: "action",
|
||||
action: "moveToSelection",
|
||||
}));
|
||||
});
|
||||
|
||||
var gridColorBox = document.getElementById('grid-color');
|
||||
|
||||
for (var i = 0; i < gridColors.length; i++) {
|
||||
var colors = gridColors[i];
|
||||
var box = document.createElement('div');
|
||||
box.setAttribute('class', 'color-box');
|
||||
box.style.background = 'rgb(' + colors.red + ', ' + colors.green + ', ' + colors.blue + ')';
|
||||
document.getElementById("grid-colors").appendChild(box);
|
||||
box.addEventListener("click", function(color, index) {
|
||||
return function() {
|
||||
gridColor = color;
|
||||
gridColorIndex = index;
|
||||
emitUpdate();
|
||||
}
|
||||
}({ red: colors.red, green: colors.green, blue: colors.blue }, i));
|
||||
}
|
||||
|
||||
EventBridge.emitWebEvent(JSON.stringify({ type: 'init' }));
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body onload='loaded();'>
|
||||
<div class="grid-section">
|
||||
|
||||
<div class="property-section">
|
||||
<label>Visible</label>
|
||||
<span>
|
||||
<input type='checkbox' id="horiz-grid-visible">
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div class="property-section">
|
||||
<label>Snap to grid</label>
|
||||
<span>
|
||||
<input type='checkbox' id="snap-to-grid">
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div id="horizontal-position" class="property-section">
|
||||
<label>Position (Y Axis)</label>
|
||||
<span>
|
||||
<input type='number' id="horiz-y" class="number" value="0.0" step="0.1"></input>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div class="property-section">
|
||||
<label>Minor Grid Size</label>
|
||||
<span>
|
||||
<input type='number' id="minor-spacing" min="0" step="0.01", ></input>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div class="property-section">
|
||||
<label>Major Grid Every</label>
|
||||
<span>
|
||||
<input type='number' id="major-spacing" min="2" step="1", ></input>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div class="property-section">
|
||||
<label>Grid Color</label>
|
||||
<span id="grid-colors"></span>
|
||||
</div>
|
||||
|
||||
<div class="property-section">
|
||||
<span>
|
||||
<input type="button" id="move-to-selection" value="Move to Selection">
|
||||
</span>
|
||||
</div>
|
||||
<div class="property-section">
|
||||
<span>
|
||||
<input type="button" id="move-to-avatar" value="Move to Avatar">
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
|
@ -73,8 +73,6 @@ body {
|
|||
}
|
||||
|
||||
.grid-section {
|
||||
border-top: 0.75pt solid #DDD;
|
||||
background-color: #efefef;
|
||||
}
|
||||
|
||||
input[type=button] {
|
||||
|
@ -169,7 +167,7 @@ input {
|
|||
color: rgb(150, 150, 150);
|
||||
}
|
||||
|
||||
#properties-list input, #properties-list textarea {
|
||||
input, textarea {
|
||||
background-color: rgb(102, 102, 102);
|
||||
color: rgb(204, 204, 204);
|
||||
border: none;
|
||||
|
|
|
@ -267,6 +267,11 @@ CameraManager = function() {
|
|||
if (that.enabled && that.mode != MODE_INACTIVE) {
|
||||
var x = Window.getCursorPositionX();
|
||||
var y = Window.getCursorPositionY();
|
||||
if (!hasDragged) {
|
||||
that.lastMousePosition.x = x;
|
||||
that.lastMousePosition.y = y;
|
||||
hasDragged = true;
|
||||
}
|
||||
if (that.mode == MODE_ORBIT) {
|
||||
var diffX = x - that.lastMousePosition.x;
|
||||
var diffY = y - that.lastMousePosition.y;
|
||||
|
@ -294,9 +299,31 @@ CameraManager = function() {
|
|||
|
||||
that.moveFocalPoint(dPosition);
|
||||
}
|
||||
var newX = Window.x + Window.innerWidth / 2;
|
||||
var newY = Window.y + Window.innerHeight / 2;
|
||||
Window.setCursorPosition(newX, newY);
|
||||
|
||||
var newX = x;
|
||||
var newY = y;
|
||||
var updatePosition = false;
|
||||
|
||||
if (x <= Window.x) {
|
||||
newX = Window.x + Window.innerWidth;
|
||||
updatePosition = true;
|
||||
} else if (x >= (Window.x + Window.innerWidth)) {
|
||||
newX = Window.x;
|
||||
updatePosition = true;
|
||||
}
|
||||
|
||||
if (y <= Window.y) {
|
||||
newY = Window.y + Window.innerHeight;
|
||||
updatePosition = true;
|
||||
} else if (y >= (Window.y + Window.innerHeight)) {
|
||||
newY = Window.y;
|
||||
updatePosition = true;
|
||||
}
|
||||
|
||||
if (updatePosition) {
|
||||
Window.setCursorPosition(newX, newY);
|
||||
}
|
||||
|
||||
that.lastMousePosition.x = newX;
|
||||
that.lastMousePosition.y = newY;
|
||||
|
||||
|
@ -305,6 +332,7 @@ CameraManager = function() {
|
|||
return false;
|
||||
}
|
||||
|
||||
var hasDragged = false;
|
||||
that.mousePressEvent = function(event) {
|
||||
if (cameraTool.mousePressEvent(event)) {
|
||||
return true;
|
||||
|
@ -319,12 +347,7 @@ CameraManager = function() {
|
|||
}
|
||||
|
||||
if (that.mode != MODE_INACTIVE) {
|
||||
var newX = Window.x + Window.innerWidth / 2;
|
||||
var newY = Window.y + Window.innerHeight / 2;
|
||||
Window.setCursorPosition(newX, newY);
|
||||
that.lastMousePosition.x = newX;
|
||||
that.lastMousePosition.y = newY;
|
||||
Window.setCursorVisible(false);
|
||||
hasDragged = false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -2,11 +2,11 @@ Grid = function(opts) {
|
|||
var that = {};
|
||||
|
||||
var colors = [
|
||||
{ red: 0, green: 255, blue: 0 },
|
||||
{ red: 255, green: 255, blue: 255 },
|
||||
{ red: 0, green: 0, blue: 0 },
|
||||
{ red: 0, green: 0, blue: 255 },
|
||||
{ red: 255, green: 255, blue: 255 },
|
||||
{ red: 255, green: 0, blue: 0 },
|
||||
{ red: 0, green: 255, blue: 0 },
|
||||
{ red: 0, green: 0, blue: 255 },
|
||||
];
|
||||
var colorIndex = 0;
|
||||
var gridAlpha = 0.6;
|
||||
|
@ -224,262 +224,50 @@ Grid = function(opts) {
|
|||
GridTool = function(opts) {
|
||||
var that = {};
|
||||
|
||||
var UI_URL = HIFI_PUBLIC_BUCKET + "images/tools/grid-toolbar.svg";
|
||||
var UI_WIDTH = 854;
|
||||
var UI_HEIGHT = 37;
|
||||
|
||||
var horizontalGrid = opts.horizontalGrid;
|
||||
var verticalGrid = opts.verticalGrid;
|
||||
var listeners = [];
|
||||
|
||||
var uiOverlays = {};
|
||||
var allOverlays = [];
|
||||
var url = Script.resolvePath('html/gridControls.html');
|
||||
var webView = new WebWindow('Grid', url, 200, 280);
|
||||
|
||||
function addUIOverlay(key, overlay, x, y, width, height) {
|
||||
uiOverlays[key] = {
|
||||
overlay: overlay,
|
||||
x: x,
|
||||
y: y,
|
||||
width: width,
|
||||
height: height,
|
||||
};
|
||||
allOverlays.push(overlay);
|
||||
}
|
||||
horizontalGrid.addListener(function(data) {
|
||||
webView.eventBridge.emitScriptEvent(JSON.stringify(data));
|
||||
selectionDisplay.updateHandles();
|
||||
});
|
||||
|
||||
var lastKnownWindowWidth = null;
|
||||
function repositionUI() {
|
||||
if (lastKnownWindowWidth == Window.innerWidth) {
|
||||
return;
|
||||
}
|
||||
|
||||
lastKnownWindowWidth = Window.innerWidth;
|
||||
var x = Window.innerWidth / 2 - UI_WIDTH / 2;
|
||||
var y = 10;
|
||||
|
||||
for (var key in uiOverlays) {
|
||||
info = uiOverlays[key];
|
||||
Overlays.editOverlay(info.overlay, {
|
||||
x: x + info.x,
|
||||
y: y + info.y,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// "Spritesheet" is laid out horizontally in this order
|
||||
var UI_SPRITE_LIST = [
|
||||
{ name: "gridText", width: 54 },
|
||||
{ name: "visibleCheckbox", width: 60 },
|
||||
{ name: "snapToGridCheckbox", width: 105 },
|
||||
|
||||
{ name: "color0", width: 27 },
|
||||
{ name: "color1", width: 27 },
|
||||
{ name: "color2", width: 27 },
|
||||
{ name: "color3", width: 27 },
|
||||
{ name: "color4", width: 27 },
|
||||
|
||||
{ name: "minorGridIcon", width: 34 },
|
||||
{ name: "minorGridDecrease", width: 25 },
|
||||
{ name: "minorGridInput", width: 26 },
|
||||
{ name: "minorGridIncrease", width: 25 },
|
||||
|
||||
{ name: "majorGridIcon", width: 40 },
|
||||
{ name: "majorGridDecrease", width: 25 },
|
||||
{ name: "majorGridInput", width: 26 },
|
||||
{ name: "majorGridIncrease", width: 25 },
|
||||
|
||||
{ name: "yPositionLabel", width: 160 },
|
||||
{ name: "moveToLabel", width: 54 },
|
||||
{ name: "moveToAvatar", width: 26 },
|
||||
{ name: "moveToSelection", width: 34 },
|
||||
];
|
||||
|
||||
// Add all overlays from spritesheet
|
||||
var x = 0;
|
||||
for (var i = 0; i < UI_SPRITE_LIST.length; i++) {
|
||||
var info = UI_SPRITE_LIST[i];
|
||||
|
||||
var props = {
|
||||
imageURL: UI_URL,
|
||||
subImage: { x: x, y: 0, width: info.width, height: UI_HEIGHT },
|
||||
width: info.width,
|
||||
height: UI_HEIGHT,
|
||||
alpha: 1.0,
|
||||
visible: false,
|
||||
};
|
||||
|
||||
var overlay = Overlays.addOverlay("image", props);
|
||||
|
||||
addUIOverlay(info.name, overlay, x, 0, info.width, UI_HEIGHT);
|
||||
|
||||
x += info.width;
|
||||
}
|
||||
|
||||
// Add Text overlays
|
||||
var textProperties = {
|
||||
color: { red: 255, green: 255, blue: 255 },
|
||||
topMargin: 6,
|
||||
leftMargin: 4,
|
||||
alpha: 1,
|
||||
backgroundAlpha: 0,
|
||||
text: "",
|
||||
font: { size: 12 },
|
||||
visible: false,
|
||||
};
|
||||
var minorGridWidthText = Overlays.addOverlay("text", textProperties);
|
||||
var majorGridEveryText = Overlays.addOverlay("text", textProperties);
|
||||
var yPositionText = Overlays.addOverlay("text", textProperties);
|
||||
|
||||
addUIOverlay('minorGridWidthText', minorGridWidthText, 414, 8, 24, 24);
|
||||
addUIOverlay('majorGridEveryText', majorGridEveryText, 530, 8, 24, 24);
|
||||
addUIOverlay('yPositionText', yPositionText, 660, 8, 24, 24);
|
||||
|
||||
var NUM_COLORS = 5;
|
||||
function updateColorIndex(index) {
|
||||
if (index < 0 || index >= NUM_COLORS) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (var i = 0 ; i < NUM_COLORS; i++) {
|
||||
var info = uiOverlays['color' + i];
|
||||
Overlays.editOverlay(info.overlay, {
|
||||
subImage: {
|
||||
x: info.x,
|
||||
y: i == index ? UI_HEIGHT : 0,
|
||||
width: info.width,
|
||||
height: info.height,
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function updateGridVisible(value) {
|
||||
var info = uiOverlays.visibleCheckbox;
|
||||
Overlays.editOverlay(info.overlay, {
|
||||
subImage: {
|
||||
x: info.x,
|
||||
y: value ? UI_HEIGHT : 0,
|
||||
width: info.width,
|
||||
height: info.height,
|
||||
webView.eventBridge.webEventReceived.connect(function(data) {
|
||||
data = JSON.parse(data);
|
||||
if (data.type == "init") {
|
||||
horizontalGrid.emitUpdate();
|
||||
} else if (data.type == "update") {
|
||||
horizontalGrid.update(data);
|
||||
for (var i = 0; i < listeners.length; i++) {
|
||||
listeners[i](data);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function updateSnapToGrid(value) {
|
||||
var info = uiOverlays.snapToGridCheckbox;
|
||||
Overlays.editOverlay(info.overlay, {
|
||||
subImage: {
|
||||
x: info.x,
|
||||
y: value ? UI_HEIGHT : 0,
|
||||
width: info.width,
|
||||
height: info.height,
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function updateMinorGridWidth(value) {
|
||||
Overlays.editOverlay(minorGridWidthText, {
|
||||
text: value.toFixed(1),
|
||||
});
|
||||
}
|
||||
|
||||
function updateMajorGridEvery(value) {
|
||||
Overlays.editOverlay(majorGridEveryText, {
|
||||
text: value,
|
||||
});
|
||||
}
|
||||
|
||||
function updateYPosition(value) {
|
||||
Overlays.editOverlay(yPositionText, {
|
||||
text: value.toFixed(2),
|
||||
});
|
||||
}
|
||||
|
||||
function updateOverlays() {
|
||||
updateGridVisible(horizontalGrid.getVisible());
|
||||
updateSnapToGrid(horizontalGrid.getSnapToGrid());
|
||||
updateColorIndex(horizontalGrid.getColorIndex());
|
||||
|
||||
updateMinorGridWidth(horizontalGrid.getMinorGridWidth());
|
||||
updateMajorGridEvery(horizontalGrid.getMajorGridEvery());
|
||||
|
||||
updateYPosition(horizontalGrid.getOrigin().y);
|
||||
}
|
||||
|
||||
that.setVisible = function(visible) {
|
||||
for (var i = 0; i < allOverlays.length; i++) {
|
||||
Overlays.editOverlay(allOverlays[i], { visible: visible });
|
||||
}
|
||||
}
|
||||
|
||||
that.mousePressEvent = function(event) {
|
||||
var overlay = Overlays.getOverlayAtPoint({ x: event.x, y: event.y });
|
||||
|
||||
if (allOverlays.indexOf(overlay) >= 0) {
|
||||
if (overlay == uiOverlays.color0.overlay) {
|
||||
horizontalGrid.setColorIndex(0);
|
||||
} else if (overlay == uiOverlays.color1.overlay) {
|
||||
horizontalGrid.setColorIndex(1);
|
||||
} else if (overlay == uiOverlays.color2.overlay) {
|
||||
horizontalGrid.setColorIndex(2);
|
||||
} else if (overlay == uiOverlays.color3.overlay) {
|
||||
horizontalGrid.setColorIndex(3);
|
||||
} else if (overlay == uiOverlays.color4.overlay) {
|
||||
horizontalGrid.setColorIndex(4);
|
||||
} else if (overlay == uiOverlays.visibleCheckbox.overlay) {
|
||||
horizontalGrid.setVisible(!horizontalGrid.getVisible());
|
||||
} else if (overlay == uiOverlays.snapToGridCheckbox.overlay) {
|
||||
horizontalGrid.setSnapToGrid(!horizontalGrid.getSnapToGrid());
|
||||
} else if (overlay == uiOverlays.moveToAvatar.overlay) {
|
||||
} else if (data.type == "action") {
|
||||
var action = data.action;
|
||||
if (action == "moveToAvatar") {
|
||||
var position = MyAvatar.getJointPosition("LeftFoot");
|
||||
if (position.x == 0 && position.y == 0 && position.z == 0) {
|
||||
position = MyAvatar.position;
|
||||
}
|
||||
horizontalGrid.setPosition(position);
|
||||
} else if (overlay == uiOverlays.moveToSelection.overlay) {
|
||||
} else if (action == "moveToSelection") {
|
||||
var newPosition = selectionManager.worldPosition;
|
||||
newPosition = Vec3.subtract(newPosition, { x: 0, y: selectionManager.worldDimensions.y * 0.5, z: 0 });
|
||||
horizontalGrid.setPosition(newPosition);
|
||||
} else if (overlay == uiOverlays.minorGridDecrease.overlay) {
|
||||
var newValue = Math.max(0.1, horizontalGrid.getMinorGridWidth() - 0.1);
|
||||
horizontalGrid.setMinorGridWidth(newValue);
|
||||
} else if (overlay == uiOverlays.minorGridIncrease.overlay) {
|
||||
horizontalGrid.setMinorGridWidth(horizontalGrid.getMinorGridWidth() + 0.1);
|
||||
} else if (overlay == uiOverlays.majorGridDecrease.overlay) {
|
||||
var newValue = Math.max(2, horizontalGrid.getMajorGridEvery() - 1);
|
||||
horizontalGrid.setMajorGridEvery(newValue);
|
||||
} else if (overlay == uiOverlays.majorGridIncrease.overlay) {
|
||||
horizontalGrid.setMajorGridEvery(horizontalGrid.getMajorGridEvery() + 1);
|
||||
} else if (overlay == uiOverlays.yPositionLabel.overlay) {
|
||||
var newValue = Window.prompt("Y Position:", horizontalGrid.getOrigin().y.toFixed(4));
|
||||
if (newValue !== null) {
|
||||
var y = parseFloat(newValue)
|
||||
if (isNaN(y)) {
|
||||
Window.alert("Invalid position");
|
||||
} else {
|
||||
horizontalGrid.setPosition({ x: 0, y: y, z: 0 });
|
||||
}
|
||||
}
|
||||
grid.setPosition(newPosition);
|
||||
}
|
||||
|
||||
// Clicking anywhere within the toolbar will "consume" this press event
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
};
|
||||
|
||||
Script.scriptEnding.connect(function() {
|
||||
for (var i = 0; i < allOverlays.length; i++) {
|
||||
Overlays.deleteOverlay(allOverlays[i]);
|
||||
}
|
||||
});
|
||||
Script.update.connect(repositionUI);
|
||||
|
||||
horizontalGrid.addListener(function() {
|
||||
selectionDisplay.updateHandles();
|
||||
updateOverlays();
|
||||
});
|
||||
that.addListener = function(callback) {
|
||||
listeners.push(callback);
|
||||
}
|
||||
|
||||
updateOverlays();
|
||||
repositionUI();
|
||||
that.setVisible = function(visible) {
|
||||
webView.setVisible(visible);
|
||||
}
|
||||
|
||||
return that;
|
||||
};
|
||||
|
|
|
@ -2790,8 +2790,7 @@ void Application::displaySide(Camera& theCamera, bool selfAvatarOnly, RenderArgs
|
|||
if (!selfAvatarOnly) {
|
||||
// draw a red sphere
|
||||
float originSphereRadius = 0.05f;
|
||||
glColor3f(1,0,0);
|
||||
DependencyManager::get<GeometryCache>()->renderSphere(originSphereRadius, 15, 15);
|
||||
DependencyManager::get<GeometryCache>()->renderSphere(originSphereRadius, 15, 15, glm::vec4(1.0f, 0.0f, 0.0f, 1.0f));
|
||||
|
||||
// also, metavoxels
|
||||
if (Menu::getInstance()->isOptionChecked(MenuOption::Metavoxels)) {
|
||||
|
@ -3398,8 +3397,10 @@ void Application::loadScripts() {
|
|||
}
|
||||
|
||||
void Application::clearScriptsBeforeRunning() {
|
||||
// clears all scripts from the settings
|
||||
SettingHandles::SettingHandle<QVariant>(SETTINGS_KEY).remove();
|
||||
// clears all scripts from the settingsSettings settings;
|
||||
Settings settings;
|
||||
settings.beginWriteArray(SETTINGS_KEY);
|
||||
settings.remove("");
|
||||
}
|
||||
|
||||
void Application::saveScripts() {
|
||||
|
@ -3411,6 +3412,7 @@ void Application::saveScripts() {
|
|||
// Saves all currently running user-loaded scripts
|
||||
Settings settings;
|
||||
settings.beginWriteArray(SETTINGS_KEY);
|
||||
settings.remove("");
|
||||
int i = 0;
|
||||
for (auto it = runningScripts.begin(); it != runningScripts.end(); ++it) {
|
||||
if (getScriptEngine(*it)->isUserLoaded()) {
|
||||
|
|
|
@ -263,7 +263,7 @@ void Environment::renderAtmosphere(Camera& camera, const EnvironmentData& data)
|
|||
|
||||
glDepthMask(GL_FALSE);
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
DependencyManager::get<GeometryCache>()->renderSphere(1.0f, 100, 50); //Draw a unit sphere
|
||||
DependencyManager::get<GeometryCache>()->renderSphere(1.0f, 100, 50, glm::vec4(1.0f, 1.0f, 1.0f, 1.0f)); //Draw a unit sphere
|
||||
glDepthMask(GL_TRUE);
|
||||
|
||||
program->release();
|
||||
|
|
|
@ -1251,7 +1251,6 @@ SphereRenderer::SphereRenderer() {
|
|||
void SphereRenderer::render(const MetavoxelLOD& lod, bool contained, bool cursor) {
|
||||
Sphere* sphere = static_cast<Sphere*>(_spanner);
|
||||
const QColor& color = sphere->getColor();
|
||||
glColor4f(color.redF(), color.greenF(), color.blueF(), color.alphaF());
|
||||
|
||||
glPushMatrix();
|
||||
const glm::vec3& translation = sphere->getTranslation();
|
||||
|
@ -1260,7 +1259,8 @@ void SphereRenderer::render(const MetavoxelLOD& lod, bool contained, bool cursor
|
|||
glm::vec3 axis = glm::axis(rotation);
|
||||
glRotatef(glm::degrees(glm::angle(rotation)), axis.x, axis.y, axis.z);
|
||||
|
||||
DependencyManager::get<DeferredLightingEffect>()->renderSolidSphere(sphere->getScale(), 32, 32);
|
||||
DependencyManager::get<DeferredLightingEffect>()->renderSolidSphere(sphere->getScale(), 32, 32,
|
||||
glm::vec4(color.redF(), color.greenF(), color.blueF(), color.alphaF()));
|
||||
|
||||
glPopMatrix();
|
||||
}
|
||||
|
@ -1271,7 +1271,6 @@ CuboidRenderer::CuboidRenderer() {
|
|||
void CuboidRenderer::render(const MetavoxelLOD& lod, bool contained, bool cursor) {
|
||||
Cuboid* cuboid = static_cast<Cuboid*>(_spanner);
|
||||
const QColor& color = cuboid->getColor();
|
||||
glColor4f(color.redF(), color.greenF(), color.blueF(), color.alphaF());
|
||||
|
||||
glPushMatrix();
|
||||
const glm::vec3& translation = cuboid->getTranslation();
|
||||
|
@ -1281,7 +1280,8 @@ void CuboidRenderer::render(const MetavoxelLOD& lod, bool contained, bool cursor
|
|||
glRotatef(glm::degrees(glm::angle(rotation)), axis.x, axis.y, axis.z);
|
||||
glScalef(1.0f, cuboid->getAspectY(), cuboid->getAspectZ());
|
||||
|
||||
DependencyManager::get<DeferredLightingEffect>()->renderSolidCube(cuboid->getScale() * 2.0f);
|
||||
DependencyManager::get<DeferredLightingEffect>()->renderSolidCube(cuboid->getScale() * 2.0f,
|
||||
glm::vec4(color.redF(), color.greenF(), color.blueF(), color.alphaF()));
|
||||
|
||||
glPopMatrix();
|
||||
}
|
||||
|
|
|
@ -36,22 +36,18 @@ void renderWorldBox() {
|
|||
auto geometryCache = DependencyManager::get<GeometryCache>();
|
||||
|
||||
// Show edge of world
|
||||
float red[] = {1, 0, 0};
|
||||
float green[] = {0, 1, 0};
|
||||
float blue[] = {0, 0, 1};
|
||||
float gray[] = {0.5, 0.5, 0.5};
|
||||
glm::vec3 red(1.0f, 0.0f, 0.0f);
|
||||
glm::vec3 green(0.0f, 1.0f, 0.0f);
|
||||
glm::vec3 blue(0.0f, 0.0f, 1.0f);
|
||||
glm::vec3 grey(0.5f, 0.5f, 0.5f);
|
||||
|
||||
glDisable(GL_LIGHTING);
|
||||
glLineWidth(1.0);
|
||||
glColor3fv(red);
|
||||
geometryCache->renderLine(glm::vec3(0, 0, 0), glm::vec3(TREE_SCALE, 0, 0));
|
||||
glColor3fv(green);
|
||||
geometryCache->renderLine(glm::vec3(0, 0, 0), glm::vec3(0, TREE_SCALE, 0));
|
||||
glColor3fv(blue);
|
||||
geometryCache->renderLine(glm::vec3(0, 0, 0), glm::vec3(0, 0, TREE_SCALE));
|
||||
glColor3fv(gray);
|
||||
geometryCache->renderLine(glm::vec3(0, 0, TREE_SCALE), glm::vec3(TREE_SCALE, 0, TREE_SCALE));
|
||||
geometryCache->renderLine(glm::vec3(TREE_SCALE, 0, TREE_SCALE), glm::vec3(TREE_SCALE, 0, 0));
|
||||
geometryCache->renderLine(glm::vec3(0, 0, 0), glm::vec3(TREE_SCALE, 0, 0), red);
|
||||
geometryCache->renderLine(glm::vec3(0, 0, 0), glm::vec3(0, TREE_SCALE, 0), green);
|
||||
geometryCache->renderLine(glm::vec3(0, 0, 0), glm::vec3(0, 0, TREE_SCALE), blue);
|
||||
geometryCache->renderLine(glm::vec3(0, 0, TREE_SCALE), glm::vec3(TREE_SCALE, 0, TREE_SCALE), grey);
|
||||
geometryCache->renderLine(glm::vec3(TREE_SCALE, 0, TREE_SCALE), glm::vec3(TREE_SCALE, 0, 0), grey);
|
||||
|
||||
|
||||
// Draw meter markers along the 3 axis to help with measuring things
|
||||
|
@ -60,23 +56,19 @@ void renderWorldBox() {
|
|||
glEnable(GL_LIGHTING);
|
||||
glPushMatrix();
|
||||
glTranslatef(MARKER_DISTANCE, 0, 0);
|
||||
glColor3fv(red);
|
||||
geometryCache->renderSphere(MARKER_RADIUS, 10, 10);
|
||||
geometryCache->renderSphere(MARKER_RADIUS, 10, 10, red);
|
||||
glPopMatrix();
|
||||
glPushMatrix();
|
||||
glTranslatef(0, MARKER_DISTANCE, 0);
|
||||
glColor3fv(green);
|
||||
geometryCache->renderSphere(MARKER_RADIUS, 10, 10);
|
||||
geometryCache->renderSphere(MARKER_RADIUS, 10, 10, green);
|
||||
glPopMatrix();
|
||||
glPushMatrix();
|
||||
glTranslatef(0, 0, MARKER_DISTANCE);
|
||||
glColor3fv(blue);
|
||||
geometryCache->renderSphere(MARKER_RADIUS, 10, 10);
|
||||
geometryCache->renderSphere(MARKER_RADIUS, 10, 10, blue);
|
||||
glPopMatrix();
|
||||
glPushMatrix();
|
||||
glColor3fv(gray);
|
||||
glTranslatef(MARKER_DISTANCE, 0, MARKER_DISTANCE);
|
||||
geometryCache->renderSphere(MARKER_RADIUS, 10, 10);
|
||||
geometryCache->renderSphere(MARKER_RADIUS, 10, 10, grey);
|
||||
glPopMatrix();
|
||||
|
||||
}
|
||||
|
@ -114,25 +106,23 @@ void drawText(int x, int y, float scale, float radians, int mono,
|
|||
//
|
||||
glPushMatrix();
|
||||
glTranslatef(static_cast<float>(x), static_cast<float>(y), 0.0f);
|
||||
glColor3fv(color);
|
||||
|
||||
|
||||
glRotated(double(radians * DEGREES_PER_RADIAN), 0.0, 0.0, 1.0);
|
||||
glScalef(scale / 0.1f, scale / 0.1f, 1.0f);
|
||||
textRenderer(mono)->draw(0, 0, string);
|
||||
|
||||
glm::vec4 colorV4 = {color[0], color[1], color[3], 1.0f };
|
||||
textRenderer(mono)->draw(0, 0, string, colorV4);
|
||||
glPopMatrix();
|
||||
}
|
||||
|
||||
void renderCollisionOverlay(int width, int height, float magnitude, float red, float blue, float green) {
|
||||
const float MIN_VISIBLE_COLLISION = 0.01f;
|
||||
if (magnitude > MIN_VISIBLE_COLLISION) {
|
||||
glColor4f(red, blue, green, magnitude);
|
||||
DependencyManager::get<GeometryCache>()->renderQuad(0, 0, width, height);
|
||||
DependencyManager::get<GeometryCache>()->renderQuad(0, 0, width, height, glm::vec4(red, blue, green, magnitude));
|
||||
}
|
||||
}
|
||||
|
||||
void renderBevelCornersRect(int x, int y, int width, int height, int bevelDistance) {
|
||||
DependencyManager::get<GeometryCache>()->renderBevelCornersRect(x, y, width, height, bevelDistance);
|
||||
}
|
||||
|
||||
// Do some basic timing tests and report the results
|
||||
void runTimingTests() {
|
||||
// How long does it take to make a call to get the time?
|
||||
|
|
|
@ -27,8 +27,6 @@ void drawText(int x, int y, float scale, float radians, int mono,
|
|||
|
||||
void renderCollisionOverlay(int width, int height, float magnitude, float red = 0, float blue = 0, float green = 0);
|
||||
|
||||
void renderBevelCornersRect(int x, int y, int width, int height, int bevelDistance);
|
||||
|
||||
void runTimingTests();
|
||||
|
||||
bool rayIntersectsSphere(const glm::vec3& rayStarting, const glm::vec3& rayNormalizedDirection,
|
||||
|
|
|
@ -49,14 +49,12 @@ void AudioIOStatsRenderer::render(const float* color, int width, int height) {
|
|||
int statsHeight = STATS_HEIGHT_PER_LINE * lines;
|
||||
|
||||
|
||||
static const float backgroundColor[4] = { 0.2f, 0.2f, 0.2f, 0.6f };
|
||||
static const glm::vec4 backgroundColor = { 0.2f, 0.2f, 0.2f, 0.6f };
|
||||
int x = std::max((width - (int)STATS_WIDTH) / 2, 0);
|
||||
int y = std::max((height - CENTERED_BACKGROUND_HEIGHT) / 2, 0);
|
||||
int w = STATS_WIDTH;
|
||||
int h = statsHeight;
|
||||
glColor4fv(backgroundColor);
|
||||
DependencyManager::get<GeometryCache>()->renderQuad(x, y, w, h);
|
||||
glColor4f(1, 1, 1, 1);
|
||||
DependencyManager::get<GeometryCache>()->renderQuad(x, y, w, h, backgroundColor);
|
||||
|
||||
int horizontalOffset = x + 5;
|
||||
int verticalOffset = y;
|
||||
|
|
|
@ -110,11 +110,11 @@ void AudioScope::render(int width, int height) {
|
|||
return;
|
||||
}
|
||||
|
||||
static const float backgroundColor[4] = { 0.4f, 0.4f, 0.4f, 0.6f };
|
||||
static const float gridColor[4] = { 0.7f, 0.7f, 0.7f, 1.0f };
|
||||
static const float inputColor[4] = { 0.3f, 1.0f, 0.3f, 1.0f };
|
||||
static const float outputLeftColor[4] = { 1.0f, 0.3f, 0.3f, 1.0f };
|
||||
static const float outputRightColor[4] = { 0.3f, 0.3f, 1.0f, 1.0f };
|
||||
static const glm::vec4 backgroundColor = { 0.4f, 0.4f, 0.4f, 0.6f };
|
||||
static const glm::vec4 gridColor = { 0.7f, 0.7f, 0.7f, 1.0f };
|
||||
static const glm::vec4 inputColor = { 0.3f, 1.0f, 0.3f, 1.0f };
|
||||
static const glm::vec4 outputLeftColor = { 1.0f, 0.3f, 0.3f, 1.0f };
|
||||
static const glm::vec4 outputRightColor = { 0.3f, 0.3f, 1.0f, 1.0f };
|
||||
static const int gridRows = 2;
|
||||
int gridCols = _framesPerScope;
|
||||
|
||||
|
@ -131,21 +131,15 @@ void AudioScope::render(int width, int height) {
|
|||
renderLineStrip(_outputRightD, outputRightColor, x, y, _samplesPerScope, _scopeOutputOffset, _scopeOutputRight);
|
||||
}
|
||||
|
||||
void AudioScope::renderBackground(const float* color, int x, int y, int width, int height) {
|
||||
glColor4fv(color);
|
||||
DependencyManager::get<GeometryCache>()->renderQuad(x, y, width, height);
|
||||
glColor4f(1, 1, 1, 1);
|
||||
void AudioScope::renderBackground(const glm::vec4& color, int x, int y, int width, int height) {
|
||||
DependencyManager::get<GeometryCache>()->renderQuad(x, y, width, height, color);
|
||||
}
|
||||
|
||||
void AudioScope::renderGrid(const float* color, int x, int y, int width, int height, int rows, int cols) {
|
||||
glColor4fv(color);
|
||||
DependencyManager::get<GeometryCache>()->renderGrid(x, y, width, height, rows, cols, _audioScopeGrid);
|
||||
glColor4f(1, 1, 1, 1);
|
||||
void AudioScope::renderGrid(const glm::vec4& color, int x, int y, int width, int height, int rows, int cols) {
|
||||
DependencyManager::get<GeometryCache>()->renderGrid(x, y, width, height, rows, cols, color, _audioScopeGrid);
|
||||
}
|
||||
|
||||
void AudioScope::renderLineStrip(int id, const float* color, int x, int y, int n, int offset, const QByteArray* byteArray) {
|
||||
|
||||
glColor4fv(color);
|
||||
void AudioScope::renderLineStrip(int id, const glm::vec4& color, int x, int y, int n, int offset, const QByteArray* byteArray) {
|
||||
|
||||
int16_t sample;
|
||||
int16_t* samples = ((int16_t*) byteArray->data()) + offset;
|
||||
|
@ -199,10 +193,8 @@ void AudioScope::renderLineStrip(int id, const float* color, int x, int y, int n
|
|||
}
|
||||
|
||||
|
||||
geometryCache->updateVertices(id, points);
|
||||
geometryCache->renderVertices(GL_LINE_STRIP, id);
|
||||
|
||||
glColor4f(1, 1, 1, 1);
|
||||
geometryCache->updateVertices(id, points, color);
|
||||
geometryCache->renderVertices(gpu::LINE_STRIP, id);
|
||||
}
|
||||
|
||||
int AudioScope::addBufferToScope(QByteArray* byteArray, int frameOffset, const int16_t* source, int sourceSamplesPerChannel,
|
||||
|
|
|
@ -12,6 +12,8 @@
|
|||
#ifndef hifi_AudioScope_h
|
||||
#define hifi_AudioScope_h
|
||||
|
||||
#include <glm/glm.hpp>
|
||||
|
||||
#include <DependencyManager.h>
|
||||
|
||||
#include <QByteArray>
|
||||
|
@ -46,9 +48,9 @@ private slots:
|
|||
|
||||
private:
|
||||
// Audio scope methods for rendering
|
||||
static void renderBackground(const float* color, int x, int y, int width, int height);
|
||||
void renderGrid(const float* color, int x, int y, int width, int height, int rows, int cols);
|
||||
void renderLineStrip(int id, const float* color, int x, int y, int n, int offset, const QByteArray* byteArray);
|
||||
static void renderBackground(const glm::vec4& color, int x, int y, int width, int height);
|
||||
void renderGrid(const glm::vec4& color, int x, int y, int width, int height, int rows, int cols);
|
||||
void renderLineStrip(int id, const glm::vec4& color, int x, int y, int n, int offset, const QByteArray* byteArray);
|
||||
|
||||
// Audio scope methods for data acquisition
|
||||
int addBufferToScope(QByteArray* byteArray, int frameOffset, const int16_t* source, int sourceSamples,
|
||||
|
|
|
@ -61,17 +61,19 @@ void AudioToolBox::render(int x, int y, bool boxed) {
|
|||
|
||||
glBindTexture(GL_TEXTURE_2D, _boxTextureId);
|
||||
|
||||
glm::vec4 quadColor;
|
||||
|
||||
if (isClipping) {
|
||||
glColor3f(1.0f, 0.0f, 0.0f);
|
||||
quadColor = glm::vec4(1.0f, 0.0f, 0.0f, 1.0f);
|
||||
} else {
|
||||
glColor3f(0.41f, 0.41f, 0.41f);
|
||||
quadColor = glm::vec4(0.41f, 0.41f, 0.41f, 1.0f);
|
||||
}
|
||||
glm::vec2 topLeft(boxBounds.left(), boxBounds.top());
|
||||
glm::vec2 bottomRight(boxBounds.right(), boxBounds.bottom());
|
||||
glm::vec2 texCoordTopLeft(1,1);
|
||||
glm::vec2 texCoordBottomRight(0,0);
|
||||
|
||||
DependencyManager::get<GeometryCache>()->renderQuad(topLeft, bottomRight, texCoordTopLeft, texCoordBottomRight);
|
||||
DependencyManager::get<GeometryCache>()->renderQuad(topLeft, bottomRight, texCoordTopLeft, texCoordBottomRight, quadColor);
|
||||
}
|
||||
|
||||
float iconColor = 1.0f;
|
||||
|
@ -97,14 +99,14 @@ void AudioToolBox::render(int x, int y, bool boxed) {
|
|||
iconColor = PULSE_MIN + (PULSE_MAX - PULSE_MIN) * pulseFactor;
|
||||
}
|
||||
|
||||
glColor3f(iconColor, iconColor, iconColor);
|
||||
glm::vec4 quadColor(iconColor, iconColor, iconColor, 1.0f);
|
||||
|
||||
glm::vec2 topLeft(_iconBounds.left(), _iconBounds.top());
|
||||
glm::vec2 bottomRight(_iconBounds.right(), _iconBounds.bottom());
|
||||
glm::vec2 texCoordTopLeft(1,1);
|
||||
glm::vec2 texCoordBottomRight(0,0);
|
||||
|
||||
DependencyManager::get<GeometryCache>()->renderQuad(topLeft, bottomRight, texCoordTopLeft, texCoordBottomRight);
|
||||
DependencyManager::get<GeometryCache>()->renderQuad(topLeft, bottomRight, texCoordTopLeft, texCoordBottomRight, quadColor);
|
||||
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
}
|
|
@ -304,8 +304,7 @@ void Avatar::render(const glm::vec3& cameraPosition, RenderMode renderMode, bool
|
|||
glm::vec3 axis = glm::axis(rotation);
|
||||
glRotatef(angle, axis.x, axis.y, axis.z);
|
||||
|
||||
glColor3f(laserColor.x, laserColor.y, laserColor.z);
|
||||
geometryCache->renderLine(glm::vec3(0.0f, 0.0f, 0.0f), glm::vec3(0.0f, laserLength, 0.0f));
|
||||
geometryCache->renderLine(glm::vec3(0.0f, 0.0f, 0.0f), glm::vec3(0.0f, laserLength, 0.0f), laserColor);
|
||||
|
||||
} glPopMatrix();
|
||||
}
|
||||
|
@ -330,8 +329,7 @@ void Avatar::render(const glm::vec3& cameraPosition, RenderMode renderMode, bool
|
|||
float angle = glm::degrees(glm::angle(rotation));
|
||||
glm::vec3 axis = glm::axis(rotation);
|
||||
glRotatef(angle, axis.x, axis.y, axis.z);
|
||||
glColor3f(laserColor.x, laserColor.y, laserColor.z);
|
||||
geometryCache->renderLine(glm::vec3(0.0f, 0.0f, 0.0f), glm::vec3(0.0f, laserLength, 0.0f));
|
||||
geometryCache->renderLine(glm::vec3(0.0f, 0.0f, 0.0f), glm::vec3(0.0f, laserLength, 0.0f), laserColor);
|
||||
|
||||
} glPopMatrix();
|
||||
}
|
||||
|
@ -407,15 +405,14 @@ void Avatar::render(const glm::vec3& cameraPosition, RenderMode renderMode, bool
|
|||
if (_isLookAtTarget && Menu::getInstance()->isOptionChecked(MenuOption::RenderFocusIndicator)) {
|
||||
const float LOOK_AT_INDICATOR_RADIUS = 0.03f;
|
||||
const float LOOK_AT_INDICATOR_OFFSET = 0.22f;
|
||||
const float LOOK_AT_INDICATOR_COLOR[] = { 0.8f, 0.0f, 0.0f, 0.75f };
|
||||
const glm::vec4 LOOK_AT_INDICATOR_COLOR = { 0.8f, 0.0f, 0.0f, 0.75f };
|
||||
glPushMatrix();
|
||||
glColor4fv(LOOK_AT_INDICATOR_COLOR);
|
||||
if (_displayName.isEmpty() || _displayNameAlpha == 0.0f) {
|
||||
glTranslatef(_position.x, getDisplayNamePosition().y, _position.z);
|
||||
} else {
|
||||
glTranslatef(_position.x, getDisplayNamePosition().y + LOOK_AT_INDICATOR_OFFSET, _position.z);
|
||||
}
|
||||
DependencyManager::get<GeometryCache>()->renderSphere(LOOK_AT_INDICATOR_RADIUS, 15, 15);
|
||||
DependencyManager::get<GeometryCache>()->renderSphere(LOOK_AT_INDICATOR_RADIUS, 15, 15, LOOK_AT_INDICATOR_COLOR);
|
||||
glPopMatrix();
|
||||
}
|
||||
}
|
||||
|
@ -439,11 +436,11 @@ void Avatar::render(const glm::vec3& cameraPosition, RenderMode renderMode, bool
|
|||
|
||||
if (renderMode == NORMAL_RENDER_MODE && (sphereRadius > MIN_SPHERE_SIZE) &&
|
||||
(angle < MAX_SPHERE_ANGLE) && (angle > MIN_SPHERE_ANGLE)) {
|
||||
glColor4f(SPHERE_COLOR[0], SPHERE_COLOR[1], SPHERE_COLOR[2], 1.0f - angle / MAX_SPHERE_ANGLE);
|
||||
glPushMatrix();
|
||||
glTranslatef(_position.x, _position.y, _position.z);
|
||||
glScalef(height, height, height);
|
||||
DependencyManager::get<GeometryCache>()->renderSphere(sphereRadius, 15, 15);
|
||||
DependencyManager::get<GeometryCache>()->renderSphere(sphereRadius, 15, 15,
|
||||
glm::vec4(SPHERE_COLOR[0], SPHERE_COLOR[1], SPHERE_COLOR[2], 1.0f - angle / MAX_SPHERE_ANGLE));
|
||||
|
||||
glPopMatrix();
|
||||
}
|
||||
|
@ -574,15 +571,12 @@ void Avatar::renderBillboard() {
|
|||
float size = getBillboardSize();
|
||||
glScalef(size, size, size);
|
||||
|
||||
glColor3f(1.0f, 1.0f, 1.0f);
|
||||
|
||||
glm::vec2 topLeft(-1.0f, -1.0f);
|
||||
glm::vec2 bottomRight(1.0f, 1.0f);
|
||||
glm::vec2 texCoordTopLeft(0.0f, 0.0f);
|
||||
glm::vec2 texCoordBottomRight(1.0f, 1.0f);
|
||||
|
||||
DependencyManager::get<GeometryCache>()->renderQuad(topLeft, bottomRight, texCoordTopLeft, texCoordBottomRight);
|
||||
|
||||
DependencyManager::get<GeometryCache>()->renderQuad(topLeft, bottomRight, texCoordTopLeft, texCoordBottomRight, glm::vec4(1.0f, 1.0f, 1.0f, 1.0f));
|
||||
|
||||
glPopMatrix();
|
||||
|
||||
|
@ -708,15 +702,15 @@ void Avatar::renderDisplayName() {
|
|||
glEnable(GL_POLYGON_OFFSET_FILL);
|
||||
glPolygonOffset(1.0f, 1.0f);
|
||||
|
||||
glColor4f(0.2f, 0.2f, 0.2f, _displayNameAlpha * DISPLAYNAME_BACKGROUND_ALPHA / DISPLAYNAME_ALPHA);
|
||||
renderBevelCornersRect(left, bottom, right - left, top - bottom, 3);
|
||||
DependencyManager::get<GeometryCache>()->renderBevelCornersRect(left, bottom, right - left, top - bottom, 3,
|
||||
glm::vec4(0.2f, 0.2f, 0.2f, _displayNameAlpha * DISPLAYNAME_BACKGROUND_ALPHA / DISPLAYNAME_ALPHA));
|
||||
|
||||
glColor4f(0.93f, 0.93f, 0.93f, _displayNameAlpha);
|
||||
glm::vec4 color(0.93f, 0.93f, 0.93f, _displayNameAlpha);
|
||||
QByteArray ba = _displayName.toLocal8Bit();
|
||||
const char* text = ba.data();
|
||||
|
||||
glDisable(GL_POLYGON_OFFSET_FILL);
|
||||
textRenderer(DISPLAYNAME)->draw(text_x, text_y, text);
|
||||
textRenderer(DISPLAYNAME)->draw(text_x, text_y, text, color);
|
||||
|
||||
glPopMatrix();
|
||||
|
||||
|
@ -951,7 +945,8 @@ int Avatar::parseDataAtOffset(const QByteArray& packet, int offset) {
|
|||
int Avatar::_jointConesID = GeometryCache::UNKNOWN_ID;
|
||||
|
||||
// render a makeshift cone section that serves as a body part connecting joint spheres
|
||||
void Avatar::renderJointConnectingCone(glm::vec3 position1, glm::vec3 position2, float radius1, float radius2) {
|
||||
void Avatar::renderJointConnectingCone(glm::vec3 position1, glm::vec3 position2,
|
||||
float radius1, float radius2, const glm::vec4& color) {
|
||||
|
||||
auto geometryCache = DependencyManager::get<GeometryCache>();
|
||||
|
||||
|
@ -996,8 +991,8 @@ void Avatar::renderJointConnectingCone(glm::vec3 position1, glm::vec3 position2,
|
|||
|
||||
// TODO: this is really inefficient constantly recreating these vertices buffers. It would be
|
||||
// better if the avatars cached these buffers for each of the joints they are rendering
|
||||
geometryCache->updateVertices(_jointConesID, points);
|
||||
geometryCache->renderVertices(GL_TRIANGLES, _jointConesID);
|
||||
geometryCache->updateVertices(_jointConesID, points, color);
|
||||
geometryCache->renderVertices(gpu::TRIANGLES, _jointConesID);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -129,7 +129,8 @@ public:
|
|||
|
||||
virtual int parseDataAtOffset(const QByteArray& packet, int offset);
|
||||
|
||||
static void renderJointConnectingCone(glm::vec3 position1, glm::vec3 position2, float radius1, float radius2);
|
||||
static void renderJointConnectingCone(glm::vec3 position1, glm::vec3 position2,
|
||||
float radius1, float radius2, const glm::vec4& color);
|
||||
|
||||
virtual void applyCollision(const glm::vec3& contactPoint, const glm::vec3& penetration) { }
|
||||
|
||||
|
|
|
@ -114,8 +114,7 @@ void Hand::render(bool isMine, Model::RenderMode renderMode) {
|
|||
glm::vec3 position = palm.getPosition();
|
||||
glPushMatrix();
|
||||
glTranslatef(position.x, position.y, position.z);
|
||||
glColor3f(0.0f, 1.0f, 0.0f);
|
||||
DependencyManager::get<GeometryCache>()->renderSphere(PALM_COLLISION_RADIUS * _owningAvatar->getScale(), 10, 10);
|
||||
DependencyManager::get<GeometryCache>()->renderSphere(PALM_COLLISION_RADIUS * _owningAvatar->getScale(), 10, 10, glm::vec3(0.0f, 1.0f, 0.0f));
|
||||
glPopMatrix();
|
||||
}
|
||||
}
|
||||
|
@ -150,8 +149,7 @@ void Hand::renderHandTargets(bool isMine) {
|
|||
glTranslatef(targetPosition.x, targetPosition.y, targetPosition.z);
|
||||
|
||||
const float collisionRadius = 0.05f;
|
||||
glColor4f(0.5f,0.5f,0.5f, alpha);
|
||||
DependencyManager::get<GeometryCache>()->renderSphere(collisionRadius, 10, 10, false);
|
||||
DependencyManager::get<GeometryCache>()->renderSphere(collisionRadius, 10, 10, glm::vec4(0.5f,0.5f,0.5f, alpha), false);
|
||||
glPopMatrix();
|
||||
}
|
||||
}
|
||||
|
@ -165,17 +163,17 @@ void Hand::renderHandTargets(bool isMine) {
|
|||
for (size_t i = 0; i < getNumPalms(); ++i) {
|
||||
PalmData& palm = getPalms()[i];
|
||||
if (palm.isActive()) {
|
||||
glColor4f(handColor.r, handColor.g, handColor.b, alpha);
|
||||
glm::vec3 tip = palm.getTipPosition();
|
||||
glm::vec3 root = palm.getPosition();
|
||||
|
||||
Avatar::renderJointConnectingCone(root, tip, PALM_FINGER_ROD_RADIUS, PALM_FINGER_ROD_RADIUS);
|
||||
Avatar::renderJointConnectingCone(root, tip, PALM_FINGER_ROD_RADIUS, PALM_FINGER_ROD_RADIUS, glm::vec4(handColor.r, handColor.g, handColor.b, alpha));
|
||||
|
||||
// Render sphere at palm/finger root
|
||||
glm::vec3 offsetFromPalm = root + palm.getNormal() * PALM_DISK_THICKNESS;
|
||||
Avatar::renderJointConnectingCone(root, offsetFromPalm, PALM_DISK_RADIUS, 0.0f);
|
||||
Avatar::renderJointConnectingCone(root, offsetFromPalm, PALM_DISK_RADIUS, 0.0f, glm::vec4(handColor.r, handColor.g, handColor.b, alpha));
|
||||
glPushMatrix();
|
||||
glTranslatef(root.x, root.y, root.z);
|
||||
DependencyManager::get<GeometryCache>()->renderSphere(PALM_BALL_RADIUS, 20.0f, 20.0f);
|
||||
DependencyManager::get<GeometryCache>()->renderSphere(PALM_BALL_RADIUS, 20.0f, 20.0f, glm::vec4(handColor.r, handColor.g, handColor.b, alpha));
|
||||
glPopMatrix();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -344,11 +344,10 @@ void Head::renderLookatVectors(glm::vec3 leftEyePosition, glm::vec3 rightEyePosi
|
|||
|
||||
glLineWidth(2.0);
|
||||
|
||||
// TODO: implement support for lines with gradient colors
|
||||
// glColor4f(0.2f, 0.2f, 0.2f, 1.0f); --> to --> glColor4f(1.0f, 1.0f, 1.0f, 0.0f);
|
||||
glColor4f(0.5f, 0.5f, 0.5f, 0.5f);
|
||||
geometryCache->renderLine(leftEyePosition, lookatPosition, _leftEyeLookAtID);
|
||||
geometryCache->renderLine(rightEyePosition, lookatPosition, _rightEyeLookAtID);
|
||||
glm::vec4 startColor(0.2f, 0.2f, 0.2f, 1.0f);
|
||||
glm::vec4 endColor(1.0f, 1.0f, 1.0f, 0.0f);
|
||||
geometryCache->renderLine(leftEyePosition, lookatPosition, startColor, endColor, _leftEyeLookAtID);
|
||||
geometryCache->renderLine(rightEyePosition, lookatPosition, startColor, endColor, _rightEyeLookAtID);
|
||||
|
||||
DependencyManager::get<GlowEffect>()->end();
|
||||
}
|
||||
|
|
|
@ -384,17 +384,15 @@ void MyAvatar::renderDebugBodyPoints() {
|
|||
// Torso Sphere
|
||||
position = torsoPosition;
|
||||
glPushMatrix();
|
||||
glColor4f(0, 1, 0, .5f);
|
||||
glTranslatef(position.x, position.y, position.z);
|
||||
DependencyManager::get<GeometryCache>()->renderSphere(0.2f, 10.0f, 10.0f);
|
||||
DependencyManager::get<GeometryCache>()->renderSphere(0.2f, 10.0f, 10.0f, glm::vec4(0, 1, 0, .5f));
|
||||
glPopMatrix();
|
||||
|
||||
// Head Sphere
|
||||
position = headPosition;
|
||||
glPushMatrix();
|
||||
glColor4f(0, 1, 0, .5f);
|
||||
glTranslatef(position.x, position.y, position.z);
|
||||
DependencyManager::get<GeometryCache>()->renderSphere(0.15f, 10.0f, 10.0f);
|
||||
DependencyManager::get<GeometryCache>()->renderSphere(0.15f, 10.0f, 10.0f, glm::vec4(0, 1, 0, .5f));
|
||||
glPopMatrix();
|
||||
}
|
||||
|
||||
|
@ -1958,14 +1956,13 @@ void MyAvatar::renderLaserPointers() {
|
|||
for (size_t i = 0; i < getHand()->getNumPalms(); ++i) {
|
||||
PalmData& palm = getHand()->getPalms()[i];
|
||||
if (palm.isActive()) {
|
||||
glColor4f(0, 1, 1, 1);
|
||||
glm::vec3 tip = getLaserPointerTipPosition(&palm);
|
||||
glm::vec3 root = palm.getPosition();
|
||||
|
||||
//Scale the root vector with the avatar scale
|
||||
scaleVectorRelativeToPosition(root);
|
||||
|
||||
Avatar::renderJointConnectingCone(root, tip, PALM_TIP_ROD_RADIUS, PALM_TIP_ROD_RADIUS);
|
||||
Avatar::renderJointConnectingCone(root, tip, PALM_TIP_ROD_RADIUS, PALM_TIP_ROD_RADIUS, glm::vec4(0, 1, 1, 1));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -354,7 +354,7 @@ void SkeletonModel::renderJointConstraints(int jointIndex) {
|
|||
} else {
|
||||
otherAxis.x = 1.0f;
|
||||
}
|
||||
glColor4f(otherAxis.r, otherAxis.g, otherAxis.b, 0.75f);
|
||||
glm::vec4 color(otherAxis.r, otherAxis.g, otherAxis.b, 0.75f);
|
||||
|
||||
QVector<glm::vec3> points;
|
||||
points << glm::vec3(0.0f, 0.0f, 0.0f);
|
||||
|
@ -366,8 +366,8 @@ void SkeletonModel::renderJointConstraints(int jointIndex) {
|
|||
}
|
||||
// TODO: this is really inefficient constantly recreating these vertices buffers. It would be
|
||||
// better if the skeleton model cached these buffers for each of the joints they are rendering
|
||||
geometryCache->updateVertices(_triangleFanID, points);
|
||||
geometryCache->renderVertices(GL_TRIANGLE_FAN, _triangleFanID);
|
||||
geometryCache->updateVertices(_triangleFanID, points, color);
|
||||
geometryCache->renderVertices(gpu::TRIANGLE_FAN, _triangleFanID);
|
||||
|
||||
}
|
||||
glPopMatrix();
|
||||
|
@ -396,14 +396,14 @@ void SkeletonModel::renderOrientationDirections(int jointIndex, glm::vec3 positi
|
|||
glm::vec3 pUp = position + orientation * IDENTITY_UP * size;
|
||||
glm::vec3 pFront = position + orientation * IDENTITY_FRONT * size;
|
||||
|
||||
glColor3f(1.0f, 0.0f, 0.0f);
|
||||
geometryCache->renderLine(position, pRight, jointLineIDs._right);
|
||||
glm::vec3 red(1.0f, 0.0f, 0.0f);
|
||||
geometryCache->renderLine(position, pRight, red, jointLineIDs._right);
|
||||
|
||||
glColor3f(0.0f, 1.0f, 0.0f);
|
||||
geometryCache->renderLine(position, pUp, jointLineIDs._up);
|
||||
glm::vec3 green(0.0f, 1.0f, 0.0f);
|
||||
geometryCache->renderLine(position, pUp, green, jointLineIDs._up);
|
||||
|
||||
glColor3f(0.0f, 0.0f, 1.0f);
|
||||
geometryCache->renderLine(position, pFront, jointLineIDs._front);
|
||||
glm::vec3 blue(0.0f, 0.0f, 1.0f);
|
||||
geometryCache->renderLine(position, pFront, blue, jointLineIDs._front);
|
||||
}
|
||||
|
||||
|
||||
|
@ -601,10 +601,8 @@ void SkeletonModel::renderRagdoll() {
|
|||
glm::vec3 position = points[i]._position - simulationTranslation;
|
||||
glTranslatef(position.x, position.y, position.z);
|
||||
// draw each point as a yellow hexagon with black border
|
||||
glColor4f(0.0f, 0.0f, 0.0f, alpha);
|
||||
geometryCache->renderSphere(radius2, BALL_SUBDIVISIONS, BALL_SUBDIVISIONS);
|
||||
glColor4f(1.0f, 1.0f, 0.0f, alpha);
|
||||
geometryCache->renderSphere(radius1, BALL_SUBDIVISIONS, BALL_SUBDIVISIONS);
|
||||
geometryCache->renderSphere(radius2, BALL_SUBDIVISIONS, BALL_SUBDIVISIONS, glm::vec4(0.0f, 0.0f, 0.0f, alpha));
|
||||
geometryCache->renderSphere(radius1, BALL_SUBDIVISIONS, BALL_SUBDIVISIONS, glm::vec4(1.0f, 1.0f, 0.0f, alpha));
|
||||
glPopMatrix();
|
||||
}
|
||||
glPopMatrix();
|
||||
|
@ -953,9 +951,8 @@ void SkeletonModel::renderBoundingCollisionShapes(float alpha) {
|
|||
_boundingShape.getEndPoint(endPoint);
|
||||
endPoint = endPoint - _translation;
|
||||
glTranslatef(endPoint.x, endPoint.y, endPoint.z);
|
||||
glColor4f(0.6f, 0.6f, 0.8f, alpha);
|
||||
auto geometryCache = DependencyManager::get<GeometryCache>();
|
||||
geometryCache->renderSphere(_boundingShape.getRadius(), BALL_SUBDIVISIONS, BALL_SUBDIVISIONS);
|
||||
geometryCache->renderSphere(_boundingShape.getRadius(), BALL_SUBDIVISIONS, BALL_SUBDIVISIONS, glm::vec4(0.6f, 0.6f, 0.8f, alpha));
|
||||
|
||||
// draw a yellow sphere at the capsule startpoint
|
||||
glm::vec3 startPoint;
|
||||
|
@ -963,13 +960,11 @@ void SkeletonModel::renderBoundingCollisionShapes(float alpha) {
|
|||
startPoint = startPoint - _translation;
|
||||
glm::vec3 axis = endPoint - startPoint;
|
||||
glTranslatef(-axis.x, -axis.y, -axis.z);
|
||||
glColor4f(0.8f, 0.8f, 0.6f, alpha);
|
||||
geometryCache->renderSphere(_boundingShape.getRadius(), BALL_SUBDIVISIONS, BALL_SUBDIVISIONS);
|
||||
geometryCache->renderSphere(_boundingShape.getRadius(), BALL_SUBDIVISIONS, BALL_SUBDIVISIONS, glm::vec4(0.8f, 0.8f, 0.6f, alpha));
|
||||
|
||||
// draw a green cylinder between the two points
|
||||
glm::vec3 origin(0.0f);
|
||||
glColor4f(0.6f, 0.8f, 0.6f, alpha);
|
||||
Avatar::renderJointConnectingCone( origin, axis, _boundingShape.getRadius(), _boundingShape.getRadius());
|
||||
Avatar::renderJointConnectingCone( origin, axis, _boundingShape.getRadius(), _boundingShape.getRadius(), glm::vec4(0.6f, 0.8f, 0.6f, alpha));
|
||||
|
||||
glPopMatrix();
|
||||
}
|
||||
|
@ -998,8 +993,7 @@ void SkeletonModel::renderJointCollisionShapes(float alpha) {
|
|||
glm::vec3 position = shape->getTranslation() - simulationTranslation;
|
||||
glTranslatef(position.x, position.y, position.z);
|
||||
// draw a grey sphere at shape position
|
||||
glColor4f(0.75f, 0.75f, 0.75f, alpha);
|
||||
geometryCache->renderSphere(shape->getBoundingRadius(), BALL_SUBDIVISIONS, BALL_SUBDIVISIONS);
|
||||
geometryCache->renderSphere(shape->getBoundingRadius(), BALL_SUBDIVISIONS, BALL_SUBDIVISIONS, glm::vec4(0.75f, 0.75f, 0.75f, alpha));
|
||||
} else if (shape->getType() == CAPSULE_SHAPE) {
|
||||
CapsuleShape* capsule = static_cast<CapsuleShape*>(shape);
|
||||
|
||||
|
@ -1008,8 +1002,7 @@ void SkeletonModel::renderJointCollisionShapes(float alpha) {
|
|||
capsule->getEndPoint(endPoint);
|
||||
endPoint = endPoint - simulationTranslation;
|
||||
glTranslatef(endPoint.x, endPoint.y, endPoint.z);
|
||||
glColor4f(0.6f, 0.6f, 0.8f, alpha);
|
||||
geometryCache->renderSphere(capsule->getRadius(), BALL_SUBDIVISIONS, BALL_SUBDIVISIONS);
|
||||
geometryCache->renderSphere(capsule->getRadius(), BALL_SUBDIVISIONS, BALL_SUBDIVISIONS, glm::vec4(0.6f, 0.6f, 0.8f, alpha));
|
||||
|
||||
// draw a yellow sphere at the capsule startpoint
|
||||
glm::vec3 startPoint;
|
||||
|
@ -1017,13 +1010,11 @@ void SkeletonModel::renderJointCollisionShapes(float alpha) {
|
|||
startPoint = startPoint - simulationTranslation;
|
||||
glm::vec3 axis = endPoint - startPoint;
|
||||
glTranslatef(-axis.x, -axis.y, -axis.z);
|
||||
glColor4f(0.8f, 0.8f, 0.6f, alpha);
|
||||
geometryCache->renderSphere(capsule->getRadius(), BALL_SUBDIVISIONS, BALL_SUBDIVISIONS);
|
||||
geometryCache->renderSphere(capsule->getRadius(), BALL_SUBDIVISIONS, BALL_SUBDIVISIONS, glm::vec4(0.8f, 0.8f, 0.6f, alpha));
|
||||
|
||||
// draw a green cylinder between the two points
|
||||
glm::vec3 origin(0.0f);
|
||||
glColor4f(0.6f, 0.8f, 0.6f, alpha);
|
||||
Avatar::renderJointConnectingCone( origin, axis, capsule->getRadius(), capsule->getRadius());
|
||||
Avatar::renderJointConnectingCone( origin, axis, capsule->getRadius(), capsule->getRadius(), glm::vec4(0.6f, 0.8f, 0.6f, alpha));
|
||||
}
|
||||
glPopMatrix();
|
||||
}
|
||||
|
|
|
@ -219,6 +219,6 @@ void PrioVR::renderCalibrationCountdown() {
|
|||
auto glCanvas = DependencyManager::get<GLCanvas>();
|
||||
textRenderer->draw((glCanvas->width() - textRenderer->computeWidth(text.constData())) / 2,
|
||||
glCanvas->height() / 2,
|
||||
text);
|
||||
text, glm::vec4(1,1,1,1));
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -43,12 +43,11 @@ void OctreeFade::render() {
|
|||
glDisable(GL_LIGHTING);
|
||||
glPushMatrix();
|
||||
glScalef(TREE_SCALE, TREE_SCALE, TREE_SCALE);
|
||||
glColor4f(red, green, blue, opacity);
|
||||
glTranslatef(voxelDetails.x + voxelDetails.s * 0.5f,
|
||||
voxelDetails.y + voxelDetails.s * 0.5f,
|
||||
voxelDetails.z + voxelDetails.s * 0.5f);
|
||||
glLineWidth(1.0f);
|
||||
DependencyManager::get<GeometryCache>()->renderSolidCube(voxelDetails.s);
|
||||
DependencyManager::get<GeometryCache>()->renderSolidCube(voxelDetails.s, glm::vec4(red, green, blue, opacity));
|
||||
glLineWidth(1.0f);
|
||||
glPopMatrix();
|
||||
glEnable(GL_LIGHTING);
|
||||
|
|
|
@ -119,10 +119,16 @@ void ApplicationOverlay::renderReticle(glm::quat orientation, float alpha) {
|
|||
glm::vec3 topRight = getPoint(-reticleSize / 2.0f, -reticleSize / 2.0f);
|
||||
glm::vec3 bottomLeft = getPoint(reticleSize / 2.0f, reticleSize / 2.0f);
|
||||
glm::vec3 bottomRight = getPoint(-reticleSize / 2.0f, reticleSize / 2.0f);
|
||||
glColor4f(RETICLE_COLOR[0], RETICLE_COLOR[1], RETICLE_COLOR[2], alpha);
|
||||
|
||||
// TODO: this version of renderQuad() needs to take a color
|
||||
glm::vec4 reticleColor = { RETICLE_COLOR[0], RETICLE_COLOR[1], RETICLE_COLOR[2], alpha };
|
||||
|
||||
|
||||
|
||||
DependencyManager::get<GeometryCache>()->renderQuad(topLeft, bottomLeft, bottomRight, topRight,
|
||||
glm::vec2(0.0f, 0.0f), glm::vec2(1.0f, 0.0f),
|
||||
glm::vec2(1.0f, 1.0f), glm::vec2(0.0f, 1.0f), _reticleQuad);
|
||||
glm::vec2(1.0f, 1.0f), glm::vec2(0.0f, 1.0f),
|
||||
reticleColor, _reticleQuad);
|
||||
} glPopMatrix();
|
||||
}
|
||||
|
||||
|
@ -246,13 +252,13 @@ void ApplicationOverlay::displayOverlayTexture() {
|
|||
glDisable(GL_LIGHTING);
|
||||
glEnable(GL_BLEND);
|
||||
|
||||
glColor4f(1.0f, 1.0f, 1.0f, _alpha);
|
||||
glm::vec2 topLeft(0.0f, 0.0f);
|
||||
glm::vec2 bottomRight(glCanvas->getDeviceWidth(), glCanvas->getDeviceHeight());
|
||||
glm::vec2 texCoordTopLeft(0.0f, 1.0f);
|
||||
glm::vec2 texCoordBottomRight(1.0f, 0.0f);
|
||||
|
||||
DependencyManager::get<GeometryCache>()->renderQuad(topLeft, bottomRight, texCoordTopLeft, texCoordBottomRight);
|
||||
DependencyManager::get<GeometryCache>()->renderQuad(topLeft, bottomRight, texCoordTopLeft, texCoordBottomRight,
|
||||
glm::vec4(1.0f, 1.0f, 1.0f, _alpha));
|
||||
|
||||
} glPopMatrix();
|
||||
|
||||
|
@ -315,8 +321,6 @@ void ApplicationOverlay::displayOverlayTextureOculus(Camera& whichCamera) {
|
|||
glDepthMask(GL_FALSE);
|
||||
glDisable(GL_ALPHA_TEST);
|
||||
|
||||
glColor4f(1.0f, 1.0f, 1.0f, _alpha);
|
||||
|
||||
static float textureFOV = 0.0f, textureAspectRatio = 1.0f;
|
||||
if (textureFOV != _textureFov ||
|
||||
textureAspectRatio != _textureAspectRatio) {
|
||||
|
@ -373,7 +377,7 @@ void ApplicationOverlay::displayOverlayTexture3DTV(Camera& whichCamera, float as
|
|||
glTranslatef(pos.x, pos.y, pos.z);
|
||||
glRotatef(glm::degrees(glm::angle(rot)), axis.x, axis.y, axis.z);
|
||||
|
||||
glColor4f(1.0f, 1.0f, 1.0f, _alpha);
|
||||
glm::vec4 overlayColor = {1.0f, 1.0f, 1.0f, _alpha};
|
||||
|
||||
//Render
|
||||
const GLfloat distance = 1.0f;
|
||||
|
@ -392,7 +396,8 @@ void ApplicationOverlay::displayOverlayTexture3DTV(Camera& whichCamera, float as
|
|||
glm::vec3(x + quadWidth, y, -distance),
|
||||
glm::vec3(x, y, -distance),
|
||||
glm::vec2(0.0f, 1.0f), glm::vec2(1.0f, 1.0f),
|
||||
glm::vec2(1.0f, 0.0f), glm::vec2(0.0f, 0.0f));
|
||||
glm::vec2(1.0f, 0.0f), glm::vec2(0.0f, 0.0f),
|
||||
overlayColor);
|
||||
|
||||
auto glCanvas = DependencyManager::get<GLCanvas>();
|
||||
if (_crosshairTexture == 0) {
|
||||
|
@ -408,7 +413,7 @@ void ApplicationOverlay::displayOverlayTexture3DTV(Camera& whichCamera, float as
|
|||
const float mouseX = (qApp->getMouseX() / (float)glCanvas->width()) * quadWidth;
|
||||
const float mouseY = (1.0 - (qApp->getMouseY() / (float)glCanvas->height())) * quadHeight;
|
||||
|
||||
glColor3f(RETICLE_COLOR[0], RETICLE_COLOR[1], RETICLE_COLOR[2]);
|
||||
glm::vec4 reticleColor = { RETICLE_COLOR[0], RETICLE_COLOR[1], RETICLE_COLOR[2], 1.0f };
|
||||
|
||||
DependencyManager::get<GeometryCache>()->renderQuad(glm::vec3(x + mouseX, y + mouseY, -distance),
|
||||
glm::vec3(x + mouseX + reticleSize, y + mouseY, -distance),
|
||||
|
@ -416,7 +421,7 @@ void ApplicationOverlay::displayOverlayTexture3DTV(Camera& whichCamera, float as
|
|||
glm::vec3(x + mouseX, y + mouseY - reticleSize, -distance),
|
||||
glm::vec2(0.0f, 0.0f), glm::vec2(1.0f, 0.0f),
|
||||
glm::vec2(1.0f, 1.0f), glm::vec2(0.0f, 1.0f),
|
||||
_reticleQuad);
|
||||
reticleColor, _reticleQuad);
|
||||
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
|
||||
|
@ -428,8 +433,6 @@ void ApplicationOverlay::displayOverlayTexture3DTV(Camera& whichCamera, float as
|
|||
|
||||
glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_CONSTANT_ALPHA, GL_ONE);
|
||||
glEnable(GL_LIGHTING);
|
||||
|
||||
glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
}
|
||||
|
||||
void ApplicationOverlay::computeOculusPickRay(float x, float y, glm::vec3& origin, glm::vec3& direction) const {
|
||||
|
@ -668,14 +671,13 @@ void ApplicationOverlay::renderControllerPointers() {
|
|||
mouseY += reticleSize / 2.0f;
|
||||
|
||||
|
||||
glColor3f(RETICLE_COLOR[0], RETICLE_COLOR[1], RETICLE_COLOR[2]);
|
||||
|
||||
glm::vec2 topLeft(mouseX, mouseY);
|
||||
glm::vec2 bottomRight(mouseX + reticleSize, mouseY - reticleSize);
|
||||
glm::vec2 texCoordTopLeft(0.0f, 0.0f);
|
||||
glm::vec2 texCoordBottomRight(1.0f, 1.0f);
|
||||
|
||||
DependencyManager::get<GeometryCache>()->renderQuad(topLeft, bottomRight, texCoordTopLeft, texCoordBottomRight);
|
||||
DependencyManager::get<GeometryCache>()->renderQuad(topLeft, bottomRight, texCoordTopLeft, texCoordBottomRight,
|
||||
glm::vec4(RETICLE_COLOR[0], RETICLE_COLOR[1], RETICLE_COLOR[2], 1.0f));
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -751,7 +753,7 @@ void ApplicationOverlay::renderMagnifier(glm::vec2 magPos, float sizeMult, bool
|
|||
border << bottomRight;
|
||||
border << topRight;
|
||||
border << topLeft;
|
||||
geometryCache->updateVertices(_magnifierBorder, border);
|
||||
geometryCache->updateVertices(_magnifierBorder, border, glm::vec4(1.0f, 0.0f, 0.0f, _alpha));
|
||||
|
||||
_previousMagnifierBottomLeft = bottomLeft;
|
||||
_previousMagnifierBottomRight = bottomRight;
|
||||
|
@ -764,18 +766,17 @@ void ApplicationOverlay::renderMagnifier(glm::vec2 magPos, float sizeMult, bool
|
|||
glDisable(GL_TEXTURE_2D);
|
||||
glLineWidth(1.0f);
|
||||
//Outer Line
|
||||
glColor4f(1.0f, 0.0f, 0.0f, _alpha);
|
||||
geometryCache->renderVertices(GL_LINE_STRIP, _magnifierBorder);
|
||||
geometryCache->renderVertices(gpu::LINE_STRIP, _magnifierBorder);
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
}
|
||||
glColor4f(1.0f, 1.0f, 1.0f, _alpha);
|
||||
glm::vec4 magnifierColor = { 1.0f, 1.0f, 1.0f, _alpha };
|
||||
|
||||
DependencyManager::get<GeometryCache>()->renderQuad(bottomLeft, bottomRight, topRight, topLeft,
|
||||
glm::vec2(magnifyULeft, magnifyVBottom),
|
||||
glm::vec2(magnifyURight, magnifyVBottom),
|
||||
glm::vec2(magnifyURight, magnifyVTop),
|
||||
glm::vec2(magnifyULeft, magnifyVTop),
|
||||
_magnifierQuad);
|
||||
magnifierColor, _magnifierQuad);
|
||||
|
||||
} glPopMatrix();
|
||||
}
|
||||
|
@ -804,9 +805,9 @@ void ApplicationOverlay::renderAudioMeter() {
|
|||
audioMeterY = AUDIO_METER_GAP + MUTE_ICON_PADDING;
|
||||
}
|
||||
|
||||
const float AUDIO_METER_BLUE[] = { 0.0, 0.0, 1.0 };
|
||||
const float AUDIO_METER_GREEN[] = { 0.0, 1.0, 0.0 };
|
||||
const float AUDIO_METER_RED[] = { 1.0, 0.0, 0.0 };
|
||||
const glm::vec4 AUDIO_METER_BLUE = { 0.0, 0.0, 1.0, 1.0 };
|
||||
const glm::vec4 AUDIO_METER_GREEN = { 0.0, 1.0, 0.0, 1.0 };
|
||||
const glm::vec4 AUDIO_METER_RED = { 1.0, 0.0, 0.0, 1.0 };
|
||||
const float AUDIO_GREEN_START = 0.25 * AUDIO_METER_SCALE_WIDTH;
|
||||
const float AUDIO_RED_START = 0.80 * AUDIO_METER_SCALE_WIDTH;
|
||||
const float CLIPPING_INDICATOR_TIME = 1.0f;
|
||||
|
@ -841,59 +842,56 @@ void ApplicationOverlay::renderAudioMeter() {
|
|||
DependencyManager::get<AudioScope>()->render(glCanvas->width(), glCanvas->height());
|
||||
DependencyManager::get<AudioIOStatsRenderer>()->render(WHITE_TEXT, glCanvas->width(), glCanvas->height());
|
||||
|
||||
if (isClipping) {
|
||||
glColor3f(1, 0, 0);
|
||||
} else {
|
||||
glColor3f(0.475f, 0.475f, 0.475f);
|
||||
}
|
||||
|
||||
audioMeterY += AUDIO_METER_HEIGHT;
|
||||
|
||||
glColor3f(0, 0, 0);
|
||||
// Draw audio meter background Quad
|
||||
DependencyManager::get<GeometryCache>()->renderQuad(AUDIO_METER_X, audioMeterY, AUDIO_METER_WIDTH, AUDIO_METER_HEIGHT);
|
||||
DependencyManager::get<GeometryCache>()->renderQuad(AUDIO_METER_X, audioMeterY, AUDIO_METER_WIDTH, AUDIO_METER_HEIGHT,
|
||||
glm::vec4(0, 0, 0, 1));
|
||||
|
||||
if (audioLevel > AUDIO_RED_START) {
|
||||
glm::vec4 quadColor;
|
||||
if (!isClipping) {
|
||||
glColor3fv(AUDIO_METER_RED);
|
||||
quadColor = AUDIO_METER_RED;
|
||||
} else {
|
||||
glColor3f(1, 1, 1);
|
||||
quadColor = glm::vec4(1, 1, 1, 1);
|
||||
}
|
||||
// Draw Red Quad
|
||||
DependencyManager::get<GeometryCache>()->renderQuad(AUDIO_METER_X + AUDIO_METER_INSET + AUDIO_RED_START,
|
||||
audioMeterY + AUDIO_METER_INSET,
|
||||
audioLevel - AUDIO_RED_START,
|
||||
AUDIO_METER_HEIGHT - AUDIO_METER_INSET,
|
||||
AUDIO_METER_HEIGHT - AUDIO_METER_INSET, quadColor,
|
||||
_audioRedQuad);
|
||||
|
||||
audioLevel = AUDIO_RED_START;
|
||||
}
|
||||
|
||||
if (audioLevel > AUDIO_GREEN_START) {
|
||||
glm::vec4 quadColor;
|
||||
if (!isClipping) {
|
||||
glColor3fv(AUDIO_METER_GREEN);
|
||||
quadColor = AUDIO_METER_GREEN;
|
||||
} else {
|
||||
glColor3f(1, 1, 1);
|
||||
quadColor = glm::vec4(1, 1, 1, 1);
|
||||
}
|
||||
// Draw Green Quad
|
||||
DependencyManager::get<GeometryCache>()->renderQuad(AUDIO_METER_X + AUDIO_METER_INSET + AUDIO_GREEN_START,
|
||||
audioMeterY + AUDIO_METER_INSET,
|
||||
audioLevel - AUDIO_GREEN_START,
|
||||
AUDIO_METER_HEIGHT - AUDIO_METER_INSET,
|
||||
AUDIO_METER_HEIGHT - AUDIO_METER_INSET, quadColor,
|
||||
_audioGreenQuad);
|
||||
|
||||
audioLevel = AUDIO_GREEN_START;
|
||||
}
|
||||
// Draw Blue Quad
|
||||
glm::vec4 quadColor;
|
||||
if (!isClipping) {
|
||||
glColor3fv(AUDIO_METER_BLUE);
|
||||
quadColor = AUDIO_METER_BLUE;
|
||||
} else {
|
||||
glColor3f(1, 1, 1);
|
||||
quadColor = glm::vec4(1, 1, 1, 1);
|
||||
}
|
||||
// Draw Blue (low level) quad
|
||||
DependencyManager::get<GeometryCache>()->renderQuad(AUDIO_METER_X + AUDIO_METER_INSET,
|
||||
audioMeterY + AUDIO_METER_INSET,
|
||||
audioLevel, AUDIO_METER_HEIGHT - AUDIO_METER_INSET,
|
||||
audioLevel, AUDIO_METER_HEIGHT - AUDIO_METER_INSET, quadColor,
|
||||
_audioBlueQuad);
|
||||
}
|
||||
|
||||
|
@ -946,23 +944,24 @@ void ApplicationOverlay::renderDomainConnectionStatusBorder() {
|
|||
int height = glCanvas->height();
|
||||
|
||||
if (width != _previousBorderWidth || height != _previousBorderHeight) {
|
||||
glm::vec4 color(CONNECTION_STATUS_BORDER_COLOR[0],
|
||||
CONNECTION_STATUS_BORDER_COLOR[1],
|
||||
CONNECTION_STATUS_BORDER_COLOR[2], 1.0f);
|
||||
|
||||
QVector<glm::vec2> border;
|
||||
border << glm::vec2(0, 0);
|
||||
border << glm::vec2(0, height);
|
||||
border << glm::vec2(width, height);
|
||||
border << glm::vec2(width, 0);
|
||||
border << glm::vec2(0, 0);
|
||||
geometryCache->updateVertices(_domainStatusBorder, border);
|
||||
geometryCache->updateVertices(_domainStatusBorder, border, color);
|
||||
_previousBorderWidth = width;
|
||||
_previousBorderHeight = height;
|
||||
}
|
||||
|
||||
glColor3f(CONNECTION_STATUS_BORDER_COLOR[0],
|
||||
CONNECTION_STATUS_BORDER_COLOR[1],
|
||||
CONNECTION_STATUS_BORDER_COLOR[2]);
|
||||
glLineWidth(CONNECTION_STATUS_BORDER_LINE_WIDTH);
|
||||
|
||||
geometryCache->renderVertices(GL_LINE_STRIP, _domainStatusBorder);
|
||||
geometryCache->renderVertices(gpu::LINE_STRIP, _domainStatusBorder);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -86,20 +86,21 @@ void BandwidthMeter::Stream::updateValue(double amount) {
|
|||
glm::clamp(dt / _msToAverage, 0.0, 1.0));
|
||||
}
|
||||
|
||||
void BandwidthMeter::setColorRGBA(unsigned c) {
|
||||
glm::vec4 BandwidthMeter::getColorRGBA(unsigned c) {
|
||||
|
||||
glColor4ub(GLubyte( c >> 24),
|
||||
GLubyte((c >> 16) & 0xff),
|
||||
GLubyte((c >> 8) & 0xff),
|
||||
GLubyte( c & 0xff));
|
||||
float r = (c >> 24) / 255.0f;
|
||||
float g = ((c >> 16) & 0xff) / 255.0f;
|
||||
float b = ((c >> 8) & 0xff) / 255.0f;
|
||||
float a = (c & 0xff) / 255.0f;
|
||||
return glm::vec4(r,g,b,a);
|
||||
}
|
||||
|
||||
void BandwidthMeter::renderBox(int x, int y, int w, int h) {
|
||||
DependencyManager::get<GeometryCache>()->renderQuad(x, y, w, h);
|
||||
void BandwidthMeter::renderBox(int x, int y, int w, int h, unsigned c) {
|
||||
DependencyManager::get<GeometryCache>()->renderQuad(x, y, w, h, getColorRGBA(c));
|
||||
}
|
||||
|
||||
void BandwidthMeter::renderVerticalLine(int x, int y, int h) {
|
||||
DependencyManager::get<GeometryCache>()->renderLine(glm::vec2(x, y), glm::vec2(x, y + h));
|
||||
void BandwidthMeter::renderVerticalLine(int x, int y, int h, unsigned c) {
|
||||
DependencyManager::get<GeometryCache>()->renderLine(glm::vec2(x, y), glm::vec2(x, y + h), getColorRGBA(c));
|
||||
}
|
||||
|
||||
inline int BandwidthMeter::centered(int subject, int object) {
|
||||
|
@ -155,15 +156,16 @@ void BandwidthMeter::render(int screenWidth, int screenHeight) {
|
|||
glTranslatef((float)barX, (float)y, 0.0f);
|
||||
|
||||
// Render captions
|
||||
setColorRGBA(COLOR_TEXT);
|
||||
_textRenderer->draw(barWidth + SPACING_LEFT_CAPTION_UNIT, textYcenteredLine, CAPTION_UNIT);
|
||||
_textRenderer->draw(-labelWidthIn - SPACING_RIGHT_CAPTION_IN_OUT, textYupperLine, CAPTION_IN);
|
||||
_textRenderer->draw(-labelWidthOut - SPACING_RIGHT_CAPTION_IN_OUT, textYlowerLine, CAPTION_OUT);
|
||||
glm::vec4 textColor = getColorRGBA(COLOR_TEXT);
|
||||
_textRenderer->draw(barWidth + SPACING_LEFT_CAPTION_UNIT, textYcenteredLine, CAPTION_UNIT, textColor);
|
||||
_textRenderer->draw(-labelWidthIn - SPACING_RIGHT_CAPTION_IN_OUT, textYupperLine, CAPTION_IN, textColor);
|
||||
_textRenderer->draw(-labelWidthOut - SPACING_RIGHT_CAPTION_IN_OUT, textYlowerLine, CAPTION_OUT, textColor);
|
||||
|
||||
// Render vertical lines for the frame
|
||||
setColorRGBA(COLOR_FRAME);
|
||||
renderVerticalLine(0, 0, h);
|
||||
renderVerticalLine(barWidth, 0, h);
|
||||
// TODO: I think there may be a bug in this newest code and/or the GeometryCache code, because it seems like
|
||||
// sometimes the bandwidth meter doesn't render the vertical lines
|
||||
renderVerticalLine(0, 0, h, COLOR_FRAME);
|
||||
renderVerticalLine(barWidth, 0, h, COLOR_FRAME);
|
||||
|
||||
// Adjust scale
|
||||
int steps;
|
||||
|
@ -192,9 +194,8 @@ void BandwidthMeter::render(int screenWidth, int screenHeight) {
|
|||
}
|
||||
|
||||
// Render scale indicators
|
||||
setColorRGBA(COLOR_INDICATOR);
|
||||
for (int j = NUMBER_OF_MARKERS; --j > 0;) {
|
||||
renderVerticalLine((barWidth * j) / NUMBER_OF_MARKERS, 0, h);
|
||||
renderVerticalLine((barWidth * j) / NUMBER_OF_MARKERS, 0, h, COLOR_INDICATOR);
|
||||
}
|
||||
|
||||
// Render bars
|
||||
|
@ -205,30 +206,27 @@ void BandwidthMeter::render(int screenWidth, int screenHeight) {
|
|||
int wIn = (int)(barWidth * inputStream(chIdx).getValue() * UNIT_SCALE / scaleMax);
|
||||
int wOut = (int)(barWidth * outputStream(chIdx).getValue() * UNIT_SCALE / scaleMax);
|
||||
|
||||
setColorRGBA(channelInfo(chIdx).colorRGBA);
|
||||
|
||||
if (wIn > 0) {
|
||||
renderBox(xIn, 0, wIn, barHeight);
|
||||
renderBox(xIn, 0, wIn, barHeight, channelInfo(chIdx).colorRGBA);
|
||||
}
|
||||
xIn += wIn;
|
||||
|
||||
if (wOut > 0) {
|
||||
renderBox(xOut, h - barHeight, wOut, barHeight);
|
||||
renderBox(xOut, h - barHeight, wOut, barHeight, channelInfo(chIdx).colorRGBA);
|
||||
}
|
||||
xOut += wOut;
|
||||
}
|
||||
|
||||
// Render numbers
|
||||
char fmtBuf[8];
|
||||
setColorRGBA(COLOR_TEXT);
|
||||
sprintf(fmtBuf, "%0.1f", totalIn);
|
||||
_textRenderer->draw(glm::max(xIn - fontMetrics.width(fmtBuf) - PADDING_HORIZ_VALUE,
|
||||
PADDING_HORIZ_VALUE),
|
||||
textYupperLine, fmtBuf);
|
||||
textYupperLine, fmtBuf, textColor);
|
||||
sprintf(fmtBuf, "%0.1f", totalOut);
|
||||
_textRenderer->draw(glm::max(xOut - fontMetrics.width(fmtBuf) - PADDING_HORIZ_VALUE,
|
||||
PADDING_HORIZ_VALUE),
|
||||
textYlowerLine, fmtBuf);
|
||||
textYlowerLine, fmtBuf, textColor);
|
||||
|
||||
glPopMatrix();
|
||||
|
||||
|
|
|
@ -73,9 +73,9 @@ public slots:
|
|||
void updateAudioOutputBytes(int numBytes) { outputStream(AUDIO).updateValue(numBytes); }
|
||||
|
||||
private:
|
||||
static void setColorRGBA(unsigned c);
|
||||
static void renderBox(int x, int y, int w, int h);
|
||||
static void renderVerticalLine(int x, int y, int h);
|
||||
static glm::vec4 getColorRGBA(unsigned c);
|
||||
static void renderBox(int x, int y, int w, int h, unsigned c);
|
||||
static void renderVerticalLine(int x, int y, int h, unsigned c);
|
||||
|
||||
static inline int centered(int subject, int object);
|
||||
|
||||
|
|
|
@ -356,11 +356,9 @@ void MetavoxelEditor::render() {
|
|||
float scale = GRID_DIVISIONS * spacing;
|
||||
glScalef(scale, scale, scale);
|
||||
|
||||
glColor3f(GRID_BRIGHTNESS, GRID_BRIGHTNESS, GRID_BRIGHTNESS);
|
||||
|
||||
_gridProgram.bind();
|
||||
|
||||
DependencyManager::get<GeometryCache>()->renderGrid(GRID_DIVISIONS, GRID_DIVISIONS);
|
||||
DependencyManager::get<GeometryCache>()->renderGrid(GRID_DIVISIONS, GRID_DIVISIONS, glm::vec4(GRID_BRIGHTNESS, GRID_BRIGHTNESS, GRID_BRIGHTNESS, 1.0f));
|
||||
|
||||
_gridProgram.release();
|
||||
|
||||
|
@ -492,17 +490,17 @@ void BoxTool::render() {
|
|||
if (_state != HOVERING_STATE) {
|
||||
const float BOX_ALPHA = 0.25f;
|
||||
QColor color = getColor();
|
||||
glm::vec4 cubeColor;
|
||||
if (color.isValid()) {
|
||||
glColor4f(color.redF(), color.greenF(), color.blueF(), BOX_ALPHA);
|
||||
cubeColor = glm::vec4(color.redF(), color.greenF(), color.blueF(), BOX_ALPHA);
|
||||
} else {
|
||||
glColor4f(GRID_BRIGHTNESS, GRID_BRIGHTNESS, GRID_BRIGHTNESS, BOX_ALPHA);
|
||||
cubeColor = glm::vec4(GRID_BRIGHTNESS, GRID_BRIGHTNESS, GRID_BRIGHTNESS, BOX_ALPHA);
|
||||
}
|
||||
glEnable(GL_CULL_FACE);
|
||||
DependencyManager::get<GeometryCache>()->renderSolidCube(1.0f);
|
||||
DependencyManager::get<GeometryCache>()->renderSolidCube(1.0f, cubeColor);
|
||||
glDisable(GL_CULL_FACE);
|
||||
}
|
||||
glColor3f(GRID_BRIGHTNESS, GRID_BRIGHTNESS, GRID_BRIGHTNESS);
|
||||
DependencyManager::get<GeometryCache>()->renderWireCube(1.0f);
|
||||
DependencyManager::get<GeometryCache>()->renderWireCube(1.0f, glm::vec4(GRID_BRIGHTNESS, GRID_BRIGHTNESS, GRID_BRIGHTNESS, 1.0f));
|
||||
glPopMatrix();
|
||||
}
|
||||
|
||||
|
|
|
@ -127,8 +127,7 @@ void NodeBounds::draw() {
|
|||
float red, green, blue;
|
||||
getColorForNodeType(selectedNode->getType(), red, green, blue);
|
||||
|
||||
glColor4f(red, green, blue, 0.2f);
|
||||
DependencyManager::get<GeometryCache>()->renderSolidCube(1.0f);
|
||||
DependencyManager::get<GeometryCache>()->renderSolidCube(1.0f, glm::vec4(red, green, blue, 0.2f));
|
||||
|
||||
glPopMatrix();
|
||||
|
||||
|
@ -152,8 +151,7 @@ void NodeBounds::drawNodeBorder(const glm::vec3& center, float scale, float red,
|
|||
glTranslatef(center.x, center.y, center.z);
|
||||
glScalef(scale, scale, scale);
|
||||
glLineWidth(2.5);
|
||||
glColor3f(red, green, blue);
|
||||
DependencyManager::get<GeometryCache>()->renderWireCube(1.0f);
|
||||
DependencyManager::get<GeometryCache>()->renderWireCube(1.0f, glm::vec4(red, green, blue, 1.0f));
|
||||
glPopMatrix();
|
||||
}
|
||||
|
||||
|
@ -179,9 +177,10 @@ void NodeBounds::drawOverlay() {
|
|||
int mouseX = application->getTrueMouseX(),
|
||||
mouseY = application->getTrueMouseY(),
|
||||
textWidth = widthText(TEXT_SCALE, 0, _overlayText);
|
||||
glColor4f(0.4f, 0.4f, 0.4f, 0.6f);
|
||||
renderBevelCornersRect(mouseX + MOUSE_OFFSET, mouseY - TEXT_HEIGHT - PADDING,
|
||||
textWidth + (2 * PADDING), TEXT_HEIGHT + (2 * PADDING), BACKGROUND_BEVEL);
|
||||
DependencyManager::get<GeometryCache>()->renderBevelCornersRect(
|
||||
mouseX + MOUSE_OFFSET, mouseY - TEXT_HEIGHT - PADDING,
|
||||
textWidth + (2 * PADDING), TEXT_HEIGHT + (2 * PADDING), BACKGROUND_BEVEL,
|
||||
glm::vec4(0.4f, 0.4f, 0.4f, 0.6f));
|
||||
drawText(mouseX + MOUSE_OFFSET + PADDING, mouseY, TEXT_SCALE, ROTATION, FONT, _overlayText, TEXT_COLOR);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -105,10 +105,11 @@ void RearMirrorTools::displayIcon(QRect bounds, QRect iconBounds, GLuint texture
|
|||
glDisable(GL_LIGHTING);
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
|
||||
glm::vec4 quadColor;
|
||||
if (selected) {
|
||||
glColor3f(.5f, .5f, .5f);
|
||||
quadColor = glm::vec4(.5f, .5f, .5f, 1.0f);
|
||||
} else {
|
||||
glColor3f(1, 1, 1);
|
||||
quadColor = glm::vec4(1, 1, 1, 1);
|
||||
}
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D, textureId);
|
||||
|
@ -118,7 +119,7 @@ void RearMirrorTools::displayIcon(QRect bounds, QRect iconBounds, GLuint texture
|
|||
glm::vec2 texCoordTopLeft(0.0f, 1.0f);
|
||||
glm::vec2 texCoordBottomRight(1.0f, 0.0f);
|
||||
|
||||
DependencyManager::get<GeometryCache>()->renderQuad(topLeft, bottomRight, texCoordTopLeft, texCoordBottomRight);
|
||||
DependencyManager::get<GeometryCache>()->renderQuad(topLeft, bottomRight, texCoordTopLeft, texCoordBottomRight, quadColor);
|
||||
|
||||
glPopMatrix();
|
||||
|
||||
|
|
|
@ -159,14 +159,12 @@ void Stats::resetWidth(int width, int horizontalOffset) {
|
|||
|
||||
// translucent background box that makes stats more readable
|
||||
void Stats::drawBackground(unsigned int rgba, int x, int y, int width, int height) {
|
||||
glColor4f(((rgba >> 24) & 0xff) / 255.0f,
|
||||
((rgba >> 16) & 0xff) / 255.0f,
|
||||
((rgba >> 8) & 0xff) / 255.0f,
|
||||
(rgba & 0xff) / 255.0f);
|
||||
glm::vec4 color(((rgba >> 24) & 0xff) / 255.0f,
|
||||
((rgba >> 16) & 0xff) / 255.0f,
|
||||
((rgba >> 8) & 0xff) / 255.0f,
|
||||
(rgba & 0xff) / 255.0f);
|
||||
|
||||
DependencyManager::get<GeometryCache>()->renderQuad(x, y, width, height);
|
||||
|
||||
glColor4f(1, 1, 1, 1);
|
||||
DependencyManager::get<GeometryCache>()->renderQuad(x, y, width, height, color);
|
||||
}
|
||||
|
||||
bool Stats::includeTimingRecord(const QString& name) {
|
||||
|
|
|
@ -95,7 +95,6 @@ void BillboardOverlay::render(RenderArgs* args) {
|
|||
const float MAX_COLOR = 255.0f;
|
||||
xColor color = getColor();
|
||||
float alpha = getAlpha();
|
||||
glColor4f(color.red / MAX_COLOR, color.green / MAX_COLOR, color.blue / MAX_COLOR, alpha);
|
||||
|
||||
glm::vec2 topLeft(-x, -y);
|
||||
glm::vec2 bottomRight(x, y);
|
||||
|
@ -104,7 +103,8 @@ void BillboardOverlay::render(RenderArgs* args) {
|
|||
glm::vec2 texCoordBottomRight(((float)_fromImage.x() + (float)_fromImage.width()) / (float)_size.width(),
|
||||
((float)_fromImage.y() + (float)_fromImage.height()) / _size.height());
|
||||
|
||||
DependencyManager::get<GeometryCache>()->renderQuad(topLeft, bottomRight, texCoordTopLeft, texCoordBottomRight);
|
||||
DependencyManager::get<GeometryCache>()->renderQuad(topLeft, bottomRight, texCoordTopLeft, texCoordBottomRight,
|
||||
glm::vec4(color.red / MAX_COLOR, color.green / MAX_COLOR, color.blue / MAX_COLOR, alpha));
|
||||
|
||||
}
|
||||
} glPopMatrix();
|
||||
|
|
|
@ -95,10 +95,9 @@ void Circle3DOverlay::render(RenderArgs* args) {
|
|||
const float SLICE_ANGLE = FULL_CIRCLE / SLICES;
|
||||
|
||||
//const int slices = 15;
|
||||
xColor color = getColor();
|
||||
xColor colorX = getColor();
|
||||
const float MAX_COLOR = 255.0f;
|
||||
glColor4f(color.red / MAX_COLOR, color.green / MAX_COLOR, color.blue / MAX_COLOR, alpha);
|
||||
|
||||
glm::vec4 color(colorX.red / MAX_COLOR, colorX.green / MAX_COLOR, colorX.blue / MAX_COLOR, alpha);
|
||||
|
||||
glDisable(GL_LIGHTING);
|
||||
|
||||
|
@ -162,10 +161,10 @@ void Circle3DOverlay::render(RenderArgs* args) {
|
|||
|
||||
points << lastOuterPoint << lastInnerPoint;
|
||||
|
||||
geometryCache->updateVertices(_quadVerticesID, points);
|
||||
geometryCache->updateVertices(_quadVerticesID, points, color);
|
||||
}
|
||||
|
||||
geometryCache->renderVertices(GL_QUAD_STRIP, _quadVerticesID);
|
||||
geometryCache->renderVertices(gpu::QUAD_STRIP, _quadVerticesID);
|
||||
|
||||
} else {
|
||||
if (_lineVerticesID == GeometryCache::UNKNOWN_ID) {
|
||||
|
@ -200,13 +199,13 @@ void Circle3DOverlay::render(RenderArgs* args) {
|
|||
glm::vec2 lastPoint(cos(angleInRadians) * outerRadius, sin(angleInRadians) * outerRadius);
|
||||
points << lastPoint;
|
||||
|
||||
geometryCache->updateVertices(_lineVerticesID, points);
|
||||
geometryCache->updateVertices(_lineVerticesID, points, color);
|
||||
}
|
||||
|
||||
if (getIsDashedLine()) {
|
||||
geometryCache->renderVertices(GL_LINES, _lineVerticesID);
|
||||
geometryCache->renderVertices(gpu::LINES, _lineVerticesID);
|
||||
} else {
|
||||
geometryCache->renderVertices(GL_LINE_STRIP, _lineVerticesID);
|
||||
geometryCache->renderVertices(gpu::LINE_STRIP, _lineVerticesID);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -270,17 +269,20 @@ void Circle3DOverlay::render(RenderArgs* args) {
|
|||
}
|
||||
}
|
||||
|
||||
geometryCache->updateVertices(_majorTicksVerticesID, majorPoints);
|
||||
geometryCache->updateVertices(_minorTicksVerticesID, minorPoints);
|
||||
xColor majorColorX = getMajorTickMarksColor();
|
||||
glm::vec4 majorColor(majorColorX.red / MAX_COLOR, majorColorX.green / MAX_COLOR, majorColorX.blue / MAX_COLOR, alpha);
|
||||
|
||||
geometryCache->updateVertices(_majorTicksVerticesID, majorPoints, majorColor);
|
||||
|
||||
xColor minorColorX = getMinorTickMarksColor();
|
||||
glm::vec4 minorColor(minorColorX.red / MAX_COLOR, minorColorX.green / MAX_COLOR, minorColorX.blue / MAX_COLOR, alpha);
|
||||
|
||||
geometryCache->updateVertices(_minorTicksVerticesID, minorPoints, minorColor);
|
||||
}
|
||||
|
||||
xColor majorColor = getMajorTickMarksColor();
|
||||
glColor4f(majorColor.red / MAX_COLOR, majorColor.green / MAX_COLOR, majorColor.blue / MAX_COLOR, alpha);
|
||||
geometryCache->renderVertices(GL_LINES, _majorTicksVerticesID);
|
||||
geometryCache->renderVertices(gpu::LINES, _majorTicksVerticesID);
|
||||
|
||||
xColor minorColor = getMinorTickMarksColor();
|
||||
glColor4f(minorColor.red / MAX_COLOR, minorColor.green / MAX_COLOR, minorColor.blue / MAX_COLOR, alpha);
|
||||
geometryCache->renderVertices(GL_LINES, _minorTicksVerticesID);
|
||||
geometryCache->renderVertices(gpu::LINES, _minorTicksVerticesID);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -47,7 +47,7 @@ void Cube3DOverlay::render(RenderArgs* args) {
|
|||
float alpha = getAlpha();
|
||||
xColor color = getColor();
|
||||
const float MAX_COLOR = 255.0f;
|
||||
glColor4f(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);
|
||||
|
||||
|
@ -74,13 +74,12 @@ void Cube3DOverlay::render(RenderArgs* args) {
|
|||
// enough for the use-case.
|
||||
glDepthMask(GL_FALSE);
|
||||
glPushMatrix();
|
||||
glColor4f(1.0f, 1.0f, 1.0f, alpha);
|
||||
glScalef(dimensions.x * _borderSize, dimensions.y * _borderSize, dimensions.z * _borderSize);
|
||||
|
||||
if (_drawOnHUD) {
|
||||
DependencyManager::get<GeometryCache>()->renderSolidCube(1.0f);
|
||||
DependencyManager::get<GeometryCache>()->renderSolidCube(1.0f, glm::vec4(1.0f, 1.0f, 1.0f, alpha));
|
||||
} else {
|
||||
DependencyManager::get<DeferredLightingEffect>()->renderSolidCube(1.0f);
|
||||
DependencyManager::get<DeferredLightingEffect>()->renderSolidCube(1.0f, glm::vec4(1.0f, 1.0f, 1.0f, alpha));
|
||||
}
|
||||
|
||||
glPopMatrix();
|
||||
|
@ -88,12 +87,11 @@ void Cube3DOverlay::render(RenderArgs* args) {
|
|||
}
|
||||
|
||||
glPushMatrix();
|
||||
glColor4f(color.red / MAX_COLOR, color.green / MAX_COLOR, color.blue / MAX_COLOR, alpha);
|
||||
glScalef(dimensions.x, dimensions.y, dimensions.z);
|
||||
if (_drawOnHUD) {
|
||||
DependencyManager::get<GeometryCache>()->renderSolidCube(1.0f);
|
||||
DependencyManager::get<GeometryCache>()->renderSolidCube(1.0f, cubeColor);
|
||||
} else {
|
||||
DependencyManager::get<DeferredLightingEffect>()->renderSolidCube(1.0f);
|
||||
DependencyManager::get<DeferredLightingEffect>()->renderSolidCube(1.0f, cubeColor);
|
||||
}
|
||||
glPopMatrix();
|
||||
} else {
|
||||
|
@ -113,24 +111,24 @@ void Cube3DOverlay::render(RenderArgs* args) {
|
|||
|
||||
auto geometryCache = DependencyManager::get<GeometryCache>();
|
||||
|
||||
geometryCache->renderDashedLine(bottomLeftNear, bottomRightNear);
|
||||
geometryCache->renderDashedLine(bottomRightNear, bottomRightFar);
|
||||
geometryCache->renderDashedLine(bottomRightFar, bottomLeftFar);
|
||||
geometryCache->renderDashedLine(bottomLeftFar, bottomLeftNear);
|
||||
geometryCache->renderDashedLine(bottomLeftNear, bottomRightNear, cubeColor);
|
||||
geometryCache->renderDashedLine(bottomRightNear, bottomRightFar, cubeColor);
|
||||
geometryCache->renderDashedLine(bottomRightFar, bottomLeftFar, cubeColor);
|
||||
geometryCache->renderDashedLine(bottomLeftFar, bottomLeftNear, cubeColor);
|
||||
|
||||
geometryCache->renderDashedLine(topLeftNear, topRightNear);
|
||||
geometryCache->renderDashedLine(topRightNear, topRightFar);
|
||||
geometryCache->renderDashedLine(topRightFar, topLeftFar);
|
||||
geometryCache->renderDashedLine(topLeftFar, topLeftNear);
|
||||
geometryCache->renderDashedLine(topLeftNear, topRightNear, cubeColor);
|
||||
geometryCache->renderDashedLine(topRightNear, topRightFar, cubeColor);
|
||||
geometryCache->renderDashedLine(topRightFar, topLeftFar, cubeColor);
|
||||
geometryCache->renderDashedLine(topLeftFar, topLeftNear, cubeColor);
|
||||
|
||||
geometryCache->renderDashedLine(bottomLeftNear, topLeftNear);
|
||||
geometryCache->renderDashedLine(bottomRightNear, topRightNear);
|
||||
geometryCache->renderDashedLine(bottomLeftFar, topLeftFar);
|
||||
geometryCache->renderDashedLine(bottomRightFar, topRightFar);
|
||||
geometryCache->renderDashedLine(bottomLeftNear, topLeftNear, cubeColor);
|
||||
geometryCache->renderDashedLine(bottomRightNear, topRightNear, cubeColor);
|
||||
geometryCache->renderDashedLine(bottomLeftFar, topLeftFar, cubeColor);
|
||||
geometryCache->renderDashedLine(bottomRightFar, topRightFar, cubeColor);
|
||||
|
||||
} else {
|
||||
glScalef(dimensions.x, dimensions.y, dimensions.z);
|
||||
DependencyManager::get<DeferredLightingEffect>()->renderWireCube(1.0f);
|
||||
DependencyManager::get<DeferredLightingEffect>()->renderWireCube(1.0f, cubeColor);
|
||||
}
|
||||
}
|
||||
glPopMatrix();
|
||||
|
|
|
@ -79,7 +79,7 @@ void Grid3DOverlay::render(RenderArgs* args) {
|
|||
const float MAX_COLOR = 255.0f;
|
||||
|
||||
|
||||
glColor4f(color.red / MAX_COLOR, color.green / MAX_COLOR, color.blue / MAX_COLOR, alpha);
|
||||
glm::vec4 gridColor(color.red / MAX_COLOR, color.green / MAX_COLOR, color.blue / MAX_COLOR, alpha);
|
||||
|
||||
_gridProgram.bind();
|
||||
|
||||
|
@ -92,7 +92,7 @@ void Grid3DOverlay::render(RenderArgs* args) {
|
|||
float scale = MINOR_GRID_DIVISIONS * spacing;
|
||||
glScalef(scale, scale, scale);
|
||||
|
||||
DependencyManager::get<GeometryCache>()->renderGrid(MINOR_GRID_DIVISIONS, MINOR_GRID_DIVISIONS);
|
||||
DependencyManager::get<GeometryCache>()->renderGrid(MINOR_GRID_DIVISIONS, MINOR_GRID_DIVISIONS, gridColor);
|
||||
}
|
||||
glPopMatrix();
|
||||
|
||||
|
@ -107,7 +107,7 @@ void Grid3DOverlay::render(RenderArgs* args) {
|
|||
float scale = MAJOR_GRID_DIVISIONS * spacing;
|
||||
glScalef(scale, scale, scale);
|
||||
|
||||
DependencyManager::get<GeometryCache>()->renderGrid(MAJOR_GRID_DIVISIONS, MAJOR_GRID_DIVISIONS);
|
||||
DependencyManager::get<GeometryCache>()->renderGrid(MAJOR_GRID_DIVISIONS, MAJOR_GRID_DIVISIONS, gridColor);
|
||||
}
|
||||
glPopMatrix();
|
||||
|
||||
|
|
|
@ -30,9 +30,9 @@ ImageOverlay::ImageOverlay() :
|
|||
|
||||
ImageOverlay::ImageOverlay(const ImageOverlay* imageOverlay) :
|
||||
Overlay2D(imageOverlay),
|
||||
_texture(imageOverlay->_texture),
|
||||
_imageURL(imageOverlay->_imageURL),
|
||||
_textureImage(imageOverlay->_textureImage),
|
||||
_texture(imageOverlay->_texture),
|
||||
_fromImage(imageOverlay->_fromImage),
|
||||
_renderImage(imageOverlay->_renderImage),
|
||||
_wantClipFromImage(imageOverlay->_wantClipFromImage)
|
||||
|
@ -45,7 +45,6 @@ ImageOverlay::~ImageOverlay() {
|
|||
// TODO: handle setting image multiple times, how do we manage releasing the bound texture?
|
||||
void ImageOverlay::setImageURL(const QUrl& url) {
|
||||
_imageURL = url;
|
||||
|
||||
if (url.isEmpty()) {
|
||||
_isLoaded = true;
|
||||
_renderImage = false;
|
||||
|
@ -76,7 +75,7 @@ void ImageOverlay::render(RenderArgs* args) {
|
|||
const float MAX_COLOR = 255.0f;
|
||||
xColor color = getColor();
|
||||
float alpha = getAlpha();
|
||||
glColor4f(color.red / MAX_COLOR, color.green / MAX_COLOR, color.blue / MAX_COLOR, alpha);
|
||||
glm::vec4 quadColor(color.red / MAX_COLOR, color.green / MAX_COLOR, color.blue / MAX_COLOR, alpha);
|
||||
|
||||
int left = _bounds.left();
|
||||
int right = _bounds.right() + 1;
|
||||
|
@ -86,9 +85,11 @@ void ImageOverlay::render(RenderArgs* args) {
|
|||
glm::vec2 topLeft(left, top);
|
||||
glm::vec2 bottomRight(right, bottom);
|
||||
|
||||
if (_renderImage) {
|
||||
float imageWidth = _texture->getWidth();
|
||||
float imageHeight = _texture->getHeight();
|
||||
float imageWidth = _texture->getWidth();
|
||||
float imageHeight = _texture->getHeight();
|
||||
|
||||
// if for some reason our image is not over 0 width or height, don't attempt to render the image
|
||||
if (_renderImage && imageWidth > 0 && imageHeight > 0) {
|
||||
|
||||
QRect fromImage;
|
||||
if (_wantClipFromImage) {
|
||||
|
@ -114,9 +115,9 @@ void ImageOverlay::render(RenderArgs* args) {
|
|||
glm::vec2 texCoordTopLeft(x, y);
|
||||
glm::vec2 texCoordBottomRight(x + w, y + h);
|
||||
|
||||
DependencyManager::get<GeometryCache>()->renderQuad(topLeft, bottomRight, texCoordTopLeft, texCoordBottomRight);
|
||||
DependencyManager::get<GeometryCache>()->renderQuad(topLeft, bottomRight, texCoordTopLeft, texCoordBottomRight, quadColor);
|
||||
} else {
|
||||
DependencyManager::get<GeometryCache>()->renderQuad(topLeft, bottomRight);
|
||||
DependencyManager::get<GeometryCache>()->renderQuad(topLeft, bottomRight, quadColor);
|
||||
}
|
||||
|
||||
if (_renderImage) {
|
||||
|
|
|
@ -49,7 +49,7 @@ void Line3DOverlay::render(RenderArgs* args) {
|
|||
float alpha = getAlpha();
|
||||
xColor color = getColor();
|
||||
const float MAX_COLOR = 255.0f;
|
||||
glColor4f(color.red / MAX_COLOR, color.green / MAX_COLOR, color.blue / MAX_COLOR, alpha);
|
||||
glm::vec4 colorv4(color.red / MAX_COLOR, color.green / MAX_COLOR, color.blue / MAX_COLOR, alpha);
|
||||
|
||||
glm::vec3 position = getPosition();
|
||||
glm::quat rotation = getRotation();
|
||||
|
@ -59,9 +59,10 @@ void Line3DOverlay::render(RenderArgs* args) {
|
|||
glRotatef(glm::degrees(glm::angle(rotation)), axis.x, axis.y, axis.z);
|
||||
|
||||
if (getIsDashedLine()) {
|
||||
DependencyManager::get<GeometryCache>()->renderDashedLine(_position, _end, _geometryCacheID);
|
||||
// TODO: add support for color to renderDashedLine()
|
||||
DependencyManager::get<GeometryCache>()->renderDashedLine(_position, _end, colorv4, _geometryCacheID);
|
||||
} else {
|
||||
DependencyManager::get<GeometryCache>()->renderLine(_start, _end, _geometryCacheID);
|
||||
DependencyManager::get<GeometryCache>()->renderLine(_start, _end, colorv4, _geometryCacheID);
|
||||
}
|
||||
glEnable(GL_LIGHTING);
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@ void Rectangle3DOverlay::render(RenderArgs* args) {
|
|||
float alpha = getAlpha();
|
||||
xColor color = getColor();
|
||||
const float MAX_COLOR = 255.0f;
|
||||
glColor4f(color.red / MAX_COLOR, color.green / MAX_COLOR, color.blue / MAX_COLOR, alpha);
|
||||
glm::vec4 rectangleColor(color.red / MAX_COLOR, color.green / MAX_COLOR, color.blue / MAX_COLOR, alpha);
|
||||
|
||||
glDisable(GL_LIGHTING);
|
||||
|
||||
|
@ -72,7 +72,7 @@ void Rectangle3DOverlay::render(RenderArgs* args) {
|
|||
if (getIsSolid()) {
|
||||
glm::vec3 topLeft(-halfDimensions.x, 0.0f, -halfDimensions.y);
|
||||
glm::vec3 bottomRight(halfDimensions.x, 0.0f, halfDimensions.y);
|
||||
DependencyManager::get<GeometryCache>()->renderQuad(topLeft, bottomRight);
|
||||
DependencyManager::get<GeometryCache>()->renderQuad(topLeft, bottomRight, rectangleColor);
|
||||
} else {
|
||||
if (getIsDashedLine()) {
|
||||
|
||||
|
@ -81,10 +81,10 @@ void Rectangle3DOverlay::render(RenderArgs* args) {
|
|||
glm::vec3 point3(halfDimensions.x, 0.0f, halfDimensions.y);
|
||||
glm::vec3 point4(-halfDimensions.x, 0.0f, halfDimensions.y);
|
||||
|
||||
geometryCache->renderDashedLine(point1, point2);
|
||||
geometryCache->renderDashedLine(point2, point3);
|
||||
geometryCache->renderDashedLine(point3, point4);
|
||||
geometryCache->renderDashedLine(point4, point1);
|
||||
geometryCache->renderDashedLine(point1, point2, rectangleColor);
|
||||
geometryCache->renderDashedLine(point2, point3, rectangleColor);
|
||||
geometryCache->renderDashedLine(point3, point4, rectangleColor);
|
||||
geometryCache->renderDashedLine(point4, point1, rectangleColor);
|
||||
|
||||
} else {
|
||||
|
||||
|
@ -95,12 +95,12 @@ void Rectangle3DOverlay::render(RenderArgs* args) {
|
|||
border << glm::vec3(halfDimensions.x, 0.0f, halfDimensions.y);
|
||||
border << glm::vec3(-halfDimensions.x, 0.0f, halfDimensions.y);
|
||||
border << glm::vec3(-halfDimensions.x, 0.0f, -halfDimensions.y);
|
||||
geometryCache->updateVertices(_geometryCacheID, border);
|
||||
geometryCache->updateVertices(_geometryCacheID, border, rectangleColor);
|
||||
|
||||
_previousHalfDimensions = halfDimensions;
|
||||
|
||||
}
|
||||
geometryCache->renderVertices(GL_LINE_STRIP, _geometryCacheID);
|
||||
geometryCache->renderVertices(gpu::LINE_STRIP, _geometryCacheID);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@ void Sphere3DOverlay::render(RenderArgs* args) {
|
|||
float alpha = getAlpha();
|
||||
xColor color = getColor();
|
||||
const float MAX_COLOR = 255.0f;
|
||||
glColor4f(color.red / MAX_COLOR, color.green / MAX_COLOR, color.blue / MAX_COLOR, alpha);
|
||||
glm::vec4 sphereColor(color.red / MAX_COLOR, color.green / MAX_COLOR, color.blue / MAX_COLOR, alpha);
|
||||
|
||||
glDisable(GL_LIGHTING);
|
||||
|
||||
|
@ -62,7 +62,7 @@ void Sphere3DOverlay::render(RenderArgs* args) {
|
|||
glm::vec3 positionToCenter = center - position;
|
||||
glTranslatef(positionToCenter.x, positionToCenter.y, positionToCenter.z);
|
||||
glScalef(dimensions.x, dimensions.y, dimensions.z);
|
||||
DependencyManager::get<GeometryCache>()->renderSphere(1.0f, SLICES, SLICES, _isSolid);
|
||||
DependencyManager::get<GeometryCache>()->renderSphere(1.0f, SLICES, SLICES, sphereColor, _isSolid);
|
||||
glPopMatrix();
|
||||
glPopMatrix();
|
||||
|
||||
|
|
|
@ -92,7 +92,7 @@ void Text3DOverlay::render(RenderArgs* args) {
|
|||
|
||||
const float MAX_COLOR = 255.0f;
|
||||
xColor backgroundColor = getBackgroundColor();
|
||||
glColor4f(backgroundColor.red / MAX_COLOR, backgroundColor.green / MAX_COLOR, backgroundColor.blue / MAX_COLOR,
|
||||
glm::vec4 quadColor(backgroundColor.red / MAX_COLOR, backgroundColor.green / MAX_COLOR, backgroundColor.blue / MAX_COLOR,
|
||||
getBackgroundAlpha());
|
||||
|
||||
glm::vec2 dimensions = getDimensions();
|
||||
|
@ -102,7 +102,7 @@ void Text3DOverlay::render(RenderArgs* args) {
|
|||
|
||||
glm::vec3 topLeft(-halfDimensions.x, -halfDimensions.y, SLIGHTLY_BEHIND);
|
||||
glm::vec3 bottomRight(halfDimensions.x, halfDimensions.y, SLIGHTLY_BEHIND);
|
||||
DependencyManager::get<GeometryCache>()->renderQuad(topLeft, bottomRight);
|
||||
DependencyManager::get<GeometryCache>()->renderQuad(topLeft, bottomRight, quadColor);
|
||||
|
||||
const int FIXED_FONT_SCALING_RATIO = FIXED_FONT_POINT_SIZE * 40.0f; // this is a ratio determined through experimentation
|
||||
|
||||
|
@ -124,12 +124,11 @@ void Text3DOverlay::render(RenderArgs* args) {
|
|||
enableClipPlane(GL_CLIP_PLANE2, 0.0f, -1.0f, 0.0f, clipMinimum.y + clipDimensions.y);
|
||||
enableClipPlane(GL_CLIP_PLANE3, 0.0f, 1.0f, 0.0f, -clipMinimum.y);
|
||||
|
||||
glColor3f(_color.red / MAX_COLOR, _color.green / MAX_COLOR, _color.blue / MAX_COLOR);
|
||||
float alpha = getAlpha();
|
||||
glm::vec4 textColor = {_color.red / MAX_COLOR, _color.green / MAX_COLOR, _color.blue / MAX_COLOR, getAlpha() };
|
||||
QStringList lines = _text.split("\n");
|
||||
int lineOffset = maxHeight;
|
||||
foreach(QString thisLine, lines) {
|
||||
textRenderer->draw(0, lineOffset, qPrintable(thisLine), alpha);
|
||||
textRenderer->draw(0, lineOffset, qPrintable(thisLine), textColor);
|
||||
lineOffset += maxHeight;
|
||||
}
|
||||
|
||||
|
|
|
@ -70,7 +70,7 @@ void TextOverlay::render(RenderArgs* args) {
|
|||
|
||||
const float MAX_COLOR = 255.0f;
|
||||
xColor backgroundColor = getBackgroundColor();
|
||||
glColor4f(backgroundColor.red / MAX_COLOR, backgroundColor.green / MAX_COLOR, backgroundColor.blue / MAX_COLOR,
|
||||
glm::vec4 quadColor(backgroundColor.red / MAX_COLOR, backgroundColor.green / MAX_COLOR, backgroundColor.blue / MAX_COLOR,
|
||||
getBackgroundAlpha());
|
||||
|
||||
int left = _bounds.left();
|
||||
|
@ -80,7 +80,7 @@ void TextOverlay::render(RenderArgs* args) {
|
|||
|
||||
glm::vec2 topLeft(left, top);
|
||||
glm::vec2 bottomRight(right, bottom);
|
||||
DependencyManager::get<GeometryCache>()->renderQuad(topLeft, bottomRight);
|
||||
DependencyManager::get<GeometryCache>()->renderQuad(topLeft, bottomRight, quadColor);
|
||||
|
||||
// Same font properties as textSize()
|
||||
TextRenderer* textRenderer = TextRenderer::getInstance(SANS_FONT_FAMILY, _fontSize, DEFAULT_FONT_WEIGHT);
|
||||
|
@ -90,15 +90,15 @@ void TextOverlay::render(RenderArgs* args) {
|
|||
int x = _bounds.left() + _leftMargin + leftAdjust;
|
||||
int y = _bounds.top() + _topMargin + topAdjust;
|
||||
|
||||
glColor3f(_color.red / MAX_COLOR, _color.green / MAX_COLOR, _color.blue / MAX_COLOR);
|
||||
float alpha = getAlpha();
|
||||
glm::vec4 textColor = {_color.red / MAX_COLOR, _color.green / MAX_COLOR, _color.blue / MAX_COLOR, alpha };
|
||||
QStringList lines = _text.split("\n");
|
||||
int lineOffset = 0;
|
||||
foreach(QString thisLine, lines) {
|
||||
if (lineOffset == 0) {
|
||||
lineOffset = textRenderer->calculateHeight(qPrintable(thisLine));
|
||||
}
|
||||
lineOffset += textRenderer->draw(x, y + lineOffset, qPrintable(thisLine), alpha);
|
||||
lineOffset += textRenderer->draw(x, y + lineOffset, qPrintable(thisLine), textColor);
|
||||
|
||||
const int lineGap = 2;
|
||||
lineOffset += lineGap;
|
||||
|
|
|
@ -394,62 +394,53 @@ const Model* EntityTreeRenderer::getModelForEntityItem(const EntityItem* entityI
|
|||
void EntityTreeRenderer::renderElementProxy(EntityTreeElement* entityTreeElement) {
|
||||
glm::vec3 elementCenter = entityTreeElement->getAACube().calcCenter() * (float) TREE_SCALE;
|
||||
float elementSize = entityTreeElement->getScale() * (float) TREE_SCALE;
|
||||
glColor3f(1.0f, 0.0f, 0.0f);
|
||||
glPushMatrix();
|
||||
glTranslatef(elementCenter.x, elementCenter.y, elementCenter.z);
|
||||
DependencyManager::get<DeferredLightingEffect>()->renderWireCube(elementSize);
|
||||
DependencyManager::get<DeferredLightingEffect>()->renderWireCube(elementSize, glm::vec4(1.0f, 0.0f, 0.0f, 1.0f));
|
||||
glPopMatrix();
|
||||
|
||||
if (_displayElementChildProxies) {
|
||||
// draw the children
|
||||
float halfSize = elementSize / 2.0f;
|
||||
float quarterSize = elementSize / 4.0f;
|
||||
glColor3f(1.0f, 1.0f, 0.0f);
|
||||
glPushMatrix();
|
||||
glTranslatef(elementCenter.x - quarterSize, elementCenter.y - quarterSize, elementCenter.z - quarterSize);
|
||||
DependencyManager::get<DeferredLightingEffect>()->renderWireCube(halfSize);
|
||||
DependencyManager::get<DeferredLightingEffect>()->renderWireCube(halfSize, glm::vec4(1.0f, 1.0f, 0.0f, 1.0f));
|
||||
glPopMatrix();
|
||||
|
||||
glColor3f(1.0f, 0.0f, 1.0f);
|
||||
glPushMatrix();
|
||||
glTranslatef(elementCenter.x + quarterSize, elementCenter.y - quarterSize, elementCenter.z - quarterSize);
|
||||
DependencyManager::get<DeferredLightingEffect>()->renderWireCube(halfSize);
|
||||
DependencyManager::get<DeferredLightingEffect>()->renderWireCube(halfSize, glm::vec4(1.0f, 0.0f, 1.0f, 1.0f));
|
||||
glPopMatrix();
|
||||
|
||||
glColor3f(0.0f, 1.0f, 0.0f);
|
||||
glPushMatrix();
|
||||
glTranslatef(elementCenter.x - quarterSize, elementCenter.y + quarterSize, elementCenter.z - quarterSize);
|
||||
DependencyManager::get<DeferredLightingEffect>()->renderWireCube(halfSize);
|
||||
DependencyManager::get<DeferredLightingEffect>()->renderWireCube(halfSize, glm::vec4(0.0f, 1.0f, 0.0f, 1.0f));
|
||||
glPopMatrix();
|
||||
|
||||
glColor3f(0.0f, 0.0f, 1.0f);
|
||||
glPushMatrix();
|
||||
glTranslatef(elementCenter.x - quarterSize, elementCenter.y - quarterSize, elementCenter.z + quarterSize);
|
||||
DependencyManager::get<DeferredLightingEffect>()->renderWireCube(halfSize);
|
||||
DependencyManager::get<DeferredLightingEffect>()->renderWireCube(halfSize, glm::vec4(0.0f, 0.0f, 1.0f, 1.0f));
|
||||
glPopMatrix();
|
||||
|
||||
glColor3f(1.0f, 1.0f, 1.0f);
|
||||
glPushMatrix();
|
||||
glTranslatef(elementCenter.x + quarterSize, elementCenter.y + quarterSize, elementCenter.z + quarterSize);
|
||||
DependencyManager::get<DeferredLightingEffect>()->renderWireCube(halfSize);
|
||||
DependencyManager::get<DeferredLightingEffect>()->renderWireCube(halfSize, glm::vec4(1.0f, 1.0f, 1.0f, 1.0f));
|
||||
glPopMatrix();
|
||||
|
||||
glColor3f(0.0f, 0.5f, 0.5f);
|
||||
glPushMatrix();
|
||||
glTranslatef(elementCenter.x - quarterSize, elementCenter.y + quarterSize, elementCenter.z + quarterSize);
|
||||
DependencyManager::get<DeferredLightingEffect>()->renderWireCube(halfSize);
|
||||
DependencyManager::get<DeferredLightingEffect>()->renderWireCube(halfSize, glm::vec4(0.0f, 0.5f, 0.5f, 1.0f));
|
||||
glPopMatrix();
|
||||
|
||||
glColor3f(0.5f, 0.0f, 0.0f);
|
||||
glPushMatrix();
|
||||
glTranslatef(elementCenter.x + quarterSize, elementCenter.y - quarterSize, elementCenter.z + quarterSize);
|
||||
DependencyManager::get<DeferredLightingEffect>()->renderWireCube(halfSize);
|
||||
DependencyManager::get<DeferredLightingEffect>()->renderWireCube(halfSize, glm::vec4(0.5f, 0.0f, 0.0f, 1.0f));
|
||||
glPopMatrix();
|
||||
|
||||
glColor3f(0.0f, 0.5f, 0.0f);
|
||||
glPushMatrix();
|
||||
glTranslatef(elementCenter.x + quarterSize, elementCenter.y + quarterSize, elementCenter.z - quarterSize);
|
||||
DependencyManager::get<DeferredLightingEffect>()->renderWireCube(halfSize);
|
||||
DependencyManager::get<DeferredLightingEffect>()->renderWireCube(halfSize, glm::vec4(0.0f, 0.5f, 0.0f, 1.0f));
|
||||
glPopMatrix();
|
||||
}
|
||||
}
|
||||
|
@ -473,25 +464,22 @@ void EntityTreeRenderer::renderProxies(const EntityItem* entity, RenderArgs* arg
|
|||
glm::vec3 entityBoxScale = entityBox.getScale();
|
||||
|
||||
// draw the max bounding cube
|
||||
glColor4f(1.0f, 1.0f, 0.0f, 1.0f);
|
||||
glPushMatrix();
|
||||
glTranslatef(maxCenter.x, maxCenter.y, maxCenter.z);
|
||||
DependencyManager::get<DeferredLightingEffect>()->renderWireCube(maxCube.getScale());
|
||||
DependencyManager::get<DeferredLightingEffect>()->renderWireCube(maxCube.getScale(), glm::vec4(1.0f, 1.0f, 0.0f, 1.0f));
|
||||
glPopMatrix();
|
||||
|
||||
// draw the min bounding cube
|
||||
glColor4f(0.0f, 1.0f, 0.0f, 1.0f);
|
||||
glPushMatrix();
|
||||
glTranslatef(minCenter.x, minCenter.y, minCenter.z);
|
||||
DependencyManager::get<DeferredLightingEffect>()->renderWireCube(minCube.getScale());
|
||||
DependencyManager::get<DeferredLightingEffect>()->renderWireCube(minCube.getScale(), glm::vec4(0.0f, 1.0f, 0.0f, 1.0f));
|
||||
glPopMatrix();
|
||||
|
||||
// draw the entityBox bounding box
|
||||
glColor4f(0.0f, 0.0f, 1.0f, 1.0f);
|
||||
glPushMatrix();
|
||||
glTranslatef(entityBoxCenter.x, entityBoxCenter.y, entityBoxCenter.z);
|
||||
glScalef(entityBoxScale.x, entityBoxScale.y, entityBoxScale.z);
|
||||
DependencyManager::get<DeferredLightingEffect>()->renderWireCube(1.0f);
|
||||
DependencyManager::get<DeferredLightingEffect>()->renderWireCube(1.0f, glm::vec4(0.0f, 0.0f, 1.0f, 1.0f));
|
||||
glPopMatrix();
|
||||
|
||||
|
||||
|
@ -500,7 +488,6 @@ void EntityTreeRenderer::renderProxies(const EntityItem* entity, RenderArgs* arg
|
|||
glm::vec3 dimensions = entity->getDimensions() * (float) TREE_SCALE;
|
||||
glm::quat rotation = entity->getRotation();
|
||||
|
||||
glColor4f(1.0f, 0.0f, 1.0f, 1.0f);
|
||||
glPushMatrix();
|
||||
glTranslatef(position.x, position.y, position.z);
|
||||
glm::vec3 axis = glm::axis(rotation);
|
||||
|
@ -509,7 +496,7 @@ void EntityTreeRenderer::renderProxies(const EntityItem* entity, RenderArgs* arg
|
|||
glm::vec3 positionToCenter = center - position;
|
||||
glTranslatef(positionToCenter.x, positionToCenter.y, positionToCenter.z);
|
||||
glScalef(dimensions.x, dimensions.y, dimensions.z);
|
||||
DependencyManager::get<DeferredLightingEffect>()->renderWireCube(1.0f);
|
||||
DependencyManager::get<DeferredLightingEffect>()->renderWireCube(1.0f, glm::vec4(1.0f, 0.0f, 1.0f, 1.0f));
|
||||
glPopMatrix();
|
||||
glPopMatrix();
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@ void RenderableBoxEntityItem::render(RenderArgs* args) {
|
|||
|
||||
const float MAX_COLOR = 255.0f;
|
||||
|
||||
glColor4f(getColor()[RED_INDEX] / MAX_COLOR, getColor()[GREEN_INDEX] / MAX_COLOR,
|
||||
glm::vec4 cubeColor(getColor()[RED_INDEX] / MAX_COLOR, getColor()[GREEN_INDEX] / MAX_COLOR,
|
||||
getColor()[BLUE_INDEX] / MAX_COLOR, getLocalRenderAlpha());
|
||||
|
||||
glPushMatrix();
|
||||
|
@ -43,7 +43,7 @@ void RenderableBoxEntityItem::render(RenderArgs* args) {
|
|||
glm::vec3 positionToCenter = center - position;
|
||||
glTranslatef(positionToCenter.x, positionToCenter.y, positionToCenter.z);
|
||||
glScalef(dimensions.x, dimensions.y, dimensions.z);
|
||||
DependencyManager::get<DeferredLightingEffect>()->renderSolidCube(1.0f);
|
||||
DependencyManager::get<DeferredLightingEffect>()->renderSolidCube(1.0f, cubeColor);
|
||||
glPopMatrix();
|
||||
glPopMatrix();
|
||||
|
||||
|
|
|
@ -64,7 +64,7 @@ void RenderableLightEntityItem::render(RenderArgs* args) {
|
|||
}
|
||||
|
||||
#ifdef WANT_DEBUG
|
||||
glColor4f(diffuseR, diffuseG, diffuseB, 1.0f);
|
||||
glm::vec4 color(diffuseR, diffuseG, diffuseB, 1.0f);
|
||||
glPushMatrix();
|
||||
glTranslatef(position.x, position.y, position.z);
|
||||
glm::vec3 axis = glm::axis(rotation);
|
||||
|
@ -74,7 +74,7 @@ void RenderableLightEntityItem::render(RenderArgs* args) {
|
|||
glTranslatef(positionToCenter.x, positionToCenter.y, positionToCenter.z);
|
||||
|
||||
glScalef(dimensions.x, dimensions.y, dimensions.z);
|
||||
DependencyManager::get<DeferredLightingEffect>()->renderWireSphere(0.5f, 15, 15);
|
||||
DependencyManager::get<DeferredLightingEffect>()->renderWireSphere(0.5f, 15, 15, color);
|
||||
glPopMatrix();
|
||||
glPopMatrix();
|
||||
#endif
|
||||
|
|
|
@ -176,27 +176,27 @@ void RenderableModelEntityItem::render(RenderArgs* args) {
|
|||
}
|
||||
} else {
|
||||
// if we couldn't get a model, then just draw a cube
|
||||
glColor3ub(getColor()[RED_INDEX],getColor()[GREEN_INDEX],getColor()[BLUE_INDEX]);
|
||||
glm::vec4 color(getColor()[RED_INDEX]/255, getColor()[GREEN_INDEX]/255, getColor()[BLUE_INDEX]/255, 1.0f);
|
||||
glPushMatrix();
|
||||
glTranslatef(position.x, position.y, position.z);
|
||||
DependencyManager::get<DeferredLightingEffect>()->renderWireCube(size);
|
||||
DependencyManager::get<DeferredLightingEffect>()->renderWireCube(size, color);
|
||||
glPopMatrix();
|
||||
}
|
||||
} else {
|
||||
// if we couldn't get a model, then just draw a cube
|
||||
glColor3ub(getColor()[RED_INDEX],getColor()[GREEN_INDEX],getColor()[BLUE_INDEX]);
|
||||
glm::vec4 color(getColor()[RED_INDEX]/255, getColor()[GREEN_INDEX]/255, getColor()[BLUE_INDEX]/255, 1.0f);
|
||||
glPushMatrix();
|
||||
glTranslatef(position.x, position.y, position.z);
|
||||
DependencyManager::get<DeferredLightingEffect>()->renderWireCube(size);
|
||||
DependencyManager::get<DeferredLightingEffect>()->renderWireCube(size, color);
|
||||
glPopMatrix();
|
||||
}
|
||||
}
|
||||
glPopMatrix();
|
||||
} else {
|
||||
glColor3ub(getColor()[RED_INDEX],getColor()[GREEN_INDEX],getColor()[BLUE_INDEX]);
|
||||
glm::vec4 color(getColor()[RED_INDEX]/255, getColor()[GREEN_INDEX]/255, getColor()[BLUE_INDEX]/255, 1.0f);
|
||||
glPushMatrix();
|
||||
glTranslatef(position.x, position.y, position.z);
|
||||
DependencyManager::get<DeferredLightingEffect>()->renderWireCube(size);
|
||||
DependencyManager::get<DeferredLightingEffect>()->renderWireCube(size, color);
|
||||
glPopMatrix();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@ void RenderableSphereEntityItem::render(RenderArgs* args) {
|
|||
glm::quat rotation = getRotation();
|
||||
|
||||
const float MAX_COLOR = 255.0f;
|
||||
glColor4f(getColor()[RED_INDEX] / MAX_COLOR, getColor()[GREEN_INDEX] / MAX_COLOR,
|
||||
glm::vec4 sphereColor(getColor()[RED_INDEX] / MAX_COLOR, getColor()[GREEN_INDEX] / MAX_COLOR,
|
||||
getColor()[BLUE_INDEX] / MAX_COLOR, getLocalRenderAlpha());
|
||||
|
||||
glPushMatrix();
|
||||
|
@ -46,7 +46,14 @@ void RenderableSphereEntityItem::render(RenderArgs* args) {
|
|||
glTranslatef(positionToCenter.x, positionToCenter.y, positionToCenter.z);
|
||||
|
||||
glScalef(dimensions.x, dimensions.y, dimensions.z);
|
||||
DependencyManager::get<DeferredLightingEffect>()->renderSolidSphere(0.5f, 15, 15);
|
||||
|
||||
// TODO: it would be cool to select different slices/stacks geometry based on the size of the sphere
|
||||
// and the distance to the viewer. This would allow us to reduce the triangle count for smaller spheres
|
||||
// that aren't close enough to see the tessellation and use larger triangle count for spheres that would
|
||||
// expose that effect
|
||||
const int SLICES = 15;
|
||||
const int STACKS = 15;
|
||||
DependencyManager::get<DeferredLightingEffect>()->renderSolidSphere(0.5f, SLICES, STACKS, sphereColor);
|
||||
glPopMatrix();
|
||||
glPopMatrix();
|
||||
};
|
||||
|
|
|
@ -49,13 +49,13 @@ void RenderableTextEntityItem::render(RenderArgs* args) {
|
|||
const float MAX_COLOR = 255.0f;
|
||||
xColor backgroundColor = getBackgroundColorX();
|
||||
float alpha = 1.0f; //getBackgroundAlpha();
|
||||
glColor4f(backgroundColor.red / MAX_COLOR, backgroundColor.green / MAX_COLOR, backgroundColor.blue / MAX_COLOR, alpha);
|
||||
glm::vec4 color(backgroundColor.red / MAX_COLOR, backgroundColor.green / MAX_COLOR, backgroundColor.blue / MAX_COLOR, alpha);
|
||||
|
||||
const float SLIGHTLY_BEHIND = -0.005f;
|
||||
|
||||
glm::vec3 topLeft(-halfDimensions.x, -halfDimensions.y, SLIGHTLY_BEHIND);
|
||||
glm::vec3 bottomRight(halfDimensions.x, halfDimensions.y, SLIGHTLY_BEHIND);
|
||||
DependencyManager::get<GeometryCache>()->renderQuad(topLeft, bottomRight);
|
||||
DependencyManager::get<GeometryCache>()->renderQuad(topLeft, bottomRight, color);
|
||||
|
||||
const int FIXED_FONT_SCALING_RATIO = FIXED_FONT_POINT_SIZE * 40.0f; // this is a ratio determined through experimentation
|
||||
|
||||
|
@ -78,12 +78,11 @@ void RenderableTextEntityItem::render(RenderArgs* args) {
|
|||
enableClipPlane(GL_CLIP_PLANE3, 0.0f, 1.0f, 0.0f, -clipMinimum.y);
|
||||
|
||||
xColor textColor = getTextColorX();
|
||||
glColor3f(textColor.red / MAX_COLOR, textColor.green / MAX_COLOR, textColor.blue / MAX_COLOR);
|
||||
glm::vec4 textColorV4(textColor.red / MAX_COLOR, textColor.green / MAX_COLOR, textColor.blue / MAX_COLOR, 1.0f);
|
||||
QStringList lines = _text.split("\n");
|
||||
int lineOffset = maxHeight;
|
||||
float textAlpha = 1.0f; // getTextAlpha()
|
||||
foreach(QString thisLine, lines) {
|
||||
textRenderer->draw(0, lineOffset, qPrintable(thisLine), textAlpha);
|
||||
textRenderer->draw(0, lineOffset, qPrintable(thisLine), textColorV4);
|
||||
lineOffset += maxHeight;
|
||||
}
|
||||
|
||||
|
|
|
@ -46,7 +46,9 @@ enum Primitive {
|
|||
LINE_STRIP,
|
||||
TRIANGLES,
|
||||
TRIANGLE_STRIP,
|
||||
TRIANGLE_FAN,
|
||||
QUADS,
|
||||
QUAD_STRIP,
|
||||
|
||||
NUM_PRIMITIVES,
|
||||
};
|
||||
|
|
|
@ -25,7 +25,9 @@ static const GLenum _primitiveToGLmode[NUM_PRIMITIVES] = {
|
|||
GL_LINE_STRIP,
|
||||
GL_TRIANGLES,
|
||||
GL_TRIANGLE_STRIP,
|
||||
GL_TRIANGLE_FAN,
|
||||
GL_QUADS,
|
||||
GL_QUAD_STRIP,
|
||||
};
|
||||
|
||||
static const GLenum _elementTypeToGLType[NUM_TYPES]= {
|
||||
|
|
|
@ -202,6 +202,14 @@ public:
|
|||
_element(element),
|
||||
_stride(uint16(element.getSize()))
|
||||
{};
|
||||
BufferView(const BufferPointer& buffer, Size offset, Size size, uint16 stride, const Element& element = Element(gpu::SCALAR, gpu::UINT8, gpu::RAW)) :
|
||||
_buffer(buffer),
|
||||
_offset(offset),
|
||||
_size(size),
|
||||
_element(element),
|
||||
_stride(stride)
|
||||
{};
|
||||
|
||||
~BufferView() {}
|
||||
BufferView(const BufferView& view) = default;
|
||||
BufferView& operator=(const BufferView& view) = default;
|
||||
|
|
|
@ -254,7 +254,16 @@ bool Texture::assignStoredMip(uint16 level, const Element& format, Size size, co
|
|||
}
|
||||
|
||||
// THen check that the mem buffer passed make sense with its format
|
||||
if (size == evalStoredMipSize(level, format)) {
|
||||
Size expectedSize = evalStoredMipSize(level, format);
|
||||
if (size == expectedSize) {
|
||||
_storage->assignMipData(level, format, size, bytes);
|
||||
_stamp++;
|
||||
return true;
|
||||
} else if (size > expectedSize) {
|
||||
// NOTE: We are facing this case sometime because apparently QImage (from where we get the bits) is generating images
|
||||
// and alligning the line of pixels to 32 bits.
|
||||
// We should probably consider something a bit more smart to get the correct result but for now (UI elements)
|
||||
// it seems to work...
|
||||
_storage->assignMipData(level, format, size, bytes);
|
||||
_stamp++;
|
||||
return true;
|
||||
|
|
|
@ -221,27 +221,27 @@ void DeferredLightingEffect::releaseSimpleProgram() {
|
|||
DependencyManager::get<TextureCache>()->setPrimaryDrawBuffers(true, false, false);
|
||||
}
|
||||
|
||||
void DeferredLightingEffect::renderSolidSphere(float radius, int slices, int stacks) {
|
||||
void DeferredLightingEffect::renderSolidSphere(float radius, int slices, int stacks, const glm::vec4& color) {
|
||||
bindSimpleProgram();
|
||||
DependencyManager::get<GeometryCache>()->renderSphere(radius, slices, stacks);
|
||||
DependencyManager::get<GeometryCache>()->renderSphere(radius, slices, stacks, color);
|
||||
releaseSimpleProgram();
|
||||
}
|
||||
|
||||
void DeferredLightingEffect::renderWireSphere(float radius, int slices, int stacks) {
|
||||
void DeferredLightingEffect::renderWireSphere(float radius, int slices, int stacks, const glm::vec4& color) {
|
||||
bindSimpleProgram();
|
||||
DependencyManager::get<GeometryCache>()->renderSphere(radius, slices, stacks, false);
|
||||
DependencyManager::get<GeometryCache>()->renderSphere(radius, slices, stacks, color, false);
|
||||
releaseSimpleProgram();
|
||||
}
|
||||
|
||||
void DeferredLightingEffect::renderSolidCube(float size) {
|
||||
void DeferredLightingEffect::renderSolidCube(float size, const glm::vec4& color) {
|
||||
bindSimpleProgram();
|
||||
DependencyManager::get<GeometryCache>()->renderSolidCube(size);
|
||||
DependencyManager::get<GeometryCache>()->renderSolidCube(size, color);
|
||||
releaseSimpleProgram();
|
||||
}
|
||||
|
||||
void DeferredLightingEffect::renderWireCube(float size) {
|
||||
void DeferredLightingEffect::renderWireCube(float size, const glm::vec4& color) {
|
||||
bindSimpleProgram();
|
||||
DependencyManager::get<GeometryCache>()->renderWireCube(size);
|
||||
DependencyManager::get<GeometryCache>()->renderWireCube(size, color);
|
||||
releaseSimpleProgram();
|
||||
}
|
||||
|
||||
|
@ -303,8 +303,6 @@ void DeferredLightingEffect::prepare() {
|
|||
|
||||
void DeferredLightingEffect::render() {
|
||||
// perform deferred lighting, rendering to free fbo
|
||||
glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
|
||||
glDisable(GL_BLEND);
|
||||
glDisable(GL_LIGHTING);
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
|
@ -471,7 +469,7 @@ void DeferredLightingEffect::render() {
|
|||
|
||||
} else {
|
||||
glTranslatef(light.position.x, light.position.y, light.position.z);
|
||||
geometryCache->renderSphere(expandedRadius, 32, 32);
|
||||
geometryCache->renderSphere(expandedRadius, 32, 32, glm::vec4(1.0f, 1.0f, 1.0f, 1.0f));
|
||||
}
|
||||
|
||||
glPopMatrix();
|
||||
|
|
|
@ -40,16 +40,16 @@ public:
|
|||
void releaseSimpleProgram();
|
||||
|
||||
//// Renders a solid sphere with the simple program.
|
||||
void renderSolidSphere(float radius, int slices, int stacks);
|
||||
void renderSolidSphere(float radius, int slices, int stacks, const glm::vec4& color);
|
||||
|
||||
//// Renders a wireframe sphere with the simple program.
|
||||
void renderWireSphere(float radius, int slices, int stacks);
|
||||
void renderWireSphere(float radius, int slices, int stacks, const glm::vec4& color);
|
||||
|
||||
//// Renders a solid cube with the simple program.
|
||||
void renderSolidCube(float size);
|
||||
void renderSolidCube(float size, const glm::vec4& color);
|
||||
|
||||
//// Renders a wireframe cube with the simple program.
|
||||
void renderWireCube(float size);
|
||||
void renderWireCube(float size, const glm::vec4& color);
|
||||
|
||||
//// Renders a solid cone with the simple program.
|
||||
void renderSolidCone(float base, float height, int slices, int stacks);
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -25,17 +25,24 @@
|
|||
|
||||
#include <AnimationCache.h>
|
||||
|
||||
#include "gpu/Stream.h"
|
||||
#include <gpu/Batch.h>
|
||||
#include <gpu/Stream.h>
|
||||
|
||||
|
||||
class NetworkGeometry;
|
||||
class NetworkMesh;
|
||||
class NetworkTexture;
|
||||
|
||||
|
||||
typedef glm::vec3 Vec3Key;
|
||||
|
||||
typedef QPair<glm::vec2, glm::vec2> Vec2Pair;
|
||||
typedef QPair<Vec2Pair, Vec2Pair> Vec2PairPair;
|
||||
typedef QPair<glm::vec3, glm::vec3> Vec3Pair;
|
||||
typedef QPair<glm::vec4, glm::vec4> Vec4Pair;
|
||||
typedef QPair<Vec3Pair, Vec2Pair> Vec3PairVec2Pair;
|
||||
typedef QPair<Vec3Pair, Vec4Pair> Vec3PairVec4Pair;
|
||||
typedef QPair<Vec4Pair, Vec4Pair> Vec4PairVec4Pair;
|
||||
|
||||
inline uint qHash(const glm::vec2& v, uint seed) {
|
||||
// multiply by prime numbers greater than the possible size
|
||||
|
@ -47,6 +54,11 @@ inline uint qHash(const Vec2Pair& v, uint seed) {
|
|||
return qHash(v.first.x + 5009 * v.first.y + 5011 * v.second.x + 5021 * v.second.y, seed);
|
||||
}
|
||||
|
||||
inline uint qHash(const glm::vec4& v, uint seed) {
|
||||
// multiply by prime numbers greater than the possible size
|
||||
return qHash(v.x + 5009 * v.y + 5011 * v.z + 5021 * v.w, seed);
|
||||
}
|
||||
|
||||
inline uint qHash(const Vec2PairPair& v, uint seed) {
|
||||
// multiply by prime numbers greater than the possible size
|
||||
return qHash(v.first.first.x + 5009 * v.first.first.y
|
||||
|
@ -55,17 +67,18 @@ inline uint qHash(const Vec2PairPair& v, uint seed) {
|
|||
+ 5051 * v.second.second.x + 5059 * v.second.second.y, seed);
|
||||
}
|
||||
|
||||
inline uint qHash(const glm::vec3& v, uint seed) {
|
||||
// multiply by prime numbers greater than the possible size
|
||||
return qHash(v.x + 5009 * v.y + 5011 * v.z, seed);
|
||||
}
|
||||
|
||||
inline uint qHash(const Vec3Pair& v, uint seed) {
|
||||
// multiply by prime numbers greater than the possible size
|
||||
return qHash(v.first.x + 5009 * v.first.y + 5011 * v.first.z
|
||||
+ 5021 * v.second.x + 5023 * v.second.y + 5039 * v.second.z, seed);
|
||||
}
|
||||
|
||||
inline uint qHash(const Vec4Pair& v, uint seed) {
|
||||
// multiply by prime numbers greater than the possible size
|
||||
return qHash(v.first.x + 5009 * v.first.y + 5011 * v.first.z + 5021 * v.first.w
|
||||
+ 5023 * v.second.x + 5039 * v.second.y + 5051 * v.second.z + 5059 * v.second.w , seed);
|
||||
}
|
||||
|
||||
inline uint qHash(const Vec3PairVec2Pair& v, uint seed) {
|
||||
// multiply by prime numbers greater than the possible size
|
||||
return qHash(v.first.first.x + 5009 * v.first.first.y + 5011 * v.first.first.z +
|
||||
|
@ -74,6 +87,23 @@ inline uint qHash(const Vec3PairVec2Pair& v, uint seed) {
|
|||
5077 * v.second.second.x + 5081 * v.second.second.y, seed);
|
||||
}
|
||||
|
||||
inline uint qHash(const Vec3PairVec4Pair& v, uint seed) {
|
||||
// multiply by prime numbers greater than the possible size
|
||||
return qHash(v.first.first.x + 5009 * v.first.first.y + 5011 * v.first.first.z
|
||||
+ 5023 * v.first.second.x + 5039 * v.first.second.y + 5051 * v.first.second.z
|
||||
+ 5077 * v.second.first.x + 5081 * v.second.first.y + 5087 * v.second.first.z + 5099 * v.second.first.w
|
||||
+ 5101 * v.second.second.x + 5107 * v.second.second.y + 5113 * v.second.second.z + 5119 * v.second.second.w,
|
||||
seed);
|
||||
}
|
||||
|
||||
inline uint qHash(const Vec4PairVec4Pair& v, uint seed) {
|
||||
// multiply by prime numbers greater than the possible size
|
||||
return qHash(v.first.first.x + 5009 * v.first.first.y + 5011 * v.first.first.z + 5021 * v.first.first.w
|
||||
+ 5023 * v.first.second.x + 5039 * v.first.second.y + 5051 * v.first.second.z + 5059 * v.first.second.w
|
||||
+ 5077 * v.second.first.x + 5081 * v.second.first.y + 5087 * v.second.first.z + 5099 * v.second.first.w
|
||||
+ 5101 * v.second.second.x + 5107 * v.second.second.y + 5113 * v.second.second.z + 5119 * v.second.second.w,
|
||||
seed);
|
||||
}
|
||||
|
||||
/// Stores cached geometry.
|
||||
class GeometryCache : public ResourceCache, public Dependency {
|
||||
|
@ -84,40 +114,72 @@ public:
|
|||
int allocateID() { return _nextID++; }
|
||||
static const int UNKNOWN_ID;
|
||||
|
||||
void renderHemisphere(int slices, int stacks);
|
||||
void renderSphere(float radius, int slices, int stacks, bool solid = true);
|
||||
void renderSquare(int xDivisions, int yDivisions);
|
||||
void renderHalfCylinder(int slices, int stacks);
|
||||
void renderCone(float base, float height, int slices, int stacks);
|
||||
void renderGrid(int xDivisions, int yDivisions);
|
||||
void renderGrid(int x, int y, int width, int height, int rows, int cols, int id = UNKNOWN_ID);
|
||||
void renderSolidCube(float size);
|
||||
void renderWireCube(float size);
|
||||
void renderBevelCornersRect(int x, int y, int width, int height, int bevelDistance, int id = UNKNOWN_ID);
|
||||
|
||||
void renderQuad(int x, int y, int width, int height, int id = UNKNOWN_ID)
|
||||
{ renderQuad(glm::vec2(x,y), glm::vec2(x + width, y + height), id); }
|
||||
void renderSphere(float radius, int slices, int stacks, const glm::vec3& color, bool solid = true)
|
||||
{ renderSphere(radius, slices, stacks, glm::vec4(color, 1.0f), solid); }
|
||||
|
||||
void renderSphere(float radius, int slices, int stacks, const glm::vec4& color, bool solid = true);
|
||||
void renderGrid(int xDivisions, int yDivisions, const glm::vec4& color);
|
||||
void renderGrid(int x, int y, int width, int height, int rows, int cols, const glm::vec4& color, int id = UNKNOWN_ID);
|
||||
void renderSolidCube(float size, const glm::vec4& color);
|
||||
void renderWireCube(float size, const glm::vec4& color);
|
||||
void renderBevelCornersRect(int x, int y, int width, int height, int bevelDistance, const glm::vec4& color, int id = UNKNOWN_ID);
|
||||
|
||||
void renderQuad(int x, int y, int width, int height, const glm::vec4& color, int id = UNKNOWN_ID)
|
||||
{ renderQuad(glm::vec2(x,y), glm::vec2(x + width, y + height), color, id); }
|
||||
|
||||
void renderQuad(const glm::vec2& minCorner, const glm::vec2& maxCorner, int id = UNKNOWN_ID);
|
||||
// TODO: I think there's a bug in this version of the renderQuad() that's not correctly rebuilding the vbos
|
||||
// if the color changes by the corners are the same, as evidenced by the audio meter which should turn white
|
||||
// when it's clipping
|
||||
void renderQuad(const glm::vec2& minCorner, const glm::vec2& maxCorner, const glm::vec4& color, int id = UNKNOWN_ID);
|
||||
|
||||
void renderQuad(const glm::vec2& minCorner, const glm::vec2& maxCorner,
|
||||
const glm::vec2& texCoordMinCorner, const glm::vec2& texCoordMaxCorner, int id = UNKNOWN_ID);
|
||||
const glm::vec2& texCoordMinCorner, const glm::vec2& texCoordMaxCorner,
|
||||
const glm::vec4& color, int id = UNKNOWN_ID);
|
||||
|
||||
void renderQuad(const glm::vec3& minCorner, const glm::vec3& maxCorner, int id = UNKNOWN_ID);
|
||||
void renderQuad(const glm::vec3& minCorner, const glm::vec3& maxCorner, const glm::vec4& color, int id = UNKNOWN_ID);
|
||||
|
||||
void renderQuad(const glm::vec3& topLeft, const glm::vec3& bottomLeft,
|
||||
const glm::vec3& bottomRight, const glm::vec3& topRight,
|
||||
const glm::vec2& texCoordTopLeft, const glm::vec2& texCoordBottomLeft,
|
||||
const glm::vec2& texCoordBottomRight, const glm::vec2& texCoordTopRight, int id = UNKNOWN_ID);
|
||||
const glm::vec2& texCoordBottomRight, const glm::vec2& texCoordTopRight,
|
||||
const glm::vec4& color, int id = UNKNOWN_ID);
|
||||
|
||||
|
||||
void renderLine(const glm::vec3& p1, const glm::vec3& p2, int id = UNKNOWN_ID);
|
||||
void renderDashedLine(const glm::vec3& start, const glm::vec3& end, int id = UNKNOWN_ID);
|
||||
void renderLine(const glm::vec2& p1, const glm::vec2& p2, int id = UNKNOWN_ID);
|
||||
void renderLine(const glm::vec3& p1, const glm::vec3& p2, const glm::vec3& color, int id = UNKNOWN_ID)
|
||||
{ renderLine(p1, p2, color, color, id); }
|
||||
|
||||
void renderLine(const glm::vec3& p1, const glm::vec3& p2,
|
||||
const glm::vec3& color1, const glm::vec3& color2, int id = UNKNOWN_ID)
|
||||
{ renderLine(p1, p2, glm::vec4(color1, 1.0f), glm::vec4(color2, 1.0f), id); }
|
||||
|
||||
void updateVertices(int id, const QVector<glm::vec2>& points);
|
||||
void updateVertices(int id, const QVector<glm::vec3>& points);
|
||||
void renderVertices(GLenum mode, int id);
|
||||
void renderLine(const glm::vec3& p1, const glm::vec3& p2,
|
||||
const glm::vec4& color, int id = UNKNOWN_ID)
|
||||
{ renderLine(p1, p2, color, color, id); }
|
||||
|
||||
void renderLine(const glm::vec3& p1, const glm::vec3& p2,
|
||||
const glm::vec4& color1, const glm::vec4& color2, int id = UNKNOWN_ID);
|
||||
|
||||
void renderDashedLine(const glm::vec3& start, const glm::vec3& end, const glm::vec4& color, int id = UNKNOWN_ID);
|
||||
|
||||
void renderLine(const glm::vec2& p1, const glm::vec2& p2, const glm::vec3& color, int id = UNKNOWN_ID)
|
||||
{ renderLine(p1, p2, glm::vec4(color, 1.0f), id); }
|
||||
|
||||
void renderLine(const glm::vec2& p1, const glm::vec2& p2, const glm::vec4& color, int id = UNKNOWN_ID)
|
||||
{ renderLine(p1, p2, color, color, id); }
|
||||
|
||||
|
||||
void renderLine(const glm::vec2& p1, const glm::vec2& p2,
|
||||
const glm::vec3& color1, const glm::vec3& color2, int id = UNKNOWN_ID)
|
||||
{ renderLine(p1, p2, glm::vec4(color1, 1.0f), glm::vec4(color2, 1.0f), id); }
|
||||
|
||||
void renderLine(const glm::vec2& p1, const glm::vec2& p2,
|
||||
const glm::vec4& color1, const glm::vec4& color2, int id = UNKNOWN_ID);
|
||||
|
||||
void updateVertices(int id, const QVector<glm::vec2>& points, const glm::vec4& color);
|
||||
void updateVertices(int id, const QVector<glm::vec3>& points, const glm::vec4& color);
|
||||
void renderVertices(gpu::Primitive primitiveType, int id);
|
||||
|
||||
/// Loads geometry from the specified URL.
|
||||
/// \param fallback a fallback URL to load if the desired one is unavailable
|
||||
|
@ -128,64 +190,91 @@ protected:
|
|||
|
||||
virtual QSharedPointer<Resource> createResource(const QUrl& url,
|
||||
const QSharedPointer<Resource>& fallback, bool delayLoad, const void* extra);
|
||||
|
||||
|
||||
private:
|
||||
GeometryCache();
|
||||
virtual ~GeometryCache();
|
||||
|
||||
typedef QPair<int, int> IntPair;
|
||||
typedef QPair<GLuint, GLuint> VerticesIndices;
|
||||
|
||||
QHash<IntPair, VerticesIndices> _hemisphereVBOs;
|
||||
QHash<IntPair, VerticesIndices> _sphereVBOs;
|
||||
QHash<IntPair, VerticesIndices> _squareVBOs;
|
||||
QHash<IntPair, VerticesIndices> _halfCylinderVBOs;
|
||||
QHash<IntPair, VerticesIndices> _coneVBOs;
|
||||
QHash<float, VerticesIndices> _wireCubeVBOs;
|
||||
QHash<float, VerticesIndices> _solidCubeVBOs;
|
||||
QHash<Vec2Pair, VerticesIndices> _quad2DVBOs;
|
||||
QHash<Vec2PairPair, VerticesIndices> _quad2DTextureVBOs;
|
||||
QHash<Vec3Pair, VerticesIndices> _quad3DVBOs;
|
||||
QHash<Vec3PairVec2Pair, VerticesIndices> _quad3DTextureVBOs;
|
||||
QHash<int, VerticesIndices> _registeredQuadVBOs;
|
||||
int _nextID;
|
||||
|
||||
QHash<int, Vec2Pair> _lastRegisteredQuad2D;
|
||||
QHash<int, Vec2PairPair> _lastRegisteredQuad2DTexture;
|
||||
QHash<int, Vec3Pair> _lastRegisteredQuad3D;
|
||||
QHash<int, Vec3PairVec2Pair> _lastRegisteredQuad3DTexture;
|
||||
|
||||
QHash<int, Vec3Pair> _lastRegisteredRect;
|
||||
QHash<Vec3Pair, VerticesIndices> _rectVBOs;
|
||||
QHash<int, VerticesIndices> _registeredRectVBOs;
|
||||
|
||||
QHash<int, Vec3Pair> _lastRegisteredLine3D;
|
||||
QHash<Vec3Pair, VerticesIndices> _line3DVBOs;
|
||||
QHash<int, VerticesIndices> _registeredLine3DVBOs;
|
||||
|
||||
QHash<int, Vec2Pair> _lastRegisteredLine2D;
|
||||
QHash<Vec2Pair, VerticesIndices> _line2DVBOs;
|
||||
QHash<int, VerticesIndices> _registeredLine2DVBOs;
|
||||
|
||||
struct BufferDetails {
|
||||
QOpenGLBuffer buffer;
|
||||
int vertices;
|
||||
int vertexSize;
|
||||
};
|
||||
|
||||
QHash<int, BufferDetails> _registeredVertices;
|
||||
QHash<float, gpu::BufferPointer> _cubeVerticies;
|
||||
QHash<Vec2Pair, gpu::BufferPointer> _cubeColors;
|
||||
gpu::BufferPointer _wireCubeIndexBuffer;
|
||||
|
||||
QHash<int, Vec3Pair> _lastRegisteredDashedLines;
|
||||
QHash<Vec3Pair, BufferDetails> _dashedLines;
|
||||
QHash<int, BufferDetails> _registeredDashedLines;
|
||||
QHash<float, gpu::BufferPointer> _solidCubeVerticies;
|
||||
QHash<Vec2Pair, gpu::BufferPointer> _solidCubeColors;
|
||||
gpu::BufferPointer _solidCubeIndexBuffer;
|
||||
|
||||
class BatchItemDetails {
|
||||
public:
|
||||
static int population;
|
||||
gpu::BufferPointer verticesBuffer;
|
||||
gpu::BufferPointer colorBuffer;
|
||||
gpu::Stream::FormatPointer streamFormat;
|
||||
gpu::BufferStreamPointer stream;
|
||||
|
||||
int vertices;
|
||||
int vertexSize;
|
||||
bool isCreated;
|
||||
|
||||
BatchItemDetails();
|
||||
BatchItemDetails(const GeometryCache::BatchItemDetails& other);
|
||||
~BatchItemDetails();
|
||||
void clear();
|
||||
};
|
||||
|
||||
QHash<IntPair, VerticesIndices> _coneVBOs;
|
||||
int _nextID;
|
||||
|
||||
QHash<int, Vec3PairVec4Pair> _lastRegisteredQuad3DTexture;
|
||||
QHash<Vec3PairVec4Pair, BatchItemDetails> _quad3DTextures;
|
||||
QHash<int, BatchItemDetails> _registeredQuad3DTextures;
|
||||
|
||||
QHash<int, Vec2PairPair> _lastRegisteredQuad2DTexture;
|
||||
QHash<Vec2PairPair, BatchItemDetails> _quad2DTextures;
|
||||
QHash<int, BatchItemDetails> _registeredQuad2DTextures;
|
||||
|
||||
QHash<IntPair, QOpenGLBuffer> _gridBuffers;
|
||||
QHash<int, QOpenGLBuffer> _registeredAlternateGridBuffers;
|
||||
QHash<Vec3Pair, QOpenGLBuffer> _alternateGridBuffers;
|
||||
QHash<int, Vec3Pair> _lastRegisteredGrid;
|
||||
QHash<int, Vec3Pair> _lastRegisteredQuad3D;
|
||||
QHash<Vec3Pair, BatchItemDetails> _quad3D;
|
||||
QHash<int, BatchItemDetails> _registeredQuad3D;
|
||||
|
||||
QHash<int, Vec2Pair> _lastRegisteredQuad2D;
|
||||
QHash<Vec2Pair, BatchItemDetails> _quad2D;
|
||||
QHash<int, BatchItemDetails> _registeredQuad2D;
|
||||
|
||||
QHash<int, Vec3Pair> _lastRegisteredBevelRects;
|
||||
QHash<Vec3Pair, BatchItemDetails> _bevelRects;
|
||||
QHash<int, BatchItemDetails> _registeredBevelRects;
|
||||
|
||||
QHash<int, Vec3Pair> _lastRegisteredLine3D;
|
||||
QHash<Vec3Pair, BatchItemDetails> _line3DVBOs;
|
||||
QHash<int, BatchItemDetails> _registeredLine3DVBOs;
|
||||
|
||||
QHash<int, Vec2Pair> _lastRegisteredLine2D;
|
||||
QHash<Vec2Pair, BatchItemDetails> _line2DVBOs;
|
||||
QHash<int, BatchItemDetails> _registeredLine2DVBOs;
|
||||
|
||||
QHash<int, BatchItemDetails> _registeredVertices;
|
||||
|
||||
QHash<int, Vec3PairVec2Pair> _lastRegisteredDashedLines;
|
||||
QHash<Vec3PairVec2Pair, BatchItemDetails> _dashedLines;
|
||||
QHash<int, BatchItemDetails> _registeredDashedLines;
|
||||
|
||||
QHash<IntPair, gpu::BufferPointer> _gridBuffers;
|
||||
QHash<int, gpu::BufferPointer> _registeredAlternateGridBuffers;
|
||||
QHash<Vec3Pair, gpu::BufferPointer> _alternateGridBuffers;
|
||||
QHash<Vec3Pair, gpu::BufferPointer> _gridColors;
|
||||
|
||||
QHash<Vec2Pair, gpu::BufferPointer> _sphereVertices;
|
||||
QHash<IntPair, gpu::BufferPointer> _sphereIndices;
|
||||
QHash<Vec3Pair, gpu::BufferPointer> _sphereColors;
|
||||
|
||||
|
||||
QHash<QUrl, QWeakPointer<NetworkGeometry> > _networkGeometry;
|
||||
};
|
||||
|
@ -211,7 +300,7 @@ public:
|
|||
|
||||
const FBXGeometry& getFBXGeometry() const { return _geometry; }
|
||||
const QVector<NetworkMesh>& getMeshes() const { return _meshes; }
|
||||
|
||||
//
|
||||
QVector<int> getJointMappings(const AnimationPointer& animation);
|
||||
|
||||
virtual void setLoadPriority(const QPointer<QObject>& owner, float priority);
|
||||
|
|
|
@ -167,7 +167,6 @@ QOpenGLFramebufferObject* GlowEffect::render(bool toTexture) {
|
|||
}
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
glDisable(GL_LIGHTING);
|
||||
glColor3f(1.0f, 1.0f, 1.0f);
|
||||
renderFullscreenQuad();
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
glEnable(GL_LIGHTING);
|
||||
|
|
|
@ -17,9 +17,11 @@
|
|||
#include "RenderUtil.h"
|
||||
|
||||
void renderFullscreenQuad(float sMin, float sMax, float tMin, float tMax) {
|
||||
glm::vec4 color(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
glm::vec2 topLeft(-1.0f, -1.0f);
|
||||
glm::vec2 bottomRight(1.0f, 1.0f);
|
||||
glm::vec2 texCoordTopLeft(sMin, tMin);
|
||||
glm::vec2 texCoordBottomRight(sMax, tMax);
|
||||
DependencyManager::get<GeometryCache>()->renderQuad(topLeft, bottomRight, texCoordTopLeft, texCoordBottomRight);
|
||||
|
||||
DependencyManager::get<GeometryCache>()->renderQuad(topLeft, bottomRight, texCoordTopLeft, texCoordBottomRight, color);
|
||||
}
|
||||
|
|
|
@ -70,16 +70,11 @@ int TextRenderer::calculateHeight(const char* str) {
|
|||
return maxHeight;
|
||||
}
|
||||
|
||||
int TextRenderer::draw(int x, int y, const char* str, float alpha) {
|
||||
// Grab the current color
|
||||
float currentColor[4];
|
||||
glGetFloatv(GL_CURRENT_COLOR, currentColor);
|
||||
alpha = std::max(0.0f, std::min(alpha, 1.0f));
|
||||
currentColor[3] *= alpha;
|
||||
int compactColor = ((int(currentColor[0] * 255.0f) & 0xFF)) |
|
||||
((int(currentColor[1] * 255.0f) & 0xFF) << 8) |
|
||||
((int(currentColor[2] * 255.0f) & 0xFF) << 16) |
|
||||
((int(currentColor[3] * 255.0f) & 0xFF) << 24);
|
||||
int TextRenderer::draw(int x, int y, const char* str, const glm::vec4& color) {
|
||||
int compactColor = ((int(color.x * 255.0f) & 0xFF)) |
|
||||
((int(color.y * 255.0f) & 0xFF) << 8) |
|
||||
((int(color.z * 255.0f) & 0xFF) << 16) |
|
||||
((int(color.w * 255.0f) & 0xFF) << 24);
|
||||
|
||||
int maxHeight = 0;
|
||||
for (const char* ch = str; *ch != 0; ch++) {
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
#define hifi_TextRenderer_h
|
||||
|
||||
#include <gpu/GPUConfig.h>
|
||||
#include <glm/glm.hpp>
|
||||
|
||||
#include <QColor>
|
||||
#include <QFont>
|
||||
|
@ -70,7 +71,7 @@ public:
|
|||
int calculateHeight(const char* str);
|
||||
|
||||
// also returns the height of the tallest character
|
||||
int draw(int x, int y, const char* str, float alpha = 1.0f);
|
||||
int draw(int x, int y, const char* str, const glm::vec4& color);
|
||||
|
||||
int computeWidth(char ch);
|
||||
int computeWidth(const char* str);
|
||||
|
|
|
@ -154,14 +154,16 @@ const gpu::TexturePointer& TextureCache::getPermutationNormalTexture() {
|
|||
}
|
||||
|
||||
const unsigned char OPAQUE_WHITE[] = { 0xFF, 0xFF, 0xFF, 0xFF };
|
||||
const unsigned char TRANSPARENT_WHITE[] = { 0xFF, 0xFF, 0xFF, 0x0 };
|
||||
const unsigned char OPAQUE_BLACK[] = { 0x0, 0x0, 0x0, 0xFF };
|
||||
//const unsigned char TRANSPARENT_WHITE[] = { 0xFF, 0xFF, 0xFF, 0x0 };
|
||||
//const unsigned char OPAQUE_BLACK[] = { 0x0, 0x0, 0x0, 0xFF };
|
||||
const unsigned char OPAQUE_BLUE[] = { 0x80, 0x80, 0xFF, 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() {
|
||||
if (_whiteTexture.isNull()) {
|
||||
|
@ -387,7 +389,7 @@ NetworkTexture::NetworkTexture(const QUrl& url, TextureType type, const QByteArr
|
|||
if (!url.isValid()) {
|
||||
_loaded = true;
|
||||
}
|
||||
|
||||
|
||||
// default to white/blue/black
|
||||
/* glBindTexture(GL_TEXTURE_2D, getID());
|
||||
switch (type) {
|
||||
|
@ -458,13 +460,18 @@ void ImageReader::run() {
|
|||
int originalWidth = image.width();
|
||||
int originalHeight = image.height();
|
||||
|
||||
// enforce a fixed maximum
|
||||
const int MAXIMUM_SIZE = 1024;
|
||||
if (image.width() > MAXIMUM_SIZE || image.height() > MAXIMUM_SIZE) {
|
||||
qDebug() << "Image greater than maximum size:" << _url << image.width() << image.height();
|
||||
image = image.scaled(MAXIMUM_SIZE, MAXIMUM_SIZE, Qt::KeepAspectRatio);
|
||||
}
|
||||
// enforce a fixed maximum area (1024 * 2048)
|
||||
const int MAXIMUM_AREA_SIZE = 2097152;
|
||||
int imageArea = image.width() * image.height();
|
||||
if (imageArea > MAXIMUM_AREA_SIZE) {
|
||||
float scaleRatio = sqrtf((float)MAXIMUM_AREA_SIZE) / sqrtf((float)imageArea);
|
||||
int resizeWidth = static_cast<int>(std::floor(scaleRatio * static_cast<float>(image.width())));
|
||||
int resizeHeight = static_cast<int>(std::floor(scaleRatio * static_cast<float>(image.height())));
|
||||
qDebug() << "Image greater than maximum size:" << _url << image.width() << image.height() <<
|
||||
" scaled to:" << resizeWidth << resizeHeight;
|
||||
image = image.scaled(resizeWidth, resizeHeight, Qt::IgnoreAspectRatio);
|
||||
imageArea = image.width() * image.height();
|
||||
}
|
||||
|
||||
const int EIGHT_BIT_MAXIMUM = 255;
|
||||
if (!image.hasAlphaChannel()) {
|
||||
|
|
|
@ -115,6 +115,16 @@ QDebug& operator<<(QDebug& dbg, const glm::vec3& v) {
|
|||
return dbg;
|
||||
}
|
||||
|
||||
QDebug& operator<<(QDebug& dbg, const glm::vec4& v) {
|
||||
dbg.nospace() << "{type='glm::vec4'"
|
||||
", x=" << v.x <<
|
||||
", y=" << v.y <<
|
||||
", z=" << v.z <<
|
||||
", w=" << v.w <<
|
||||
"}";
|
||||
return dbg;
|
||||
}
|
||||
|
||||
QDebug& operator<<(QDebug& dbg, const glm::quat& q) {
|
||||
dbg.nospace() << "{type='glm::quat'"
|
||||
", x=" << q.x <<
|
||||
|
|
|
@ -51,6 +51,7 @@ class QDebug;
|
|||
// Add support for writing these to qDebug().
|
||||
QDebug& operator<<(QDebug& s, const glm::vec2& v);
|
||||
QDebug& operator<<(QDebug& s, const glm::vec3& v);
|
||||
QDebug& operator<<(QDebug& s, const glm::vec4& v);
|
||||
QDebug& operator<<(QDebug& s, const glm::quat& q);
|
||||
QDebug& operator<<(QDebug& s, const glm::mat4& m);
|
||||
#endif // QT_NO_DEBUG_STREAM
|
||||
|
|
Loading…
Reference in a new issue