mirror of
https://github.com/overte-org/overte.git
synced 2025-04-21 09:44:21 +02:00
Merge branch 'master' of https://github.com/worklist/hifi
This commit is contained in:
commit
b76f5bf272
46 changed files with 1163 additions and 828 deletions
|
@ -15,8 +15,8 @@ macro(INCLUDE_DEPENDENCY_INCLUDES)
|
|||
|
||||
# include those in our own target
|
||||
include_directories(SYSTEM ${${TARGET_NAME}_DEPENDENCY_INCLUDES})
|
||||
endif ()
|
||||
|
||||
# set the property on this target so it can be retreived by targets linking to us
|
||||
set_target_properties(${TARGET_NAME} PROPERTIES DEPENDENCY_INCLUDES "${${TARGET_NAME}_DEPENDENCY_INCLUDES}")
|
||||
|
||||
# set the property on this target so it can be retreived by targets linking to us
|
||||
set_target_properties(${TARGET_NAME} PROPERTIES DEPENDENCY_INCLUDES "${${TARGET_NAME}_DEPENDENCY_INCLUDES}")
|
||||
endif()
|
||||
endmacro(INCLUDE_DEPENDENCY_INCLUDES)
|
|
@ -27,7 +27,10 @@ macro(LINK_HIFI_LIBRARIES)
|
|||
|
||||
# ask the library what its include dependencies are and link them
|
||||
get_target_property(LINKED_TARGET_DEPENDENCY_INCLUDES ${HIFI_LIBRARY} DEPENDENCY_INCLUDES)
|
||||
list(APPEND ${TARGET_NAME}_DEPENDENCY_INCLUDES ${LINKED_TARGET_DEPENDENCY_INCLUDES})
|
||||
|
||||
if(LINKED_TARGET_DEPENDENCY_INCLUDES)
|
||||
list(APPEND ${TARGET_NAME}_DEPENDENCY_INCLUDES ${LINKED_TARGET_DEPENDENCY_INCLUDES})
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
endmacro(LINK_HIFI_LIBRARIES)
|
|
@ -494,8 +494,10 @@ var mouseHasMovedSincePress = false;
|
|||
|
||||
function mousePressEvent(event) {
|
||||
mouseHasMovedSincePress = false;
|
||||
mouseCapturedByTool = false;
|
||||
|
||||
if (toolBar.mousePressEvent(event) || progressDialog.mousePressEvent(event)) {
|
||||
if (toolBar.mousePressEvent(event) || progressDialog.mousePressEvent(event) || gridTool.mousePressEvent(event)) {
|
||||
mouseCapturedByTool = true;
|
||||
return;
|
||||
}
|
||||
if (isActive) {
|
||||
|
@ -519,6 +521,7 @@ function mousePressEvent(event) {
|
|||
}
|
||||
|
||||
var highlightedEntityID = { isKnownID: false };
|
||||
var mouseCapturedByTool = false;
|
||||
|
||||
function mouseMoveEvent(event) {
|
||||
mouseHasMovedSincePress = true;
|
||||
|
@ -563,6 +566,9 @@ function mouseReleaseEvent(event) {
|
|||
if (isActive && selectionManager.hasSelection()) {
|
||||
tooltip.show(false);
|
||||
}
|
||||
if (mouseCapturedByTool) {
|
||||
return;
|
||||
}
|
||||
|
||||
cameraManager.mouseReleaseEvent(event);
|
||||
|
||||
|
|
|
@ -1,167 +0,0 @@
|
|||
<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 },
|
||||
];
|
||||
|
||||
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,
|
||||
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) {
|
||||
return function() {
|
||||
gridColor = color;
|
||||
emitUpdate();
|
||||
}
|
||||
}({ red: colors.red, green: colors.green, blue: colors.blue }));
|
||||
}
|
||||
|
||||
EventBridge.emitWebEvent(JSON.stringify({ type: 'init' }));
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body onload='loaded();'>
|
||||
<div class="section-header">
|
||||
<label>Horizontal Grid</label>
|
||||
</div>
|
||||
|
||||
<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>
|
|
@ -1,35 +1,35 @@
|
|||
Grid = function(opts) {
|
||||
var that = {};
|
||||
|
||||
var color = { red: 100, green: 152, blue: 203 };
|
||||
var gridColor = { red: 100, green: 152, blue: 203 };
|
||||
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: 0, blue: 0 },
|
||||
];
|
||||
var colorIndex = 0;
|
||||
var gridAlpha = 1.0;
|
||||
var origin = { x: 0, y: 0, z: 0 };
|
||||
var majorGridEvery = 5;
|
||||
var minorGridSpacing = 0.2;
|
||||
var minorGridWidth = 0.2;
|
||||
var halfSize = 40;
|
||||
var yOffset = 0.001;
|
||||
|
||||
var worldSize = 16384;
|
||||
|
||||
var minorGridWidth = 0.5;
|
||||
var majorGridWidth = 1.5;
|
||||
|
||||
var snapToGrid = false;
|
||||
|
||||
var gridOverlay = Overlays.addOverlay("grid", {
|
||||
position: { x: 0 , y: 0, z: 0 },
|
||||
visible: true,
|
||||
color: { red: 0, green: 0, blue: 128 },
|
||||
color: colors[0],
|
||||
alpha: 1.0,
|
||||
rotation: Quat.fromPitchYawRollDegrees(90, 0, 0),
|
||||
minorGridWidth: 0.1,
|
||||
majorGridEvery: 2,
|
||||
});
|
||||
|
||||
that.getMinorIncrement = function() { return minorGridSpacing; };
|
||||
that.getMajorIncrement = function() { return minorGridSpacing * majorGridEvery; };
|
||||
|
||||
that.visible = false;
|
||||
that.enabled = false;
|
||||
|
||||
|
@ -37,13 +37,39 @@ Grid = function(opts) {
|
|||
return origin;
|
||||
}
|
||||
|
||||
that.getMinorIncrement = function() { return minorGridWidth; };
|
||||
that.getMajorIncrement = function() { return minorGridWidth * majorGridEvery; };
|
||||
|
||||
that.getMinorGridWidth = function() { return minorGridWidth; };
|
||||
that.setMinorGridWidth = function(value) {
|
||||
minorGridWidth = value;
|
||||
updateGrid();
|
||||
};
|
||||
|
||||
that.getMajorGridEvery = function() { return majorGridEvery; };
|
||||
that.setMajorGridEvery = function(value) {
|
||||
majorGridEvery = value;
|
||||
updateGrid();
|
||||
};
|
||||
|
||||
that.getColorIndex = function() { return colorIndex; };
|
||||
that.setColorIndex = function(value) {
|
||||
colorIndex = value;
|
||||
updateGrid();
|
||||
};
|
||||
|
||||
that.getSnapToGrid = function() { return snapToGrid; };
|
||||
that.setSnapToGrid = function(value) {
|
||||
snapToGrid = value;
|
||||
that.emitUpdate();
|
||||
};
|
||||
|
||||
that.setEnabled = function(enabled) {
|
||||
that.enabled = enabled;
|
||||
updateGrid();
|
||||
}
|
||||
|
||||
that.getVisible = function() { return that.visible; };
|
||||
that.setVisible = function(visible, noUpdate) {
|
||||
that.visible = visible;
|
||||
updateGrid();
|
||||
|
@ -78,7 +104,7 @@ Grid = function(opts) {
|
|||
dimensions = { x: 0, y: 0, z: 0 };
|
||||
}
|
||||
|
||||
var spacing = majorOnly ? (minorGridSpacing * majorGridEvery) : minorGridSpacing;
|
||||
var spacing = majorOnly ? (minorGridWidth * majorGridEvery) : minorGridWidth;
|
||||
|
||||
position = Vec3.subtract(position, origin);
|
||||
|
||||
|
@ -94,7 +120,7 @@ Grid = function(opts) {
|
|||
return delta;
|
||||
}
|
||||
|
||||
var spacing = majorOnly ? (minorGridSpacing * majorGridEvery) : minorGridSpacing;
|
||||
var spacing = majorOnly ? (minorGridWidth * majorGridEvery) : minorGridWidth;
|
||||
|
||||
var snappedDelta = {
|
||||
x: Math.round(delta.x / spacing) * spacing,
|
||||
|
@ -121,12 +147,11 @@ Grid = function(opts) {
|
|||
if (that.onUpdate) {
|
||||
that.onUpdate({
|
||||
origin: origin,
|
||||
minorGridSpacing: minorGridSpacing,
|
||||
minorGridWidth: minorGridWidth,
|
||||
majorGridEvery: majorGridEvery,
|
||||
gridSize: halfSize,
|
||||
visible: that.visible,
|
||||
snapToGrid: snapToGrid,
|
||||
gridColor: gridColor,
|
||||
});
|
||||
}
|
||||
};
|
||||
|
@ -144,16 +169,16 @@ Grid = function(opts) {
|
|||
that.setPosition(pos, true);
|
||||
}
|
||||
|
||||
if (data.minorGridSpacing) {
|
||||
minorGridSpacing = data.minorGridSpacing;
|
||||
if (data.minorGridWidth) {
|
||||
minorGridWidth = data.minorGridWidth;
|
||||
}
|
||||
|
||||
if (data.majorGridEvery) {
|
||||
majorGridEvery = data.majorGridEvery;
|
||||
}
|
||||
|
||||
if (data.gridColor) {
|
||||
gridColor = data.gridColor;
|
||||
if (data.colorIndex !== undefined) {
|
||||
colorIndex = data.colorIndex;
|
||||
}
|
||||
|
||||
if (data.gridSize) {
|
||||
|
@ -171,10 +196,10 @@ Grid = function(opts) {
|
|||
Overlays.editOverlay(gridOverlay, {
|
||||
position: { x: origin.y, y: origin.y, z: -origin.y },
|
||||
visible: that.visible && that.enabled,
|
||||
minorGridWidth: minorGridSpacing,
|
||||
minorGridWidth: minorGridWidth,
|
||||
majorGridEvery: majorGridEvery,
|
||||
color: gridColor,
|
||||
alpha: gridAlpha,
|
||||
color: colors[colorIndex],
|
||||
alpha: gridAlpha,
|
||||
});
|
||||
|
||||
that.emitUpdate();
|
||||
|
@ -199,46 +224,269 @@ 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 url = Script.resolvePath('html/gridControls.html');
|
||||
var webView = new WebWindow('Grid', url, 200, 280);
|
||||
var uiOverlays = {};
|
||||
var allOverlays = [];
|
||||
|
||||
horizontalGrid.addListener(function(data) {
|
||||
webView.eventBridge.emitScriptEvent(JSON.stringify(data));
|
||||
selectionDisplay.updateHandles();
|
||||
});
|
||||
function addUIOverlay(key, overlay, x, y, width, height) {
|
||||
uiOverlays[key] = {
|
||||
overlay: overlay,
|
||||
x: x,
|
||||
y: y,
|
||||
width: width,
|
||||
height: height,
|
||||
};
|
||||
allOverlays.push(overlay);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
} else if (data.type == "action") {
|
||||
var action = data.action;
|
||||
if (action == "moveToAvatar") {
|
||||
grid.setPosition(MyAvatar.position);
|
||||
} else if (action == "moveToSelection") {
|
||||
var newPosition = selectionManager.worldPosition;
|
||||
newPosition = Vec3.subtract(newPosition, { x: 0, y: selectionManager.worldDimensions.y * 0.5, z: 0 });
|
||||
grid.setPosition(newPosition);
|
||||
}
|
||||
var lastKnownWindowWidth = null;
|
||||
function repositionUI() {
|
||||
if (lastKnownWindowWidth == Window.innerWidth) {
|
||||
return;
|
||||
}
|
||||
});
|
||||
|
||||
that.addListener = function(callback) {
|
||||
listeners.push(callback);
|
||||
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 baseOverlay = null;
|
||||
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;
|
||||
if (baseOverlay == null) {
|
||||
overlay = Overlays.addOverlay("image", {
|
||||
imageURL: UI_URL,
|
||||
});
|
||||
baseOverlay = overlay;
|
||||
} else {
|
||||
overlay = Overlays.cloneOverlay(baseOverlay);
|
||||
}
|
||||
|
||||
Overlays.editOverlay(overlay, 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,
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
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) {
|
||||
webView.setVisible(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) {
|
||||
horizontalGrid.setPosition(MyAvatar.position);
|
||||
} else if (overlay == uiOverlays.moveToSelection.overlay) {
|
||||
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 });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 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();
|
||||
});
|
||||
|
||||
updateOverlays();
|
||||
repositionUI();
|
||||
|
||||
return that;
|
||||
};
|
||||
|
|
|
@ -1306,21 +1306,13 @@ void Audio::renderToolBox(int x, int y, bool boxed) {
|
|||
} else {
|
||||
glColor3f(0.41f, 0.41f, 0.41f);
|
||||
}
|
||||
glBegin(GL_QUADS);
|
||||
|
||||
glTexCoord2f(1, 1);
|
||||
glVertex2f(boxBounds.left(), boxBounds.top());
|
||||
|
||||
glTexCoord2f(0, 1);
|
||||
glVertex2f(boxBounds.right(), boxBounds.top());
|
||||
|
||||
glTexCoord2f(0, 0);
|
||||
glVertex2f(boxBounds.right(), boxBounds.bottom());
|
||||
|
||||
glTexCoord2f(1, 0);
|
||||
glVertex2f(boxBounds.left(), boxBounds.bottom());
|
||||
|
||||
glEnd();
|
||||
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);
|
||||
}
|
||||
|
||||
_iconBounds = QRect(x, y, MUTE_ICON_SIZE, MUTE_ICON_SIZE);
|
||||
|
@ -1345,21 +1337,14 @@ void Audio::renderToolBox(int x, int y, bool boxed) {
|
|||
}
|
||||
|
||||
glColor3f(_iconColor, _iconColor, _iconColor);
|
||||
glBegin(GL_QUADS);
|
||||
|
||||
glm::vec2 topLeft(_iconBounds.left(), _iconBounds.top());
|
||||
glm::vec2 bottomRight(_iconBounds.right(), _iconBounds.bottom());
|
||||
glm::vec2 texCoordTopLeft(1,1);
|
||||
glm::vec2 texCoordBottomRight(0,0);
|
||||
|
||||
glTexCoord2f(1.0f, 1.0f);
|
||||
glVertex2f(_iconBounds.left(), _iconBounds.top());
|
||||
|
||||
glTexCoord2f(0.0f, 1.0f);
|
||||
glVertex2f(_iconBounds.right(), _iconBounds.top());
|
||||
|
||||
glTexCoord2f(0.0f, 0.0f);
|
||||
glVertex2f(_iconBounds.right(), _iconBounds.bottom());
|
||||
|
||||
glTexCoord2f(1.0f, 0.0f);
|
||||
glVertex2f(_iconBounds.left(), _iconBounds.bottom());
|
||||
|
||||
glEnd();
|
||||
DependencyManager::get<GeometryCache>()->renderQuad(topLeft, bottomRight, texCoordTopLeft, texCoordBottomRight);
|
||||
|
||||
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
}
|
||||
|
@ -1702,14 +1687,7 @@ void Audio::renderScope(int width, int height) {
|
|||
void Audio::renderBackground(const float* color, int x, int y, int width, int height) {
|
||||
|
||||
glColor4fv(color);
|
||||
glBegin(GL_QUADS);
|
||||
|
||||
glVertex2i(x, y);
|
||||
glVertex2i(x + width, y);
|
||||
glVertex2i(x + width, y + height);
|
||||
glVertex2i(x , y + height);
|
||||
|
||||
glEnd();
|
||||
DependencyManager::get<GeometryCache>()->renderQuad(x, y, width, height);
|
||||
glColor4f(1, 1, 1, 1);
|
||||
}
|
||||
|
||||
|
|
|
@ -55,8 +55,8 @@ static const QString MODEL_URL = "/api/v1/models";
|
|||
|
||||
static const QString SETTING_NAME = "LastModelUploadLocation";
|
||||
|
||||
static const int BYTES_PER_MEGABYTES = 1024 * 1024;
|
||||
static const unsigned long MAX_SIZE = 50 * 1024 * BYTES_PER_MEGABYTES; // 50 GB (Virtually remove limit)
|
||||
static const long long BYTES_PER_MEGABYTES = 1024 * 1024;
|
||||
static const unsigned long long MAX_SIZE = 50 * 1024 * BYTES_PER_MEGABYTES; // 50 GB (Virtually remove limit)
|
||||
static const int MAX_TEXTURE_SIZE = 1024;
|
||||
static const int TIMEOUT = 1000;
|
||||
static const int MAX_CHECK = 30;
|
||||
|
|
|
@ -130,38 +130,10 @@ void renderCollisionOverlay(int width, int height, float magnitude, float red, f
|
|||
const float MIN_VISIBLE_COLLISION = 0.01f;
|
||||
if (magnitude > MIN_VISIBLE_COLLISION) {
|
||||
glColor4f(red, blue, green, magnitude);
|
||||
glBegin(GL_QUADS);
|
||||
glVertex2f(0, 0);
|
||||
glVertex2d(width, 0);
|
||||
glVertex2d(width, height);
|
||||
glVertex2d(0, height);
|
||||
glEnd();
|
||||
DependencyManager::get<GeometryCache>()->renderQuad(0, 0, width, height);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void renderCircle(glm::vec3 position, float radius, glm::vec3 surfaceNormal, int numSides) {
|
||||
glm::vec3 perp1 = glm::vec3(surfaceNormal.y, surfaceNormal.z, surfaceNormal.x);
|
||||
glm::vec3 perp2 = glm::vec3(surfaceNormal.z, surfaceNormal.x, surfaceNormal.y);
|
||||
|
||||
glBegin(GL_LINE_STRIP);
|
||||
|
||||
for (int i=0; i<numSides+1; i++) {
|
||||
float r = ((float)i / (float)numSides) * TWO_PI;
|
||||
float s = radius * sinf(r);
|
||||
float c = radius * cosf(r);
|
||||
glVertex3f
|
||||
(
|
||||
position.x + perp1.x * s + perp2.x * c,
|
||||
position.y + perp1.y * s + perp2.y * c,
|
||||
position.z + perp1.z * s + perp2.z * c
|
||||
);
|
||||
}
|
||||
glEnd();
|
||||
}
|
||||
|
||||
|
||||
void renderBevelCornersRect(int x, int y, int width, int height, int bevelDistance) {
|
||||
glBegin(GL_POLYGON);
|
||||
|
||||
|
|
|
@ -633,17 +633,14 @@ void Avatar::renderBillboard() {
|
|||
glScalef(size, size, size);
|
||||
|
||||
glColor3f(1.0f, 1.0f, 1.0f);
|
||||
|
||||
glBegin(GL_QUADS);
|
||||
glTexCoord2f(0.0f, 0.0f);
|
||||
glVertex2f(-1.0f, -1.0f);
|
||||
glTexCoord2f(1.0f, 0.0f);
|
||||
glVertex2f(1.0f, -1.0f);
|
||||
glTexCoord2f(1.0f, 1.0f);
|
||||
glVertex2f(1.0f, 1.0f);
|
||||
glTexCoord2f(0.0f, 1.0f);
|
||||
glVertex2f(-1.0f, 1.0f);
|
||||
glEnd();
|
||||
|
||||
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);
|
||||
|
||||
|
||||
glPopMatrix();
|
||||
|
||||
|
|
|
@ -106,23 +106,17 @@ bool raySphereIntersect(const glm::vec3 &dir, const glm::vec3 &origin, float r,
|
|||
}
|
||||
|
||||
void renderReticle(glm::quat orientation, float alpha) {
|
||||
glm::vec3 topLeft = getPoint(reticleSize / 2.0f, -reticleSize / 2.0f);
|
||||
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);
|
||||
|
||||
glPushMatrix(); {
|
||||
glm::vec3 axis = glm::axis(orientation);
|
||||
glRotatef(glm::degrees(glm::angle(orientation)), axis.x, axis.y, axis.z);
|
||||
|
||||
glBegin(GL_QUADS); {
|
||||
glColor4f(RETICLE_COLOR[0], RETICLE_COLOR[1], RETICLE_COLOR[2], alpha);
|
||||
|
||||
glTexCoord2f(0.0f, 0.0f); glVertex3f(topLeft.x, topLeft.y, topLeft.z);
|
||||
glTexCoord2f(1.0f, 0.0f); glVertex3f(bottomLeft.x, bottomLeft.y, bottomLeft.z);
|
||||
glTexCoord2f(1.0f, 1.0f); glVertex3f(bottomRight.x, bottomRight.y, bottomRight.z);
|
||||
glTexCoord2f(0.0f, 1.0f); glVertex3f(topRight.x, topRight.y, topRight.z);
|
||||
} glEnd();
|
||||
glm::vec3 topLeft = getPoint(reticleSize / 2.0f, -reticleSize / 2.0f);
|
||||
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);
|
||||
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));
|
||||
} glPopMatrix();
|
||||
}
|
||||
|
||||
|
@ -229,13 +223,14 @@ void ApplicationOverlay::displayOverlayTexture() {
|
|||
glDisable(GL_LIGHTING);
|
||||
glEnable(GL_BLEND);
|
||||
|
||||
glBegin(GL_QUADS); {
|
||||
glColor4f(1.0f, 1.0f, 1.0f, _alpha);
|
||||
glTexCoord2f(0, 0); glVertex2i(0, glCanvas->getDeviceHeight());
|
||||
glTexCoord2f(1, 0); glVertex2i(glCanvas->getDeviceWidth(), glCanvas->getDeviceHeight());
|
||||
glTexCoord2f(1, 1); glVertex2i(glCanvas->getDeviceWidth(), 0);
|
||||
glTexCoord2f(0, 1); glVertex2i(0, 0);
|
||||
} glEnd();
|
||||
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);
|
||||
|
||||
} glPopMatrix();
|
||||
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
|
@ -370,15 +365,13 @@ void ApplicationOverlay::displayOverlayTexture3DTV(Camera& whichCamera, float as
|
|||
GLfloat x = -halfQuadWidth;
|
||||
GLfloat y = -halfQuadHeight;
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
|
||||
glBegin(GL_QUADS);
|
||||
|
||||
glTexCoord2f(0.0f, 1.0f); glVertex3f(x, y + quadHeight, -distance);
|
||||
glTexCoord2f(1.0f, 1.0f); glVertex3f(x + quadWidth, y + quadHeight, -distance);
|
||||
glTexCoord2f(1.0f, 0.0f); glVertex3f(x + quadWidth, y, -distance);
|
||||
glTexCoord2f(0.0f, 0.0f); glVertex3f(x, y, -distance);
|
||||
|
||||
glEnd();
|
||||
|
||||
DependencyManager::get<GeometryCache>()->renderQuad(glm::vec3(x, y + quadHeight, -distance),
|
||||
glm::vec3(x + quadWidth, y + quadHeight, -distance),
|
||||
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));
|
||||
|
||||
GLCanvas::SharedPointer glCanvas = DependencyManager::get<GLCanvas>();
|
||||
if (_crosshairTexture == 0) {
|
||||
|
@ -394,17 +387,15 @@ void ApplicationOverlay::displayOverlayTexture3DTV(Camera& whichCamera, float as
|
|||
const float mouseX = (application->getMouseX() / (float)glCanvas->width()) * quadWidth;
|
||||
const float mouseY = (1.0 - (application->getMouseY() / (float)glCanvas->height())) * quadHeight;
|
||||
|
||||
glBegin(GL_QUADS);
|
||||
|
||||
glColor3f(RETICLE_COLOR[0], RETICLE_COLOR[1], RETICLE_COLOR[2]);
|
||||
|
||||
glTexCoord2d(0.0f, 0.0f); glVertex3f(x + mouseX, y + mouseY, -distance);
|
||||
glTexCoord2d(1.0f, 0.0f); glVertex3f(x + mouseX + reticleSize, y + mouseY, -distance);
|
||||
glTexCoord2d(1.0f, 1.0f); glVertex3f(x + mouseX + reticleSize, y + mouseY - reticleSize, -distance);
|
||||
glTexCoord2d(0.0f, 1.0f); glVertex3f(x + mouseX, y + mouseY - reticleSize, -distance);
|
||||
|
||||
glEnd();
|
||||
|
||||
|
||||
DependencyManager::get<GeometryCache>()->renderQuad(glm::vec3(x + mouseX, y + mouseY, -distance),
|
||||
glm::vec3(x + mouseX + reticleSize, y + mouseY, -distance),
|
||||
glm::vec3(x + mouseX + reticleSize, y + mouseY - reticleSize, -distance),
|
||||
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));
|
||||
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
|
||||
glPopMatrix();
|
||||
|
@ -658,16 +649,16 @@ void ApplicationOverlay::renderControllerPointers() {
|
|||
mouseX -= reticleSize / 2.0f;
|
||||
mouseY += reticleSize / 2.0f;
|
||||
|
||||
glBegin(GL_QUADS);
|
||||
|
||||
glColor3f(RETICLE_COLOR[0], RETICLE_COLOR[1], RETICLE_COLOR[2]);
|
||||
|
||||
glTexCoord2d(0.0f, 0.0f); glVertex2i(mouseX, mouseY);
|
||||
glTexCoord2d(1.0f, 0.0f); glVertex2i(mouseX + reticleSize, mouseY);
|
||||
glTexCoord2d(1.0f, 1.0f); glVertex2i(mouseX + reticleSize, mouseY - reticleSize);
|
||||
glTexCoord2d(0.0f, 1.0f); glVertex2i(mouseX, mouseY - reticleSize);
|
||||
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);
|
||||
|
||||
glEnd();
|
||||
DependencyManager::get<GeometryCache>()->renderQuad(topLeft, bottomRight, texCoordTopLeft, texCoordBottomRight);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -750,13 +741,13 @@ void ApplicationOverlay::renderMagnifier(glm::vec2 magPos, float sizeMult, bool
|
|||
glEnable(GL_TEXTURE_2D);
|
||||
}
|
||||
glColor4f(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));
|
||||
|
||||
glBegin(GL_QUADS); {
|
||||
glTexCoord2f(magnifyULeft, magnifyVBottom); glVertex3f(bottomLeft.x, bottomLeft.y, bottomLeft.z);
|
||||
glTexCoord2f(magnifyURight, magnifyVBottom); glVertex3f(bottomRight.x, bottomRight.y, bottomRight.z);
|
||||
glTexCoord2f(magnifyURight, magnifyVTop); glVertex3f(topRight.x, topRight.y, topRight.z);
|
||||
glTexCoord2f(magnifyULeft, magnifyVTop); glVertex3f(topLeft.x, topLeft.y, topLeft.z);
|
||||
} glEnd();
|
||||
} glPopMatrix();
|
||||
}
|
||||
|
||||
|
@ -835,7 +826,6 @@ void ApplicationOverlay::renderAudioMeter() {
|
|||
|
||||
audio->renderStats(WHITE_TEXT, glCanvas->width(), glCanvas->height());
|
||||
|
||||
glBegin(GL_QUADS);
|
||||
if (isClipping) {
|
||||
glColor3f(1, 0, 0);
|
||||
} else {
|
||||
|
@ -846,10 +836,7 @@ void ApplicationOverlay::renderAudioMeter() {
|
|||
|
||||
glColor3f(0, 0, 0);
|
||||
// Draw audio meter background Quad
|
||||
glVertex2i(AUDIO_METER_X, audioMeterY);
|
||||
glVertex2i(AUDIO_METER_X + AUDIO_METER_WIDTH, audioMeterY);
|
||||
glVertex2i(AUDIO_METER_X + AUDIO_METER_WIDTH, audioMeterY + AUDIO_METER_HEIGHT);
|
||||
glVertex2i(AUDIO_METER_X, audioMeterY + AUDIO_METER_HEIGHT);
|
||||
DependencyManager::get<GeometryCache>()->renderQuad(AUDIO_METER_X, audioMeterY, AUDIO_METER_WIDTH, AUDIO_METER_HEIGHT);
|
||||
|
||||
if (audioLevel > AUDIO_RED_START) {
|
||||
if (!isClipping) {
|
||||
|
@ -858,12 +845,14 @@ void ApplicationOverlay::renderAudioMeter() {
|
|||
glColor3f(1, 1, 1);
|
||||
}
|
||||
// Draw Red Quad
|
||||
glVertex2i(AUDIO_METER_X + AUDIO_METER_INSET + AUDIO_RED_START, audioMeterY + AUDIO_METER_INSET);
|
||||
glVertex2i(AUDIO_METER_X + AUDIO_METER_INSET + audioLevel, audioMeterY + AUDIO_METER_INSET);
|
||||
glVertex2i(AUDIO_METER_X + AUDIO_METER_INSET + audioLevel, audioMeterY + AUDIO_METER_HEIGHT - AUDIO_METER_INSET);
|
||||
glVertex2i(AUDIO_METER_X + AUDIO_METER_INSET + AUDIO_RED_START, audioMeterY + AUDIO_METER_HEIGHT - AUDIO_METER_INSET);
|
||||
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);
|
||||
|
||||
audioLevel = AUDIO_RED_START;
|
||||
}
|
||||
|
||||
if (audioLevel > AUDIO_GREEN_START) {
|
||||
if (!isClipping) {
|
||||
glColor3fv(AUDIO_METER_GREEN);
|
||||
|
@ -871,10 +860,11 @@ void ApplicationOverlay::renderAudioMeter() {
|
|||
glColor3f(1, 1, 1);
|
||||
}
|
||||
// Draw Green Quad
|
||||
glVertex2i(AUDIO_METER_X + AUDIO_METER_INSET + AUDIO_GREEN_START, audioMeterY + AUDIO_METER_INSET);
|
||||
glVertex2i(AUDIO_METER_X + AUDIO_METER_INSET + audioLevel, audioMeterY + AUDIO_METER_INSET);
|
||||
glVertex2i(AUDIO_METER_X + AUDIO_METER_INSET + audioLevel, audioMeterY + AUDIO_METER_HEIGHT - AUDIO_METER_INSET);
|
||||
glVertex2i(AUDIO_METER_X + AUDIO_METER_INSET + AUDIO_GREEN_START, audioMeterY + AUDIO_METER_HEIGHT - AUDIO_METER_INSET);
|
||||
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);
|
||||
|
||||
audioLevel = AUDIO_GREEN_START;
|
||||
}
|
||||
// Draw Blue Quad
|
||||
|
@ -884,11 +874,9 @@ void ApplicationOverlay::renderAudioMeter() {
|
|||
glColor3f(1, 1, 1);
|
||||
}
|
||||
// Draw Blue (low level) quad
|
||||
glVertex2i(AUDIO_METER_X + AUDIO_METER_INSET, audioMeterY + AUDIO_METER_INSET);
|
||||
glVertex2i(AUDIO_METER_X + AUDIO_METER_INSET + audioLevel, audioMeterY + AUDIO_METER_INSET);
|
||||
glVertex2i(AUDIO_METER_X + AUDIO_METER_INSET + audioLevel, audioMeterY + AUDIO_METER_HEIGHT - AUDIO_METER_INSET);
|
||||
glVertex2i(AUDIO_METER_X + AUDIO_METER_INSET, audioMeterY + AUDIO_METER_HEIGHT - AUDIO_METER_INSET);
|
||||
glEnd();
|
||||
DependencyManager::get<GeometryCache>()->renderQuad(AUDIO_METER_X + AUDIO_METER_INSET,
|
||||
audioMeterY + AUDIO_METER_INSET,
|
||||
audioLevel, AUDIO_METER_HEIGHT - AUDIO_METER_INSET);
|
||||
}
|
||||
|
||||
void ApplicationOverlay::renderStatsAndLogs() {
|
||||
|
|
|
@ -11,6 +11,9 @@
|
|||
|
||||
#include <cstdio>
|
||||
|
||||
#include <DependencyManager.h>
|
||||
#include <GeometryCache.h>
|
||||
|
||||
#include "BandwidthMeter.h"
|
||||
#include "InterfaceConfig.h"
|
||||
|
||||
|
@ -92,13 +95,7 @@ void BandwidthMeter::setColorRGBA(unsigned c) {
|
|||
}
|
||||
|
||||
void BandwidthMeter::renderBox(int x, int y, int w, int h) {
|
||||
|
||||
glBegin(GL_QUADS);
|
||||
glVertex2i(x, y);
|
||||
glVertex2i(x + w, y);
|
||||
glVertex2i(x + w, y + h);
|
||||
glVertex2i(x, y + h);
|
||||
glEnd();
|
||||
DependencyManager::get<GeometryCache>()->renderQuad(x, y, w, h);
|
||||
}
|
||||
|
||||
void BandwidthMeter::renderVerticalLine(int x, int y, int h) {
|
||||
|
|
|
@ -140,22 +140,14 @@ void RearMirrorTools::displayIcon(QRect bounds, QRect iconBounds, GLuint texture
|
|||
}
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D, textureId);
|
||||
glBegin(GL_QUADS);
|
||||
{
|
||||
glTexCoord2f(0, 0);
|
||||
glVertex2f(iconBounds.left(), iconBounds.bottom());
|
||||
|
||||
glTexCoord2f(0, 1);
|
||||
glVertex2f(iconBounds.left(), iconBounds.top());
|
||||
|
||||
glTexCoord2f(1, 1);
|
||||
glVertex2f(iconBounds.right(), iconBounds.top());
|
||||
|
||||
glTexCoord2f(1, 0);
|
||||
glVertex2f(iconBounds.right(), iconBounds.bottom());
|
||||
|
||||
}
|
||||
glEnd();
|
||||
|
||||
glm::vec2 topLeft(iconBounds.left(), iconBounds.top());
|
||||
glm::vec2 bottomRight(iconBounds.right(), iconBounds.bottom());
|
||||
glm::vec2 texCoordTopLeft(0.0f, 1.0f);
|
||||
glm::vec2 texCoordBottomRight(1.0f, 0.0f);
|
||||
|
||||
DependencyManager::get<GeometryCache>()->renderQuad(topLeft, bottomRight, texCoordTopLeft, texCoordBottomRight);
|
||||
|
||||
glPopMatrix();
|
||||
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
|
|
|
@ -154,16 +154,13 @@ 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) {
|
||||
glBegin(GL_QUADS);
|
||||
glColor4f(((rgba >> 24) & 0xff) / 255.0f,
|
||||
((rgba >> 16) & 0xff) / 255.0f,
|
||||
((rgba >> 8) & 0xff) / 255.0f,
|
||||
(rgba & 0xff) / 255.0f);
|
||||
glVertex3f(x, y, 0);
|
||||
glVertex3f(x + width, y, 0);
|
||||
glVertex3f(x + width, y + height, 0);
|
||||
glVertex3f(x , y + height, 0);
|
||||
glEnd();
|
||||
|
||||
DependencyManager::get<GeometryCache>()->renderQuad(x, y, width, height);
|
||||
|
||||
glColor4f(1, 1, 1, 1);
|
||||
}
|
||||
|
||||
|
|
|
@ -96,21 +96,16 @@ void BillboardOverlay::render(RenderArgs* args) {
|
|||
xColor color = getColor();
|
||||
float alpha = getAlpha();
|
||||
glColor4f(color.red / MAX_COLOR, color.green / MAX_COLOR, color.blue / MAX_COLOR, alpha);
|
||||
glBegin(GL_QUADS); {
|
||||
glTexCoord2f((float)_fromImage.x() / (float)_size.width(),
|
||||
(float)_fromImage.y() / (float)_size.height());
|
||||
|
||||
glm::vec2 topLeft(-x, -y);
|
||||
glm::vec2 bottomRight(x, y);
|
||||
glm::vec2 texCoordTopLeft((float)_fromImage.x() / (float)_size.width(),
|
||||
(float)_fromImage.y() / (float)_size.height());
|
||||
glm::vec2 texCoordBottomRight(((float)_fromImage.x() + (float)_fromImage.width()) / (float)_size.width(),
|
||||
((float)_fromImage.y() + (float)_fromImage.height()) / _size.height());
|
||||
|
||||
glVertex2f(-x, -y);
|
||||
glTexCoord2f(((float)_fromImage.x() + (float)_fromImage.width()) / (float)_size.width(),
|
||||
(float)_fromImage.y() / (float)_size.height());
|
||||
glVertex2f(x, -y);
|
||||
glTexCoord2f(((float)_fromImage.x() + (float)_fromImage.width()) / (float)_size.width(),
|
||||
((float)_fromImage.y() + (float)_fromImage.height()) / _size.height());
|
||||
glVertex2f(x, y);
|
||||
glTexCoord2f((float)_fromImage.x() / (float)_size.width(),
|
||||
((float)_fromImage.y() + (float)_fromImage.height()) / (float)_size.height());
|
||||
glVertex2f(-x, y);
|
||||
} glEnd();
|
||||
DependencyManager::get<GeometryCache>()->renderQuad(topLeft, bottomRight, texCoordTopLeft, texCoordBottomRight);
|
||||
|
||||
}
|
||||
} glPopMatrix();
|
||||
|
||||
|
|
|
@ -14,6 +14,9 @@
|
|||
#include <QGLWidget>
|
||||
#include <QPainter>
|
||||
#include <QSvgRenderer>
|
||||
|
||||
#include <DependencyManager.h>
|
||||
#include <GeometryCache.h>
|
||||
#include <SharedUtil.h>
|
||||
|
||||
#include "ImageOverlay.h"
|
||||
|
@ -105,27 +108,16 @@ void ImageOverlay::render(RenderArgs* args) {
|
|||
int top = _bounds.top();
|
||||
int bottom = _bounds.bottom() + 1;
|
||||
|
||||
glBegin(GL_QUADS);
|
||||
if (_renderImage) {
|
||||
glTexCoord2f(x, 1.0f - y);
|
||||
}
|
||||
glVertex2f(left, top);
|
||||
glm::vec2 topLeft(left, top);
|
||||
glm::vec2 bottomRight(right, bottom);
|
||||
glm::vec2 texCoordTopLeft(x, 1.0f - y);
|
||||
glm::vec2 texCoordBottomRight(x + w, 1.0f - (y + h));
|
||||
|
||||
if (_renderImage) {
|
||||
glTexCoord2f(x + w, 1.0f - y);
|
||||
}
|
||||
glVertex2f(right, top);
|
||||
|
||||
if (_renderImage) {
|
||||
glTexCoord2f(x + w, 1.0f - (y + h));
|
||||
}
|
||||
glVertex2f(right, bottom);
|
||||
|
||||
if (_renderImage) {
|
||||
glTexCoord2f(x, 1.0f - (y + h));
|
||||
}
|
||||
glVertex2f(left, bottom);
|
||||
glEnd();
|
||||
if (_renderImage) {
|
||||
DependencyManager::get<GeometryCache>()->renderQuad(topLeft, bottomRight, texCoordTopLeft, texCoordBottomRight);
|
||||
} else {
|
||||
DependencyManager::get<GeometryCache>()->renderQuad(topLeft, bottomRight);
|
||||
}
|
||||
|
||||
if (_renderImage) {
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
|
||||
#include <QGLWidget>
|
||||
|
||||
#include <GeometryCache.h>
|
||||
#include <GlowEffect.h>
|
||||
#include <SharedUtil.h>
|
||||
|
||||
|
@ -66,14 +67,9 @@ void Rectangle3DOverlay::render(RenderArgs* args) {
|
|||
|
||||
// for our overlay, is solid means we draw a solid "filled" rectangle otherwise we just draw a border line...
|
||||
if (getIsSolid()) {
|
||||
glBegin(GL_QUADS);
|
||||
|
||||
glVertex3f(-halfDimensions.x, 0.0f, -halfDimensions.y);
|
||||
glVertex3f(halfDimensions.x, 0.0f, -halfDimensions.y);
|
||||
glVertex3f(halfDimensions.x, 0.0f, halfDimensions.y);
|
||||
glVertex3f(-halfDimensions.x, 0.0f, halfDimensions.y);
|
||||
|
||||
glEnd();
|
||||
glm::vec3 topLeft(-halfDimensions.x, 0.0f, -halfDimensions.y);
|
||||
glm::vec3 bottomRight(halfDimensions.x, 0.0f, halfDimensions.y);
|
||||
DependencyManager::get<GeometryCache>()->renderQuad(topLeft, bottomRight);
|
||||
} else {
|
||||
if (getIsDashedLine()) {
|
||||
|
||||
|
|
|
@ -100,12 +100,9 @@ void Text3DOverlay::render(RenderArgs* args) {
|
|||
|
||||
const float SLIGHTLY_BEHIND = -0.005f;
|
||||
|
||||
glBegin(GL_QUADS);
|
||||
glVertex3f(-halfDimensions.x, -halfDimensions.y, SLIGHTLY_BEHIND);
|
||||
glVertex3f(halfDimensions.x, -halfDimensions.y, SLIGHTLY_BEHIND);
|
||||
glVertex3f(halfDimensions.x, halfDimensions.y, SLIGHTLY_BEHIND);
|
||||
glVertex3f(-halfDimensions.x, halfDimensions.y, SLIGHTLY_BEHIND);
|
||||
glEnd();
|
||||
glm::vec3 topLeft(-halfDimensions.x, -halfDimensions.y, SLIGHTLY_BEHIND);
|
||||
glm::vec3 bottomRight(halfDimensions.x, halfDimensions.y, SLIGHTLY_BEHIND);
|
||||
DependencyManager::get<GeometryCache>()->renderQuad(topLeft, bottomRight);
|
||||
|
||||
const int FIXED_FONT_SCALING_RATIO = FIXED_FONT_POINT_SIZE * 40.0f; // this is a ratio determined through experimentation
|
||||
|
||||
|
|
|
@ -12,6 +12,9 @@
|
|||
#include "InterfaceConfig.h"
|
||||
|
||||
#include <QGLWidget>
|
||||
|
||||
#include <DependencyManager.h>
|
||||
#include <GeometryCache.h>
|
||||
#include <SharedUtil.h>
|
||||
#include <TextRenderer.h>
|
||||
|
||||
|
@ -75,12 +78,9 @@ void TextOverlay::render(RenderArgs* args) {
|
|||
int top = _bounds.top();
|
||||
int bottom = _bounds.bottom() + 1;
|
||||
|
||||
glBegin(GL_QUADS);
|
||||
glVertex2f(left, top);
|
||||
glVertex2f(right, top);
|
||||
glVertex2f(right, bottom);
|
||||
glVertex2f(left, bottom);
|
||||
glEnd();
|
||||
glm::vec2 topLeft(left, top);
|
||||
glm::vec2 bottomRight(right, bottom);
|
||||
DependencyManager::get<GeometryCache>()->renderQuad(topLeft, bottomRight);
|
||||
|
||||
// Same font properties as textSize()
|
||||
TextRenderer* textRenderer = TextRenderer::getInstance(SANS_FONT_FAMILY, _fontSize, DEFAULT_FONT_WEIGHT);
|
||||
|
|
|
@ -12,16 +12,18 @@
|
|||
#include "AnimationCache.h"
|
||||
#include "AnimationLoop.h"
|
||||
|
||||
const float AnimationLoop::MAXIMUM_POSSIBLE_FRAME = 100000.0f;
|
||||
|
||||
AnimationLoop::AnimationLoop() :
|
||||
_fps(30.0f),
|
||||
_loop(false),
|
||||
_hold(false),
|
||||
_startAutomatically(false),
|
||||
_firstFrame(0.0f),
|
||||
_lastFrame(FLT_MAX),
|
||||
_lastFrame(MAXIMUM_POSSIBLE_FRAME),
|
||||
_running(false),
|
||||
_frameIndex(0.0f),
|
||||
_maxFrameIndexHint(FLT_MAX)
|
||||
_maxFrameIndexHint(MAXIMUM_POSSIBLE_FRAME)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -53,10 +55,9 @@ AnimationLoop::AnimationLoop(float fps, bool loop, bool hold, bool startAutomati
|
|||
void AnimationLoop::simulate(float deltaTime) {
|
||||
_frameIndex += deltaTime * _fps;
|
||||
|
||||
|
||||
// If we knew the number of frames from the animation, we'd consider using it here
|
||||
// animationGeometry.animationFrames.size()
|
||||
float maxFrame = _maxFrameIndexHint;
|
||||
float maxFrame = _maxFrameIndexHint;
|
||||
float endFrameIndex = qMin(_lastFrame, maxFrame - (_loop ? 0.0f : 1.0f));
|
||||
float startFrameIndex = qMin(_firstFrame, endFrameIndex);
|
||||
if ((!_loop && (_frameIndex < startFrameIndex || _frameIndex > endFrameIndex)) || startFrameIndex == endFrameIndex) {
|
||||
|
|
|
@ -16,6 +16,8 @@ class AnimationDetails;
|
|||
|
||||
class AnimationLoop {
|
||||
public:
|
||||
static const float MAXIMUM_POSSIBLE_FRAME;
|
||||
|
||||
AnimationLoop();
|
||||
AnimationLoop(const AnimationDetails& animationDetails);
|
||||
AnimationLoop(float fps, bool loop, bool hold, bool startAutomatically, float firstFrame,
|
||||
|
@ -33,10 +35,10 @@ public:
|
|||
void setStartAutomatically(bool startAutomatically);
|
||||
bool getStartAutomatically() const { return _startAutomatically; }
|
||||
|
||||
void setFirstFrame(float firstFrame) { _firstFrame = firstFrame; }
|
||||
void setFirstFrame(float firstFrame) { _firstFrame = glm::clamp(firstFrame, 0.0f, MAXIMUM_POSSIBLE_FRAME); }
|
||||
float getFirstFrame() const { return _firstFrame; }
|
||||
|
||||
void setLastFrame(float lastFrame) { _lastFrame = lastFrame; }
|
||||
void setLastFrame(float lastFrame) { _lastFrame = glm::clamp(lastFrame, 0.0f, MAXIMUM_POSSIBLE_FRAME); }
|
||||
float getLastFrame() const { return _lastFrame; }
|
||||
|
||||
void setRunning(bool running);
|
||||
|
@ -45,7 +47,7 @@ public:
|
|||
void setFrameIndex(float frameIndex) { _frameIndex = glm::clamp(frameIndex, _firstFrame, _lastFrame); }
|
||||
float getFrameIndex() const { return _frameIndex; }
|
||||
|
||||
void setMaxFrameIndexHint(float value) { _maxFrameIndexHint = value; }
|
||||
void setMaxFrameIndexHint(float value) { _maxFrameIndexHint = glm::clamp(value, 0.0f, MAXIMUM_POSSIBLE_FRAME); }
|
||||
float getMaxFrameIndexHint() const { return _maxFrameIndexHint; }
|
||||
|
||||
void start() { setRunning(true); }
|
||||
|
|
|
@ -12,6 +12,8 @@
|
|||
#include <glm/gtx/quaternion.hpp>
|
||||
|
||||
#include <gpu/GPUConfig.h>
|
||||
|
||||
#include <GeometryCache.h>
|
||||
#include <PerfStat.h>
|
||||
#include <TextRenderer.h>
|
||||
|
||||
|
@ -51,12 +53,9 @@ void RenderableTextEntityItem::render(RenderArgs* args) {
|
|||
|
||||
const float SLIGHTLY_BEHIND = -0.005f;
|
||||
|
||||
glBegin(GL_QUADS);
|
||||
glVertex3f(-halfDimensions.x, -halfDimensions.y, SLIGHTLY_BEHIND);
|
||||
glVertex3f(halfDimensions.x, -halfDimensions.y, SLIGHTLY_BEHIND);
|
||||
glVertex3f(halfDimensions.x, halfDimensions.y, SLIGHTLY_BEHIND);
|
||||
glVertex3f(-halfDimensions.x, halfDimensions.y, SLIGHTLY_BEHIND);
|
||||
glEnd();
|
||||
glm::vec3 topLeft(-halfDimensions.x, -halfDimensions.y, SLIGHTLY_BEHIND);
|
||||
glm::vec3 bottomRight(halfDimensions.x, halfDimensions.y, SLIGHTLY_BEHIND);
|
||||
DependencyManager::get<GeometryCache>()->renderQuad(topLeft, bottomRight);
|
||||
|
||||
const int FIXED_FONT_SCALING_RATIO = FIXED_FONT_POINT_SIZE * 40.0f; // this is a ratio determined through experimentation
|
||||
|
||||
|
|
|
@ -401,6 +401,19 @@ void ModelEntityItem::setAnimationURL(const QString& url) {
|
|||
_animationURL = url;
|
||||
}
|
||||
|
||||
void ModelEntityItem::setAnimationFrameIndex(float value) {
|
||||
#ifdef WANT_DEBUG
|
||||
if (isAnimatingSomething()) {
|
||||
qDebug() << "ModelEntityItem::setAnimationFrameIndex()";
|
||||
qDebug() << " value:" << value;
|
||||
qDebug() << " was:" << _animationLoop.getFrameIndex();
|
||||
qDebug() << " model URL:" << getModelURL();
|
||||
qDebug() << " animation URL:" << getAnimationURL();
|
||||
}
|
||||
#endif
|
||||
_animationLoop.setFrameIndex(value);
|
||||
}
|
||||
|
||||
void ModelEntityItem::setAnimationSettings(const QString& value) {
|
||||
// the animations setting is a JSON string that may contain various animation settings.
|
||||
// if it includes fps, frameIndex, or running, those values will be parsed out and
|
||||
|
@ -416,6 +429,17 @@ void ModelEntityItem::setAnimationSettings(const QString& value) {
|
|||
|
||||
if (settingsMap.contains("frameIndex")) {
|
||||
float frameIndex = settingsMap["frameIndex"].toFloat();
|
||||
#ifdef WANT_DEBUG
|
||||
if (isAnimatingSomething()) {
|
||||
qDebug() << "ModelEntityItem::setAnimationSettings() calling setAnimationFrameIndex()...";
|
||||
qDebug() << " model URL:" << getModelURL();
|
||||
qDebug() << " animation URL:" << getAnimationURL();
|
||||
qDebug() << " settings:" << value;
|
||||
qDebug() << " settingsMap[frameIndex]:" << settingsMap["frameIndex"];
|
||||
qDebug(" frameIndex: %20.5f", frameIndex);
|
||||
}
|
||||
#endif
|
||||
|
||||
setAnimationFrameIndex(frameIndex);
|
||||
}
|
||||
|
||||
|
|
|
@ -75,7 +75,7 @@ public:
|
|||
void setModelURL(const QString& url) { _modelURL = url; }
|
||||
void setAnimationURL(const QString& url);
|
||||
static const float DEFAULT_ANIMATION_FRAME_INDEX;
|
||||
void setAnimationFrameIndex(float value) { _animationLoop.setFrameIndex(value); }
|
||||
void setAnimationFrameIndex(float value);
|
||||
void setAnimationSettings(const QString& value);
|
||||
|
||||
static const bool DEFAULT_ANIMATION_IS_PLAYING;
|
||||
|
|
|
@ -353,7 +353,7 @@ void DatagramSequencer::sendRecordLost(const SendRecord& record) {
|
|||
if (_packetDropCount == 0 || record.packetNumber == _lastPacketDropped + 1) {
|
||||
_packetDropCount++;
|
||||
_lastPacketDropped = record.packetNumber;
|
||||
const int CONSECUTIVE_DROPS_BEFORE_REDUCTION = 3;
|
||||
const int CONSECUTIVE_DROPS_BEFORE_REDUCTION = 1;
|
||||
if (_packetDropCount >= CONSECUTIVE_DROPS_BEFORE_REDUCTION && record.packetNumber >= _packetRateDecreasePacketNumber) {
|
||||
_packetsPerGroup = qMax(_packetsPerGroup * 0.5f, 1.0f);
|
||||
_slowStartThreshold = _packetsPerGroup;
|
||||
|
|
|
@ -147,28 +147,21 @@ QUdpSocket& LimitedNodeList::getDTLSSocket() {
|
|||
}
|
||||
|
||||
void LimitedNodeList::changeSocketBufferSizes(int numBytes) {
|
||||
// change the socket send buffer size to be 1MB
|
||||
int oldBufferSize = 0;
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
int sizeOfInt = sizeof(oldBufferSize);
|
||||
#else
|
||||
unsigned int sizeOfInt = sizeof(oldBufferSize);
|
||||
#endif
|
||||
|
||||
for (int i = 0; i < 2; i++) {
|
||||
int bufferOpt = (i == 0) ? SO_SNDBUF : SO_RCVBUF;
|
||||
|
||||
getsockopt(_nodeSocket.socketDescriptor(), SOL_SOCKET, bufferOpt, reinterpret_cast<char*>(&oldBufferSize), &sizeOfInt);
|
||||
|
||||
setsockopt(_nodeSocket.socketDescriptor(), SOL_SOCKET, bufferOpt, reinterpret_cast<const char*>(&numBytes),
|
||||
sizeof(numBytes));
|
||||
|
||||
QString bufferTypeString = (i == 0) ? "send" : "receive";
|
||||
|
||||
QAbstractSocket::SocketOption bufferOpt;
|
||||
QString bufferTypeString;
|
||||
if (i == 0) {
|
||||
bufferOpt = QAbstractSocket::SendBufferSizeSocketOption;
|
||||
bufferTypeString = "send";
|
||||
|
||||
} else {
|
||||
bufferOpt = QAbstractSocket::ReceiveBufferSizeSocketOption;
|
||||
bufferTypeString = "receive";
|
||||
}
|
||||
int oldBufferSize = _nodeSocket.socketOption(bufferOpt).toInt();
|
||||
if (oldBufferSize < numBytes) {
|
||||
int newBufferSize = 0;
|
||||
getsockopt(_nodeSocket.socketDescriptor(), SOL_SOCKET, bufferOpt, reinterpret_cast<char*>(&newBufferSize), &sizeOfInt);
|
||||
_nodeSocket.setSocketOption(bufferOpt, numBytes);
|
||||
int newBufferSize = _nodeSocket.socketOption(bufferOpt).toInt();
|
||||
|
||||
qDebug() << "Changed socket" << bufferTypeString << "buffer size from" << oldBufferSize << "to"
|
||||
<< newBufferSize << "bytes";
|
||||
|
|
|
@ -661,7 +661,290 @@ void GeometryCache::renderWireCube(float size) {
|
|||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
|
||||
}
|
||||
|
||||
void GeometryCache::renderQuad(const glm::vec2& topLeft, const glm::vec2& bottomRight) {
|
||||
Vec2Pair key(topLeft, bottomRight);
|
||||
VerticesIndices& vbo = _quad2DVBOs[key];
|
||||
const int FLOATS_PER_VERTEX = 2;
|
||||
const int NUM_BYTES_PER_VERTEX = FLOATS_PER_VERTEX * sizeof(GLfloat);
|
||||
const int vertices = 4;
|
||||
const int indices = 4;
|
||||
if (vbo.first == 0) {
|
||||
int vertexPoints = vertices * FLOATS_PER_VERTEX;
|
||||
GLfloat* vertexData = new GLfloat[vertexPoints]; // only vertices, no normals because we're a 2D quad
|
||||
GLfloat* vertex = vertexData;
|
||||
static GLubyte cannonicalIndices[indices] = {0, 1, 2, 3};
|
||||
|
||||
vertex[0] = topLeft.x;
|
||||
vertex[1] = topLeft.y;
|
||||
vertex[2] = bottomRight.x;
|
||||
vertex[3] = topLeft.y;
|
||||
vertex[4] = bottomRight.x;
|
||||
vertex[5] = bottomRight.y;
|
||||
vertex[6] = topLeft.x;
|
||||
vertex[7] = bottomRight.y;
|
||||
|
||||
glGenBuffers(1, &vbo.first);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, vbo.first);
|
||||
glBufferData(GL_ARRAY_BUFFER, vertices * NUM_BYTES_PER_VERTEX, vertexData, GL_STATIC_DRAW);
|
||||
delete[] vertexData;
|
||||
|
||||
GLushort* indexData = new GLushort[indices];
|
||||
GLushort* index = indexData;
|
||||
for (int i = 0; i < indices; i++) {
|
||||
index[i] = cannonicalIndices[i];
|
||||
}
|
||||
|
||||
glGenBuffers(1, &vbo.second);
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, vbo.second);
|
||||
glBufferData(GL_ELEMENT_ARRAY_BUFFER, indices * NUM_BYTES_PER_INDEX, indexData, GL_STATIC_DRAW);
|
||||
delete[] indexData;
|
||||
|
||||
#ifdef WANT_DEBUG
|
||||
qDebug() << "new quad VBO made -- _quad2DVBOs.size():" << _quad2DVBOs.size();
|
||||
#endif
|
||||
|
||||
} else {
|
||||
glBindBuffer(GL_ARRAY_BUFFER, vbo.first);
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, vbo.second);
|
||||
}
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
glVertexPointer(FLOATS_PER_VERTEX, GL_FLOAT, FLOATS_PER_VERTEX * sizeof(float), 0);
|
||||
glDrawRangeElementsEXT(GL_QUADS, 0, vertices - 1, indices, GL_UNSIGNED_SHORT, 0);
|
||||
glDisableClientState(GL_VERTEX_ARRAY);
|
||||
|
||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
|
||||
}
|
||||
|
||||
|
||||
void GeometryCache::renderQuad(const glm::vec2& topLeft, const glm::vec2& bottomRight,
|
||||
const glm::vec2& texCoordTopLeft, const glm::vec2& texCoordBottomRight) {
|
||||
Vec2PairPair key(Vec2Pair(topLeft, bottomRight), Vec2Pair(texCoordTopLeft, texCoordBottomRight));
|
||||
|
||||
VerticesIndices& vbo = _quad2DTextureVBOs[key];
|
||||
const int FLOATS_PER_VERTEX = 2 * 2; // text coords & vertices
|
||||
const int NUM_BYTES_PER_VERTEX = FLOATS_PER_VERTEX * sizeof(GLfloat);
|
||||
const int vertices = 4;
|
||||
const int indices = 4;
|
||||
if (vbo.first == 0) {
|
||||
int vertexPoints = vertices * FLOATS_PER_VERTEX;
|
||||
GLfloat* vertexData = new GLfloat[vertexPoints]; // text coords & vertices
|
||||
GLfloat* vertex = vertexData;
|
||||
static GLubyte cannonicalIndices[indices] = {0, 1, 2, 3};
|
||||
int v = 0;
|
||||
|
||||
vertex[v++] = topLeft.x;
|
||||
vertex[v++] = topLeft.y;
|
||||
vertex[v++] = texCoordTopLeft.x;
|
||||
vertex[v++] = texCoordTopLeft.y;
|
||||
|
||||
vertex[v++] = bottomRight.x;
|
||||
vertex[v++] = topLeft.y;
|
||||
vertex[v++] = texCoordBottomRight.x;
|
||||
vertex[v++] = texCoordTopLeft.y;
|
||||
|
||||
vertex[v++] = bottomRight.x;
|
||||
vertex[v++] = bottomRight.y;
|
||||
vertex[v++] = texCoordBottomRight.x;
|
||||
vertex[v++] = texCoordBottomRight.y;
|
||||
|
||||
vertex[v++] = topLeft.x;
|
||||
vertex[v++] = bottomRight.y;
|
||||
vertex[v++] = texCoordTopLeft.x;
|
||||
vertex[v++] = texCoordBottomRight.y;
|
||||
|
||||
glGenBuffers(1, &vbo.first);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, vbo.first);
|
||||
glBufferData(GL_ARRAY_BUFFER, vertices * NUM_BYTES_PER_VERTEX, vertexData, GL_STATIC_DRAW);
|
||||
delete[] vertexData;
|
||||
|
||||
GLushort* indexData = new GLushort[indices];
|
||||
GLushort* index = indexData;
|
||||
for (int i = 0; i < indices; i++) {
|
||||
index[i] = cannonicalIndices[i];
|
||||
}
|
||||
|
||||
glGenBuffers(1, &vbo.second);
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, vbo.second);
|
||||
glBufferData(GL_ELEMENT_ARRAY_BUFFER, indices * NUM_BYTES_PER_INDEX, indexData, GL_STATIC_DRAW);
|
||||
delete[] indexData;
|
||||
|
||||
#ifdef WANT_DEBUG
|
||||
qDebug() << "new quad + texture VBO made -- _quad2DTextureVBOs.size():" << _quad2DTextureVBOs.size();
|
||||
#endif
|
||||
} else {
|
||||
glBindBuffer(GL_ARRAY_BUFFER, vbo.first);
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, vbo.second);
|
||||
}
|
||||
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
glVertexPointer(2, GL_FLOAT, NUM_BYTES_PER_VERTEX, 0);
|
||||
glTexCoordPointer(2, GL_FLOAT, NUM_BYTES_PER_VERTEX, (const void *)(2 * sizeof(float)));
|
||||
|
||||
glDrawRangeElementsEXT(GL_QUADS, 0, vertices - 1, indices, GL_UNSIGNED_SHORT, 0);
|
||||
|
||||
glDisableClientState(GL_VERTEX_ARRAY);
|
||||
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
|
||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
|
||||
}
|
||||
|
||||
void GeometryCache::renderQuad(const glm::vec3& topLeft, const glm::vec3& bottomRight) {
|
||||
Vec3Pair key(topLeft, bottomRight);
|
||||
VerticesIndices& vbo = _quad3DVBOs[key];
|
||||
const int FLOATS_PER_VERTEX = 3;
|
||||
const int NUM_BYTES_PER_VERTEX = FLOATS_PER_VERTEX * sizeof(GLfloat);
|
||||
const int vertices = 4;
|
||||
const int indices = 4;
|
||||
if (vbo.first == 0) {
|
||||
int vertexPoints = vertices * FLOATS_PER_VERTEX;
|
||||
GLfloat* vertexData = new GLfloat[vertexPoints]; // only vertices
|
||||
GLfloat* vertex = vertexData;
|
||||
static GLubyte cannonicalIndices[indices] = {0, 1, 2, 3};
|
||||
int v = 0;
|
||||
|
||||
vertex[v++] = topLeft.x;
|
||||
vertex[v++] = topLeft.y;
|
||||
vertex[v++] = topLeft.z;
|
||||
|
||||
vertex[v++] = bottomRight.x;
|
||||
vertex[v++] = topLeft.y;
|
||||
vertex[v++] = topLeft.z;
|
||||
|
||||
vertex[v++] = bottomRight.x;
|
||||
vertex[v++] = bottomRight.y;
|
||||
vertex[v++] = bottomRight.z;
|
||||
|
||||
vertex[v++] = topLeft.x;
|
||||
vertex[v++] = bottomRight.y;
|
||||
vertex[v++] = bottomRight.z;
|
||||
|
||||
glGenBuffers(1, &vbo.first);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, vbo.first);
|
||||
glBufferData(GL_ARRAY_BUFFER, vertices * NUM_BYTES_PER_VERTEX, vertexData, GL_STATIC_DRAW);
|
||||
delete[] vertexData;
|
||||
|
||||
GLushort* indexData = new GLushort[indices];
|
||||
GLushort* index = indexData;
|
||||
for (int i = 0; i < indices; i++) {
|
||||
index[i] = cannonicalIndices[i];
|
||||
}
|
||||
|
||||
glGenBuffers(1, &vbo.second);
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, vbo.second);
|
||||
glBufferData(GL_ELEMENT_ARRAY_BUFFER, indices * NUM_BYTES_PER_INDEX, indexData, GL_STATIC_DRAW);
|
||||
delete[] indexData;
|
||||
|
||||
#ifdef WANT_DEBUG
|
||||
qDebug() << "new quad VBO made -- _quad3DVBOs.size():" << _quad3DVBOs.size();
|
||||
#endif
|
||||
|
||||
} else {
|
||||
glBindBuffer(GL_ARRAY_BUFFER, vbo.first);
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, vbo.second);
|
||||
}
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
glVertexPointer(FLOATS_PER_VERTEX, GL_FLOAT, FLOATS_PER_VERTEX * sizeof(float), 0);
|
||||
glDrawRangeElementsEXT(GL_QUADS, 0, vertices - 1, indices, GL_UNSIGNED_SHORT, 0);
|
||||
glDisableClientState(GL_VERTEX_ARRAY);
|
||||
|
||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
|
||||
}
|
||||
|
||||
|
||||
void GeometryCache::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) {
|
||||
|
||||
#ifdef WANT_DEBUG
|
||||
qDebug() << "renderQuad() vec3 + texture VBO...";
|
||||
qDebug() << " topLeft:" << topLeft;
|
||||
qDebug() << " bottomLeft:" << bottomLeft;
|
||||
qDebug() << " bottomRight:" << bottomRight;
|
||||
qDebug() << " topRight:" << topRight;
|
||||
qDebug() << " texCoordTopLeft:" << texCoordTopLeft;
|
||||
qDebug() << " texCoordBottomRight:" << texCoordBottomRight;
|
||||
#endif //def WANT_DEBUG
|
||||
|
||||
Vec3PairVec2Pair key(Vec3Pair(topLeft, bottomRight), Vec2Pair(texCoordTopLeft, texCoordBottomRight));
|
||||
|
||||
VerticesIndices& vbo = _quad3DTextureVBOs[key];
|
||||
const int FLOATS_PER_VERTEX = 5; // text coords & vertices
|
||||
const int NUM_BYTES_PER_VERTEX = FLOATS_PER_VERTEX * sizeof(GLfloat);
|
||||
const int vertices = 4;
|
||||
const int indices = 4;
|
||||
if (vbo.first == 0) {
|
||||
int vertexPoints = vertices * FLOATS_PER_VERTEX;
|
||||
GLfloat* vertexData = new GLfloat[vertexPoints]; // text coords & vertices
|
||||
GLfloat* vertex = vertexData;
|
||||
static GLubyte cannonicalIndices[indices] = {0, 1, 2, 3};
|
||||
int v = 0;
|
||||
|
||||
vertex[v++] = topLeft.x;
|
||||
vertex[v++] = topLeft.y;
|
||||
vertex[v++] = topLeft.z;
|
||||
vertex[v++] = texCoordTopLeft.x;
|
||||
vertex[v++] = texCoordTopLeft.y;
|
||||
|
||||
vertex[v++] = bottomLeft.x;
|
||||
vertex[v++] = bottomLeft.y;
|
||||
vertex[v++] = bottomLeft.z;
|
||||
vertex[v++] = texCoordBottomLeft.x;
|
||||
vertex[v++] = texCoordBottomLeft.y;
|
||||
|
||||
vertex[v++] = bottomRight.x;
|
||||
vertex[v++] = bottomRight.y;
|
||||
vertex[v++] = bottomRight.z;
|
||||
vertex[v++] = texCoordBottomRight.x;
|
||||
vertex[v++] = texCoordBottomRight.y;
|
||||
|
||||
vertex[v++] = topRight.x;
|
||||
vertex[v++] = topRight.y;
|
||||
vertex[v++] = topRight.z;
|
||||
vertex[v++] = texCoordTopRight.x;
|
||||
vertex[v++] = texCoordTopRight.y;
|
||||
|
||||
glGenBuffers(1, &vbo.first);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, vbo.first);
|
||||
glBufferData(GL_ARRAY_BUFFER, vertices * NUM_BYTES_PER_VERTEX, vertexData, GL_STATIC_DRAW);
|
||||
delete[] vertexData;
|
||||
|
||||
GLushort* indexData = new GLushort[indices];
|
||||
GLushort* index = indexData;
|
||||
for (int i = 0; i < indices; i++) {
|
||||
index[i] = cannonicalIndices[i];
|
||||
}
|
||||
|
||||
glGenBuffers(1, &vbo.second);
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, vbo.second);
|
||||
glBufferData(GL_ELEMENT_ARRAY_BUFFER, indices * NUM_BYTES_PER_INDEX, indexData, GL_STATIC_DRAW);
|
||||
delete[] indexData;
|
||||
|
||||
#ifdef WANT_DEBUG
|
||||
qDebug() << " _quad3DTextureVBOs.size():" << _quad3DTextureVBOs.size();
|
||||
#endif
|
||||
} else {
|
||||
glBindBuffer(GL_ARRAY_BUFFER, vbo.first);
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, vbo.second);
|
||||
}
|
||||
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
glVertexPointer(3, GL_FLOAT, NUM_BYTES_PER_VERTEX, 0);
|
||||
glTexCoordPointer(2, GL_FLOAT, NUM_BYTES_PER_VERTEX, (const void *)(3 * sizeof(float)));
|
||||
|
||||
glDrawRangeElementsEXT(GL_QUADS, 0, vertices - 1, indices, GL_UNSIGNED_SHORT, 0);
|
||||
|
||||
glDisableClientState(GL_VERTEX_ARRAY);
|
||||
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
|
||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
|
||||
}
|
||||
QSharedPointer<NetworkGeometry> GeometryCache::getGeometry(const QUrl& url, const QUrl& fallback, bool delayLoad) {
|
||||
return getResource(url, fallback, delayLoad).staticCast<NetworkGeometry>();
|
||||
}
|
||||
|
|
|
@ -31,6 +31,50 @@ class NetworkGeometry;
|
|||
class NetworkMesh;
|
||||
class NetworkTexture;
|
||||
|
||||
|
||||
typedef QPair<glm::vec2, glm::vec2> Vec2Pair;
|
||||
typedef QPair<Vec2Pair, Vec2Pair> Vec2PairPair;
|
||||
typedef QPair<glm::vec3, glm::vec3> Vec3Pair;
|
||||
typedef QPair<Vec3Pair, Vec2Pair> Vec3PairVec2Pair;
|
||||
|
||||
inline uint qHash(const glm::vec2& v, uint seed) {
|
||||
// multiply by prime numbers greater than the possible size
|
||||
return qHash(v.x + 5009 * v.y, seed);
|
||||
}
|
||||
|
||||
inline uint qHash(const Vec2Pair& v, uint seed) {
|
||||
// multiply by prime numbers greater than the possible size
|
||||
return qHash(v.first.x + 5009 * v.first.y + 5011 * v.second.x + 5021 * v.second.y, 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
|
||||
+ 5011 * v.first.second.x + 5021 * v.first.second.y
|
||||
+ 5023 * v.second.first.x + 5039 * v.second.first.y
|
||||
+ 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 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 +
|
||||
5021 * v.first.second.x + 5023 * v.first.second.y + 5039 * v.first.second.z +
|
||||
5051 * v.second.first.x + 5059 * v.second.first.y +
|
||||
5077 * v.second.second.x + 5081 * v.second.second.y, seed);
|
||||
}
|
||||
|
||||
|
||||
/// Stores cached geometry.
|
||||
class GeometryCache : public ResourceCache {
|
||||
Q_OBJECT
|
||||
|
@ -46,6 +90,24 @@ public:
|
|||
void renderSolidCube(float size);
|
||||
void renderWireCube(float size);
|
||||
|
||||
|
||||
void renderQuad(int x, int y, int width, int height) { renderQuad(glm::vec2(x,y), glm::vec2(x + width, y + height)); }
|
||||
void renderQuad(const glm::vec2& topLeft, const glm::vec2& bottomRight);
|
||||
|
||||
void renderQuad(const glm::vec2& topLeft, const glm::vec2& bottomRight,
|
||||
const glm::vec2& texCoordTopLeft, const glm::vec2& texCoordBottomRight);
|
||||
|
||||
|
||||
void renderQuad(const glm::vec3& topLeft, const glm::vec3& bottomRight);
|
||||
|
||||
//void renderQuad(const glm::vec3& topLeft, const glm::vec3& bottomRight,
|
||||
// const glm::vec2& texCoordTopLeft, const glm::vec2& texCoordBottomRight);
|
||||
|
||||
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);
|
||||
|
||||
/// Loads geometry from the specified URL.
|
||||
/// \param fallback a fallback URL to load if the desired one is unavailable
|
||||
/// \param delayLoad if true, don't load the geometry immediately; wait until load is first requested
|
||||
|
@ -70,6 +132,11 @@ private:
|
|||
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<IntPair, QOpenGLBuffer> _gridBuffers;
|
||||
|
||||
QHash<QUrl, QWeakPointer<NetworkGeometry> > _networkGeometry;
|
||||
|
|
|
@ -36,7 +36,25 @@
|
|||
#include "Model.h"
|
||||
|
||||
#include "model_vert.h"
|
||||
#include "model_shadow_vert.h"
|
||||
#include "model_normal_map_vert.h"
|
||||
#include "model_lightmap_vert.h"
|
||||
#include "model_lightmap_normal_map_vert.h"
|
||||
#include "skin_model_vert.h"
|
||||
#include "skin_model_shadow_vert.h"
|
||||
#include "skin_model_normal_map_vert.h"
|
||||
|
||||
#include "model_frag.h"
|
||||
#include "model_shadow_frag.h"
|
||||
#include "model_normal_map_frag.h"
|
||||
#include "model_normal_specular_map_frag.h"
|
||||
#include "model_specular_map_frag.h"
|
||||
#include "model_lightmap_frag.h"
|
||||
#include "model_lightmap_normal_map_frag.h"
|
||||
#include "model_lightmap_normal_specular_map_frag.h"
|
||||
#include "model_lightmap_specular_map_frag.h"
|
||||
#include "model_translucent_frag.h"
|
||||
|
||||
|
||||
#define GLBATCH( call ) batch._##call
|
||||
//#define GLBATCH( call ) call
|
||||
|
@ -237,106 +255,69 @@ void Model::init() {
|
|||
if (!_program.isLinked()) {
|
||||
_program.addShaderFromSourceCode(QGLShader::Vertex, model_vert);
|
||||
_program.addShaderFromSourceCode(QGLShader::Fragment, model_frag);
|
||||
|
||||
initProgram(_program, _locations);
|
||||
|
||||
_normalMapProgram.addShaderFromSourceFile(QGLShader::Vertex,
|
||||
PathUtils::resourcesPath() + "shaders/model_normal_map.vert");
|
||||
_normalMapProgram.addShaderFromSourceFile(QGLShader::Fragment,
|
||||
PathUtils::resourcesPath() + "shaders/model_normal_map.frag");
|
||||
|
||||
initProgram(_normalMapProgram, _normalMapLocations);
|
||||
|
||||
_specularMapProgram.addShaderFromSourceCode(QGLShader::Vertex, model_vert);
|
||||
_specularMapProgram.addShaderFromSourceFile(QGLShader::Fragment,
|
||||
PathUtils::resourcesPath() + "shaders/model_specular_map.frag");
|
||||
|
||||
initProgram(_specularMapProgram, _specularMapLocations);
|
||||
|
||||
_normalSpecularMapProgram.addShaderFromSourceFile(QGLShader::Vertex,
|
||||
PathUtils::resourcesPath() + "shaders/model_normal_map.vert");
|
||||
_normalSpecularMapProgram.addShaderFromSourceFile(QGLShader::Fragment,
|
||||
PathUtils::resourcesPath() + "shaders/model_normal_specular_map.frag");
|
||||
|
||||
initProgram(_normalSpecularMapProgram, _normalSpecularMapLocations);
|
||||
|
||||
_translucentProgram.addShaderFromSourceCode(QGLShader::Vertex, model_vert);
|
||||
_translucentProgram.addShaderFromSourceFile(QGLShader::Fragment,
|
||||
PathUtils::resourcesPath() + "shaders/model_translucent.frag");
|
||||
|
||||
initProgram(_translucentProgram, _translucentLocations);
|
||||
|
||||
// Lightmap
|
||||
_lightmapProgram.addShaderFromSourceFile(QGLShader::Vertex, PathUtils::resourcesPath() + "shaders/model_lightmap.vert");
|
||||
_lightmapProgram.addShaderFromSourceFile(QGLShader::Fragment, PathUtils::resourcesPath() + "shaders/model_lightmap.frag");
|
||||
|
||||
initProgram(_lightmapProgram, _lightmapLocations);
|
||||
|
||||
_lightmapNormalMapProgram.addShaderFromSourceFile(QGLShader::Vertex,
|
||||
PathUtils::resourcesPath() + "shaders/model_lightmap_normal_map.vert");
|
||||
_lightmapNormalMapProgram.addShaderFromSourceFile(QGLShader::Fragment,
|
||||
PathUtils::resourcesPath() + "shaders/model_lightmap_normal_map.frag");
|
||||
|
||||
initProgram(_lightmapNormalMapProgram, _lightmapNormalMapLocations);
|
||||
|
||||
_lightmapSpecularMapProgram.addShaderFromSourceFile(QGLShader::Vertex,
|
||||
PathUtils::resourcesPath() + "shaders/model_lightmap.vert");
|
||||
_lightmapSpecularMapProgram.addShaderFromSourceFile(QGLShader::Fragment,
|
||||
PathUtils::resourcesPath() + "shaders/model_lightmap_specular_map.frag");
|
||||
|
||||
initProgram(_lightmapSpecularMapProgram, _lightmapSpecularMapLocations);
|
||||
|
||||
_lightmapNormalSpecularMapProgram.addShaderFromSourceFile(QGLShader::Vertex,
|
||||
PathUtils::resourcesPath() + "shaders/model_lightmap_normal_map.vert");
|
||||
_lightmapNormalSpecularMapProgram.addShaderFromSourceFile(QGLShader::Fragment,
|
||||
PathUtils::resourcesPath() + "shaders/model_lightmap_normal_specular_map.frag");
|
||||
|
||||
initProgram(_lightmapNormalSpecularMapProgram, _lightmapNormalSpecularMapLocations);
|
||||
// end lightmap
|
||||
|
||||
|
||||
_shadowProgram.addShaderFromSourceFile(QGLShader::Vertex, PathUtils::resourcesPath() + "shaders/model_shadow.vert");
|
||||
_shadowProgram.addShaderFromSourceFile(QGLShader::Fragment,
|
||||
PathUtils::resourcesPath() + "shaders/model_shadow.frag");
|
||||
|
||||
_skinProgram.addShaderFromSourceFile(QGLShader::Vertex, PathUtils::resourcesPath() + "shaders/skin_model.vert");
|
||||
_skinProgram.addShaderFromSourceCode(QGLShader::Fragment, model_frag);
|
||||
|
||||
initSkinProgram(_skinProgram, _skinLocations);
|
||||
|
||||
_skinNormalMapProgram.addShaderFromSourceFile(QGLShader::Vertex,
|
||||
PathUtils::resourcesPath() + "shaders/skin_model_normal_map.vert");
|
||||
_skinNormalMapProgram.addShaderFromSourceFile(QGLShader::Fragment,
|
||||
PathUtils::resourcesPath() + "shaders/model_normal_map.frag");
|
||||
|
||||
initSkinProgram(_skinNormalMapProgram, _skinNormalMapLocations);
|
||||
|
||||
_skinSpecularMapProgram.addShaderFromSourceFile(QGLShader::Vertex,
|
||||
PathUtils::resourcesPath() + "shaders/skin_model.vert");
|
||||
_skinSpecularMapProgram.addShaderFromSourceFile(QGLShader::Fragment,
|
||||
PathUtils::resourcesPath() + "shaders/model_specular_map.frag");
|
||||
|
||||
initSkinProgram(_skinSpecularMapProgram, _skinSpecularMapLocations);
|
||||
|
||||
_skinNormalSpecularMapProgram.addShaderFromSourceFile(QGLShader::Vertex,
|
||||
PathUtils::resourcesPath() + "shaders/skin_model_normal_map.vert");
|
||||
_skinNormalSpecularMapProgram.addShaderFromSourceFile(QGLShader::Fragment,
|
||||
PathUtils::resourcesPath() + "shaders/model_normal_specular_map.frag");
|
||||
|
||||
initSkinProgram(_skinNormalSpecularMapProgram, _skinNormalSpecularMapLocations);
|
||||
|
||||
_skinShadowProgram.addShaderFromSourceFile(QGLShader::Vertex,
|
||||
PathUtils::resourcesPath() + "shaders/skin_model_shadow.vert");
|
||||
_skinShadowProgram.addShaderFromSourceFile(QGLShader::Fragment,
|
||||
PathUtils::resourcesPath() + "shaders/model_shadow.frag");
|
||||
|
||||
initSkinProgram(_skinShadowProgram, _skinShadowLocations);
|
||||
|
||||
_skinTranslucentProgram.addShaderFromSourceFile(QGLShader::Vertex,
|
||||
PathUtils::resourcesPath() + "shaders/skin_model.vert");
|
||||
_skinTranslucentProgram.addShaderFromSourceFile(QGLShader::Fragment,
|
||||
PathUtils::resourcesPath() + "shaders/model_translucent.frag");
|
||||
|
||||
_normalMapProgram.addShaderFromSourceCode(QGLShader::Vertex, model_normal_map_vert);
|
||||
_normalMapProgram.addShaderFromSourceCode(QGLShader::Fragment, model_normal_map_frag);
|
||||
initProgram(_normalMapProgram, _normalMapLocations);
|
||||
|
||||
_specularMapProgram.addShaderFromSourceCode(QGLShader::Vertex, model_vert);
|
||||
_specularMapProgram.addShaderFromSourceCode(QGLShader::Fragment, model_specular_map_frag);
|
||||
initProgram(_specularMapProgram, _specularMapLocations);
|
||||
|
||||
_normalSpecularMapProgram.addShaderFromSourceCode(QGLShader::Vertex, model_normal_map_vert);
|
||||
_normalSpecularMapProgram.addShaderFromSourceCode(QGLShader::Fragment, model_normal_specular_map_frag);
|
||||
initProgram(_normalSpecularMapProgram, _normalSpecularMapLocations);
|
||||
|
||||
_translucentProgram.addShaderFromSourceCode(QGLShader::Vertex, model_vert);
|
||||
_translucentProgram.addShaderFromSourceCode(QGLShader::Fragment, model_translucent_frag);
|
||||
initProgram(_translucentProgram, _translucentLocations);
|
||||
|
||||
// Lightmap
|
||||
_lightmapProgram.addShaderFromSourceCode(QGLShader::Vertex, model_lightmap_vert);
|
||||
_lightmapProgram.addShaderFromSourceCode(QGLShader::Fragment, model_lightmap_frag);
|
||||
initProgram(_lightmapProgram, _lightmapLocations);
|
||||
|
||||
_lightmapNormalMapProgram.addShaderFromSourceCode(QGLShader::Vertex, model_lightmap_normal_map_vert);
|
||||
_lightmapNormalMapProgram.addShaderFromSourceCode(QGLShader::Fragment, model_lightmap_normal_map_frag);
|
||||
initProgram(_lightmapNormalMapProgram, _lightmapNormalMapLocations);
|
||||
|
||||
_lightmapSpecularMapProgram.addShaderFromSourceCode(QGLShader::Vertex, model_lightmap_vert);
|
||||
_lightmapSpecularMapProgram.addShaderFromSourceCode(QGLShader::Fragment, model_lightmap_specular_map_frag);
|
||||
initProgram(_lightmapSpecularMapProgram, _lightmapSpecularMapLocations);
|
||||
|
||||
_lightmapNormalSpecularMapProgram.addShaderFromSourceCode(QGLShader::Vertex, model_lightmap_normal_map_vert);
|
||||
_lightmapNormalSpecularMapProgram.addShaderFromSourceCode(QGLShader::Fragment, model_lightmap_normal_specular_map_frag);
|
||||
initProgram(_lightmapNormalSpecularMapProgram, _lightmapNormalSpecularMapLocations);
|
||||
// end lightmap
|
||||
|
||||
|
||||
_shadowProgram.addShaderFromSourceCode(QGLShader::Vertex, model_shadow_vert);
|
||||
_shadowProgram.addShaderFromSourceCode(QGLShader::Fragment, model_shadow_frag);
|
||||
|
||||
_skinProgram.addShaderFromSourceCode(QGLShader::Vertex, skin_model_vert);
|
||||
_skinProgram.addShaderFromSourceCode(QGLShader::Fragment, model_frag);
|
||||
initSkinProgram(_skinProgram, _skinLocations);
|
||||
|
||||
_skinNormalMapProgram.addShaderFromSourceCode(QGLShader::Vertex, skin_model_normal_map_vert);
|
||||
_skinNormalMapProgram.addShaderFromSourceCode(QGLShader::Fragment, model_normal_map_frag);
|
||||
initSkinProgram(_skinNormalMapProgram, _skinNormalMapLocations);
|
||||
|
||||
_skinSpecularMapProgram.addShaderFromSourceCode(QGLShader::Vertex, model_vert);
|
||||
_skinSpecularMapProgram.addShaderFromSourceCode(QGLShader::Fragment, model_specular_map_frag);
|
||||
initSkinProgram(_skinSpecularMapProgram, _skinSpecularMapLocations);
|
||||
|
||||
_skinNormalSpecularMapProgram.addShaderFromSourceCode(QGLShader::Vertex, skin_model_normal_map_vert);
|
||||
_skinNormalSpecularMapProgram.addShaderFromSourceCode(QGLShader::Fragment, model_normal_specular_map_frag);
|
||||
initSkinProgram(_skinNormalSpecularMapProgram, _skinNormalSpecularMapLocations);
|
||||
|
||||
_skinShadowProgram.addShaderFromSourceCode(QGLShader::Vertex, skin_model_shadow_vert);
|
||||
_skinShadowProgram.addShaderFromSourceCode(QGLShader::Fragment, model_shadow_frag);
|
||||
initSkinProgram(_skinShadowProgram, _skinShadowLocations);
|
||||
|
||||
|
||||
_skinTranslucentProgram.addShaderFromSourceCode(QGLShader::Vertex, skin_model_vert);
|
||||
_skinTranslucentProgram.addShaderFromSourceCode(QGLShader::Fragment, model_translucent_frag);
|
||||
initSkinProgram(_skinTranslucentProgram, _skinTranslucentLocations);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,17 +10,16 @@
|
|||
//
|
||||
|
||||
#include <gpu/GPUConfig.h>
|
||||
|
||||
#include <DependencyManager.h>
|
||||
#include "GeometryCache.h"
|
||||
|
||||
#include "RenderUtil.h"
|
||||
|
||||
void renderFullscreenQuad(float sMin, float sMax, float tMin, float tMax) {
|
||||
glBegin(GL_QUADS);
|
||||
glTexCoord2f(sMin, tMin);
|
||||
glVertex2f(-1.0f, -1.0f);
|
||||
glTexCoord2f(sMax, tMin);
|
||||
glVertex2f(1.0f, -1.0f);
|
||||
glTexCoord2f(sMax, tMax);
|
||||
glVertex2f(1.0f, 1.0f);
|
||||
glTexCoord2f(sMin, tMax);
|
||||
glVertex2f(-1.0f, 1.0f);
|
||||
glEnd();
|
||||
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);
|
||||
}
|
||||
|
|
|
@ -81,9 +81,6 @@ int TextRenderer::draw(int x, int y, const char* str, float alpha) {
|
|||
((int(currentColor[2] * 255.0f) & 0xFF) << 16) |
|
||||
((int(currentColor[3] * 255.0f) & 0xFF) << 24);
|
||||
|
||||
// TODO: Remove that code once we test for performance improvments
|
||||
//glEnable(GL_TEXTURE_2D);
|
||||
|
||||
int maxHeight = 0;
|
||||
for (const char* ch = str; *ch != 0; ch++) {
|
||||
const Glyph& glyph = getGlyph(*ch);
|
||||
|
@ -111,20 +108,6 @@ int TextRenderer::draw(int x, int y, const char* str, float alpha) {
|
|||
float bt = glyph.location().y() * scale;
|
||||
float tt = (glyph.location().y() + glyph.bounds().height()) * scale;
|
||||
|
||||
// TODO: Remove that code once we test for performance improvments
|
||||
/*
|
||||
glBegin(GL_QUADS);
|
||||
glTexCoord2f(ls, bt);
|
||||
glVertex2f(left, bottom);
|
||||
glTexCoord2f(rs, bt);
|
||||
glVertex2f(right, bottom);
|
||||
glTexCoord2f(rs, tt);
|
||||
glVertex2f(right, top);
|
||||
glTexCoord2f(ls, tt);
|
||||
glVertex2f(left, top);
|
||||
glEnd();
|
||||
*/
|
||||
|
||||
const int NUM_COORDS_SCALARS_PER_GLYPH = 16;
|
||||
float vertexBuffer[NUM_COORDS_SCALARS_PER_GLYPH] = { leftBottom.x, leftBottom.y, ls, bt,
|
||||
rightTop.x, leftBottom.y, rs, bt,
|
||||
|
@ -152,10 +135,6 @@ int TextRenderer::draw(int x, int y, const char* str, float alpha) {
|
|||
drawBatch();
|
||||
clearBatch();
|
||||
|
||||
// TODO: Remove that code once we test for performance improvments
|
||||
// glBindTexture(GL_TEXTURE_2D, 0);
|
||||
// glDisable(GL_TEXTURE_2D);
|
||||
|
||||
return maxHeight;
|
||||
}
|
||||
|
||||
|
|
5
interface/resources/shaders/model_lightmap.frag → libraries/render-utils/src/model_lightmap.slf
Normal file → Executable file
5
interface/resources/shaders/model_lightmap.frag → libraries/render-utils/src/model_lightmap.slf
Normal file → Executable file
|
@ -1,5 +1,6 @@
|
|||
#version 120
|
||||
|
||||
<@include Config.slh@>
|
||||
<$VERSION_HEADER$>
|
||||
// Generated on <$_SCRIBE_DATE$>
|
||||
//
|
||||
// model_lightmap.frag
|
||||
// fragment shader
|
5
interface/resources/shaders/model_lightmap.vert → libraries/render-utils/src/model_lightmap.slv
Normal file → Executable file
5
interface/resources/shaders/model_lightmap.vert → libraries/render-utils/src/model_lightmap.slv
Normal file → Executable file
|
@ -1,5 +1,6 @@
|
|||
#version 120
|
||||
|
||||
<@include Config.slh@>
|
||||
<$VERSION_HEADER$>
|
||||
// Generated on <$_SCRIBE_DATE$>
|
||||
//
|
||||
// model_lightmap.vert
|
||||
// vertex shader
|
5
interface/resources/shaders/model_lightmap_normal_map.frag → libraries/render-utils/src/model_lightmap_normal_map.slf
Normal file → Executable file
5
interface/resources/shaders/model_lightmap_normal_map.frag → libraries/render-utils/src/model_lightmap_normal_map.slf
Normal file → Executable file
|
@ -1,5 +1,6 @@
|
|||
#version 120
|
||||
|
||||
<@include Config.slh@>
|
||||
<$VERSION_HEADER$>
|
||||
// Generated on <$_SCRIBE_DATE$>
|
||||
//
|
||||
// model_lightmap_normal_map.frag
|
||||
// fragment shader
|
5
interface/resources/shaders/model_lightmap_normal_map.vert → libraries/render-utils/src/model_lightmap_normal_map.slv
Normal file → Executable file
5
interface/resources/shaders/model_lightmap_normal_map.vert → libraries/render-utils/src/model_lightmap_normal_map.slv
Normal file → Executable file
|
@ -1,5 +1,6 @@
|
|||
#version 120
|
||||
|
||||
<@include Config.slh@>
|
||||
<$VERSION_HEADER$>
|
||||
// Generated on <$_SCRIBE_DATE$>
|
||||
//
|
||||
// model_lightmap_normal_map.vert
|
||||
// vertex shader
|
|
@ -1,5 +1,6 @@
|
|||
#version 120
|
||||
|
||||
<@include Config.slh@>
|
||||
<$VERSION_HEADER$>
|
||||
// Generated on <$_SCRIBE_DATE$>
|
||||
//
|
||||
// model_lightmap_normal_specular_map.frag
|
||||
// fragment shader
|
5
interface/resources/shaders/model_lightmap_specular_map.frag → libraries/render-utils/src/model_lightmap_specular_map.slf
Normal file → Executable file
5
interface/resources/shaders/model_lightmap_specular_map.frag → libraries/render-utils/src/model_lightmap_specular_map.slf
Normal file → Executable file
|
@ -1,5 +1,6 @@
|
|||
#version 120
|
||||
|
||||
<@include Config.slh@>
|
||||
<$VERSION_HEADER$>
|
||||
// Generated on <$_SCRIBE_DATE$>
|
||||
//
|
||||
// model_lightmap_specular_map.frag
|
||||
// fragment shader
|
5
interface/resources/shaders/model_normal_map.frag → libraries/render-utils/src/model_normal_map.slf
Normal file → Executable file
5
interface/resources/shaders/model_normal_map.frag → libraries/render-utils/src/model_normal_map.slf
Normal file → Executable file
|
@ -1,5 +1,6 @@
|
|||
#version 120
|
||||
|
||||
<@include Config.slh@>
|
||||
<$VERSION_HEADER$>
|
||||
// Generated on <$_SCRIBE_DATE$>
|
||||
//
|
||||
// model_normal_map.frag
|
||||
// fragment shader
|
81
interface/resources/shaders/model_normal_map.vert → libraries/render-utils/src/model_normal_map.slv
Normal file → Executable file
81
interface/resources/shaders/model_normal_map.vert → libraries/render-utils/src/model_normal_map.slv
Normal file → Executable file
|
@ -1,40 +1,41 @@
|
|||
#version 120
|
||||
|
||||
//
|
||||
// model.vert
|
||||
// vertex shader
|
||||
//
|
||||
// Created by Andrzej Kapolka on 10/14/13.
|
||||
// Copyright 2013 High Fidelity, Inc.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
const int MAX_TEXCOORDS = 2;
|
||||
|
||||
uniform mat4 texcoordMatrices[MAX_TEXCOORDS];
|
||||
|
||||
// the tangent vector
|
||||
attribute vec3 tangent;
|
||||
|
||||
// the interpolated normal
|
||||
varying vec4 interpolatedNormal;
|
||||
|
||||
// the interpolated tangent
|
||||
varying vec4 interpolatedTangent;
|
||||
|
||||
void main(void) {
|
||||
// transform and store the normal and tangent for interpolation
|
||||
interpolatedNormal = gl_ModelViewMatrix * vec4(gl_Normal, 0.0);
|
||||
interpolatedTangent = gl_ModelViewMatrix * vec4(tangent, 0.0);
|
||||
|
||||
// pass along the diffuse color
|
||||
gl_FrontColor = gl_Color * gl_FrontMaterial.diffuse;
|
||||
|
||||
// and the texture coordinates
|
||||
gl_TexCoord[0] = texcoordMatrices[0] * vec4(gl_MultiTexCoord0.xy, 0.0, 1.0);
|
||||
|
||||
// use standard pipeline transform
|
||||
gl_Position = ftransform();
|
||||
}
|
||||
<@include Config.slh@>
|
||||
<$VERSION_HEADER$>
|
||||
// Generated on <$_SCRIBE_DATE$>
|
||||
//
|
||||
// model.vert
|
||||
// vertex shader
|
||||
//
|
||||
// Created by Andrzej Kapolka on 10/14/13.
|
||||
// Copyright 2013 High Fidelity, Inc.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
const int MAX_TEXCOORDS = 2;
|
||||
|
||||
uniform mat4 texcoordMatrices[MAX_TEXCOORDS];
|
||||
|
||||
// the tangent vector
|
||||
attribute vec3 tangent;
|
||||
|
||||
// the interpolated normal
|
||||
varying vec4 interpolatedNormal;
|
||||
|
||||
// the interpolated tangent
|
||||
varying vec4 interpolatedTangent;
|
||||
|
||||
void main(void) {
|
||||
// transform and store the normal and tangent for interpolation
|
||||
interpolatedNormal = gl_ModelViewMatrix * vec4(gl_Normal, 0.0);
|
||||
interpolatedTangent = gl_ModelViewMatrix * vec4(tangent, 0.0);
|
||||
|
||||
// pass along the diffuse color
|
||||
gl_FrontColor = gl_Color * gl_FrontMaterial.diffuse;
|
||||
|
||||
// and the texture coordinates
|
||||
gl_TexCoord[0] = texcoordMatrices[0] * vec4(gl_MultiTexCoord0.xy, 0.0, 1.0);
|
||||
|
||||
// use standard pipeline transform
|
||||
gl_Position = ftransform();
|
||||
}
|
5
interface/resources/shaders/model_normal_specular_map.frag → libraries/render-utils/src/model_normal_specular_map.slf
Normal file → Executable file
5
interface/resources/shaders/model_normal_specular_map.frag → libraries/render-utils/src/model_normal_specular_map.slf
Normal file → Executable file
|
@ -1,5 +1,6 @@
|
|||
#version 120
|
||||
|
||||
<@include Config.slh@>
|
||||
<$VERSION_HEADER$>
|
||||
// Generated on <$_SCRIBE_DATE$>
|
||||
//
|
||||
// model_normal_specular_map.frag
|
||||
// fragment shader
|
5
interface/resources/shaders/model_shadow.frag → libraries/render-utils/src/model_shadow.slf
Normal file → Executable file
5
interface/resources/shaders/model_shadow.frag → libraries/render-utils/src/model_shadow.slf
Normal file → Executable file
|
@ -1,5 +1,6 @@
|
|||
#version 120
|
||||
|
||||
<@include Config.slh@>
|
||||
<$VERSION_HEADER$>
|
||||
// Generated on <$_SCRIBE_DATE$>
|
||||
//
|
||||
// model_shadow.frag
|
||||
// fragment shader
|
35
interface/resources/shaders/model_shadow.vert → libraries/render-utils/src/model_shadow.slv
Normal file → Executable file
35
interface/resources/shaders/model_shadow.vert → libraries/render-utils/src/model_shadow.slv
Normal file → Executable file
|
@ -1,17 +1,18 @@
|
|||
#version 120
|
||||
|
||||
//
|
||||
// model_shadow.vert
|
||||
// vertex shader
|
||||
//
|
||||
// Created by Andrzej Kapolka on 3/24/14.
|
||||
// Copyright 2014 High Fidelity, Inc.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
void main(void) {
|
||||
// just use standard pipeline transform
|
||||
gl_Position = ftransform();
|
||||
}
|
||||
<@include Config.slh@>
|
||||
<$VERSION_HEADER$>
|
||||
// Generated on <$_SCRIBE_DATE$>
|
||||
//
|
||||
// model_shadow.vert
|
||||
// vertex shader
|
||||
//
|
||||
// Created by Andrzej Kapolka on 3/24/14.
|
||||
// Copyright 2014 High Fidelity, Inc.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
void main(void) {
|
||||
// just use standard pipeline transform
|
||||
gl_Position = ftransform();
|
||||
}
|
5
interface/resources/shaders/model_specular_map.frag → libraries/render-utils/src/model_specular_map.slf
Normal file → Executable file
5
interface/resources/shaders/model_specular_map.frag → libraries/render-utils/src/model_specular_map.slf
Normal file → Executable file
|
@ -1,5 +1,6 @@
|
|||
#version 120
|
||||
|
||||
<@include Config.slh@>
|
||||
<$VERSION_HEADER$>
|
||||
// Generated on <$_SCRIBE_DATE$>
|
||||
//
|
||||
// model_specular_map.frag
|
||||
// fragment shader
|
5
interface/resources/shaders/model_translucent.frag → libraries/render-utils/src/model_translucent.slf
Normal file → Executable file
5
interface/resources/shaders/model_translucent.frag → libraries/render-utils/src/model_translucent.slf
Normal file → Executable file
|
@ -1,5 +1,6 @@
|
|||
#version 120
|
||||
|
||||
<@include Config.slh@>
|
||||
<$VERSION_HEADER$>
|
||||
// Generated on <$_SCRIBE_DATE$>
|
||||
//
|
||||
// model_translucent.frag
|
||||
// fragment shader
|
93
interface/resources/shaders/skin_model.vert → libraries/render-utils/src/skin_model.slv
Normal file → Executable file
93
interface/resources/shaders/skin_model.vert → libraries/render-utils/src/skin_model.slv
Normal file → Executable file
|
@ -1,46 +1,47 @@
|
|||
#version 120
|
||||
|
||||
//
|
||||
// skin_model.vert
|
||||
// vertex shader
|
||||
//
|
||||
// Created by Andrzej Kapolka on 10/14/13.
|
||||
// Copyright 2013 High Fidelity, Inc.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
const int MAX_TEXCOORDS = 2;
|
||||
const int MAX_CLUSTERS = 128;
|
||||
const int INDICES_PER_VERTEX = 4;
|
||||
|
||||
uniform mat4 clusterMatrices[MAX_CLUSTERS];
|
||||
uniform mat4 texcoordMatrices[MAX_TEXCOORDS];
|
||||
|
||||
attribute vec4 clusterIndices;
|
||||
attribute vec4 clusterWeights;
|
||||
|
||||
// the interpolated normal
|
||||
varying vec4 normal;
|
||||
|
||||
void main(void) {
|
||||
vec4 position = vec4(0.0, 0.0, 0.0, 0.0);
|
||||
normal = vec4(0.0, 0.0, 0.0, 0.0);
|
||||
for (int i = 0; i < INDICES_PER_VERTEX; i++) {
|
||||
mat4 clusterMatrix = clusterMatrices[int(clusterIndices[i])];
|
||||
float clusterWeight = clusterWeights[i];
|
||||
position += clusterMatrix * gl_Vertex * clusterWeight;
|
||||
normal += clusterMatrix * vec4(gl_Normal, 0.0) * clusterWeight;
|
||||
}
|
||||
|
||||
normal = normalize(gl_ModelViewMatrix * normal);
|
||||
|
||||
// pass along the diffuse color
|
||||
gl_FrontColor = gl_FrontMaterial.diffuse;
|
||||
|
||||
// and the texture coordinates
|
||||
gl_TexCoord[0] = texcoordMatrices[0] * vec4(gl_MultiTexCoord0.xy, 0.0, 1.0);
|
||||
|
||||
gl_Position = gl_ModelViewProjectionMatrix * position;
|
||||
}
|
||||
<@include Config.slh@>
|
||||
<$VERSION_HEADER$>
|
||||
// Generated on <$_SCRIBE_DATE$>
|
||||
//
|
||||
// skin_model.vert
|
||||
// vertex shader
|
||||
//
|
||||
// Created by Andrzej Kapolka on 10/14/13.
|
||||
// Copyright 2013 High Fidelity, Inc.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
const int MAX_TEXCOORDS = 2;
|
||||
const int MAX_CLUSTERS = 128;
|
||||
const int INDICES_PER_VERTEX = 4;
|
||||
|
||||
uniform mat4 clusterMatrices[MAX_CLUSTERS];
|
||||
uniform mat4 texcoordMatrices[MAX_TEXCOORDS];
|
||||
|
||||
attribute vec4 clusterIndices;
|
||||
attribute vec4 clusterWeights;
|
||||
|
||||
// the interpolated normal
|
||||
varying vec4 normal;
|
||||
|
||||
void main(void) {
|
||||
vec4 position = vec4(0.0, 0.0, 0.0, 0.0);
|
||||
normal = vec4(0.0, 0.0, 0.0, 0.0);
|
||||
for (int i = 0; i < INDICES_PER_VERTEX; i++) {
|
||||
mat4 clusterMatrix = clusterMatrices[int(clusterIndices[i])];
|
||||
float clusterWeight = clusterWeights[i];
|
||||
position += clusterMatrix * gl_Vertex * clusterWeight;
|
||||
normal += clusterMatrix * vec4(gl_Normal, 0.0) * clusterWeight;
|
||||
}
|
||||
|
||||
normal = normalize(gl_ModelViewMatrix * normal);
|
||||
|
||||
// pass along the diffuse color
|
||||
gl_FrontColor = gl_FrontMaterial.diffuse;
|
||||
|
||||
// and the texture coordinates
|
||||
gl_TexCoord[0] = texcoordMatrices[0] * vec4(gl_MultiTexCoord0.xy, 0.0, 1.0);
|
||||
|
||||
gl_Position = gl_ModelViewProjectionMatrix * position;
|
||||
}
|
109
interface/resources/shaders/skin_model_normal_map.vert → libraries/render-utils/src/skin_model_normal_map.slv
Normal file → Executable file
109
interface/resources/shaders/skin_model_normal_map.vert → libraries/render-utils/src/skin_model_normal_map.slv
Normal file → Executable file
|
@ -1,54 +1,55 @@
|
|||
#version 120
|
||||
|
||||
//
|
||||
// skin_model_normal_map.vert
|
||||
// vertex shader
|
||||
//
|
||||
// Created by Andrzej Kapolka on 10/29/13.
|
||||
// Copyright 2013 High Fidelity, Inc.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
const int MAX_TEXCOORDS = 2;
|
||||
const int MAX_CLUSTERS = 128;
|
||||
const int INDICES_PER_VERTEX = 4;
|
||||
|
||||
uniform mat4 clusterMatrices[MAX_CLUSTERS];
|
||||
uniform mat4 texcoordMatrices[MAX_TEXCOORDS];
|
||||
|
||||
// the tangent vector
|
||||
attribute vec3 tangent;
|
||||
|
||||
attribute vec4 clusterIndices;
|
||||
attribute vec4 clusterWeights;
|
||||
|
||||
// the interpolated normal
|
||||
varying vec4 interpolatedNormal;
|
||||
|
||||
// the interpolated tangent
|
||||
varying vec4 interpolatedTangent;
|
||||
|
||||
void main(void) {
|
||||
vec4 interpolatedPosition = vec4(0.0, 0.0, 0.0, 0.0);
|
||||
interpolatedNormal = vec4(0.0, 0.0, 0.0, 0.0);
|
||||
interpolatedTangent = vec4(0.0, 0.0, 0.0, 0.0);
|
||||
for (int i = 0; i < INDICES_PER_VERTEX; i++) {
|
||||
mat4 clusterMatrix = clusterMatrices[int(clusterIndices[i])];
|
||||
float clusterWeight = clusterWeights[i];
|
||||
interpolatedPosition += clusterMatrix * gl_Vertex * clusterWeight;
|
||||
interpolatedNormal += clusterMatrix * vec4(gl_Normal, 0.0) * clusterWeight;
|
||||
interpolatedTangent += clusterMatrix * vec4(tangent, 0.0) * clusterWeight;
|
||||
}
|
||||
interpolatedNormal = gl_ModelViewMatrix * interpolatedNormal;
|
||||
interpolatedTangent = gl_ModelViewMatrix * interpolatedTangent;
|
||||
|
||||
// pass along the diffuse color
|
||||
gl_FrontColor = gl_FrontMaterial.diffuse;
|
||||
|
||||
// and the texture coordinates
|
||||
gl_TexCoord[0] = texcoordMatrices[0] * vec4(gl_MultiTexCoord0.xy, 0.0, 1.0);
|
||||
|
||||
gl_Position = gl_ModelViewProjectionMatrix * interpolatedPosition;
|
||||
}
|
||||
<@include Config.slh@>
|
||||
<$VERSION_HEADER$>
|
||||
// Generated on <$_SCRIBE_DATE$>
|
||||
//
|
||||
// skin_model_normal_map.vert
|
||||
// vertex shader
|
||||
//
|
||||
// Created by Andrzej Kapolka on 10/29/13.
|
||||
// Copyright 2013 High Fidelity, Inc.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
const int MAX_TEXCOORDS = 2;
|
||||
const int MAX_CLUSTERS = 128;
|
||||
const int INDICES_PER_VERTEX = 4;
|
||||
|
||||
uniform mat4 clusterMatrices[MAX_CLUSTERS];
|
||||
uniform mat4 texcoordMatrices[MAX_TEXCOORDS];
|
||||
|
||||
// the tangent vector
|
||||
attribute vec3 tangent;
|
||||
|
||||
attribute vec4 clusterIndices;
|
||||
attribute vec4 clusterWeights;
|
||||
|
||||
// the interpolated normal
|
||||
varying vec4 interpolatedNormal;
|
||||
|
||||
// the interpolated tangent
|
||||
varying vec4 interpolatedTangent;
|
||||
|
||||
void main(void) {
|
||||
vec4 interpolatedPosition = vec4(0.0, 0.0, 0.0, 0.0);
|
||||
interpolatedNormal = vec4(0.0, 0.0, 0.0, 0.0);
|
||||
interpolatedTangent = vec4(0.0, 0.0, 0.0, 0.0);
|
||||
for (int i = 0; i < INDICES_PER_VERTEX; i++) {
|
||||
mat4 clusterMatrix = clusterMatrices[int(clusterIndices[i])];
|
||||
float clusterWeight = clusterWeights[i];
|
||||
interpolatedPosition += clusterMatrix * gl_Vertex * clusterWeight;
|
||||
interpolatedNormal += clusterMatrix * vec4(gl_Normal, 0.0) * clusterWeight;
|
||||
interpolatedTangent += clusterMatrix * vec4(tangent, 0.0) * clusterWeight;
|
||||
}
|
||||
interpolatedNormal = gl_ModelViewMatrix * interpolatedNormal;
|
||||
interpolatedTangent = gl_ModelViewMatrix * interpolatedTangent;
|
||||
|
||||
// pass along the diffuse color
|
||||
gl_FrontColor = gl_FrontMaterial.diffuse;
|
||||
|
||||
// and the texture coordinates
|
||||
gl_TexCoord[0] = texcoordMatrices[0] * vec4(gl_MultiTexCoord0.xy, 0.0, 1.0);
|
||||
|
||||
gl_Position = gl_ModelViewProjectionMatrix * interpolatedPosition;
|
||||
}
|
61
interface/resources/shaders/skin_model_shadow.vert → libraries/render-utils/src/skin_model_shadow.slv
Normal file → Executable file
61
interface/resources/shaders/skin_model_shadow.vert → libraries/render-utils/src/skin_model_shadow.slv
Normal file → Executable file
|
@ -1,30 +1,31 @@
|
|||
#version 120
|
||||
|
||||
//
|
||||
// skin_model_shadow.vert
|
||||
// vertex shader
|
||||
//
|
||||
// Created by Andrzej Kapolka on 3/24/14.
|
||||
// Copyright 2014 High Fidelity, Inc.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
const int MAX_CLUSTERS = 128;
|
||||
const int INDICES_PER_VERTEX = 4;
|
||||
|
||||
uniform mat4 clusterMatrices[MAX_CLUSTERS];
|
||||
|
||||
attribute vec4 clusterIndices;
|
||||
attribute vec4 clusterWeights;
|
||||
|
||||
void main(void) {
|
||||
vec4 position = vec4(0.0, 0.0, 0.0, 0.0);
|
||||
for (int i = 0; i < INDICES_PER_VERTEX; i++) {
|
||||
mat4 clusterMatrix = clusterMatrices[int(clusterIndices[i])];
|
||||
float clusterWeight = clusterWeights[i];
|
||||
position += clusterMatrix * gl_Vertex * clusterWeight;
|
||||
}
|
||||
gl_Position = gl_ModelViewProjectionMatrix * position;
|
||||
}
|
||||
<@include Config.slh@>
|
||||
<$VERSION_HEADER$>
|
||||
// Generated on <$_SCRIBE_DATE$>
|
||||
//
|
||||
// skin_model_shadow.vert
|
||||
// vertex shader
|
||||
//
|
||||
// Created by Andrzej Kapolka on 3/24/14.
|
||||
// Copyright 2014 High Fidelity, Inc.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
const int MAX_CLUSTERS = 128;
|
||||
const int INDICES_PER_VERTEX = 4;
|
||||
|
||||
uniform mat4 clusterMatrices[MAX_CLUSTERS];
|
||||
|
||||
attribute vec4 clusterIndices;
|
||||
attribute vec4 clusterWeights;
|
||||
|
||||
void main(void) {
|
||||
vec4 position = vec4(0.0, 0.0, 0.0, 0.0);
|
||||
for (int i = 0; i < INDICES_PER_VERTEX; i++) {
|
||||
mat4 clusterMatrix = clusterMatrices[int(clusterIndices[i])];
|
||||
float clusterWeight = clusterWeights[i];
|
||||
position += clusterMatrix * gl_Vertex * clusterWeight;
|
||||
}
|
||||
gl_Position = gl_ModelViewProjectionMatrix * position;
|
||||
}
|
Loading…
Reference in a new issue