mirror of
https://github.com/overte-org/overte.git
synced 2025-04-20 14:03:55 +02:00
Merge remote-tracking branch 'upstream/master'
This commit is contained in:
commit
987f8ad8ad
34 changed files with 513 additions and 180 deletions
|
@ -39,8 +39,6 @@
|
|||
const QString ASSIGNMENT_CLIENT_TARGET_NAME = "assignment-client";
|
||||
const long long ASSIGNMENT_REQUEST_INTERVAL_MSECS = 1 * 1000;
|
||||
|
||||
int hifiSockAddrMeta = qRegisterMetaType<HifiSockAddr>("HifiSockAddr");
|
||||
|
||||
AssignmentClient::AssignmentClient(Assignment::Type requestAssignmentType, QString assignmentPool,
|
||||
quint16 listenPort, QUuid walletUUID, QString assignmentServerHostname,
|
||||
quint16 assignmentServerPort, quint16 assignmentMonitorPort) :
|
||||
|
|
|
@ -305,15 +305,12 @@
|
|||
|
||||
var elParticleSections = document.querySelectorAll(".particle-section");
|
||||
allSections.push(elParticleSections);
|
||||
var elParticleIsEmitting = document.getElementById("property-particle-is-emitting");
|
||||
var elParticleMaxParticles = document.getElementById("property-particle-maxparticles");
|
||||
var elParticleLifeSpan = document.getElementById("property-particle-lifespan");
|
||||
var elParticleEmitRate = document.getElementById("property-particle-emit-rate");
|
||||
var elParticleEmitDirectionX = document.getElementById("property-particle-emit-direction-x");
|
||||
var elParticleEmitDirectionY = document.getElementById("property-particle-emit-direction-y");
|
||||
var elParticleEmitDirectionZ = document.getElementById("property-particle-emit-direction-z");
|
||||
var elParticleEmitStrength = document.getElementById("property-particle-emit-strength");
|
||||
var elParticleLocalGravity = document.getElementById("property-particle-localgravity");
|
||||
var elParticleRadius = document.getElementById("property-particle-radius");
|
||||
var elParticleTextures = document.getElementById("property-particle-textures");
|
||||
|
||||
var elTextSections = document.querySelectorAll(".text-section");
|
||||
allSections.push(elTextSections);
|
||||
|
@ -511,7 +508,7 @@
|
|||
elColorSection.style.display = 'none';
|
||||
}
|
||||
|
||||
if (properties.type == "Model" || properties.type == "ParticleEffect") {
|
||||
if (properties.type == "Model") {
|
||||
for (var i = 0; i < elModelSections.length; i++) {
|
||||
elModelSections[i].style.display = 'block';
|
||||
}
|
||||
|
@ -529,7 +526,7 @@
|
|||
elModelAnimationHold.checked = properties.animation.hold;
|
||||
elModelAnimationStartAutomatically.checked = properties.animation.startAutomatically;
|
||||
elModelTextures.value = properties.textures;
|
||||
elModelOriginalTextures.value = properties.originalTextures;
|
||||
elModelOriginalTextures.value = properties.originalTextures;
|
||||
} else if (properties.type == "Web") {
|
||||
for (var i = 0; i < elWebSections.length; i++) {
|
||||
elWebSections[i].style.display = 'block';
|
||||
|
@ -617,15 +614,13 @@
|
|||
elParticleSections[i].style.display = 'block';
|
||||
}
|
||||
|
||||
elParticleIsEmitting.checked = properties.isEmitting;
|
||||
elParticleMaxParticles.value = properties.maxParticles;
|
||||
elParticleLifeSpan.value = properties.lifespan.toFixed(2);
|
||||
elParticleEmitRate.value = properties.emitRate.toFixed(1);
|
||||
elParticleEmitDirectionX.value = properties.emitDirection.x.toFixed(2);
|
||||
elParticleEmitDirectionY.value = properties.emitDirection.y.toFixed(2);
|
||||
elParticleEmitDirectionZ.value = properties.emitDirection.z.toFixed(2);
|
||||
elParticleEmitStrength.value = properties.emitStrength.toFixed(2);
|
||||
elParticleLocalGravity.value = properties.localGravity.toFixed(2);
|
||||
elParticleRadius.value = properties.particleRadius.toFixed(3);
|
||||
elParticleTextures.value = properties.textures;
|
||||
|
||||
} else if (properties.type == "PolyVox") {
|
||||
for (var i = 0; i < elPolyVoxSections.length; i++) {
|
||||
elPolyVoxSections[i].style.display = 'block';
|
||||
|
@ -758,17 +753,12 @@
|
|||
|
||||
elWebSourceURL.addEventListener('change', createEmitTextPropertyUpdateFunction('sourceUrl'));
|
||||
|
||||
elParticleIsEmitting.addEventListener('change', createEmitCheckedPropertyUpdateFunction('isEmitting'));
|
||||
elParticleMaxParticles.addEventListener('change', createEmitNumberPropertyUpdateFunction('maxParticles'));
|
||||
elParticleLifeSpan.addEventListener('change', createEmitNumberPropertyUpdateFunction('lifespan'));
|
||||
elParticleEmitRate.addEventListener('change', createEmitNumberPropertyUpdateFunction('emitRate'));
|
||||
var particleEmitDirectionChangeFunction = createEmitVec3PropertyUpdateFunctionWithMultiplier(
|
||||
'emitDirection', elParticleEmitDirectionX, elParticleEmitDirectionY, elParticleEmitDirectionZ, DEGREES_TO_RADIANS);
|
||||
elParticleEmitDirectionX.addEventListener('change', particleEmitDirectionChangeFunction);
|
||||
elParticleEmitDirectionY.addEventListener('change', particleEmitDirectionChangeFunction);
|
||||
elParticleEmitDirectionZ.addEventListener('change', particleEmitDirectionChangeFunction);
|
||||
elParticleEmitStrength.addEventListener('change', createEmitNumberPropertyUpdateFunction('emitStrength'));
|
||||
elParticleLocalGravity.addEventListener('change', createEmitNumberPropertyUpdateFunction('localGravity'));
|
||||
elParticleRadius.addEventListener('change', createEmitNumberPropertyUpdateFunction('particleRadius'));
|
||||
elParticleTextures.addEventListener('change', createEmitTextPropertyUpdateFunction('textures'));
|
||||
|
||||
elModelURL.addEventListener('change', createEmitTextPropertyUpdateFunction('modelURL'));
|
||||
elShapeType.addEventListener('change', createEmitTextPropertyUpdateFunction('shapeType'));
|
||||
|
@ -1335,13 +1325,13 @@
|
|||
<div class="model-section property">
|
||||
<div class="label">Textures</div>
|
||||
<div class="value">
|
||||
<textarea id="property-model-textures" value='asdfasdf'></textarea>
|
||||
<textarea id="property-model-textures" value=''></textarea>
|
||||
</div>
|
||||
</div>
|
||||
<div class="model-section property">
|
||||
<div class="label">Original Textures</div>
|
||||
<div class="value">
|
||||
<textarea id="property-model-original-textures" readonly value='asdfasdf'></textarea>
|
||||
<textarea id="property-model-original-textures" readonly value=''></textarea>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
@ -1362,6 +1352,12 @@
|
|||
<label>Particle</label>
|
||||
</div>
|
||||
|
||||
<div class="particle-section property">
|
||||
<span class="label">Is Emitting</span>
|
||||
<span class="value">
|
||||
<input type='checkbox' id="property-particle-is-emitting">
|
||||
</span>
|
||||
</div>
|
||||
<div class="particle-section property">
|
||||
<div class="label">Max Particles</div>
|
||||
<div class="value">
|
||||
|
@ -1380,30 +1376,16 @@
|
|||
<input type='number' id="property-particle-emit-rate" min="0" step="0.5">
|
||||
</div>
|
||||
</div>
|
||||
<div class="particle-section property">
|
||||
<div class="label">Particle Emission Direction</div>
|
||||
<div class="value">
|
||||
<div class="input-area">X <input class="coord" type='number' id="property-particle-emit-direction-x"></div>
|
||||
<div class="input-area">Y <input class="coord" type='number' id="property-particle-emit-direction-y"></div>
|
||||
<div class="input-area">Z <input class="coord" type='number' id="property-particle-emit-direction-z"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="particle-section property">
|
||||
<div class="label">Particle Emission Strength</div>
|
||||
<div class="value">
|
||||
<input type='number' id="property-particle-emit-strength" min="0" step="0.1">
|
||||
</div>
|
||||
</div>
|
||||
<div class="particle-section property">
|
||||
<div class="label">Particle Local Gravity</div>
|
||||
<div class="value">
|
||||
<input class="coord" type='number' id="property-particle-localgravity" step="0.05">
|
||||
</div>
|
||||
</div>
|
||||
<div class="particle-section property">
|
||||
<div class="label">Particle Radius</div>
|
||||
<div class="value">
|
||||
<input class="coord" type='number' id="property-particle-radius" min="0" step="0.005">
|
||||
<input class="coord" type='number' id="property-particle-radius" min="0" step="0.005">
|
||||
</div>
|
||||
</div>
|
||||
<div class="particle-section property">
|
||||
<div class="label">Textures</div>
|
||||
<div class="value">
|
||||
<textarea id="property-particle-textures" value=''></textarea>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
|
@ -13,8 +13,8 @@ Script.include("../../utilities.js");
|
|||
|
||||
var scriptURL = Script.resolvePath('pingPongGun.js');
|
||||
|
||||
var MODEL_URL = 'http://hifi-public.s3.amazonaws.com/models/ping_pong_gun/ping_pong_gun.fbx?123'
|
||||
var COLLISION_HULL_URL = 'http://hifi-public.s3.amazonaws.com/models/ping_pong_gun/ping_pong_gun_collision_hull.obj?123';
|
||||
var MODEL_URL = 'http://hifi-public.s3.amazonaws.com/models/ping_pong_gun/ping_pong_gun.fbx'
|
||||
var COLLISION_HULL_URL = 'http://hifi-public.s3.amazonaws.com/models/ping_pong_gun/ping_pong_gun_collision_hull.obj';
|
||||
|
||||
var center = Vec3.sum(Vec3.sum(MyAvatar.position, {
|
||||
x: 0,
|
||||
|
|
154
examples/toys/ping_pong_gun/createTargets.js
Normal file
154
examples/toys/ping_pong_gun/createTargets.js
Normal file
|
@ -0,0 +1,154 @@
|
|||
// createTargets.js
|
||||
//
|
||||
// Script Type: Entity Spawner
|
||||
// Created by James B. Pollack on 9/30/2015
|
||||
// Copyright 2015 High Fidelity, Inc.
|
||||
//
|
||||
// This script creates targets that fall down when you shoot them and then automatically reset to their original position.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
/*global MyAvatar, Entities, AnimationCache, SoundCache, Scene, Camera, Overlays, HMD, AvatarList, AvatarManager, Controller, UndoStack, Window, Account, GlobalServices, Script, ScriptDiscoveryService, LODManager, Menu, Vec3, Quat, AudioDevice, Paths, Clipboard, Settings, XMLHttpRequest, randFloat, randInt */
|
||||
Script.include("../../utilities.js");
|
||||
Script.include("../../libraries/utils.js");
|
||||
var scriptURL = Script.resolvePath('wallTarget.js');
|
||||
|
||||
var MODEL_URL = 'http://hifi-public.s3.amazonaws.com/models/ping_pong_gun/target.fbx';
|
||||
var COLLISION_HULL_URL = 'http://hifi-public.s3.amazonaws.com/models/ping_pong_gun/target_collision_hull.obj';
|
||||
|
||||
var RESET_DISTANCE = 1;
|
||||
var TARGET_USER_DATA_KEY = 'hifi-ping_pong_target';
|
||||
var NUMBER_OF_TARGETS = 6;
|
||||
var TARGETS_PER_ROW = 3;
|
||||
|
||||
var TARGET_DIMENSIONS = {
|
||||
x: 0.06,
|
||||
y: 0.42,
|
||||
z: 0.42
|
||||
};
|
||||
|
||||
var VERTICAL_SPACING = TARGET_DIMENSIONS.y + 0.5;
|
||||
var HORIZONTAL_SPACING = TARGET_DIMENSIONS.z + 0.5;
|
||||
|
||||
|
||||
var startPosition = {
|
||||
x: 548.68,
|
||||
y: 497.30,
|
||||
z: 509.74
|
||||
};
|
||||
|
||||
var rotation = Quat.fromPitchYawRollDegrees(0, -55.25, 0);
|
||||
|
||||
var targetIntervalClearer = Entities.addEntity({
|
||||
name: 'Target Interval Clearer - delete me to clear',
|
||||
type: 'Box',
|
||||
position: startPosition,
|
||||
dimensions: TARGET_DIMENSIONS,
|
||||
color: {
|
||||
red: 0,
|
||||
green: 255,
|
||||
blue: 0
|
||||
},
|
||||
rotation: rotation,
|
||||
visible: false,
|
||||
collisionsWillMove: false,
|
||||
ignoreForCollisions: true,
|
||||
});
|
||||
|
||||
var targets = [];
|
||||
|
||||
var originalPositions = [];
|
||||
|
||||
function addTargets() {
|
||||
var i;
|
||||
var row = -1;
|
||||
|
||||
for (i = 0; i < NUMBER_OF_TARGETS; i++) {
|
||||
|
||||
if (i % TARGETS_PER_ROW === 0) {
|
||||
row++;
|
||||
}
|
||||
|
||||
var vHat = Quat.getFront(rotation);
|
||||
var spacer = HORIZONTAL_SPACING * (i % TARGETS_PER_ROW) + (row * HORIZONTAL_SPACING / 2);
|
||||
var multiplier = Vec3.multiply(spacer, vHat);
|
||||
var position = Vec3.sum(startPosition, multiplier);
|
||||
position.y = startPosition.y - (row * VERTICAL_SPACING);
|
||||
|
||||
originalPositions.push(position);
|
||||
|
||||
var targetProperties = {
|
||||
name: 'Target',
|
||||
type: 'Model',
|
||||
modelURL: MODEL_URL,
|
||||
shapeType: 'compound',
|
||||
collisionsWillMove: true,
|
||||
dimensions: TARGET_DIMENSIONS,
|
||||
compoundShapeURL: COLLISION_HULL_URL,
|
||||
position: position,
|
||||
rotation: rotation,
|
||||
script: scriptURL
|
||||
};
|
||||
|
||||
targets.push(Entities.addEntity(targetProperties));
|
||||
}
|
||||
}
|
||||
|
||||
function testTargetDistanceFromStart() {
|
||||
targets.forEach(function(target, index) {
|
||||
|
||||
var currentPosition = Entities.getEntityProperties(target, "position").position;
|
||||
var originalPosition = originalPositions[index];
|
||||
var distance = Vec3.subtract(originalPosition, currentPosition);
|
||||
var length = Vec3.length(distance);
|
||||
|
||||
if (length > RESET_DISTANCE) {
|
||||
|
||||
Entities.deleteEntity(target);
|
||||
|
||||
var targetProperties = {
|
||||
name: 'Target',
|
||||
type: 'Model',
|
||||
modelURL: MODEL_URL,
|
||||
shapeType: 'compound',
|
||||
collisionsWillMove: true,
|
||||
dimensions: TARGET_DIMENSIONS,
|
||||
compoundShapeURL: COLLISION_HULL_URL,
|
||||
position: originalPositions[index],
|
||||
rotation: rotation,
|
||||
script: scriptURL
|
||||
};
|
||||
|
||||
targets[index] = Entities.addEntity(targetProperties);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
function deleteEntity(entityID) {
|
||||
if (entityID === targetIntervalClearer) {
|
||||
deleteTargets();
|
||||
Script.clearInterval(distanceCheckInterval);
|
||||
Entities.deletingEntity.disconnect(deleteEntity);
|
||||
}
|
||||
}
|
||||
|
||||
function deleteTargets() {
|
||||
while (targets.length > 0) {
|
||||
Entities.deleteEntity(targets.pop());
|
||||
}
|
||||
Entities.deleteEntity(targetIntervalClearer);
|
||||
}
|
||||
|
||||
Entities.deletingEntity.connect(deleteEntity);
|
||||
var distanceCheckInterval = Script.setInterval(testTargetDistanceFromStart, 1000);
|
||||
|
||||
addTargets();
|
||||
|
||||
function atEnd() {
|
||||
Script.clearInterval(distanceCheckInterval);
|
||||
deleteTargets();
|
||||
}
|
||||
|
||||
Script.scriptEnding.connect(atEnd);
|
|
@ -14,6 +14,7 @@
|
|||
Script.include("../../libraries/utils.js");
|
||||
|
||||
var SHOOTING_SOUND_URL = 'http://hifi-public.s3.amazonaws.com/sounds/ping_pong_gun/pong_sound.wav';
|
||||
var PING_PONG_BALL_URL = 'http://hifi-public.s3.amazonaws.com/models/ping_pong_gun/ping_pong_ball.fbx';
|
||||
|
||||
function PingPongGun() {
|
||||
return;
|
||||
|
@ -23,7 +24,7 @@
|
|||
var RELOAD_THRESHOLD = 0.95;
|
||||
var GUN_TIP_FWD_OFFSET =-0.35;
|
||||
var GUN_TIP_UP_OFFSET = 0.040;
|
||||
var GUN_FORCE = 9;
|
||||
var GUN_FORCE = 5;
|
||||
var BALL_RESTITUTION = 0.6;
|
||||
var BALL_LINEAR_DAMPING = 0.4;
|
||||
var BALL_GRAVITY = {
|
||||
|
@ -115,7 +116,10 @@
|
|||
forwardVec = Vec3.multiply(forwardVec, GUN_FORCE);
|
||||
|
||||
var properties = {
|
||||
type: 'Sphere',
|
||||
// type: 'Model',
|
||||
// modelURL:PING_PONG_BALL_URL,
|
||||
shapeType:'sphere',
|
||||
type:'Sphere',
|
||||
color: BALL_COLOR,
|
||||
dimensions: BALL_DIMENSIONS,
|
||||
linearDamping: BALL_LINEAR_DAMPING,
|
||||
|
|
56
examples/toys/ping_pong_gun/wallTarget.js
Normal file
56
examples/toys/ping_pong_gun/wallTarget.js
Normal file
|
@ -0,0 +1,56 @@
|
|||
// wallTarget.js
|
||||
//
|
||||
// Script Type: Entity
|
||||
// Created by James B. Pollack @imgntn on 9/21/2015
|
||||
// Copyright 2015 High Fidelity, Inc.
|
||||
//
|
||||
// This script resets an object to its original position when it stops moving after a collision
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
/*global print, MyAvatar, Entities, AnimationCache, SoundCache, Scene, Camera, Overlays, Audio, HMD, AvatarList, AvatarManager, Controller, UndoStack, Window, Account, GlobalServices, Script, ScriptDiscoveryService, LODManager, Menu, Vec3, Quat, AudioDevice, Paths, Clipboard, Settings, XMLHttpRequest, randFloat, randInt */
|
||||
(function() {
|
||||
|
||||
|
||||
function Target() {
|
||||
return;
|
||||
}
|
||||
|
||||
Target.prototype = {
|
||||
hasPlayedSound: false,
|
||||
preload: function(entityID) {
|
||||
this.entityID = entityID;
|
||||
var SOUND_URL = "http://hifi-public.s3.amazonaws.com/sounds/Clay_Pigeon_02.L.wav";
|
||||
this.hitSound = SoundCache.getSound(SOUND_URL);
|
||||
},
|
||||
collisionWithEntity: function(me, otherEntity) {
|
||||
var position = Entities.getEntityProperties(me, "position").position;
|
||||
Entities.editEntity(me, {
|
||||
gravity: {
|
||||
x: 0,
|
||||
y: -9.8,
|
||||
z: 0
|
||||
},
|
||||
velocity: {
|
||||
x: 0,
|
||||
y: -0.01,
|
||||
z: 0
|
||||
}
|
||||
});
|
||||
|
||||
if (this.hasPlayedSound === false) {
|
||||
this.audioInjector = Audio.playSound(this.hitSound, {
|
||||
position: position,
|
||||
volume: 0.5
|
||||
});
|
||||
|
||||
this.hasPlayedSound = true;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
// entity scripts always need to return a newly constructed object of our type
|
||||
return new Target();
|
||||
});
|
|
@ -215,7 +215,7 @@ bool JointState::rotationIsDefault(const glm::quat& rotation, float tolerance) c
|
|||
}
|
||||
|
||||
bool JointState::translationIsDefault(const glm::vec3& translation, float tolerance) const {
|
||||
return glm::distance(_defaultTranslation * _unitsScale, translation * _unitsScale) < tolerance;
|
||||
return glm::distance(_defaultTranslation * _unitsScale, translation) < tolerance;
|
||||
}
|
||||
|
||||
glm::quat JointState::getDefaultRotationInParentFrame() const {
|
||||
|
|
|
@ -287,6 +287,7 @@ QByteArray AvatarData::toByteArray(bool cullSmallChanges, bool sendAll) {
|
|||
|
||||
#ifdef WANT_DEBUG
|
||||
int rotationSentCount = 0;
|
||||
unsigned char* beforeRotations = destinationBuffer;
|
||||
#endif
|
||||
|
||||
_lastSentJointData.resize(_jointData.size());
|
||||
|
@ -335,6 +336,7 @@ QByteArray AvatarData::toByteArray(bool cullSmallChanges, bool sendAll) {
|
|||
|
||||
#ifdef WANT_DEBUG
|
||||
int translationSentCount = 0;
|
||||
unsigned char* beforeTranslations = destinationBuffer;
|
||||
#endif
|
||||
|
||||
float maxTranslationDimension = 0.0;
|
||||
|
@ -387,10 +389,15 @@ QByteArray AvatarData::toByteArray(bool cullSmallChanges, bool sendAll) {
|
|||
|
||||
#ifdef WANT_DEBUG
|
||||
if (sendAll) {
|
||||
qDebug() << "SENDING -- rotations:" << rotationSentCount << "translations:" << translationSentCount
|
||||
qDebug() << "AvatarData::toByteArray" << cullSmallChanges << sendAll
|
||||
<< "rotations:" << rotationSentCount << "translations:" << translationSentCount
|
||||
<< "largest:" << maxTranslationDimension
|
||||
<< "radix:" << translationCompressionRadix
|
||||
<< "size:" << (int)(destinationBuffer - startPosition);
|
||||
<< "size:"
|
||||
<< (beforeRotations - startPosition) << "+"
|
||||
<< (beforeTranslations - beforeRotations) << "+"
|
||||
<< (destinationBuffer - beforeTranslations) << "="
|
||||
<< (destinationBuffer - startPosition);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -409,7 +416,8 @@ void AvatarData::doneEncoding(bool cullSmallChanges) {
|
|||
_lastSentJointData[i].rotation = data.rotation;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
if (_lastSentJointData[i].translation != data.translation) {
|
||||
if (!cullSmallChanges ||
|
||||
glm::distance(data.translation, _lastSentJointData[i].translation) > AVATAR_MIN_TRANSLATION) {
|
||||
if (data.translationSet) {
|
||||
|
|
|
@ -313,6 +313,7 @@ EntityPropertyFlags EntityItemProperties::getChangedProperties() const {
|
|||
CHECK_PROPERTY_CHANGE(PROP_TEXT_COLOR, textColor);
|
||||
CHECK_PROPERTY_CHANGE(PROP_BACKGROUND_COLOR, backgroundColor);
|
||||
CHECK_PROPERTY_CHANGE(PROP_SHAPE_TYPE, shapeType);
|
||||
CHECK_PROPERTY_CHANGE(PROP_EMITTING_PARTICLES, isEmitting);
|
||||
CHECK_PROPERTY_CHANGE(PROP_MAX_PARTICLES, maxParticles);
|
||||
CHECK_PROPERTY_CHANGE(PROP_LIFESPAN, lifespan);
|
||||
CHECK_PROPERTY_CHANGE(PROP_EMIT_RATE, emitRate);
|
||||
|
@ -424,6 +425,7 @@ QScriptValue EntityItemProperties::copyToScriptValue(QScriptEngine* engine, bool
|
|||
|
||||
// Particles only
|
||||
if (_type == EntityTypes::ParticleEffect) {
|
||||
COPY_PROPERTY_TO_QSCRIPTVALUE(PROP_EMITTING_PARTICLES, isEmitting);
|
||||
COPY_PROPERTY_TO_QSCRIPTVALUE(PROP_MAX_PARTICLES, maxParticles);
|
||||
COPY_PROPERTY_TO_QSCRIPTVALUE(PROP_LIFESPAN, lifespan);
|
||||
COPY_PROPERTY_TO_QSCRIPTVALUE(PROP_EMIT_RATE, emitRate);
|
||||
|
@ -1118,6 +1120,7 @@ bool EntityItemProperties::encodeEntityEditPacket(PacketType command, EntityItem
|
|||
APPEND_ENTITY_PROPERTY(PROP_ACTION_DATA, properties.getActionData());
|
||||
APPEND_ENTITY_PROPERTY(PROP_ALPHA, properties.getAlpha());
|
||||
}
|
||||
|
||||
if (propertyCount > 0) {
|
||||
int endOfEntityItemData = packetData->getUncompressedByteOffset();
|
||||
|
||||
|
@ -1472,6 +1475,7 @@ void EntityItemProperties::markAllChanged() {
|
|||
_backgroundColorChanged = true;
|
||||
_shapeTypeChanged = true;
|
||||
|
||||
_isEmittingChanged = true;
|
||||
_maxParticlesChanged = true;
|
||||
_lifespanChanged = true;
|
||||
_emitRateChanged = true;
|
||||
|
|
|
@ -329,7 +329,7 @@ EntityItemProperties ParticleEffectEntityItem::getProperties(EntityPropertyFlags
|
|||
COPY_ENTITY_PROPERTY_TO_PROPERTIES(color, getXColor);
|
||||
COPY_ENTITY_PROPERTY_TO_PROPERTIES(alpha, getAlpha);
|
||||
COPY_ENTITY_PROPERTY_TO_PROPERTIES(glowLevel, getGlowLevel);
|
||||
COPY_ENTITY_PROPERTY_TO_PROPERTIES(shapeType, getShapeType);
|
||||
COPY_ENTITY_PROPERTY_TO_PROPERTIES(shapeType, getShapeType); // FIXME - this doesn't appear to get used
|
||||
COPY_ENTITY_PROPERTY_TO_PROPERTIES(maxParticles, getMaxParticles);
|
||||
COPY_ENTITY_PROPERTY_TO_PROPERTIES(lifespan, getLifespan);
|
||||
COPY_ENTITY_PROPERTY_TO_PROPERTIES(isEmitting, getIsEmitting);
|
||||
|
|
|
@ -1512,7 +1512,7 @@ FBXGeometry* FBXReader::extractFBXGeometry(const QVariantHash& mapping, const QS
|
|||
}
|
||||
extracted.mesh.isEye = (maxJointIndex == geometry.leftEyeJointIndex || maxJointIndex == geometry.rightEyeJointIndex);
|
||||
|
||||
buildModelMesh(extracted, url);
|
||||
buildModelMesh(extracted.mesh, url);
|
||||
|
||||
if (extracted.mesh.isEye) {
|
||||
if (maxJointIndex == geometry.leftEyeJointIndex) {
|
||||
|
|
|
@ -388,7 +388,7 @@ public:
|
|||
|
||||
ExtractedMesh extractMesh(const FBXNode& object, unsigned int& meshIndex);
|
||||
QHash<QString, ExtractedMesh> meshes;
|
||||
void buildModelMesh(ExtractedMesh& extracted, const QString& url);
|
||||
static void buildModelMesh(FBXMesh& extractedMesh, const QString& url);
|
||||
|
||||
FBXTexture getTexture(const QString& textureID);
|
||||
|
||||
|
|
|
@ -386,11 +386,11 @@ ExtractedMesh FBXReader::extractMesh(const FBXNode& object, unsigned int& meshIn
|
|||
return data.extracted;
|
||||
}
|
||||
|
||||
void FBXReader::buildModelMesh(ExtractedMesh& extracted, const QString& url) {
|
||||
void FBXReader::buildModelMesh(FBXMesh& extractedMesh, const QString& url) {
|
||||
static QString repeatedMessage = LogHandler::getInstance().addRepeatedMessageRegex("buildModelMesh failed -- .*");
|
||||
|
||||
unsigned int totalSourceIndices = 0;
|
||||
foreach(const FBXMeshPart& part, extracted.mesh.parts) {
|
||||
foreach(const FBXMeshPart& part, extractedMesh.parts) {
|
||||
totalSourceIndices += (part.quadTrianglesIndices.size() + part.triangleIndices.size());
|
||||
}
|
||||
|
||||
|
@ -399,18 +399,18 @@ void FBXReader::buildModelMesh(ExtractedMesh& extracted, const QString& url) {
|
|||
return;
|
||||
}
|
||||
|
||||
if (extracted.mesh.vertices.size() == 0) {
|
||||
if (extractedMesh.vertices.size() == 0) {
|
||||
qCDebug(modelformat) << "buildModelMesh failed -- no vertices, url = " << url;
|
||||
return;
|
||||
}
|
||||
|
||||
FBXMesh& fbxMesh = extracted.mesh;
|
||||
FBXMesh& fbxMesh = extractedMesh;
|
||||
model::MeshPointer mesh(new model::Mesh());
|
||||
|
||||
// Grab the vertices in a buffer
|
||||
auto vb = std::make_shared<gpu::Buffer>();
|
||||
vb->setData(extracted.mesh.vertices.size() * sizeof(glm::vec3),
|
||||
(const gpu::Byte*) extracted.mesh.vertices.data());
|
||||
vb->setData(extractedMesh.vertices.size() * sizeof(glm::vec3),
|
||||
(const gpu::Byte*) extractedMesh.vertices.data());
|
||||
gpu::BufferView vbv(vb, gpu::Element(gpu::VEC3, gpu::FLOAT, gpu::XYZ));
|
||||
mesh->setVertexBuffer(vbv);
|
||||
|
||||
|
@ -486,7 +486,7 @@ void FBXReader::buildModelMesh(ExtractedMesh& extracted, const QString& url) {
|
|||
|
||||
|
||||
unsigned int totalIndices = 0;
|
||||
foreach(const FBXMeshPart& part, extracted.mesh.parts) {
|
||||
foreach(const FBXMeshPart& part, extractedMesh.parts) {
|
||||
totalIndices += (part.quadTrianglesIndices.size() + part.triangleIndices.size());
|
||||
}
|
||||
|
||||
|
@ -502,10 +502,10 @@ void FBXReader::buildModelMesh(ExtractedMesh& extracted, const QString& url) {
|
|||
int offset = 0;
|
||||
|
||||
std::vector< model::Mesh::Part > parts;
|
||||
if (extracted.mesh.parts.size() > 1) {
|
||||
if (extractedMesh.parts.size() > 1) {
|
||||
indexNum = 0;
|
||||
}
|
||||
foreach(const FBXMeshPart& part, extracted.mesh.parts) {
|
||||
foreach(const FBXMeshPart& part, extractedMesh.parts) {
|
||||
model::Mesh::Part modelPart(indexNum, 0, 0, model::Mesh::TRIANGLES);
|
||||
|
||||
if (part.quadTrianglesIndices.size()) {
|
||||
|
@ -545,5 +545,5 @@ void FBXReader::buildModelMesh(ExtractedMesh& extracted, const QString& url) {
|
|||
// model::Box box =
|
||||
mesh->evalPartBound(0);
|
||||
|
||||
extracted.mesh._mesh = mesh;
|
||||
extractedMesh._mesh = mesh;
|
||||
}
|
||||
|
|
|
@ -532,6 +532,8 @@ FBXGeometry* OBJReader::readOBJ(QByteArray& model, const QVariantHash& mapping,
|
|||
mesh.meshExtents.addPoint(vertex);
|
||||
geometry.meshExtents.addPoint(vertex);
|
||||
}
|
||||
|
||||
FBXReader::buildModelMesh(mesh, url.toString());
|
||||
// fbxDebugDump(geometry);
|
||||
} catch(const std::exception& e) {
|
||||
qCDebug(modelformat) << "OBJ reader fail: " << e.what();
|
||||
|
|
|
@ -205,6 +205,13 @@ void Batch::setViewportTransform(const Vec4i& viewport) {
|
|||
_params.push_back(cacheData(sizeof(Vec4i), &viewport));
|
||||
}
|
||||
|
||||
void Batch::setDepthRangeTransform(float nearDepth, float farDepth) {
|
||||
ADD_COMMAND(setDepthRangeTransform);
|
||||
|
||||
_params.push_back(farDepth);
|
||||
_params.push_back(nearDepth);
|
||||
}
|
||||
|
||||
void Batch::setPipeline(const PipelinePointer& pipeline) {
|
||||
ADD_COMMAND(setPipeline);
|
||||
|
||||
|
|
|
@ -187,6 +187,7 @@ public:
|
|||
void setProjectionTransform(const Mat4& proj);
|
||||
// Viewport is xy = low left corner in framebuffer, zw = width height of the viewport, expressed in pixels
|
||||
void setViewportTransform(const Vec4i& viewport);
|
||||
void setDepthRangeTransform(float nearDepth, float farDepth);
|
||||
|
||||
// Pipeline Stage
|
||||
void setPipeline(const PipelinePointer& pipeline);
|
||||
|
@ -285,6 +286,7 @@ public:
|
|||
COMMAND_setViewTransform,
|
||||
COMMAND_setProjectionTransform,
|
||||
COMMAND_setViewportTransform,
|
||||
COMMAND_setDepthRangeTransform,
|
||||
|
||||
COMMAND_setPipeline,
|
||||
COMMAND_setStateBlendFactor,
|
||||
|
|
|
@ -14,11 +14,12 @@
|
|||
out vec2 varTexCoord0;
|
||||
|
||||
void main(void) {
|
||||
const float depth = 1.0;
|
||||
const vec4 UNIT_QUAD[4] = vec4[4](
|
||||
vec4(-1.0, -1.0, 0.0, 1.0),
|
||||
vec4(1.0, -1.0, 0.0, 1.0),
|
||||
vec4(-1.0, 1.0, 0.0, 1.0),
|
||||
vec4(1.0, 1.0, 0.0, 1.0)
|
||||
vec4(-1.0, -1.0, depth, 1.0),
|
||||
vec4(1.0, -1.0, depth, 1.0),
|
||||
vec4(-1.0, 1.0, depth, 1.0),
|
||||
vec4(1.0, 1.0, depth, 1.0)
|
||||
);
|
||||
vec4 pos = UNIT_QUAD[gl_VertexID];
|
||||
|
||||
|
|
|
@ -35,6 +35,7 @@ GLBackend::CommandCall GLBackend::_commandCalls[Batch::NUM_COMMANDS] =
|
|||
(&::gpu::GLBackend::do_setViewTransform),
|
||||
(&::gpu::GLBackend::do_setProjectionTransform),
|
||||
(&::gpu::GLBackend::do_setViewportTransform),
|
||||
(&::gpu::GLBackend::do_setDepthRangeTransform),
|
||||
|
||||
(&::gpu::GLBackend::do_setPipeline),
|
||||
(&::gpu::GLBackend::do_setStateBlendFactor),
|
||||
|
|
|
@ -314,6 +314,7 @@ protected:
|
|||
void do_setViewTransform(Batch& batch, uint32 paramOffset);
|
||||
void do_setProjectionTransform(Batch& batch, uint32 paramOffset);
|
||||
void do_setViewportTransform(Batch& batch, uint32 paramOffset);
|
||||
void do_setDepthRangeTransform(Batch& batch, uint32 paramOffset);
|
||||
|
||||
void initTransform();
|
||||
void killTransform();
|
||||
|
@ -339,6 +340,7 @@ protected:
|
|||
Transform _view;
|
||||
Mat4 _projection;
|
||||
Vec4i _viewport{ 0, 0, 1, 1 };
|
||||
Vec2 _depthRange{ 0.0f, 1.0f };
|
||||
bool _invalidModel{true};
|
||||
bool _invalidView{false};
|
||||
bool _invalidProj{false};
|
||||
|
|
|
@ -45,10 +45,21 @@ void GLBackend::do_setViewportTransform(Batch& batch, uint32 paramOffset) {
|
|||
|
||||
glViewport(vp.x, vp.y, vp.z, vp.w);
|
||||
|
||||
// The Viewport is tagged invalid because the CameraTransformUBO is not up to date and willl need update on next drawcall
|
||||
// The Viewport is tagged invalid because the CameraTransformUBO is not up to date and will need update on next drawcall
|
||||
_transform._invalidViewport = true;
|
||||
}
|
||||
|
||||
void GLBackend::do_setDepthRangeTransform(Batch& batch, uint32 paramOffset) {
|
||||
|
||||
Vec2 depthRange(batch._params[paramOffset + 0]._float, batch._params[paramOffset + 1]._float);
|
||||
|
||||
if ((depthRange.x != _transform._depthRange.x) || (depthRange.y != _transform._depthRange.y)) {
|
||||
_transform._depthRange = depthRange;
|
||||
|
||||
glDepthRangef(depthRange.x, depthRange.y);
|
||||
}
|
||||
}
|
||||
|
||||
void GLBackend::initTransform() {
|
||||
glGenBuffers(1, &_transform._objectBuffer);
|
||||
glGenBuffers(1, &_transform._cameraBuffer);
|
||||
|
@ -75,6 +86,8 @@ void GLBackend::syncTransformStateCache() {
|
|||
|
||||
glGetIntegerv(GL_VIEWPORT, (GLint*) &_transform._viewport);
|
||||
|
||||
glGetFloatv(GL_DEPTH_RANGE, (GLfloat*)&_transform._depthRange);
|
||||
|
||||
Mat4 modelView;
|
||||
auto modelViewInv = glm::inverse(modelView);
|
||||
_transform._view.evalFromRawMatrix(modelViewInv);
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
#include "HifiSockAddr.h"
|
||||
#include "NetworkLogging.h"
|
||||
|
||||
static int hifiSockAddrMetaTypeId = qMetaTypeId<HifiSockAddr>();
|
||||
static int hifiSockAddrMetaTypeId = qRegisterMetaType<HifiSockAddr>();
|
||||
|
||||
HifiSockAddr::HifiSockAddr() :
|
||||
_address(),
|
||||
|
|
|
@ -94,6 +94,6 @@ namespace std {
|
|||
|
||||
QHostAddress getLocalAddress();
|
||||
|
||||
Q_DECLARE_METATYPE(HifiSockAddr)
|
||||
Q_DECLARE_METATYPE(HifiSockAddr);
|
||||
|
||||
#endif // hifi_HifiSockAddr_h
|
||||
|
|
|
@ -501,7 +501,7 @@ SharedNodePointer LimitedNodeList::addOrUpdateNode(const QUuid& uuid, NodeType_t
|
|||
LimitedNodeList::flagTimeForConnectionStep(LimitedNodeList::AddedAudioMixer);
|
||||
}
|
||||
|
||||
SharedNodePointer newNodePointer(newNode);
|
||||
SharedNodePointer newNodePointer(newNode, &QObject::deleteLater);
|
||||
|
||||
_nodeHash.insert(UUIDNodePair(newNode->getUUID(), newNodePointer));
|
||||
|
||||
|
|
|
@ -60,8 +60,6 @@ const QHostAddress DEFAULT_ASSIGNMENT_CLIENT_MONITOR_HOSTNAME = QHostAddress::Lo
|
|||
|
||||
const QString USERNAME_UUID_REPLACEMENT_STATS_KEY = "$username";
|
||||
|
||||
class HifiSockAddr;
|
||||
|
||||
using namespace tbb;
|
||||
typedef std::pair<QUuid, SharedNodePointer> UUIDNodePair;
|
||||
typedef concurrent_unordered_map<QUuid, SharedNodePointer, UUIDHasher> NodeHash;
|
||||
|
|
|
@ -150,6 +150,8 @@ void PacketList::preparePackets(MessageNumber messageNumber) {
|
|||
}
|
||||
}
|
||||
|
||||
const qint64 PACKET_LIST_WRITE_ERROR = -1;
|
||||
|
||||
qint64 PacketList::writeData(const char* data, qint64 maxSize) {
|
||||
auto sizeRemaining = maxSize;
|
||||
|
||||
|
@ -176,26 +178,41 @@ qint64 PacketList::writeData(const char* data, qint64 maxSize) {
|
|||
// We need to try and pull the first part of the segment out to our new packet
|
||||
|
||||
// check now to see if this is an unsupported write
|
||||
int numBytesToEnd = _currentPacket->bytesAvailableForWrite();
|
||||
|
||||
if ((newPacket->size() - numBytesToEnd) < sizeRemaining) {
|
||||
int segmentSize = _currentPacket->pos() - _segmentStartIndex;
|
||||
|
||||
if (segmentSize + sizeRemaining > newPacket->getPayloadCapacity()) {
|
||||
// this is an unsupported case - the segment is bigger than the size of an individual packet
|
||||
// but the PacketList is not going to be sent ordered
|
||||
qDebug() << "Error in PacketList::writeData - attempted to write a segment to an unordered packet that is"
|
||||
<< "larger than the payload size.";
|
||||
Q_ASSERT(false);
|
||||
|
||||
// we won't be writing this new data to the packet
|
||||
// go back before the current segment and return -1 to indicate error
|
||||
_currentPacket->seek(_segmentStartIndex);
|
||||
_currentPacket->setPayloadSize(_segmentStartIndex);
|
||||
|
||||
return PACKET_LIST_WRITE_ERROR;
|
||||
} else {
|
||||
// copy from currentPacket where the segment started to the beginning of the newPacket
|
||||
newPacket->write(_currentPacket->getPayload() + _segmentStartIndex, segmentSize);
|
||||
|
||||
// shrink the current payload to the actual size of the packet
|
||||
_currentPacket->setPayloadSize(_segmentStartIndex);
|
||||
|
||||
// the current segment now starts at the beginning of the new packet
|
||||
_segmentStartIndex = _extendedHeader.size();
|
||||
}
|
||||
|
||||
int segmentSize = _currentPacket->pos() - _segmentStartIndex;
|
||||
|
||||
// copy from currentPacket where the segment started to the beginning of the newPacket
|
||||
newPacket->write(_currentPacket->getPayload() + _segmentStartIndex, segmentSize);
|
||||
|
||||
// the current segment now starts at the beginning of the new packet
|
||||
_segmentStartIndex = _extendedHeader.size();
|
||||
|
||||
// shrink the current payload to the actual size of the packet
|
||||
_currentPacket->setPayloadSize(_segmentStartIndex);
|
||||
}
|
||||
|
||||
if (sizeRemaining > newPacket->getPayloadCapacity()) {
|
||||
// this is an unsupported case - attempting to write a block of data larger
|
||||
// than the capacity of a new packet in an unordered PacketList
|
||||
qDebug() << "Error in PacketList::writeData - attempted to write data to an unordered packet that is"
|
||||
<< "larger than the payload size.";
|
||||
Q_ASSERT(false);
|
||||
|
||||
return PACKET_LIST_WRITE_ERROR;
|
||||
}
|
||||
|
||||
// move the current packet to our list of packets
|
||||
|
|
|
@ -355,11 +355,12 @@ bool SendQueue::maybeResendPacket() {
|
|||
// we found the packet - grab it
|
||||
auto& resendPacket = *(it->second);
|
||||
|
||||
// send it off
|
||||
sendPacket(resendPacket);
|
||||
|
||||
// unlock the sent packets
|
||||
sentLocker.unlock();
|
||||
|
||||
// send it off
|
||||
sendPacket(resendPacket);
|
||||
emit packetRetransmitted();
|
||||
|
||||
// Signal that we did resend a packet
|
||||
|
|
|
@ -31,8 +31,8 @@ Socket::Socket(QObject* parent) :
|
|||
QObject(parent),
|
||||
_synTimer(new QTimer(this))
|
||||
{
|
||||
qRegisterMetaType<Packet*>();
|
||||
qRegisterMetaType<PacketList*>();
|
||||
qRegisterMetaType<Packet*>("Packet*");
|
||||
qRegisterMetaType<PacketList*>("PacketList*");
|
||||
|
||||
connect(&_udpSocket, &QUdpSocket::readyRead, this, &Socket::readPendingDatagrams);
|
||||
|
||||
|
|
|
@ -35,9 +35,7 @@ void FramebufferCache::setFrameBufferSize(QSize frameBufferSize) {
|
|||
_frameBufferSize = frameBufferSize;
|
||||
_primaryFramebufferFull.reset();
|
||||
_primaryFramebufferDepthColor.reset();
|
||||
_primaryFramebufferStencilColor.reset();
|
||||
_primaryDepthTexture.reset();
|
||||
_primaryStencilTexture.reset();
|
||||
_primaryColorTexture.reset();
|
||||
_primaryNormalTexture.reset();
|
||||
_primarySpecularTexture.reset();
|
||||
|
@ -49,7 +47,6 @@ void FramebufferCache::setFrameBufferSize(QSize frameBufferSize) {
|
|||
void FramebufferCache::createPrimaryFramebuffer() {
|
||||
_primaryFramebufferFull = gpu::FramebufferPointer(gpu::Framebuffer::create());
|
||||
_primaryFramebufferDepthColor = gpu::FramebufferPointer(gpu::Framebuffer::create());
|
||||
_primaryFramebufferStencilColor = gpu::FramebufferPointer(gpu::Framebuffer::create());
|
||||
|
||||
auto colorFormat = gpu::Element(gpu::VEC4, gpu::NUINT8, gpu::RGBA);
|
||||
auto width = _frameBufferSize.width();
|
||||
|
@ -66,20 +63,14 @@ void FramebufferCache::createPrimaryFramebuffer() {
|
|||
|
||||
_primaryFramebufferDepthColor->setRenderBuffer(0, _primaryColorTexture);
|
||||
|
||||
_primaryFramebufferStencilColor->setRenderBuffer(0, _primaryColorTexture);
|
||||
|
||||
auto depthFormat = gpu::Element(gpu::SCALAR, gpu::FLOAT, gpu::DEPTH);
|
||||
// auto depthFormat = gpu::Element(gpu::SCALAR, gpu::FLOAT, gpu::DEPTH);
|
||||
auto depthFormat = gpu::Element(gpu::SCALAR, gpu::UINT32, gpu::DEPTH_STENCIL); // Depth24_Stencil8 texel format
|
||||
_primaryDepthTexture = gpu::TexturePointer(gpu::Texture::create2D(depthFormat, width, height, defaultSampler));
|
||||
|
||||
auto stencilFormat = gpu::Element(gpu::SCALAR, gpu::UINT32, gpu::DEPTH_STENCIL); // Depth24_Stencil8 texel format
|
||||
_primaryStencilTexture = gpu::TexturePointer(gpu::Texture::create2D(stencilFormat, width, height, defaultSampler));
|
||||
|
||||
|
||||
_primaryFramebufferFull->setDepthStencilBuffer(_primaryDepthTexture, depthFormat);
|
||||
|
||||
_primaryFramebufferDepthColor->setDepthStencilBuffer(_primaryDepthTexture, depthFormat);
|
||||
|
||||
_primaryFramebufferStencilColor->setDepthStencilBuffer(_primaryStencilTexture, stencilFormat);
|
||||
|
||||
|
||||
_selfieFramebuffer = gpu::FramebufferPointer(gpu::Framebuffer::create());
|
||||
auto tex = gpu::TexturePointer(gpu::Texture::create2D(colorFormat, width * 0.5, height * 0.5, defaultSampler));
|
||||
_selfieFramebuffer->setRenderBuffer(0, tex);
|
||||
|
@ -99,13 +90,6 @@ gpu::FramebufferPointer FramebufferCache::getPrimaryFramebufferDepthColor() {
|
|||
return _primaryFramebufferDepthColor;
|
||||
}
|
||||
|
||||
gpu::FramebufferPointer FramebufferCache::getPrimaryFramebufferStencilColor() {
|
||||
if (!_primaryFramebufferStencilColor) {
|
||||
createPrimaryFramebuffer();
|
||||
}
|
||||
return _primaryFramebufferStencilColor;
|
||||
}
|
||||
|
||||
gpu::TexturePointer FramebufferCache::getPrimaryDepthTexture() {
|
||||
if (!_primaryDepthTexture) {
|
||||
createPrimaryFramebuffer();
|
||||
|
@ -113,13 +97,6 @@ gpu::TexturePointer FramebufferCache::getPrimaryDepthTexture() {
|
|||
return _primaryDepthTexture;
|
||||
}
|
||||
|
||||
gpu::TexturePointer FramebufferCache::getPrimaryStencilTexture() {
|
||||
if (!_primaryStencilTexture) {
|
||||
createPrimaryFramebuffer();
|
||||
}
|
||||
return _primaryStencilTexture;
|
||||
}
|
||||
|
||||
gpu::TexturePointer FramebufferCache::getPrimaryColorTexture() {
|
||||
if (!_primaryColorTexture) {
|
||||
createPrimaryFramebuffer();
|
||||
|
|
|
@ -31,10 +31,8 @@ public:
|
|||
/// used for scene rendering.
|
||||
gpu::FramebufferPointer getPrimaryFramebuffer();
|
||||
gpu::FramebufferPointer getPrimaryFramebufferDepthColor();
|
||||
gpu::FramebufferPointer getPrimaryFramebufferStencilColor();
|
||||
|
||||
gpu::TexturePointer getPrimaryDepthTexture();
|
||||
gpu::TexturePointer getPrimaryStencilTexture();
|
||||
gpu::TexturePointer getPrimaryColorTexture();
|
||||
gpu::TexturePointer getPrimaryNormalTexture();
|
||||
gpu::TexturePointer getPrimarySpecularTexture();
|
||||
|
@ -60,9 +58,8 @@ private:
|
|||
|
||||
gpu::FramebufferPointer _primaryFramebufferFull;
|
||||
gpu::FramebufferPointer _primaryFramebufferDepthColor;
|
||||
gpu::FramebufferPointer _primaryFramebufferStencilColor;
|
||||
|
||||
gpu::TexturePointer _primaryDepthTexture;
|
||||
gpu::TexturePointer _primaryStencilTexture;
|
||||
gpu::TexturePointer _primaryColorTexture;
|
||||
gpu::TexturePointer _primaryNormalTexture;
|
||||
gpu::TexturePointer _primarySpecularTexture;
|
||||
|
|
|
@ -37,22 +37,17 @@ void SetupDeferred::run(const SceneContextPointer& sceneContext, const RenderCon
|
|||
RenderArgs* args = renderContext->args;
|
||||
gpu::doInBatch(args->_context, [=](gpu::Batch& batch) {
|
||||
|
||||
auto primaryFboStencil = DependencyManager::get<FramebufferCache>()->getPrimaryFramebufferStencilColor();
|
||||
auto primaryFbo = DependencyManager::get<FramebufferCache>()->getPrimaryFramebufferDepthColor();
|
||||
|
||||
batch.enableStereo(false);
|
||||
batch.setViewportTransform(args->_viewport);
|
||||
batch.setStateScissorRect(args->_viewport);
|
||||
|
||||
batch.setFramebuffer(primaryFboStencil);
|
||||
batch.clearFramebuffer(
|
||||
gpu::Framebuffer::BUFFER_STENCIL,
|
||||
vec4(vec3(0), 1), 1.0, 0.0, true);
|
||||
|
||||
batch.setFramebuffer(primaryFbo);
|
||||
batch.clearFramebuffer(
|
||||
gpu::Framebuffer::BUFFER_COLOR0 |
|
||||
gpu::Framebuffer::BUFFER_DEPTH,
|
||||
gpu::Framebuffer::BUFFER_DEPTH |
|
||||
gpu::Framebuffer::BUFFER_STENCIL,
|
||||
vec4(vec3(0), 1), 1.0, 0.0, true);
|
||||
});
|
||||
}
|
||||
|
@ -313,7 +308,8 @@ const gpu::PipelinePointer& DrawStencilDeferred::getOpaquePipeline() {
|
|||
gpu::Shader::makeProgram((*program));
|
||||
|
||||
auto state = std::make_shared<gpu::State>();
|
||||
state->setStencilTest(true, 0xFF, gpu::State::StencilTest(STENCIL_OPAQUE, 0xFF, gpu::ALWAYS, gpu::State::STENCIL_OP_REPLACE, gpu::State::STENCIL_OP_REPLACE, gpu::State::STENCIL_OP_REPLACE));
|
||||
state->setDepthTest(true, false, gpu::LESS_EQUAL);
|
||||
state->setStencilTest(true, 0xFF, gpu::State::StencilTest(STENCIL_OPAQUE, 0xFF, gpu::ALWAYS, gpu::State::STENCIL_OP_REPLACE, gpu::State::STENCIL_OP_KEEP, gpu::State::STENCIL_OP_REPLACE));
|
||||
state->setColorWriteMask(0);
|
||||
|
||||
_opaquePipeline.reset(gpu::Pipeline::create(program, state));
|
||||
|
@ -330,9 +326,8 @@ void DrawStencilDeferred::run(const SceneContextPointer& sceneContext, const Ren
|
|||
doInBatch(args->_context, [=](gpu::Batch& batch) {
|
||||
args->_batch = &batch;
|
||||
|
||||
auto primaryFboColorDepthStencil = DependencyManager::get<FramebufferCache>()->getPrimaryFramebufferStencilColor();
|
||||
auto primaryDepth = DependencyManager::get<FramebufferCache>()->getPrimaryDepthTexture();
|
||||
|
||||
auto primaryFboColorDepthStencil = DependencyManager::get<FramebufferCache>()->getPrimaryFramebufferDepthColor();
|
||||
|
||||
batch.enableStereo(false);
|
||||
|
||||
batch.setFramebuffer(primaryFboColorDepthStencil);
|
||||
|
@ -340,7 +335,6 @@ void DrawStencilDeferred::run(const SceneContextPointer& sceneContext, const Ren
|
|||
batch.setStateScissorRect(args->_viewport);
|
||||
|
||||
batch.setPipeline(getOpaquePipeline());
|
||||
batch.setResourceTexture(0, primaryDepth);
|
||||
|
||||
batch.draw(gpu::TRIANGLE_STRIP, 4);
|
||||
batch.setResourceTexture(0, nullptr);
|
||||
|
@ -367,12 +361,12 @@ void DrawBackgroundDeferred::run(const SceneContextPointer& sceneContext, const
|
|||
doInBatch(args->_context, [=](gpu::Batch& batch) {
|
||||
args->_batch = &batch;
|
||||
|
||||
auto primaryFboColorStencil = DependencyManager::get<FramebufferCache>()->getPrimaryFramebufferStencilColor();
|
||||
auto primaryFboColorDepthStencil = DependencyManager::get<FramebufferCache>()->getPrimaryFramebufferDepthColor();
|
||||
auto primaryFboFull = DependencyManager::get<FramebufferCache>()->getPrimaryFramebuffer();
|
||||
|
||||
batch.enableSkybox(true);
|
||||
|
||||
batch.setFramebuffer(primaryFboColorStencil);
|
||||
batch.setFramebuffer(primaryFboColorDepthStencil);
|
||||
|
||||
batch.setViewportTransform(args->_viewport);
|
||||
batch.setStateScissorRect(args->_viewport);
|
||||
|
|
|
@ -12,13 +12,5 @@
|
|||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
in vec2 varTexCoord0;
|
||||
|
||||
uniform sampler2D depthTexture;
|
||||
|
||||
void main(void) {
|
||||
float depth = texture(depthTexture, varTexCoord0.xy).r;
|
||||
if (depth >= 1.0) {
|
||||
discard;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
//
|
||||
|
||||
|
||||
(function () {
|
||||
(function() {
|
||||
|
||||
var _this;
|
||||
|
||||
|
@ -22,13 +22,13 @@
|
|||
var dollScriptURL = Script.resolvePath("../examples/toys/doll/doll.js");
|
||||
var lightsScriptURL = Script.resolvePath("../examples/toys/lightSwitch.js");
|
||||
|
||||
ResetSwitch = function () {
|
||||
ResetSwitch = function() {
|
||||
_this = this;
|
||||
};
|
||||
|
||||
ResetSwitch.prototype = {
|
||||
|
||||
clickReleaseOnEntity: function (entityId, mouseEvent) {
|
||||
clickReleaseOnEntity: function(entityId, mouseEvent) {
|
||||
if (!mouseEvent.isLeftButton) {
|
||||
return;
|
||||
}
|
||||
|
@ -36,26 +36,22 @@
|
|||
|
||||
},
|
||||
|
||||
startNearGrabNonColliding: function () {
|
||||
startNearGrabNonColliding: function() {
|
||||
this.triggerReset();
|
||||
},
|
||||
|
||||
startFarGrabNonColliding: function () {
|
||||
this.triggerReset();
|
||||
},
|
||||
|
||||
triggerReset: function () {
|
||||
triggerReset: function() {
|
||||
MasterReset();
|
||||
},
|
||||
|
||||
preload: function (entityID) {
|
||||
preload: function(entityID) {
|
||||
this.entityID = entityID;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
MasterReset = function () {
|
||||
MasterReset = function() {
|
||||
var resetKey = "resetMe";
|
||||
var GRABBABLE_DATA_KEY = "grabbableKey";
|
||||
|
||||
|
@ -145,7 +141,7 @@
|
|||
function deleteAllToys() {
|
||||
var entities = Entities.findEntities(MyAvatar.position, 100);
|
||||
|
||||
entities.forEach(function (entity) {
|
||||
entities.forEach(function(entity) {
|
||||
//params: customKey, id, defaultValue
|
||||
var shouldReset = getEntityCustomData(resetKey, entity, {}).resetMe;
|
||||
if (shouldReset === true) {
|
||||
|
@ -330,14 +326,14 @@
|
|||
function testBallDistanceFromStart() {
|
||||
var resetCount = 0;
|
||||
|
||||
collidingBalls.forEach(function (ball, index) {
|
||||
collidingBalls.forEach(function(ball, index) {
|
||||
var currentPosition = Entities.getEntityProperties(ball, "position").position;
|
||||
var originalPosition = originalBallPositions[index];
|
||||
var distance = Vec3.subtract(originalPosition, currentPosition);
|
||||
var length = Vec3.length(distance);
|
||||
|
||||
if (length > RESET_DISTANCE) {
|
||||
Script.setTimeout(function () {
|
||||
Script.setTimeout(function() {
|
||||
var newPosition = Entities.getEntityProperties(ball, "position").position;
|
||||
var moving = Vec3.length(Vec3.subtract(currentPosition, newPosition));
|
||||
if (moving < MINIMUM_MOVE_LENGTH) {
|
||||
|
|
|
@ -24,28 +24,17 @@ function createHiddenMasterSwitch() {
|
|||
type: "Box",
|
||||
name: "Master Switch",
|
||||
script: hiddenEntityScriptURL,
|
||||
dimensions: {
|
||||
x: 0.2,
|
||||
y: 0.2,
|
||||
z: 0.2
|
||||
},
|
||||
color: {
|
||||
red: 42,
|
||||
green: 36,
|
||||
blue: 30
|
||||
},
|
||||
position: {
|
||||
x: 554,
|
||||
y: 495.5,
|
||||
z: 503.2
|
||||
}
|
||||
dimensions: {x: 0.7, y: 0.2, z: 0.1},
|
||||
position: {x: 543.9, y: 496.05, z: 502.43},
|
||||
rotation: Quat.fromPitchYawRollDegrees(0, 33, 0),
|
||||
visible: false
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
var entities = Entities.findEntities(MyAvatar.position, 100);
|
||||
|
||||
entities.forEach(function (entity) {
|
||||
entities.forEach(function(entity) {
|
||||
//params: customKey, id, defaultValue
|
||||
var name = Entities.getEntityProperties(entity, "name").name
|
||||
if (name === "Master Switch") {
|
||||
|
|
|
@ -21,10 +21,11 @@ var pingPongScriptURL = Script.resolvePath('../examples/toys/ping_pong_gun/pingP
|
|||
var wandScriptURL = Script.resolvePath("../examples/toys/bubblewand/wand.js");
|
||||
var dollScriptURL = Script.resolvePath("../examples/toys/doll/doll.js");
|
||||
var lightsScriptURL = Script.resolvePath("../examples/toys/lightSwitch.js");
|
||||
var targetsScriptURL = Script.resolvePath('../examples/toys/ping_pong_gun/wallTarget.js');
|
||||
|
||||
|
||||
|
||||
MasterReset = function () {
|
||||
MasterReset = function() {
|
||||
var resetKey = "resetMe";
|
||||
var GRABBABLE_DATA_KEY = "grabbableKey";
|
||||
|
||||
|
@ -109,12 +110,14 @@ MasterReset = function () {
|
|||
z: 503.91
|
||||
});
|
||||
|
||||
createTargets();
|
||||
|
||||
}
|
||||
|
||||
function deleteAllToys() {
|
||||
var entities = Entities.findEntities(MyAvatar.position, 100);
|
||||
|
||||
entities.forEach(function (entity) {
|
||||
entities.forEach(function(entity) {
|
||||
//params: customKey, id, defaultValue
|
||||
var shouldReset = getEntityCustomData(resetKey, entity, {}).resetMe;
|
||||
if (shouldReset === true) {
|
||||
|
@ -299,14 +302,14 @@ MasterReset = function () {
|
|||
function testBallDistanceFromStart() {
|
||||
var resetCount = 0;
|
||||
|
||||
collidingBalls.forEach(function (ball, index) {
|
||||
collidingBalls.forEach(function(ball, index) {
|
||||
var currentPosition = Entities.getEntityProperties(ball, "position").position;
|
||||
var originalPosition = originalBallPositions[index];
|
||||
var distance = Vec3.subtract(originalPosition, currentPosition);
|
||||
var length = Vec3.length(distance);
|
||||
|
||||
if (length > RESET_DISTANCE) {
|
||||
Script.setTimeout(function () {
|
||||
Script.setTimeout(function() {
|
||||
var newPosition = Entities.getEntityProperties(ball, "position").position;
|
||||
var moving = Vec3.length(Vec3.subtract(currentPosition, newPosition));
|
||||
if (moving < MINIMUM_MOVE_LENGTH) {
|
||||
|
@ -341,6 +344,141 @@ MasterReset = function () {
|
|||
var distanceCheckInterval = Script.setInterval(testBallDistanceFromStart, 1000);
|
||||
}
|
||||
|
||||
function createTargets() {
|
||||
|
||||
var MODEL_URL = 'http://hifi-public.s3.amazonaws.com/models/ping_pong_gun/target.fbx';
|
||||
var COLLISION_HULL_URL = 'http://hifi-public.s3.amazonaws.com/models/ping_pong_gun/target_collision_hull.obj';
|
||||
|
||||
var RESET_DISTANCE = 1;
|
||||
var TARGET_USER_DATA_KEY = 'hifi-ping_pong_target';
|
||||
var NUMBER_OF_TARGETS = 6;
|
||||
var TARGETS_PER_ROW = 3;
|
||||
|
||||
var TARGET_DIMENSIONS = {
|
||||
x: 0.06,
|
||||
y: 0.42,
|
||||
z: 0.42
|
||||
};
|
||||
|
||||
var VERTICAL_SPACING = TARGET_DIMENSIONS.y + 0.5;
|
||||
var HORIZONTAL_SPACING = TARGET_DIMENSIONS.z + 0.5;
|
||||
|
||||
|
||||
var startPosition = {
|
||||
x: 548.68,
|
||||
y: 497.30,
|
||||
z: 509.74
|
||||
};
|
||||
|
||||
var rotation = Quat.fromPitchYawRollDegrees(0, -55.25, 0);
|
||||
|
||||
var targetIntervalClearer = Entities.addEntity({
|
||||
name: 'Target Interval Clearer - delete me to clear',
|
||||
type: 'Box',
|
||||
position: startPosition,
|
||||
dimensions: TARGET_DIMENSIONS,
|
||||
color: {
|
||||
red: 0,
|
||||
green: 255,
|
||||
blue: 0
|
||||
},
|
||||
rotation: rotation,
|
||||
visible: false,
|
||||
collisionsWillMove: false,
|
||||
ignoreForCollisions: true,
|
||||
});
|
||||
|
||||
var targets = [];
|
||||
|
||||
var originalPositions = [];
|
||||
|
||||
function addTargets() {
|
||||
var i;
|
||||
var row = -1;
|
||||
for (i = 0; i < NUMBER_OF_TARGETS; i++) {
|
||||
|
||||
if (i % TARGETS_PER_ROW === 0) {
|
||||
row++;
|
||||
}
|
||||
|
||||
var vHat = Quat.getFront(rotation);
|
||||
var spacer = HORIZONTAL_SPACING * (i % TARGETS_PER_ROW) + (row * HORIZONTAL_SPACING / 2);
|
||||
var multiplier = Vec3.multiply(spacer, vHat);
|
||||
var position = Vec3.sum(startPosition, multiplier);
|
||||
position.y = startPosition.y - (row * VERTICAL_SPACING);
|
||||
|
||||
originalPositions.push(position);
|
||||
|
||||
var targetProperties = {
|
||||
name: 'Target',
|
||||
type: 'Model',
|
||||
modelURL: MODEL_URL,
|
||||
shapeType: 'compound',
|
||||
collisionsWillMove: true,
|
||||
dimensions: TARGET_DIMENSIONS,
|
||||
compoundShapeURL: COLLISION_HULL_URL,
|
||||
position: position,
|
||||
rotation: rotation,
|
||||
script: targetsScriptURL
|
||||
};
|
||||
|
||||
targets.push(Entities.addEntity(targetProperties));
|
||||
}
|
||||
}
|
||||
|
||||
function testTargetDistanceFromStart() {
|
||||
targets.forEach(function(target, index) {
|
||||
|
||||
var currentPosition = Entities.getEntityProperties(target, "position").position;
|
||||
var originalPosition = originalPositions[index];
|
||||
var distance = Vec3.subtract(originalPosition, currentPosition);
|
||||
var length = Vec3.length(distance);
|
||||
|
||||
if (length > RESET_DISTANCE) {
|
||||
|
||||
Entities.deleteEntity(target);
|
||||
|
||||
var targetProperties = {
|
||||
name: 'Target',
|
||||
type: 'Model',
|
||||
modelURL: MODEL_URL,
|
||||
shapeType: 'compound',
|
||||
collisionsWillMove: true,
|
||||
dimensions: TARGET_DIMENSIONS,
|
||||
compoundShapeURL: COLLISION_HULL_URL,
|
||||
position: originalPositions[index],
|
||||
rotation: rotation,
|
||||
script: targetsScriptURL
|
||||
};
|
||||
|
||||
targets[index] = Entities.addEntity(targetProperties);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
function deleteEntity(entityID) {
|
||||
if (entityID === targetIntervalClearer) {
|
||||
deleteTargets();
|
||||
Script.clearInterval(distanceCheckInterval);
|
||||
Entities.deletingEntity.disconnect(deleteEntity);
|
||||
}
|
||||
}
|
||||
|
||||
function deleteTargets() {
|
||||
while (targets.length > 0) {
|
||||
Entities.deleteEntity(targets.pop());
|
||||
}
|
||||
Entities.deleteEntity(targetIntervalClearer);
|
||||
}
|
||||
|
||||
Entities.deletingEntity.connect(deleteEntity);
|
||||
var distanceCheckInterval = Script.setInterval(testTargetDistanceFromStart, 1000);
|
||||
|
||||
addTargets();
|
||||
|
||||
}
|
||||
|
||||
function createCat(position) {
|
||||
|
||||
var modelURL = "http://hifi-public.s3.amazonaws.com/ryan/Dark_Cat.fbx";
|
||||
|
|
Loading…
Reference in a new issue