mirror of
https://github.com/overte-org/overte.git
synced 2025-04-19 15:43:50 +02:00
Merge branch 'master' of https://github.com/highfidelity/hifi into dont-use-other-avatar-sounds
This commit is contained in:
commit
308fd0cf7e
43 changed files with 1088 additions and 359 deletions
|
@ -226,7 +226,7 @@ SharedNodePointer DomainGatekeeper::processAgentConnectRequest(const NodeConnect
|
|||
// if the allowed editors list is empty then everyone can adjust locks
|
||||
bool canAdjustLocks = allowedEditors.empty();
|
||||
|
||||
if (allowedEditors.contains(username)) {
|
||||
if (allowedEditors.contains(username, Qt::CaseInsensitive)) {
|
||||
// we have a non-empty allowed editors list - check if this user is verified to be in it
|
||||
if (!verifiedUsername) {
|
||||
if (!verifyUserSignature(username, usernameSignature, HifiSockAddr())) {
|
||||
|
|
|
@ -74,8 +74,8 @@ var MSEC_PER_SEC = 1000.0;
|
|||
|
||||
// these control how long an abandoned pointer line will hang around
|
||||
var LIFETIME = 10;
|
||||
var ACTION_LIFETIME = 15; // seconds
|
||||
var ACTION_LIFETIME_REFRESH = 5;
|
||||
var ACTION_TTL = 15; // seconds
|
||||
var ACTION_TTL_REFRESH = 5;
|
||||
var PICKS_PER_SECOND_PER_HAND = 5;
|
||||
var MSECS_PER_SEC = 1000.0;
|
||||
|
||||
|
@ -422,12 +422,12 @@ function MyController(hand, triggerAction) {
|
|||
targetRotation: this.currentObjectRotation,
|
||||
angularTimeScale: DISTANCE_HOLDING_ACTION_TIMEFRAME,
|
||||
tag: getTag(),
|
||||
lifetime: ACTION_LIFETIME
|
||||
ttl: ACTION_TTL
|
||||
});
|
||||
if (this.actionID === NULL_ACTION_ID) {
|
||||
this.actionID = null;
|
||||
}
|
||||
this.actionTimeout = now + (ACTION_LIFETIME * MSEC_PER_SEC);
|
||||
this.actionTimeout = now + (ACTION_TTL * MSEC_PER_SEC);
|
||||
|
||||
if (this.actionID !== null) {
|
||||
this.setState(STATE_CONTINUE_DISTANCE_HOLDING);
|
||||
|
@ -524,9 +524,9 @@ function MyController(hand, triggerAction) {
|
|||
linearTimeScale: DISTANCE_HOLDING_ACTION_TIMEFRAME,
|
||||
targetRotation: this.currentObjectRotation,
|
||||
angularTimeScale: DISTANCE_HOLDING_ACTION_TIMEFRAME,
|
||||
lifetime: ACTION_LIFETIME
|
||||
ttl: ACTION_TTL
|
||||
});
|
||||
this.actionTimeout = now + (ACTION_LIFETIME * MSEC_PER_SEC);
|
||||
this.actionTimeout = now + (ACTION_TTL * MSEC_PER_SEC);
|
||||
};
|
||||
|
||||
this.nearGrabbing = function() {
|
||||
|
@ -579,12 +579,12 @@ function MyController(hand, triggerAction) {
|
|||
timeScale: NEAR_GRABBING_ACTION_TIMEFRAME,
|
||||
relativePosition: this.offsetPosition,
|
||||
relativeRotation: this.offsetRotation,
|
||||
lifetime: ACTION_LIFETIME
|
||||
ttl: ACTION_TTL
|
||||
});
|
||||
if (this.actionID === NULL_ACTION_ID) {
|
||||
this.actionID = null;
|
||||
} else {
|
||||
this.actionTimeout = now + (ACTION_LIFETIME * MSEC_PER_SEC);
|
||||
this.actionTimeout = now + (ACTION_TTL * MSEC_PER_SEC);
|
||||
this.setState(STATE_CONTINUE_NEAR_GRABBING);
|
||||
if (this.hand === RIGHT_HAND) {
|
||||
Entities.callEntityMethod(this.grabbedEntity, "setRightHand");
|
||||
|
@ -624,16 +624,16 @@ function MyController(hand, triggerAction) {
|
|||
this.currentObjectTime = now;
|
||||
Entities.callEntityMethod(this.grabbedEntity, "continueNearGrab");
|
||||
|
||||
if (this.actionTimeout - now < ACTION_LIFETIME_REFRESH * MSEC_PER_SEC) {
|
||||
// if less than a 5 seconds left, refresh the actions lifetime
|
||||
if (this.actionTimeout - now < ACTION_TTL_REFRESH * MSEC_PER_SEC) {
|
||||
// if less than a 5 seconds left, refresh the actions ttl
|
||||
Entities.updateAction(this.grabbedEntity, this.actionID, {
|
||||
hand: this.hand === RIGHT_HAND ? "right" : "left",
|
||||
timeScale: NEAR_GRABBING_ACTION_TIMEFRAME,
|
||||
relativePosition: this.offsetPosition,
|
||||
relativeRotation: this.offsetRotation,
|
||||
lifetime: ACTION_LIFETIME
|
||||
ttl: ACTION_TTL
|
||||
});
|
||||
this.actionTimeout = now + (ACTION_LIFETIME * MSEC_PER_SEC);
|
||||
this.actionTimeout = now + (ACTION_TTL * MSEC_PER_SEC);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -1510,9 +1510,9 @@ PropertiesTool = function(opts) {
|
|||
if (entity.properties.rotation !== undefined) {
|
||||
entity.properties.rotation = Quat.safeEulerAngles(entity.properties.rotation);
|
||||
}
|
||||
if (entity.properties.keyLightDirection !== undefined) {
|
||||
entity.properties.keyLightDirection = Vec3.multiply(RADIANS_TO_DEGREES, Vec3.toPolar(entity.properties.keyLightDirection));
|
||||
entity.properties.keyLightDirection.z = 0.0;
|
||||
if (entity.properties.keyLight.direction !== undefined) {
|
||||
entity.properties.keyLight.direction = Vec3.multiply(RADIANS_TO_DEGREES, Vec3.toPolar(entity.properties.keyLight.direction));
|
||||
entity.properties.keyLight.direction.z = 0.0;
|
||||
}
|
||||
selections.push(entity);
|
||||
}
|
||||
|
@ -1541,9 +1541,9 @@ PropertiesTool = function(opts) {
|
|||
var rotation = data.properties.rotation;
|
||||
data.properties.rotation = Quat.fromPitchYawRollDegrees(rotation.x, rotation.y, rotation.z);
|
||||
}
|
||||
if (data.properties.keyLightDirection !== undefined) {
|
||||
data.properties.keyLightDirection = Vec3.fromPolar(
|
||||
data.properties.keyLightDirection.x * DEGREES_TO_RADIANS, data.properties.keyLightDirection.y * DEGREES_TO_RADIANS);
|
||||
if (data.properties.keyLight.direction !== undefined) {
|
||||
data.properties.keyLight.direction = Vec3.fromPolar(
|
||||
data.properties.keyLight.direction.x * DEGREES_TO_RADIANS, data.properties.keyLight.direction.y * DEGREES_TO_RADIANS);
|
||||
}
|
||||
Entities.editEntity(selectionManager.selections[0], data.properties);
|
||||
if (data.properties.name != undefined) {
|
||||
|
|
|
@ -47,7 +47,7 @@ var IDENTITY_QUAT = {
|
|||
z: 0,
|
||||
w: 0
|
||||
};
|
||||
var ACTION_LIFETIME = 10; // seconds
|
||||
var ACTION_TTL = 10; // seconds
|
||||
|
||||
function getTag() {
|
||||
return "grab-" + MyAvatar.sessionUUID;
|
||||
|
@ -403,7 +403,7 @@ Grabber.prototype.moveEvent = function(event) {
|
|||
|
||||
var actionArgs = {
|
||||
tag: getTag(),
|
||||
lifetime: ACTION_LIFETIME
|
||||
ttl: ACTION_TTL
|
||||
};
|
||||
|
||||
if (this.mode === "rotate") {
|
||||
|
@ -424,7 +424,7 @@ Grabber.prototype.moveEvent = function(event) {
|
|||
targetRotation: this.lastRotation,
|
||||
angularTimeScale: 0.1,
|
||||
tag: getTag(),
|
||||
lifetime: ACTION_LIFETIME
|
||||
ttl: ACTION_TTL
|
||||
};
|
||||
|
||||
} else {
|
||||
|
@ -459,7 +459,7 @@ Grabber.prototype.moveEvent = function(event) {
|
|||
targetPosition: this.targetPosition,
|
||||
linearTimeScale: 0.1,
|
||||
tag: getTag(),
|
||||
lifetime: ACTION_LIFETIME
|
||||
ttl: ACTION_TTL
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -328,6 +328,7 @@
|
|||
var elZoneSections = document.querySelectorAll(".zone-section");
|
||||
allSections.push(elZoneSections);
|
||||
var elZoneStageSunModelEnabled = document.getElementById("property-zone-stage-sun-model-enabled");
|
||||
|
||||
var elZoneKeyLightColor = document.getElementById("property-zone-key-light-color");
|
||||
var elZoneKeyLightColorRed = document.getElementById("property-zone-key-light-color-red");
|
||||
var elZoneKeyLightColorGreen = document.getElementById("property-zone-key-light-color-green");
|
||||
|
@ -337,6 +338,7 @@
|
|||
var elZoneKeyLightDirectionX = document.getElementById("property-zone-key-light-direction-x");
|
||||
var elZoneKeyLightDirectionY = document.getElementById("property-zone-key-light-direction-y");
|
||||
var elZoneKeyLightDirectionZ = document.getElementById("property-zone-key-light-direction-z");
|
||||
var elZoneKeyLightAmbientURL = document.getElementById("property-zone-key-ambient-url");
|
||||
|
||||
var elZoneStageLatitude = document.getElementById("property-zone-stage-latitude");
|
||||
var elZoneStageLongitude = document.getElementById("property-zone-stage-longitude");
|
||||
|
@ -568,15 +570,17 @@
|
|||
}
|
||||
|
||||
elZoneStageSunModelEnabled.checked = properties.stage.sunModelEnabled;
|
||||
elZoneKeyLightColor.style.backgroundColor = "rgb(" + properties.keyLightColor.red + "," + properties.keyLightColor.green + "," + properties.keyLightColor.blue + ")";
|
||||
elZoneKeyLightColorRed.value = properties.keyLightColor.red;
|
||||
elZoneKeyLightColorGreen.value = properties.keyLightColor.green;
|
||||
elZoneKeyLightColorBlue.value = properties.keyLightColor.blue;
|
||||
elZoneKeyLightIntensity.value = properties.keyLightIntensity.toFixed(2);
|
||||
elZoneKeyLightAmbientIntensity.value = properties.keyLightAmbientIntensity.toFixed(2);
|
||||
elZoneKeyLightDirectionX.value = properties.keyLightDirection.x.toFixed(2);
|
||||
elZoneKeyLightDirectionY.value = properties.keyLightDirection.y.toFixed(2);
|
||||
elZoneKeyLightDirectionZ.value = properties.keyLightDirection.z.toFixed(2);
|
||||
elZoneKeyLightColor.style.backgroundColor = "rgb(" + properties.keyLight.color.red + "," + properties.keyLight.color.green + "," + properties.keyLight.color.blue + ")";
|
||||
elZoneKeyLightColorRed.value = properties.keyLight.color.red;
|
||||
elZoneKeyLightColorGreen.value = properties.keyLight.color.green;
|
||||
elZoneKeyLightColorBlue.value = properties.keyLight.color.blue;
|
||||
elZoneKeyLightIntensity.value = properties.keyLight.intensity.toFixed(2);
|
||||
elZoneKeyLightAmbientIntensity.value = properties.keyLight.ambientIntensity.toFixed(2);
|
||||
elZoneKeyLightDirectionX.value = properties.keyLight.direction.x.toFixed(2);
|
||||
elZoneKeyLightDirectionY.value = properties.keyLight.direction.y.toFixed(2);
|
||||
elZoneKeyLightDirectionZ.value = properties.keyLight.direction.z.toFixed(2);
|
||||
elZoneKeyLightAmbientURL.value = properties.keyLight.ambientURL;
|
||||
|
||||
|
||||
elZoneStageLatitude.value = properties.stage.latitude.toFixed(2);
|
||||
elZoneStageLongitude.value = properties.stage.longitude.toFixed(2);
|
||||
|
@ -819,21 +823,20 @@
|
|||
onSubmit: function(hsb, hex, rgb, el) {
|
||||
$(el).css('background-color', '#'+hex);
|
||||
$(el).colpickHide();
|
||||
emitColorPropertyUpdate('keyLightColor', rgb.r, rgb.g, rgb.b);
|
||||
emitColorPropertyUpdate('color', rgb.r, rgb.g, rgb.b, 'keyLight');
|
||||
}
|
||||
});
|
||||
var zoneKeyLightColorChangeFunction = createEmitColorPropertyUpdateFunction(
|
||||
'keyLightColor', elZoneKeyLightColorRed, elZoneKeyLightColorGreen, elZoneKeyLightColorBlue);
|
||||
var zoneKeyLightColorChangeFunction = createEmitGroupColorPropertyUpdateFunction('keyLight','color', elZoneKeyLightColorRed, elZoneKeyLightColorGreen, elZoneKeyLightColorBlue);
|
||||
elZoneKeyLightColorRed.addEventListener('change', zoneKeyLightColorChangeFunction);
|
||||
elZoneKeyLightColorGreen.addEventListener('change', zoneKeyLightColorChangeFunction);
|
||||
elZoneKeyLightColorBlue.addEventListener('change', zoneKeyLightColorChangeFunction);
|
||||
elZoneKeyLightIntensity.addEventListener('change', createEmitNumberPropertyUpdateFunction('keyLightIntensity'));
|
||||
elZoneKeyLightAmbientIntensity.addEventListener('change', createEmitNumberPropertyUpdateFunction('keyLightAmbientIntensity'));
|
||||
var zoneKeyLightDirectionChangeFunction = createEmitVec3PropertyUpdateFunction(
|
||||
'keyLightDirection', elZoneKeyLightDirectionX, elZoneKeyLightDirectionY, elZoneKeyLightDirectionZ);
|
||||
elZoneKeyLightIntensity.addEventListener('change', createEmitGroupNumberPropertyUpdateFunction('intensity','keyLight'));
|
||||
elZoneKeyLightAmbientIntensity.addEventListener('change', createEmitGroupNumberPropertyUpdateFunction('keyLight','ambientIntensity'));
|
||||
var zoneKeyLightDirectionChangeFunction = createEmitGroupVec3PropertyUpdateFunction('keyLight','direction', elZoneKeyLightDirectionX, elZoneKeyLightDirectionY, elZoneKeyLightDirectionZ);
|
||||
elZoneKeyLightDirectionX.addEventListener('change', zoneKeyLightDirectionChangeFunction);
|
||||
elZoneKeyLightDirectionY.addEventListener('change', zoneKeyLightDirectionChangeFunction);
|
||||
elZoneKeyLightDirectionZ.addEventListener('change', zoneKeyLightDirectionChangeFunction);
|
||||
elZoneKeyLightAmbientURL.addEventListener('change', createEmitGroupTextPropertyUpdateFunction('keyLight','ambientURL'));
|
||||
|
||||
elZoneStageLatitude.addEventListener('change', createEmitGroupNumberPropertyUpdateFunction('stage','latitude'));
|
||||
elZoneStageLongitude.addEventListener('change', createEmitGroupNumberPropertyUpdateFunction('stage','longitude'));
|
||||
|
@ -1476,8 +1479,12 @@
|
|||
</span>
|
||||
</div>
|
||||
|
||||
<div class="zone-section property">
|
||||
<div class="label">Key Light Color</div>
|
||||
<div class="sub-section-header zone-section keyLight-section">
|
||||
<label>KeyLight</label>
|
||||
</div>
|
||||
|
||||
<div class="zone-section keyLight-section property">
|
||||
<div class="label">Light Color</div>
|
||||
<div class="value">
|
||||
<div class='color-picker' id="property-zone-key-light-color"></div>
|
||||
<div class="input-area">R <input class="coord" type='number' id="property-zone-key-light-color-red" min="0" max="255" step="1"></div>
|
||||
|
@ -1485,20 +1492,16 @@
|
|||
<div class="input-area">B <input class="coord" type='number' id="property-zone-key-light-color-blue" min="0" max="255" step="1"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="zone-section property">
|
||||
<div class="label">Key Light Intensity</div>
|
||||
|
||||
<div class="zone-section keyLight-section property">
|
||||
<div class="label">Light Intensity</div>
|
||||
<div class="value">
|
||||
<input class="coord" type='number' id="property-zone-key-intensity" min="0" max="10" step="0.1">
|
||||
</div>
|
||||
</div>
|
||||
<div class="zone-section property">
|
||||
<div class="label">Key Light Ambient Intensity</div>
|
||||
<div class="value">
|
||||
<input class="coord" type='number' id="property-zone-key-ambient-intensity" min="0" max="10" step="0.1">
|
||||
</div>
|
||||
</div>
|
||||
<div class="zone-section property">
|
||||
<div class="label">Key Light Direction</div>
|
||||
|
||||
<div class="zone-section keyLight-section property">
|
||||
<div class="label">Light Direction</div>
|
||||
<div class="value">
|
||||
<div class="input-area">Pitch <input class="coord" type='number' id="property-zone-key-light-direction-x"></div>
|
||||
<div class="input-area">Yaw <input class="coord" type='number' id="property-zone-key-light-direction-y"></div>
|
||||
|
@ -1506,46 +1509,69 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<div class="zone-section property">
|
||||
<div class="zone-section keyLight-section property">
|
||||
<div class="label">Ambient Intensity</div>
|
||||
<div class="value">
|
||||
<input class="coord" type='number' id="property-zone-key-ambient-intensity" min="0" max="10" step="0.1">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="zone-section keyLight-section property">
|
||||
<div class="label">Ambient URL</div>
|
||||
<div class="value">
|
||||
<input type="text" id="property-zone-skybox-url" class="url">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="sub-section-header zone-section stage-section">
|
||||
<label>Stage</label>
|
||||
</div>
|
||||
|
||||
<div class="zone-section stage-section property">
|
||||
<div class="label">Stage Latitude</div>
|
||||
<div class="value">
|
||||
<input class="coord" type='number' id="property-zone-stage-latitude" min="-90" max="90" step="1">
|
||||
</div>
|
||||
</div>
|
||||
<div class="zone-section property">
|
||||
<div class="zone-section stage-section property">
|
||||
<div class="label">Stage Longitude</div>
|
||||
<div class="value">
|
||||
<input class="coord" type='number' id="property-zone-stage-longitude" min="-180" max="180" step="1">
|
||||
</div>
|
||||
</div>
|
||||
<div class="zone-section property">
|
||||
<div class="zone-section stage-section property">
|
||||
<div class="label">Stage Altitude</div>
|
||||
<div class="value">
|
||||
<input class="coord" type='number' id="property-zone-stage-altitude" step="1">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="zone-section property">
|
||||
<div class="zone-section stage-section property">
|
||||
<span class="label">Automatically calculate stage hour and day from location and clock.</span>
|
||||
<span class="value">
|
||||
<input type='checkbox' id="property-zone-stage-automatic-hour-day">
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div class="zone-section property">
|
||||
<div class="zone-section stage-section property">
|
||||
<div class="label">Stage Day</div>
|
||||
<div class="value">
|
||||
<input class="coord" type='number' id="property-zone-stage-day" min="0" max="365" step="1">
|
||||
</div>
|
||||
</div>
|
||||
<div class="zone-section property">
|
||||
<div class="zone-section stage-section property">
|
||||
<div class="label">Stage Hour</div>
|
||||
<div class="value">
|
||||
<input class="coord" type='number' id="property-zone-stage-hour" min="0" max="24" step="0.5">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="zone-section property">
|
||||
<div class="sub-section-header zone-section background-section">
|
||||
<label>Background</label>
|
||||
</div>
|
||||
|
||||
<div class="zone-section background-section property">
|
||||
<div class="label">Background Mode</div>
|
||||
<div class="value">
|
||||
<select name="SelectBackgroundMode" id="property-zone-background-mode">
|
||||
|
|
|
@ -65,7 +65,7 @@ var soundMap = [{
|
|||
y: 495.60,
|
||||
z: 502.08
|
||||
},
|
||||
volume: 0.25,
|
||||
volume: 0.03,
|
||||
loop: true
|
||||
}
|
||||
}, {
|
||||
|
@ -73,14 +73,27 @@ var soundMap = [{
|
|||
url: "http://hifi-public.s3.amazonaws.com/ryan/dogs_barking_1.L.wav",
|
||||
audioOptions: {
|
||||
position: {
|
||||
x: 551.61,
|
||||
x: 523,
|
||||
y: 494.88,
|
||||
z: 502.00
|
||||
z: 469
|
||||
},
|
||||
volume: 0.15,
|
||||
volume: 0.05,
|
||||
loop: false
|
||||
},
|
||||
playAtInterval: 60 * 1000
|
||||
}, {
|
||||
name: 'arcade game',
|
||||
url: "http://hifi-public.s3.amazonaws.com/ryan/ARCADE_GAMES_VID.L.L.wav",
|
||||
audioOptions: {
|
||||
position: {
|
||||
x: 543.77,
|
||||
y: 495.07,
|
||||
z: 502.25
|
||||
},
|
||||
volume: 0.01,
|
||||
loop: false,
|
||||
},
|
||||
playAtInterval: 90 * 1000
|
||||
}];
|
||||
|
||||
function loadSounds() {
|
||||
|
|
|
@ -66,7 +66,8 @@ EntityActionPointer InterfaceActionFactory::factoryBA(EntityItemPointer ownerEnt
|
|||
if (action) {
|
||||
action->deserialize(data);
|
||||
if (action->lifetimeIsOver()) {
|
||||
qDebug() << "InterfaceActionFactory::factoryBA lifetimeIsOver during action creation";
|
||||
qDebug() << "InterfaceActionFactory::factoryBA lifetimeIsOver during action creation --"
|
||||
<< action->getExpires() << "<" << usecTimestampNow();
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -454,7 +454,7 @@ void Avatar::render(RenderArgs* renderArgs, const glm::vec3& cameraPosition) {
|
|||
*/
|
||||
|
||||
bool renderBounding = Menu::getInstance()->isOptionChecked(MenuOption::RenderBoundingCollisionShapes);
|
||||
if (renderBounding && shouldRenderHead(renderArgs)) {
|
||||
if (renderBounding && shouldRenderHead(renderArgs) && _skeletonModel.isRenderable()) {
|
||||
_skeletonModel.renderBoundingCollisionShapes(*renderArgs->_batch, 0.7f);
|
||||
}
|
||||
|
||||
|
|
|
@ -243,7 +243,7 @@ QByteArray AvatarActionHold::serialize() const {
|
|||
dataStream << _linearTimeScale;
|
||||
dataStream << _hand;
|
||||
|
||||
dataStream << _expires + getEntityServerClockSkew();
|
||||
dataStream << localTimeToServerTime(_expires);
|
||||
dataStream << _tag;
|
||||
dataStream << _kinematic;
|
||||
dataStream << _kinematicSetVelocity;
|
||||
|
@ -277,8 +277,10 @@ void AvatarActionHold::deserialize(QByteArray serializedArguments) {
|
|||
_angularTimeScale = _linearTimeScale;
|
||||
dataStream >> _hand;
|
||||
|
||||
dataStream >> _expires;
|
||||
_expires -= getEntityServerClockSkew();
|
||||
quint64 serverExpires;
|
||||
dataStream >> serverExpires;
|
||||
_expires = serverTimeToLocalTime(serverExpires);
|
||||
|
||||
dataStream >> _tag;
|
||||
dataStream >> _kinematic;
|
||||
dataStream >> _kinematicSetVelocity;
|
||||
|
|
|
@ -77,7 +77,10 @@ AvatarManager::AvatarManager(QObject* parent) :
|
|||
|
||||
void AvatarManager::init() {
|
||||
_myAvatar->init();
|
||||
_avatarHash.insert(MY_AVATAR_KEY, _myAvatar);
|
||||
{
|
||||
QWriteLocker locker(&_hashLock);
|
||||
_avatarHash.insert(MY_AVATAR_KEY, _myAvatar);
|
||||
}
|
||||
|
||||
connect(DependencyManager::get<SceneScriptingInterface>().data(), &SceneScriptingInterface::shouldRenderAvatarsChanged, this, &AvatarManager::updateAvatarRenderStatus, Qt::QueuedConnection);
|
||||
|
||||
|
@ -127,6 +130,7 @@ void AvatarManager::updateOtherAvatars(float deltaTime) {
|
|||
} else if (avatar->shouldDie()) {
|
||||
removeAvatarMotionState(avatar);
|
||||
_avatarFades.push_back(avatarIterator.value());
|
||||
QWriteLocker locker(&_hashLock);
|
||||
avatarIterator = _avatarHash.erase(avatarIterator);
|
||||
} else {
|
||||
avatar->startUpdate();
|
||||
|
@ -202,6 +206,7 @@ void AvatarManager::removeAvatar(const QUuid& sessionUUID) {
|
|||
if (avatar != _myAvatar && avatar->isInitialized()) {
|
||||
removeAvatarMotionState(avatar);
|
||||
_avatarFades.push_back(avatarIterator.value());
|
||||
QWriteLocker locker(&_hashLock);
|
||||
_avatarHash.erase(avatarIterator);
|
||||
}
|
||||
}
|
||||
|
@ -218,6 +223,7 @@ void AvatarManager::clearOtherAvatars() {
|
|||
} else {
|
||||
removeAvatarMotionState(avatar);
|
||||
_avatarFades.push_back(avatarIterator.value());
|
||||
QWriteLocker locker(&_hashLock);
|
||||
avatarIterator = _avatarHash.erase(avatarIterator);
|
||||
}
|
||||
}
|
||||
|
@ -349,5 +355,6 @@ AvatarSharedPointer AvatarManager::getAvatarBySessionID(const QUuid& sessionID)
|
|||
if (sessionID == _myAvatar->getSessionUUID()) {
|
||||
return std::static_pointer_cast<Avatar>(_myAvatar);
|
||||
}
|
||||
return getAvatarHash()[sessionID];
|
||||
QReadLocker locker(&_hashLock);
|
||||
return _avatarHash[sessionID];
|
||||
}
|
||||
|
|
|
@ -208,6 +208,11 @@ void MyAvatar::update(float deltaTime) {
|
|||
setPosition(_goToPosition);
|
||||
setOrientation(_goToOrientation);
|
||||
_goToPending = false;
|
||||
// updateFromHMDSensorMatrix (called from paintGL) expects that the sensorToWorldMatrix is updated for any position changes
|
||||
// that happen between render and Application::update (which calls updateSensorToWorldMatrix to do so).
|
||||
// However, render/MyAvatar::update/Application::update don't always match (e.g., when using the separate avatar update thread),
|
||||
// so we update now. It's ok if it updates again in the normal way.
|
||||
updateSensorToWorldMatrix();
|
||||
}
|
||||
|
||||
if (_referential) {
|
||||
|
@ -1020,7 +1025,11 @@ void MyAvatar::updateLookAtTargetAvatar() {
|
|||
const float KEEP_LOOKING_AT_CURRENT_ANGLE_FACTOR = 1.3f;
|
||||
const float GREATEST_LOOKING_AT_DISTANCE = 10.0f;
|
||||
|
||||
foreach (const AvatarSharedPointer& avatarPointer, DependencyManager::get<AvatarManager>()->getAvatarHash()) {
|
||||
AvatarHash hash;
|
||||
DependencyManager::get<AvatarManager>()->withAvatarHash([&] (const AvatarHash& locked) {
|
||||
hash = locked; // make a shallow copy and operate on that, to minimize lock time
|
||||
});
|
||||
foreach (const AvatarSharedPointer& avatarPointer, hash) {
|
||||
auto avatar = static_pointer_cast<Avatar>(avatarPointer);
|
||||
bool isCurrentTarget = avatar->getIsLookAtTarget();
|
||||
float distanceTo = glm::length(avatar->getHead()->getEyePosition() - cameraPosition);
|
||||
|
@ -1052,7 +1061,6 @@ void MyAvatar::updateLookAtTargetAvatar() {
|
|||
glm::vec3 humanLeftEye = humanSystem->getPosition() + (humanSystem->getOrientation() * leftEyeHeadLocal);
|
||||
glm::vec3 humanRightEye = humanSystem->getPosition() + (humanSystem->getOrientation() * rightEyeHeadLocal);
|
||||
|
||||
|
||||
// First find out where (in world space) the person is looking relative to that bridge-of-the-avatar point.
|
||||
// (We will be adding that offset to the camera position, after making some other adjustments.)
|
||||
glm::vec3 gazeOffset = lookAtPosition - getHead()->getEyePosition();
|
||||
|
@ -1064,14 +1072,14 @@ void MyAvatar::updateLookAtTargetAvatar() {
|
|||
|
||||
// If the camera is also not oriented with the head, adjust by getting the offset in head-space...
|
||||
/* Not needed (i.e., code is a no-op), but I'm leaving the example code here in case something like this is needed someday.
|
||||
glm::quat avatarHeadOrientation = getHead()->getOrientation();
|
||||
glm::vec3 gazeOffsetLocalToHead = glm::inverse(avatarHeadOrientation) * gazeOffset;
|
||||
// ... and treat that as though it were in camera space, bringing it back to world space.
|
||||
// But camera is fudged to make the picture feel like the avatar's orientation.
|
||||
glm::quat humanOrientation = humanSystem->getOrientation(); // or just avatar getOrienation() ?
|
||||
gazeOffset = humanOrientation * gazeOffsetLocalToHead;
|
||||
glm::vec3 corrected = humanSystem->getPosition() + gazeOffset;
|
||||
*/
|
||||
glm::quat avatarHeadOrientation = getHead()->getOrientation();
|
||||
glm::vec3 gazeOffsetLocalToHead = glm::inverse(avatarHeadOrientation) * gazeOffset;
|
||||
// ... and treat that as though it were in camera space, bringing it back to world space.
|
||||
// But camera is fudged to make the picture feel like the avatar's orientation.
|
||||
glm::quat humanOrientation = humanSystem->getOrientation(); // or just avatar getOrienation() ?
|
||||
gazeOffset = humanOrientation * gazeOffsetLocalToHead;
|
||||
glm::vec3 corrected = humanSystem->getPosition() + gazeOffset;
|
||||
*/
|
||||
|
||||
// And now we can finally add that offset to the camera.
|
||||
glm::vec3 corrected = qApp->getViewFrustum()->getPosition() + gazeOffset;
|
||||
|
|
|
@ -114,15 +114,12 @@ void SkeletonModel::updateRig(float deltaTime, glm::mat4 parentTransform) {
|
|||
if (_owningAvatar->isMyAvatar()) {
|
||||
_rig->computeMotionAnimationState(deltaTime, _owningAvatar->getPosition(), _owningAvatar->getVelocity(), _owningAvatar->getOrientation());
|
||||
}
|
||||
Model::updateRig(deltaTime, parentTransform);
|
||||
Head* head = _owningAvatar->getHead();
|
||||
if (_owningAvatar->isMyAvatar()) {
|
||||
MyAvatar* myAvatar = static_cast<MyAvatar*>(_owningAvatar);
|
||||
const FBXGeometry& geometry = _geometry->getFBXGeometry();
|
||||
|
||||
Rig::HeadParameters headParams;
|
||||
headParams.modelRotation = getRotation();
|
||||
headParams.modelTranslation = getTranslation();
|
||||
headParams.enableLean = qApp->getAvatarUpdater()->isHMDMode();
|
||||
headParams.leanSideways = head->getFinalLeanSideways();
|
||||
headParams.leanForward = head->getFinalLeanForward();
|
||||
|
@ -156,19 +153,13 @@ void SkeletonModel::updateRig(float deltaTime, glm::mat4 parentTransform) {
|
|||
headParams.worldHeadOrientation = head->getFinalOrientationInWorldFrame();
|
||||
}
|
||||
|
||||
headParams.eyeLookAt = head->getLookAtPosition();
|
||||
headParams.eyeSaccade = head->getSaccade();
|
||||
headParams.leanJointIndex = geometry.leanJointIndex;
|
||||
headParams.neckJointIndex = geometry.neckJointIndex;
|
||||
headParams.leftEyeJointIndex = geometry.leftEyeJointIndex;
|
||||
headParams.rightEyeJointIndex = geometry.rightEyeJointIndex;
|
||||
|
||||
headParams.isTalking = head->getTimeWithoutTalking() <= 1.5f;
|
||||
|
||||
_rig->updateFromHeadParameters(headParams, deltaTime);
|
||||
|
||||
Rig::HandParameters handParams;
|
||||
|
||||
const PalmData* leftPalm = getPalmWithIndex(myAvatar->getHand(), LEFT_HAND_INDEX);
|
||||
if (leftPalm && leftPalm->isActive()) {
|
||||
handParams.isLeftEnabled = true;
|
||||
|
@ -191,7 +182,28 @@ void SkeletonModel::updateRig(float deltaTime, glm::mat4 parentTransform) {
|
|||
|
||||
_rig->updateFromHandParameters(handParams, deltaTime);
|
||||
|
||||
// evaluate AnimGraph animation and update jointStates.
|
||||
Model::updateRig(deltaTime, parentTransform);
|
||||
|
||||
Rig::EyeParameters eyeParams;
|
||||
eyeParams.worldHeadOrientation = headParams.worldHeadOrientation;
|
||||
eyeParams.eyeLookAt = head->getLookAtPosition();
|
||||
eyeParams.eyeSaccade = head->getSaccade();
|
||||
eyeParams.modelRotation = getRotation();
|
||||
eyeParams.modelTranslation = getTranslation();
|
||||
eyeParams.leftEyeJointIndex = geometry.leftEyeJointIndex;
|
||||
eyeParams.rightEyeJointIndex = geometry.rightEyeJointIndex;
|
||||
|
||||
_rig->updateFromEyeParameters(eyeParams);
|
||||
|
||||
// rebuild the jointState transform for the eyes only
|
||||
_rig->updateJointState(eyeParams.leftEyeJointIndex, parentTransform);
|
||||
_rig->updateJointState(eyeParams.rightEyeJointIndex, parentTransform);
|
||||
|
||||
} else {
|
||||
|
||||
Model::updateRig(deltaTime, parentTransform);
|
||||
|
||||
// This is a little more work than we really want.
|
||||
//
|
||||
// Other avatars joint, including their eyes, should already be set just like any other joints
|
||||
|
@ -208,9 +220,16 @@ void SkeletonModel::updateRig(float deltaTime, glm::mat4 parentTransform) {
|
|||
head->setBasePitch(glm::degrees(-eulers.x));
|
||||
head->setBaseYaw(glm::degrees(eulers.y));
|
||||
head->setBaseRoll(glm::degrees(-eulers.z));
|
||||
_rig->updateEyeJoints(geometry.leftEyeJointIndex, geometry.rightEyeJointIndex,
|
||||
getTranslation(), getRotation(),
|
||||
head->getFinalOrientationInWorldFrame(), head->getCorrectedLookAtPosition());
|
||||
|
||||
Rig::EyeParameters eyeParams;
|
||||
eyeParams.worldHeadOrientation = head->getFinalOrientationInWorldFrame();
|
||||
eyeParams.eyeLookAt = head->getCorrectedLookAtPosition();
|
||||
eyeParams.eyeSaccade = glm::vec3();
|
||||
eyeParams.modelRotation = getRotation();
|
||||
eyeParams.modelTranslation = getTranslation();
|
||||
eyeParams.leftEyeJointIndex = geometry.leftEyeJointIndex;
|
||||
eyeParams.rightEyeJointIndex = geometry.rightEyeJointIndex;
|
||||
_rig->updateFromEyeParameters(eyeParams);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -65,11 +65,12 @@ AudioStatsDialog::AudioStatsDialog(QWidget* parent) :
|
|||
// Get statistics from the Audio Client
|
||||
_stats = &DependencyManager::get<AudioClient>()->getStats();
|
||||
|
||||
// Create layouter
|
||||
// Create layout
|
||||
_form = new QFormLayout();
|
||||
_form->setSizeConstraint(QLayout::SetFixedSize);
|
||||
QDialog::setLayout(_form);
|
||||
|
||||
// Load and initilize all channels
|
||||
// Load and initialize all channels
|
||||
renderStats();
|
||||
|
||||
_audioDisplayChannels = QVector<QVector<AudioStatsDisplay*>>(1);
|
||||
|
@ -80,10 +81,8 @@ AudioStatsDialog::AudioStatsDialog(QWidget* parent) :
|
|||
_downstreamID = addChannel(_form, _downstreamStats, COLOR3);
|
||||
_upstreamInjectedID = addChannel(_form, _upstreamInjectedStats, COLOR0);
|
||||
|
||||
|
||||
connect(averageUpdateTimer, SIGNAL(timeout()), this, SLOT(updateTimerTimeout()));
|
||||
averageUpdateTimer->start(1000);
|
||||
|
||||
}
|
||||
|
||||
int AudioStatsDialog::addChannel(QFormLayout* form, QVector<QString>& stats, const unsigned color) {
|
||||
|
@ -243,7 +242,6 @@ void AudioStatsDialog::paintEvent(QPaintEvent* event) {
|
|||
}
|
||||
|
||||
QDialog::paintEvent(event);
|
||||
setFixedSize(width(), height());
|
||||
}
|
||||
|
||||
void AudioStatsDialog::reject() {
|
||||
|
|
|
@ -72,8 +72,9 @@ BandwidthDialog::BandwidthDialog(QWidget* parent) :
|
|||
|
||||
this->setWindowTitle("Bandwidth Details");
|
||||
|
||||
// Create layouter
|
||||
// Create layout
|
||||
QFormLayout* form = new QFormLayout();
|
||||
form->setSizeConstraint(QLayout::SetFixedSize);
|
||||
this->QDialog::setLayout(form);
|
||||
|
||||
QSharedPointer<BandwidthRecorder> bandwidthRecorder = DependencyManager::get<BandwidthRecorder>();
|
||||
|
@ -118,7 +119,6 @@ void BandwidthDialog::paintEvent(QPaintEvent* event) {
|
|||
for (unsigned int i=0; i<_CHANNELCOUNT; i++)
|
||||
_allChannelDisplays[i]->paint();
|
||||
this->QDialog::paintEvent(event);
|
||||
this->setFixedSize(this->width(), this->height());
|
||||
}
|
||||
|
||||
void BandwidthDialog::reject() {
|
||||
|
|
|
@ -22,34 +22,6 @@
|
|||
#include "AnimSkeleton.h"
|
||||
#include "IKTarget.h"
|
||||
|
||||
|
||||
void Rig::HeadParameters::dump() const {
|
||||
qCDebug(animation, "HeadParameters =");
|
||||
qCDebug(animation, " leanSideways = %0.5f", (double)leanSideways);
|
||||
qCDebug(animation, " leanForward = %0.5f", (double)leanForward);
|
||||
qCDebug(animation, " torsoTwist = %0.5f", (double)torsoTwist);
|
||||
glm::vec3 axis = glm::axis(localHeadOrientation);
|
||||
float theta = glm::angle(localHeadOrientation);
|
||||
qCDebug(animation, " localHeadOrientation axis = (%.5f, %.5f, %.5f), theta = %0.5f", (double)axis.x, (double)axis.y, (double)axis.z, (double)theta);
|
||||
axis = glm::axis(worldHeadOrientation);
|
||||
theta = glm::angle(worldHeadOrientation);
|
||||
qCDebug(animation, " localHead pitch = %.5f, yaw = %.5f, roll = %.5f", (double)localHeadPitch, (double)localHeadYaw, (double)localHeadRoll);
|
||||
qCDebug(animation, " localHeadPosition = (%.5f, %.5f, %.5f)", (double)localHeadPosition.x, (double)localHeadPosition.y, (double)localHeadPosition.z);
|
||||
qCDebug(animation, " isInHMD = %s", isInHMD ? "true" : "false");
|
||||
qCDebug(animation, " worldHeadOrientation axis = (%.5f, %.5f, %.5f), theta = %0.5f", (double)axis.x, (double)axis.y, (double)axis.z, (double)theta);
|
||||
axis = glm::axis(modelRotation);
|
||||
theta = glm::angle(modelRotation);
|
||||
qCDebug(animation, " modelRotation axis = (%.5f, %.5f, %.5f), theta = %0.5f", (double)axis.x, (double)axis.y, (double)axis.z, (double)theta);
|
||||
qCDebug(animation, " modelTranslation = (%.5f, %.5f, %.5f)", (double)modelTranslation.x, (double)modelTranslation.y, (double)modelTranslation.z);
|
||||
qCDebug(animation, " eyeLookAt = (%.5f, %.5f, %.5f)", (double)eyeLookAt.x, (double)eyeLookAt.y, (double)eyeLookAt.z);
|
||||
qCDebug(animation, " eyeSaccade = (%.5f, %.5f, %.5f)", (double)eyeSaccade.x, (double)eyeSaccade.y, (double)eyeSaccade.z);
|
||||
qCDebug(animation, " leanJointIndex = %.d", leanJointIndex);
|
||||
qCDebug(animation, " neckJointIndex = %.d", neckJointIndex);
|
||||
qCDebug(animation, " leftEyeJointIndex = %.d", leftEyeJointIndex);
|
||||
qCDebug(animation, " rightEyeJointIndex = %.d", rightEyeJointIndex);
|
||||
qCDebug(animation, " isTalking = %s", isTalking ? "true" : "false");
|
||||
}
|
||||
|
||||
void insertSorted(QList<AnimationHandlePointer>& handles, const AnimationHandlePointer& handle) {
|
||||
for (QList<AnimationHandlePointer>::iterator it = handles.begin(); it != handles.end(); it++) {
|
||||
if (handle->getPriority() > (*it)->getPriority()) {
|
||||
|
@ -981,8 +953,6 @@ void Rig::updateFromHeadParameters(const HeadParameters& params, float dt) {
|
|||
_animVars.unset("lean");
|
||||
}
|
||||
updateNeckJoint(params.neckJointIndex, params);
|
||||
updateEyeJoints(params.leftEyeJointIndex, params.rightEyeJointIndex, params.modelTranslation, params.modelRotation,
|
||||
params.worldHeadOrientation, params.eyeLookAt, params.eyeSaccade);
|
||||
|
||||
if (_enableAnimGraph) {
|
||||
_animVars.set("isTalking", params.isTalking);
|
||||
|
@ -990,6 +960,13 @@ void Rig::updateFromHeadParameters(const HeadParameters& params, float dt) {
|
|||
}
|
||||
}
|
||||
|
||||
void Rig::updateFromEyeParameters(const EyeParameters& params) {
|
||||
updateEyeJoint(params.leftEyeJointIndex, params.modelTranslation, params.modelRotation,
|
||||
params.worldHeadOrientation, params.eyeLookAt, params.eyeSaccade);
|
||||
updateEyeJoint(params.rightEyeJointIndex, params.modelTranslation, params.modelRotation,
|
||||
params.worldHeadOrientation, params.eyeLookAt, params.eyeSaccade);
|
||||
}
|
||||
|
||||
static const glm::vec3 X_AXIS(1.0f, 0.0f, 0.0f);
|
||||
static const glm::vec3 Y_AXIS(0.0f, 1.0f, 0.0f);
|
||||
static const glm::vec3 Z_AXIS(0.0f, 0.0f, 1.0f);
|
||||
|
@ -1145,12 +1122,6 @@ void Rig::updateNeckJoint(int index, const HeadParameters& params) {
|
|||
}
|
||||
}
|
||||
|
||||
void Rig::updateEyeJoints(int leftEyeIndex, int rightEyeIndex, const glm::vec3& modelTranslation, const glm::quat& modelRotation,
|
||||
const glm::quat& worldHeadOrientation, const glm::vec3& lookAtSpot, const glm::vec3& saccade) {
|
||||
updateEyeJoint(leftEyeIndex, modelTranslation, modelRotation, worldHeadOrientation, lookAtSpot, saccade);
|
||||
updateEyeJoint(rightEyeIndex, modelTranslation, modelRotation, worldHeadOrientation, lookAtSpot, saccade);
|
||||
}
|
||||
|
||||
void Rig::updateEyeJoint(int index, const glm::vec3& modelTranslation, const glm::quat& modelRotation, const glm::quat& worldHeadOrientation, const glm::vec3& lookAtSpot, const glm::vec3& saccade) {
|
||||
if (index >= 0 && _jointStates[index].getParentIndex() >= 0) {
|
||||
auto& state = _jointStates[index];
|
||||
|
|
|
@ -57,24 +57,26 @@ public:
|
|||
float leanForward = 0.0f; // degrees
|
||||
float torsoTwist = 0.0f; // degrees
|
||||
bool enableLean = false;
|
||||
glm::quat modelRotation = glm::quat();
|
||||
glm::quat worldHeadOrientation = glm::quat();
|
||||
glm::quat localHeadOrientation = glm::quat();
|
||||
float localHeadPitch = 0.0f; // degrees
|
||||
float localHeadYaw = 0.0f; // degrees
|
||||
float localHeadRoll = 0.0f; // degrees
|
||||
glm::vec3 localHeadPosition = glm::vec3();
|
||||
bool isInHMD = false;
|
||||
int leanJointIndex = -1;
|
||||
int neckJointIndex = -1;
|
||||
bool isTalking = false;
|
||||
};
|
||||
|
||||
struct EyeParameters {
|
||||
glm::quat worldHeadOrientation = glm::quat();
|
||||
glm::vec3 eyeLookAt = glm::vec3(); // world space
|
||||
glm::vec3 eyeSaccade = glm::vec3(); // world space
|
||||
glm::vec3 modelTranslation = glm::vec3();
|
||||
int leanJointIndex = -1;
|
||||
int neckJointIndex = -1;
|
||||
glm::quat modelRotation = glm::quat();
|
||||
int leftEyeJointIndex = -1;
|
||||
int rightEyeJointIndex = -1;
|
||||
bool isTalking = false;
|
||||
|
||||
void dump() const;
|
||||
};
|
||||
|
||||
struct HandParameters {
|
||||
|
@ -185,9 +187,7 @@ public:
|
|||
bool getEnableAnimGraph() const { return _enableAnimGraph; }
|
||||
|
||||
void updateFromHeadParameters(const HeadParameters& params, float dt);
|
||||
void updateEyeJoints(int leftEyeIndex, int rightEyeIndex, const glm::vec3& modelTranslation, const glm::quat& modelRotation,
|
||||
const glm::quat& worldHeadOrientation, const glm::vec3& lookAtSpot, const glm::vec3& saccade = glm::vec3(0.0f));
|
||||
|
||||
void updateFromEyeParameters(const EyeParameters& params);
|
||||
void updateFromHandParameters(const HandParameters& params, float dt);
|
||||
|
||||
virtual void setHandPosition(int jointIndex, const glm::vec3& position, const glm::quat& rotation,
|
||||
|
|
|
@ -22,7 +22,12 @@ AvatarHashMap::AvatarHashMap() {
|
|||
connect(DependencyManager::get<NodeList>().data(), &NodeList::uuidChanged, this, &AvatarHashMap::sessionUUIDChanged);
|
||||
}
|
||||
|
||||
void AvatarHashMap::withAvatarHash(std::function<void(const AvatarHash& hash)> callback) {
|
||||
QReadLocker locker(&_hashLock);
|
||||
callback(_avatarHash);
|
||||
}
|
||||
bool AvatarHashMap::isAvatarInRange(const glm::vec3& position, const float range) {
|
||||
QReadLocker locker(&_hashLock);
|
||||
foreach(const AvatarSharedPointer& sharedAvatar, _avatarHash) {
|
||||
glm::vec3 avatarPosition = sharedAvatar->getPosition();
|
||||
float distance = glm::distance(avatarPosition, position);
|
||||
|
@ -43,6 +48,7 @@ AvatarSharedPointer AvatarHashMap::addAvatar(const QUuid& sessionUUID, const QWe
|
|||
AvatarSharedPointer avatar = newSharedAvatar();
|
||||
avatar->setSessionUUID(sessionUUID);
|
||||
avatar->setOwningAvatarMixer(mixerWeakPointer);
|
||||
QWriteLocker locker(&_hashLock);
|
||||
_avatarHash.insert(sessionUUID, avatar);
|
||||
|
||||
return avatar;
|
||||
|
@ -134,6 +140,7 @@ void AvatarHashMap::processKillAvatar(QSharedPointer<NLPacket> packet, SharedNod
|
|||
}
|
||||
|
||||
void AvatarHashMap::removeAvatar(const QUuid& sessionUUID) {
|
||||
QWriteLocker locker(&_hashLock);
|
||||
_avatarHash.remove(sessionUUID);
|
||||
}
|
||||
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
#include <QtCore/QSharedPointer>
|
||||
#include <QtCore/QUuid>
|
||||
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
|
||||
#include <DependencyManager.h>
|
||||
|
@ -30,7 +31,7 @@ class AvatarHashMap : public QObject, public Dependency {
|
|||
SINGLETON_DEPENDENCY
|
||||
|
||||
public:
|
||||
const AvatarHash& getAvatarHash() { return _avatarHash; }
|
||||
void withAvatarHash(std::function<void(const AvatarHash& hash)>);
|
||||
int size() { return _avatarHash.size(); }
|
||||
|
||||
public slots:
|
||||
|
@ -52,6 +53,9 @@ protected:
|
|||
virtual void removeAvatar(const QUuid& sessionUUID);
|
||||
|
||||
AvatarHash _avatarHash;
|
||||
// "Case-based safety": Most access to the _avatarHash is on the same thread. Write access is protected by a write-lock.
|
||||
// If you read from a different thread, you must read-lock the _hashLock. (Scripted write access is not supported).
|
||||
QReadWriteLock _hashLock;
|
||||
|
||||
private:
|
||||
QUuid _lastOwnerSessionUUID;
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
#include <QEventLoop>
|
||||
#include <QScriptSyntaxCheckResult>
|
||||
|
||||
#include <ColorUtils.h>
|
||||
#include <AbstractScriptingServicesInterface.h>
|
||||
#include <AbstractViewStateInterface.h>
|
||||
#include <DeferredLightingEffect.h>
|
||||
|
@ -270,10 +271,10 @@ void EntityTreeRenderer::applyZonePropertiesToScene(std::shared_ptr<ZoneEntityIt
|
|||
_previousStageDay = scene->getStageYearTime();
|
||||
_hasPreviousZone = true;
|
||||
}
|
||||
scene->setKeyLightColor(zone->getKeyLightColorVec3());
|
||||
scene->setKeyLightIntensity(zone->getKeyLightIntensity());
|
||||
scene->setKeyLightAmbientIntensity(zone->getKeyLightAmbientIntensity());
|
||||
scene->setKeyLightDirection(zone->getKeyLightDirection());
|
||||
scene->setKeyLightColor(ColorUtils::toVec3(zone->getKeyLightProperties().getColor()));
|
||||
scene->setKeyLightIntensity(zone->getKeyLightProperties().getIntensity());
|
||||
scene->setKeyLightAmbientIntensity(zone->getKeyLightProperties().getAmbientIntensity());
|
||||
scene->setKeyLightDirection(zone->getKeyLightProperties().getDirection());
|
||||
scene->setStageSunModelEnable(zone->getStageProperties().getSunModelEnabled());
|
||||
scene->setStageLocation(zone->getStageProperties().getLongitude(), zone->getStageProperties().getLatitude(),
|
||||
zone->getStageProperties().getAltitude());
|
||||
|
|
|
@ -47,6 +47,7 @@ public:
|
|||
static QString actionTypeToString(EntityActionType actionType);
|
||||
|
||||
virtual bool lifetimeIsOver() { return false; }
|
||||
virtual quint64 getExpires() { return 0; }
|
||||
|
||||
bool locallyAddedButNotYetReceived = false;
|
||||
|
||||
|
|
|
@ -28,6 +28,7 @@ AnimationPropertyGroup EntityItemProperties::_staticAnimation;
|
|||
AtmospherePropertyGroup EntityItemProperties::_staticAtmosphere;
|
||||
SkyboxPropertyGroup EntityItemProperties::_staticSkybox;
|
||||
StagePropertyGroup EntityItemProperties::_staticStage;
|
||||
KeyLightPropertyGroup EntityItemProperties::_staticKeyLight;
|
||||
|
||||
EntityPropertyList PROP_LAST_ITEM = (EntityPropertyList)(PROP_AFTER_LAST_ITEM - 1);
|
||||
|
||||
|
@ -80,7 +81,8 @@ void EntityItemProperties::debugDump() const {
|
|||
getAnimation().debugDump();
|
||||
getAtmosphere().debugDump();
|
||||
getSkybox().debugDump();
|
||||
|
||||
getKeyLight().debugDump();
|
||||
|
||||
qCDebug(entities) << " changed properties...";
|
||||
EntityPropertyFlags props = getChangedProperties();
|
||||
props.debugDumpBits();
|
||||
|
@ -235,10 +237,6 @@ EntityPropertyFlags EntityItemProperties::getChangedProperties() const {
|
|||
CHECK_PROPERTY_CHANGE(PROP_RADIUS_FINISH, radiusFinish);
|
||||
CHECK_PROPERTY_CHANGE(PROP_MARKETPLACE_ID, marketplaceID);
|
||||
CHECK_PROPERTY_CHANGE(PROP_NAME, name);
|
||||
CHECK_PROPERTY_CHANGE(PROP_KEYLIGHT_COLOR, keyLightColor);
|
||||
CHECK_PROPERTY_CHANGE(PROP_KEYLIGHT_INTENSITY, keyLightIntensity);
|
||||
CHECK_PROPERTY_CHANGE(PROP_KEYLIGHT_AMBIENT_INTENSITY, keyLightAmbientIntensity);
|
||||
CHECK_PROPERTY_CHANGE(PROP_KEYLIGHT_DIRECTION, keyLightDirection);
|
||||
CHECK_PROPERTY_CHANGE(PROP_BACKGROUND_MODE, backgroundMode);
|
||||
CHECK_PROPERTY_CHANGE(PROP_SOURCE_URL, sourceUrl);
|
||||
CHECK_PROPERTY_CHANGE(PROP_VOXEL_VOLUME_SIZE, voxelVolumeSize);
|
||||
|
@ -263,6 +261,7 @@ EntityPropertyFlags EntityItemProperties::getChangedProperties() const {
|
|||
CHECK_PROPERTY_CHANGE(PROP_Z_P_NEIGHBOR_ID, zPNeighborID);
|
||||
|
||||
changedProperties += _animation.getChangedProperties();
|
||||
changedProperties += _keyLight.getChangedProperties();
|
||||
changedProperties += _atmosphere.getChangedProperties();
|
||||
changedProperties += _skybox.getChangedProperties();
|
||||
changedProperties += _stage.getChangedProperties();
|
||||
|
@ -392,10 +391,8 @@ QScriptValue EntityItemProperties::copyToScriptValue(QScriptEngine* engine, bool
|
|||
|
||||
// Zones only
|
||||
if (_type == EntityTypes::Zone) {
|
||||
COPY_PROPERTY_TO_QSCRIPTVALUE(PROP_KEYLIGHT_COLOR, keyLightColor);
|
||||
COPY_PROPERTY_TO_QSCRIPTVALUE(PROP_KEYLIGHT_INTENSITY, keyLightIntensity);
|
||||
COPY_PROPERTY_TO_QSCRIPTVALUE(PROP_KEYLIGHT_AMBIENT_INTENSITY, keyLightAmbientIntensity);
|
||||
COPY_PROPERTY_TO_QSCRIPTVALUE(PROP_KEYLIGHT_DIRECTION, keyLightDirection);
|
||||
_keyLight.copyToScriptValue(_desiredProperties, properties, engine, skipDefaults, defaultEntityProperties);
|
||||
|
||||
COPY_PROPERTY_TO_QSCRIPTVALUE_GETTER(PROP_BACKGROUND_MODE, backgroundMode, getBackgroundModeAsString());
|
||||
|
||||
_stage.copyToScriptValue(_desiredProperties, properties, engine, skipDefaults, defaultEntityProperties);
|
||||
|
@ -546,10 +543,6 @@ void EntityItemProperties::copyFromScriptValue(const QScriptValue& object, bool
|
|||
COPY_PROPERTY_FROM_QSCRIPTVALUE(name, QString, setName);
|
||||
COPY_PROPERTY_FROM_QSCRIPTVALUE(collisionSoundURL, QString, setCollisionSoundURL);
|
||||
|
||||
COPY_PROPERTY_FROM_QSCRIPTVALUE(keyLightColor, xColor, setKeyLightColor);
|
||||
COPY_PROPERTY_FROM_QSCRIPTVALUE(keyLightIntensity, float, setKeyLightIntensity);
|
||||
COPY_PROPERTY_FROM_QSCRIPTVALUE(keyLightAmbientIntensity, float, setKeyLightAmbientIntensity);
|
||||
COPY_PROPERTY_FROM_QSCRIPTVALUE(keyLightDirection, glmVec3, setKeyLightDirection);
|
||||
COPY_PROPERTY_FROM_QSCRITPTVALUE_ENUM(backgroundMode, BackgroundMode);
|
||||
COPY_PROPERTY_FROM_QSCRIPTVALUE(sourceUrl, QString, setSourceUrl);
|
||||
COPY_PROPERTY_FROM_QSCRIPTVALUE(voxelVolumeSize, glmVec3, setVoxelVolumeSize);
|
||||
|
@ -575,6 +568,7 @@ void EntityItemProperties::copyFromScriptValue(const QScriptValue& object, bool
|
|||
}
|
||||
|
||||
_animation.copyFromScriptValue(object, _defaultSettings);
|
||||
_keyLight.copyFromScriptValue(object, _defaultSettings);
|
||||
_atmosphere.copyFromScriptValue(object, _defaultSettings);
|
||||
_skybox.copyFromScriptValue(object, _defaultSettings);
|
||||
_stage.copyFromScriptValue(object, _defaultSettings);
|
||||
|
@ -968,11 +962,9 @@ bool EntityItemProperties::encodeEntityEditPacket(PacketType command, EntityItem
|
|||
}
|
||||
|
||||
if (properties.getType() == EntityTypes::Zone) {
|
||||
APPEND_ENTITY_PROPERTY(PROP_KEYLIGHT_COLOR, properties.getKeyLightColor());
|
||||
APPEND_ENTITY_PROPERTY(PROP_KEYLIGHT_INTENSITY, properties.getKeyLightIntensity());
|
||||
APPEND_ENTITY_PROPERTY(PROP_KEYLIGHT_AMBIENT_INTENSITY, properties.getKeyLightAmbientIntensity());
|
||||
APPEND_ENTITY_PROPERTY(PROP_KEYLIGHT_DIRECTION, properties.getKeyLightDirection());
|
||||
|
||||
_staticKeyLight.setProperties(properties);
|
||||
_staticKeyLight.appendToEditPacket(packetData, requestedProperties, propertyFlags, propertiesDidntFit, propertyCount, appendState);
|
||||
|
||||
_staticStage.setProperties(properties);
|
||||
_staticStage.appendToEditPacket(packetData, requestedProperties, propertyFlags, propertiesDidntFit, propertyCount, appendState);
|
||||
|
||||
|
@ -1252,11 +1244,7 @@ bool EntityItemProperties::decodeEntityEditPacket(const unsigned char* data, int
|
|||
}
|
||||
|
||||
if (properties.getType() == EntityTypes::Zone) {
|
||||
READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_KEYLIGHT_COLOR, xColor, setKeyLightColor);
|
||||
READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_KEYLIGHT_INTENSITY, float, setKeyLightIntensity);
|
||||
READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_KEYLIGHT_AMBIENT_INTENSITY, float, setKeyLightAmbientIntensity);
|
||||
READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_KEYLIGHT_DIRECTION, glm::vec3, setKeyLightDirection);
|
||||
|
||||
properties.getKeyLight().decodeFromEditPacket(propertyFlags, dataAt , processedBytes);
|
||||
properties.getStage().decodeFromEditPacket(propertyFlags, dataAt , processedBytes);
|
||||
|
||||
READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_SHAPE_TYPE, ShapeType, setShapeType);
|
||||
|
@ -1407,10 +1395,7 @@ void EntityItemProperties::markAllChanged() {
|
|||
|
||||
_marketplaceIDChanged = true;
|
||||
|
||||
_keyLightColorChanged = true;
|
||||
_keyLightIntensityChanged = true;
|
||||
_keyLightAmbientIntensityChanged = true;
|
||||
_keyLightDirectionChanged = true;
|
||||
_keyLight.markAllChanged();
|
||||
|
||||
_backgroundModeChanged = true;
|
||||
|
||||
|
@ -1764,6 +1749,7 @@ QList<QString> EntityItemProperties::listChangedProperties() {
|
|||
}
|
||||
|
||||
getAnimation().listChangedProperties(out);
|
||||
getKeyLight().listChangedProperties(out);
|
||||
getAtmosphere().listChangedProperties(out);
|
||||
getSkybox().listChangedProperties(out);
|
||||
getStage().listChangedProperties(out);
|
||||
|
|
|
@ -160,10 +160,7 @@ public:
|
|||
DEFINE_PROPERTY(PROP_RADIUS_START, RadiusStart, radiusStart, float, ParticleEffectEntityItem::DEFAULT_RADIUS_START);
|
||||
DEFINE_PROPERTY(PROP_RADIUS_FINISH, RadiusFinish, radiusFinish, float, ParticleEffectEntityItem::DEFAULT_RADIUS_FINISH);
|
||||
DEFINE_PROPERTY_REF(PROP_MARKETPLACE_ID, MarketplaceID, marketplaceID, QString, ENTITY_ITEM_DEFAULT_MARKETPLACE_ID);
|
||||
DEFINE_PROPERTY_REF(PROP_KEYLIGHT_COLOR, KeyLightColor, keyLightColor, xColor, ZoneEntityItem::DEFAULT_KEYLIGHT_COLOR);
|
||||
DEFINE_PROPERTY(PROP_KEYLIGHT_INTENSITY, KeyLightIntensity, keyLightIntensity, float, ZoneEntityItem::DEFAULT_KEYLIGHT_INTENSITY);
|
||||
DEFINE_PROPERTY(PROP_KEYLIGHT_AMBIENT_INTENSITY, KeyLightAmbientIntensity, keyLightAmbientIntensity, float, ZoneEntityItem::DEFAULT_KEYLIGHT_AMBIENT_INTENSITY);
|
||||
DEFINE_PROPERTY_REF(PROP_KEYLIGHT_DIRECTION, KeyLightDirection, keyLightDirection, glm::vec3, ZoneEntityItem::DEFAULT_KEYLIGHT_DIRECTION);
|
||||
DEFINE_PROPERTY_GROUP(KeyLight, keyLight, KeyLightPropertyGroup);
|
||||
DEFINE_PROPERTY_REF(PROP_VOXEL_VOLUME_SIZE, VoxelVolumeSize, voxelVolumeSize, glm::vec3, PolyVoxEntityItem::DEFAULT_VOXEL_VOLUME_SIZE);
|
||||
DEFINE_PROPERTY_REF(PROP_VOXEL_DATA, VoxelData, voxelData, QByteArray, PolyVoxEntityItem::DEFAULT_VOXEL_DATA);
|
||||
DEFINE_PROPERTY_REF(PROP_VOXEL_SURFACE_STYLE, VoxelSurfaceStyle, voxelSurfaceStyle, uint16_t, PolyVoxEntityItem::DEFAULT_VOXEL_SURFACE_STYLE);
|
||||
|
|
|
@ -189,7 +189,8 @@ enum EntityPropertyList {
|
|||
PROP_BACKGROUND_MODE = PROP_MODEL_URL,
|
||||
PROP_SKYBOX_COLOR = PROP_ANIMATION_URL,
|
||||
PROP_SKYBOX_URL = PROP_ANIMATION_FPS,
|
||||
|
||||
PROP_KEYLIGHT_AMBIENT_URL = PROP_ANIMATION_FRAME_INDEX,
|
||||
|
||||
// Aliases/Piggyback properties for Web. These properties intentionally reuse the enum values for
|
||||
// other properties which will never overlap with each other.
|
||||
PROP_SOURCE_URL = PROP_MODEL_URL,
|
||||
|
|
211
libraries/entities/src/KeyLightPropertyGroup.cpp
Normal file
211
libraries/entities/src/KeyLightPropertyGroup.cpp
Normal file
|
@ -0,0 +1,211 @@
|
|||
//
|
||||
// KeyLightPropertyGroup.h
|
||||
// libraries/entities/src
|
||||
//
|
||||
// Created by Sam Gateau on 2015/10/23.
|
||||
// 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
|
||||
//
|
||||
|
||||
#include <QJsonDocument>
|
||||
#include <OctreePacketData.h>
|
||||
|
||||
#include <AnimationLoop.h>
|
||||
|
||||
#include "KeyLightPropertyGroup.h"
|
||||
#include "EntityItemProperties.h"
|
||||
#include "EntityItemPropertiesMacros.h"
|
||||
|
||||
|
||||
const xColor KeyLightPropertyGroup::DEFAULT_KEYLIGHT_COLOR = { 255, 255, 255 };
|
||||
const float KeyLightPropertyGroup::DEFAULT_KEYLIGHT_INTENSITY = 1.0f;
|
||||
const float KeyLightPropertyGroup::DEFAULT_KEYLIGHT_AMBIENT_INTENSITY = 0.5f;
|
||||
const glm::vec3 KeyLightPropertyGroup::DEFAULT_KEYLIGHT_DIRECTION = { 0.0f, -1.0f, 0.0f };
|
||||
|
||||
void KeyLightPropertyGroup::copyToScriptValue(const EntityPropertyFlags& desiredProperties, QScriptValue& properties, QScriptEngine* engine, bool skipDefaults, EntityItemProperties& defaultEntityProperties) const {
|
||||
|
||||
COPY_GROUP_PROPERTY_TO_QSCRIPTVALUE(PROP_KEYLIGHT_COLOR, KeyLight, keyLight, Color, color);
|
||||
COPY_GROUP_PROPERTY_TO_QSCRIPTVALUE(PROP_KEYLIGHT_INTENSITY, KeyLight, keyLight, Intensity, intensity);
|
||||
COPY_GROUP_PROPERTY_TO_QSCRIPTVALUE(PROP_KEYLIGHT_AMBIENT_INTENSITY, KeyLight, keyLight, AmbientIntensity, ambientIntensity);
|
||||
COPY_GROUP_PROPERTY_TO_QSCRIPTVALUE(PROP_KEYLIGHT_DIRECTION, KeyLight, keyLight, Direction, direction);
|
||||
COPY_GROUP_PROPERTY_TO_QSCRIPTVALUE(PROP_KEYLIGHT_AMBIENT_URL, KeyLight, keyLight, AmbientURL, ambientUrl);
|
||||
|
||||
}
|
||||
|
||||
void KeyLightPropertyGroup::copyFromScriptValue(const QScriptValue& object, bool& _defaultSettings) {
|
||||
|
||||
COPY_GROUP_PROPERTY_FROM_QSCRIPTVALUE(keyLight, color, xColor, setColor);
|
||||
COPY_GROUP_PROPERTY_FROM_QSCRIPTVALUE(keyLight, intensity, float, setIntensity);
|
||||
COPY_GROUP_PROPERTY_FROM_QSCRIPTVALUE(keyLight, ambientIntensity, float, setAmbientIntensity);
|
||||
COPY_GROUP_PROPERTY_FROM_QSCRIPTVALUE(keyLight, direction, glmVec3, setDirection);
|
||||
COPY_GROUP_PROPERTY_FROM_QSCRIPTVALUE(keyLight, ambientURL, QString, setAmbientURL);
|
||||
|
||||
// legacy property support
|
||||
COPY_PROPERTY_FROM_QSCRIPTVALUE_GETTER(keyLightColor, xColor, setColor, getColor);
|
||||
COPY_PROPERTY_FROM_QSCRIPTVALUE_GETTER(keyLightIntensity, float, setIntensity, getIntensity);
|
||||
COPY_PROPERTY_FROM_QSCRIPTVALUE_GETTER(keyLightAmbientIntensity, float, setAmbientIntensity, getAmbientIntensity);
|
||||
COPY_PROPERTY_FROM_QSCRIPTVALUE_GETTER(keyLightDirection, glmVec3, setDirection, getDirection);
|
||||
}
|
||||
|
||||
|
||||
void KeyLightPropertyGroup::debugDump() const {
|
||||
qDebug() << " KeyLightPropertyGroup: ---------------------------------------------";
|
||||
qDebug() << " color:" << getColor(); // << "," << getColor()[1] << "," << getColor()[2];
|
||||
qDebug() << " intensity:" << getIntensity();
|
||||
qDebug() << " direction:" << getDirection();
|
||||
qDebug() << " ambientIntensity:" << getAmbientIntensity();
|
||||
qDebug() << " ambientURL:" << getAmbientURL();
|
||||
}
|
||||
|
||||
void KeyLightPropertyGroup::listChangedProperties(QList<QString>& out) {
|
||||
if (colorChanged()) {
|
||||
out << "keyLight-color";
|
||||
}
|
||||
if (intensityChanged()) {
|
||||
out << "keyLight-intensity";
|
||||
}
|
||||
if (directionChanged()) {
|
||||
out << "keyLight-direction";
|
||||
}
|
||||
if (ambientIntensityChanged()) {
|
||||
out << "keyLight-ambientIntensity";
|
||||
}
|
||||
if (ambientURLChanged()) {
|
||||
out << "keyLight-ambientURL";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool KeyLightPropertyGroup::appendToEditPacket(OctreePacketData* packetData,
|
||||
EntityPropertyFlags& requestedProperties,
|
||||
EntityPropertyFlags& propertyFlags,
|
||||
EntityPropertyFlags& propertiesDidntFit,
|
||||
int& propertyCount,
|
||||
OctreeElement::AppendState& appendState) const {
|
||||
|
||||
bool successPropertyFits = true;
|
||||
|
||||
APPEND_ENTITY_PROPERTY(PROP_KEYLIGHT_COLOR, getColor());
|
||||
APPEND_ENTITY_PROPERTY(PROP_KEYLIGHT_INTENSITY, getIntensity());
|
||||
APPEND_ENTITY_PROPERTY(PROP_KEYLIGHT_AMBIENT_INTENSITY, getAmbientIntensity());
|
||||
APPEND_ENTITY_PROPERTY(PROP_KEYLIGHT_DIRECTION, getDirection());
|
||||
APPEND_ENTITY_PROPERTY(PROP_KEYLIGHT_AMBIENT_URL, getAmbientURL());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool KeyLightPropertyGroup::decodeFromEditPacket(EntityPropertyFlags& propertyFlags, const unsigned char*& dataAt , int& processedBytes) {
|
||||
|
||||
int bytesRead = 0;
|
||||
bool overwriteLocalData = true;
|
||||
bool somethingChanged = false;
|
||||
|
||||
READ_ENTITY_PROPERTY(PROP_KEYLIGHT_COLOR, xColor, setColor);
|
||||
READ_ENTITY_PROPERTY(PROP_KEYLIGHT_INTENSITY, float, setIntensity);
|
||||
READ_ENTITY_PROPERTY(PROP_KEYLIGHT_AMBIENT_INTENSITY, float, setAmbientIntensity);
|
||||
READ_ENTITY_PROPERTY(PROP_KEYLIGHT_DIRECTION, glm::vec3, setDirection);
|
||||
READ_ENTITY_PROPERTY(PROP_KEYLIGHT_AMBIENT_URL, QString, setAmbientURL);
|
||||
|
||||
|
||||
DECODE_GROUP_PROPERTY_HAS_CHANGED(PROP_KEYLIGHT_COLOR, Color);
|
||||
DECODE_GROUP_PROPERTY_HAS_CHANGED(PROP_KEYLIGHT_INTENSITY, Intensity);
|
||||
DECODE_GROUP_PROPERTY_HAS_CHANGED(PROP_KEYLIGHT_AMBIENT_INTENSITY, AmbientIntensity);
|
||||
DECODE_GROUP_PROPERTY_HAS_CHANGED(PROP_KEYLIGHT_DIRECTION, Direction);
|
||||
DECODE_GROUP_PROPERTY_HAS_CHANGED(PROP_KEYLIGHT_AMBIENT_URL, AmbientURL);
|
||||
|
||||
processedBytes += bytesRead;
|
||||
|
||||
Q_UNUSED(somethingChanged);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void KeyLightPropertyGroup::markAllChanged() {
|
||||
_colorChanged = true;
|
||||
_intensityChanged = true;
|
||||
_ambientIntensityChanged = true;
|
||||
_directionChanged = true;
|
||||
_ambientURLChanged = true;
|
||||
}
|
||||
|
||||
EntityPropertyFlags KeyLightPropertyGroup::getChangedProperties() const {
|
||||
EntityPropertyFlags changedProperties;
|
||||
|
||||
CHECK_PROPERTY_CHANGE(PROP_KEYLIGHT_COLOR, color);
|
||||
CHECK_PROPERTY_CHANGE(PROP_KEYLIGHT_INTENSITY, intensity);
|
||||
CHECK_PROPERTY_CHANGE(PROP_KEYLIGHT_AMBIENT_INTENSITY, ambientIntensity);
|
||||
CHECK_PROPERTY_CHANGE(PROP_KEYLIGHT_DIRECTION, direction);
|
||||
CHECK_PROPERTY_CHANGE(PROP_KEYLIGHT_AMBIENT_URL, ambientURL);
|
||||
|
||||
return changedProperties;
|
||||
}
|
||||
|
||||
void KeyLightPropertyGroup::getProperties(EntityItemProperties& properties) const {
|
||||
|
||||
COPY_ENTITY_GROUP_PROPERTY_TO_PROPERTIES(KeyLight, Color, getColor);
|
||||
COPY_ENTITY_GROUP_PROPERTY_TO_PROPERTIES(KeyLight, Intensity, getIntensity);
|
||||
COPY_ENTITY_GROUP_PROPERTY_TO_PROPERTIES(KeyLight, AmbientIntensity, getAmbientIntensity);
|
||||
COPY_ENTITY_GROUP_PROPERTY_TO_PROPERTIES(KeyLight, Direction, getDirection);
|
||||
COPY_ENTITY_GROUP_PROPERTY_TO_PROPERTIES(KeyLight, AmbientURL, getAmbientURL);
|
||||
}
|
||||
|
||||
bool KeyLightPropertyGroup::setProperties(const EntityItemProperties& properties) {
|
||||
bool somethingChanged = false;
|
||||
|
||||
SET_ENTITY_GROUP_PROPERTY_FROM_PROPERTIES(KeyLight, Color, color, setColor);
|
||||
SET_ENTITY_GROUP_PROPERTY_FROM_PROPERTIES(KeyLight, Intensity, intensity, setIntensity);
|
||||
SET_ENTITY_GROUP_PROPERTY_FROM_PROPERTIES(KeyLight, AmbientIntensity, ambientIntensity, setAmbientIntensity);
|
||||
SET_ENTITY_GROUP_PROPERTY_FROM_PROPERTIES(KeyLight, Direction, direction, setDirection);
|
||||
SET_ENTITY_GROUP_PROPERTY_FROM_PROPERTIES(KeyLight, AmbientURL, ambientURL, setAmbientURL);
|
||||
|
||||
return somethingChanged;
|
||||
}
|
||||
|
||||
EntityPropertyFlags KeyLightPropertyGroup::getEntityProperties(EncodeBitstreamParams& params) const {
|
||||
EntityPropertyFlags requestedProperties;
|
||||
|
||||
requestedProperties += PROP_KEYLIGHT_COLOR;
|
||||
requestedProperties += PROP_KEYLIGHT_INTENSITY;
|
||||
requestedProperties += PROP_KEYLIGHT_AMBIENT_INTENSITY;
|
||||
requestedProperties += PROP_KEYLIGHT_DIRECTION;
|
||||
requestedProperties += PROP_KEYLIGHT_AMBIENT_URL;
|
||||
|
||||
return requestedProperties;
|
||||
}
|
||||
|
||||
void KeyLightPropertyGroup::appendSubclassData(OctreePacketData* packetData, EncodeBitstreamParams& params,
|
||||
EntityTreeElementExtraEncodeData* entityTreeElementExtraEncodeData,
|
||||
EntityPropertyFlags& requestedProperties,
|
||||
EntityPropertyFlags& propertyFlags,
|
||||
EntityPropertyFlags& propertiesDidntFit,
|
||||
int& propertyCount,
|
||||
OctreeElement::AppendState& appendState) const {
|
||||
|
||||
bool successPropertyFits = true;
|
||||
|
||||
APPEND_ENTITY_PROPERTY(PROP_KEYLIGHT_COLOR, getColor());
|
||||
APPEND_ENTITY_PROPERTY(PROP_KEYLIGHT_INTENSITY, getIntensity());
|
||||
APPEND_ENTITY_PROPERTY(PROP_KEYLIGHT_AMBIENT_INTENSITY, getAmbientIntensity());
|
||||
APPEND_ENTITY_PROPERTY(PROP_KEYLIGHT_DIRECTION, getDirection());
|
||||
APPEND_ENTITY_PROPERTY(PROP_KEYLIGHT_AMBIENT_URL, getAmbientURL());
|
||||
}
|
||||
|
||||
int KeyLightPropertyGroup::readEntitySubclassDataFromBuffer(const unsigned char* data, int bytesLeftToRead,
|
||||
ReadBitstreamToTreeParams& args,
|
||||
EntityPropertyFlags& propertyFlags, bool overwriteLocalData,
|
||||
bool& somethingChanged) {
|
||||
|
||||
int bytesRead = 0;
|
||||
const unsigned char* dataAt = data;
|
||||
|
||||
READ_ENTITY_PROPERTY(PROP_KEYLIGHT_COLOR, xColor, setColor);
|
||||
READ_ENTITY_PROPERTY(PROP_KEYLIGHT_INTENSITY, float, setIntensity);
|
||||
READ_ENTITY_PROPERTY(PROP_KEYLIGHT_AMBIENT_INTENSITY, float, setAmbientIntensity);
|
||||
READ_ENTITY_PROPERTY(PROP_KEYLIGHT_DIRECTION, glm::vec3, setDirection);
|
||||
READ_ENTITY_PROPERTY(PROP_KEYLIGHT_AMBIENT_URL, QString, setAmbientURL);
|
||||
|
||||
return bytesRead;
|
||||
}
|
86
libraries/entities/src/KeyLightPropertyGroup.h
Normal file
86
libraries/entities/src/KeyLightPropertyGroup.h
Normal file
|
@ -0,0 +1,86 @@
|
|||
//
|
||||
// KeyLightPropertyGroup.h
|
||||
// libraries/entities/src
|
||||
//
|
||||
// Created by Sam Gateau on 2015/10/23.
|
||||
// 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
|
||||
//
|
||||
|
||||
|
||||
#ifndef hifi_KeyLightPropertyGroup_h
|
||||
#define hifi_KeyLightPropertyGroup_h
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include <glm/glm.hpp>
|
||||
|
||||
#include <QtScript/QScriptEngine>
|
||||
#include "EntityItemPropertiesMacros.h"
|
||||
#include "PropertyGroup.h"
|
||||
|
||||
class EntityItemProperties;
|
||||
class EncodeBitstreamParams;
|
||||
class OctreePacketData;
|
||||
class EntityTreeElementExtraEncodeData;
|
||||
class ReadBitstreamToTreeParams;
|
||||
|
||||
class KeyLightPropertyGroup : public PropertyGroup {
|
||||
public:
|
||||
// EntityItemProperty related helpers
|
||||
virtual void copyToScriptValue(const EntityPropertyFlags& desiredProperties, QScriptValue& properties, QScriptEngine* engine, bool skipDefaults, EntityItemProperties& defaultEntityProperties) const;
|
||||
virtual void copyFromScriptValue(const QScriptValue& object, bool& _defaultSettings);
|
||||
virtual void debugDump() const;
|
||||
virtual void listChangedProperties(QList<QString>& out);
|
||||
|
||||
virtual bool appendToEditPacket(OctreePacketData* packetData,
|
||||
EntityPropertyFlags& requestedProperties,
|
||||
EntityPropertyFlags& propertyFlags,
|
||||
EntityPropertyFlags& propertiesDidntFit,
|
||||
int& propertyCount,
|
||||
OctreeElement::AppendState& appendState) const;
|
||||
|
||||
virtual bool decodeFromEditPacket(EntityPropertyFlags& propertyFlags, const unsigned char*& dataAt , int& processedBytes);
|
||||
virtual void markAllChanged();
|
||||
virtual EntityPropertyFlags getChangedProperties() const;
|
||||
|
||||
// EntityItem related helpers
|
||||
// methods for getting/setting all properties of an entity
|
||||
virtual void getProperties(EntityItemProperties& propertiesOut) const;
|
||||
|
||||
/// returns true if something changed
|
||||
virtual bool setProperties(const EntityItemProperties& properties);
|
||||
|
||||
virtual EntityPropertyFlags getEntityProperties(EncodeBitstreamParams& params) const;
|
||||
|
||||
virtual void appendSubclassData(OctreePacketData* packetData, EncodeBitstreamParams& params,
|
||||
EntityTreeElementExtraEncodeData* entityTreeElementExtraEncodeData,
|
||||
EntityPropertyFlags& requestedProperties,
|
||||
EntityPropertyFlags& propertyFlags,
|
||||
EntityPropertyFlags& propertiesDidntFit,
|
||||
int& propertyCount,
|
||||
OctreeElement::AppendState& appendState) const;
|
||||
|
||||
virtual int readEntitySubclassDataFromBuffer(const unsigned char* data, int bytesLeftToRead,
|
||||
ReadBitstreamToTreeParams& args,
|
||||
EntityPropertyFlags& propertyFlags, bool overwriteLocalData,
|
||||
bool& somethingChanged);
|
||||
|
||||
static const xColor DEFAULT_KEYLIGHT_COLOR;
|
||||
static const float DEFAULT_KEYLIGHT_INTENSITY;
|
||||
static const float DEFAULT_KEYLIGHT_AMBIENT_INTENSITY;
|
||||
static const glm::vec3 DEFAULT_KEYLIGHT_DIRECTION;
|
||||
|
||||
DEFINE_PROPERTY_REF(PROP_KEYLIGHT_COLOR, Color, color, xColor, DEFAULT_KEYLIGHT_COLOR);
|
||||
DEFINE_PROPERTY(PROP_KEYLIGHT_INTENSITY, Intensity, intensity, float, DEFAULT_KEYLIGHT_INTENSITY);
|
||||
DEFINE_PROPERTY(PROP_KEYLIGHT_AMBIENT_INTENSITY, AmbientIntensity, ambientIntensity, float, DEFAULT_KEYLIGHT_AMBIENT_INTENSITY);
|
||||
DEFINE_PROPERTY_REF(PROP_KEYLIGHT_DIRECTION, Direction, direction, glm::vec3, DEFAULT_KEYLIGHT_DIRECTION);
|
||||
DEFINE_PROPERTY_REF(PROP_KEYLIGHT_AMBIENT_URL, AmbientURL, ambientURL, QString, "");
|
||||
|
||||
protected:
|
||||
|
||||
};
|
||||
|
||||
#endif // hifi_KeyLightPropertyGroup_h
|
|
@ -23,10 +23,6 @@
|
|||
bool ZoneEntityItem::_zonesArePickable = false;
|
||||
bool ZoneEntityItem::_drawZoneBoundaries = false;
|
||||
|
||||
const xColor ZoneEntityItem::DEFAULT_KEYLIGHT_COLOR = { 255, 255, 255 };
|
||||
const float ZoneEntityItem::DEFAULT_KEYLIGHT_INTENSITY = 1.0f;
|
||||
const float ZoneEntityItem::DEFAULT_KEYLIGHT_AMBIENT_INTENSITY = 0.5f;
|
||||
const glm::vec3 ZoneEntityItem::DEFAULT_KEYLIGHT_DIRECTION = { 0.0f, -1.0f, 0.0f };
|
||||
const ShapeType ZoneEntityItem::DEFAULT_SHAPE_TYPE = SHAPE_TYPE_BOX;
|
||||
const QString ZoneEntityItem::DEFAULT_COMPOUND_SHAPE_URL = "";
|
||||
|
||||
|
@ -39,13 +35,6 @@ ZoneEntityItem::ZoneEntityItem(const EntityItemID& entityItemID, const EntityIte
|
|||
{
|
||||
_type = EntityTypes::Zone;
|
||||
|
||||
_keyLightColor[RED_INDEX] = DEFAULT_KEYLIGHT_COLOR.red;
|
||||
_keyLightColor[GREEN_INDEX] = DEFAULT_KEYLIGHT_COLOR.green;
|
||||
_keyLightColor[BLUE_INDEX] = DEFAULT_KEYLIGHT_COLOR.blue;
|
||||
|
||||
_keyLightIntensity = DEFAULT_KEYLIGHT_INTENSITY;
|
||||
_keyLightAmbientIntensity = DEFAULT_KEYLIGHT_AMBIENT_INTENSITY;
|
||||
_keyLightDirection = DEFAULT_KEYLIGHT_DIRECTION;
|
||||
_shapeType = DEFAULT_SHAPE_TYPE;
|
||||
_compoundShapeURL = DEFAULT_COMPOUND_SHAPE_URL;
|
||||
|
||||
|
@ -77,11 +66,9 @@ EnvironmentData ZoneEntityItem::getEnvironmentData() const {
|
|||
EntityItemProperties ZoneEntityItem::getProperties(EntityPropertyFlags desiredProperties) const {
|
||||
EntityItemProperties properties = EntityItem::getProperties(desiredProperties); // get the properties from our base class
|
||||
|
||||
COPY_ENTITY_PROPERTY_TO_PROPERTIES(keyLightColor, getKeyLightColor);
|
||||
COPY_ENTITY_PROPERTY_TO_PROPERTIES(keyLightIntensity, getKeyLightIntensity);
|
||||
COPY_ENTITY_PROPERTY_TO_PROPERTIES(keyLightAmbientIntensity, getKeyLightAmbientIntensity);
|
||||
COPY_ENTITY_PROPERTY_TO_PROPERTIES(keyLightDirection, getKeyLightDirection);
|
||||
|
||||
|
||||
_keyLightProperties.getProperties(properties);
|
||||
|
||||
_stageProperties.getProperties(properties);
|
||||
|
||||
COPY_ENTITY_PROPERTY_TO_PROPERTIES(shapeType, getShapeType);
|
||||
|
@ -98,11 +85,8 @@ bool ZoneEntityItem::setProperties(const EntityItemProperties& properties) {
|
|||
bool somethingChanged = false;
|
||||
somethingChanged = EntityItem::setProperties(properties); // set the properties in our base class
|
||||
|
||||
SET_ENTITY_PROPERTY_FROM_PROPERTIES(keyLightColor, setKeyLightColor);
|
||||
SET_ENTITY_PROPERTY_FROM_PROPERTIES(keyLightIntensity, setKeyLightIntensity);
|
||||
SET_ENTITY_PROPERTY_FROM_PROPERTIES(keyLightAmbientIntensity, setKeyLightAmbientIntensity);
|
||||
SET_ENTITY_PROPERTY_FROM_PROPERTIES(keyLightDirection, setKeyLightDirection);
|
||||
|
||||
bool somethingChangedInKeyLight = _keyLightProperties.setProperties(properties);
|
||||
|
||||
bool somethingChangedInStage = _stageProperties.setProperties(properties);
|
||||
|
||||
SET_ENTITY_PROPERTY_FROM_PROPERTIES(shapeType, updateShapeType);
|
||||
|
@ -112,7 +96,7 @@ bool ZoneEntityItem::setProperties(const EntityItemProperties& properties) {
|
|||
bool somethingChangedInAtmosphere = _atmosphereProperties.setProperties(properties);
|
||||
bool somethingChangedInSkybox = _skyboxProperties.setProperties(properties);
|
||||
|
||||
somethingChanged = somethingChanged || somethingChangedInStage || somethingChangedInAtmosphere || somethingChangedInSkybox;
|
||||
somethingChanged = somethingChanged || somethingChangedInKeyLight || somethingChangedInStage || somethingChangedInAtmosphere || somethingChangedInSkybox;
|
||||
|
||||
if (somethingChanged) {
|
||||
bool wantDebug = false;
|
||||
|
@ -135,14 +119,15 @@ int ZoneEntityItem::readEntitySubclassDataFromBuffer(const unsigned char* data,
|
|||
int bytesRead = 0;
|
||||
const unsigned char* dataAt = data;
|
||||
|
||||
READ_ENTITY_PROPERTY(PROP_KEYLIGHT_COLOR, rgbColor, setKeyLightColor);
|
||||
READ_ENTITY_PROPERTY(PROP_KEYLIGHT_INTENSITY, float, setKeyLightIntensity);
|
||||
READ_ENTITY_PROPERTY(PROP_KEYLIGHT_AMBIENT_INTENSITY, float, setKeyLightAmbientIntensity);
|
||||
READ_ENTITY_PROPERTY(PROP_KEYLIGHT_DIRECTION, glm::vec3, setKeyLightDirection);
|
||||
int bytesFromKeylight = _keyLightProperties.readEntitySubclassDataFromBuffer(dataAt, (bytesLeftToRead - bytesRead), args,
|
||||
propertyFlags, overwriteLocalData, somethingChanged);
|
||||
|
||||
bytesRead += bytesFromKeylight;
|
||||
dataAt += bytesFromKeylight;
|
||||
|
||||
int bytesFromStage = _stageProperties.readEntitySubclassDataFromBuffer(dataAt, (bytesLeftToRead - bytesRead), args,
|
||||
propertyFlags, overwriteLocalData, somethingChanged);
|
||||
|
||||
|
||||
bytesRead += bytesFromStage;
|
||||
dataAt += bytesFromStage;
|
||||
|
||||
|
@ -169,10 +154,8 @@ int ZoneEntityItem::readEntitySubclassDataFromBuffer(const unsigned char* data,
|
|||
EntityPropertyFlags ZoneEntityItem::getEntityProperties(EncodeBitstreamParams& params) const {
|
||||
EntityPropertyFlags requestedProperties = EntityItem::getEntityProperties(params);
|
||||
|
||||
requestedProperties += PROP_KEYLIGHT_COLOR;
|
||||
requestedProperties += PROP_KEYLIGHT_INTENSITY;
|
||||
requestedProperties += PROP_KEYLIGHT_AMBIENT_INTENSITY;
|
||||
requestedProperties += PROP_KEYLIGHT_DIRECTION;
|
||||
requestedProperties += _keyLightProperties.getEntityProperties(params);
|
||||
|
||||
requestedProperties += PROP_SHAPE_TYPE;
|
||||
requestedProperties += PROP_COMPOUND_SHAPE_URL;
|
||||
requestedProperties += PROP_BACKGROUND_MODE;
|
||||
|
@ -193,10 +176,8 @@ void ZoneEntityItem::appendSubclassData(OctreePacketData* packetData, EncodeBits
|
|||
|
||||
bool successPropertyFits = true;
|
||||
|
||||
APPEND_ENTITY_PROPERTY(PROP_KEYLIGHT_COLOR, _keyLightColor);
|
||||
APPEND_ENTITY_PROPERTY(PROP_KEYLIGHT_INTENSITY, getKeyLightIntensity());
|
||||
APPEND_ENTITY_PROPERTY(PROP_KEYLIGHT_AMBIENT_INTENSITY, getKeyLightAmbientIntensity());
|
||||
APPEND_ENTITY_PROPERTY(PROP_KEYLIGHT_DIRECTION, getKeyLightDirection());
|
||||
_keyLightProperties.appendSubclassData(packetData, params, modelTreeElementExtraEncodeData, requestedProperties,
|
||||
propertyFlags, propertiesDidntFit, propertyCount, appendState);
|
||||
|
||||
_stageProperties.appendSubclassData(packetData, params, modelTreeElementExtraEncodeData, requestedProperties,
|
||||
propertyFlags, propertiesDidntFit, propertyCount, appendState);
|
||||
|
@ -217,15 +198,12 @@ void ZoneEntityItem::appendSubclassData(OctreePacketData* packetData, EncodeBits
|
|||
void ZoneEntityItem::debugDump() const {
|
||||
quint64 now = usecTimestampNow();
|
||||
qCDebug(entities) << " ZoneEntityItem id:" << getEntityItemID() << "---------------------------------------------";
|
||||
qCDebug(entities) << " keyLightColor:" << _keyLightColor[0] << "," << _keyLightColor[1] << "," << _keyLightColor[2];
|
||||
qCDebug(entities) << " position:" << debugTreeVector(getPosition());
|
||||
qCDebug(entities) << " dimensions:" << debugTreeVector(getDimensions());
|
||||
qCDebug(entities) << " getLastEdited:" << debugTime(getLastEdited(), now);
|
||||
qCDebug(entities) << " _keyLightIntensity:" << _keyLightIntensity;
|
||||
qCDebug(entities) << " _keyLightAmbientIntensity:" << _keyLightAmbientIntensity;
|
||||
qCDebug(entities) << " _keyLightDirection:" << _keyLightDirection;
|
||||
qCDebug(entities) << " _backgroundMode:" << EntityItemProperties::getBackgroundModeString(_backgroundMode);
|
||||
|
||||
_keyLightProperties.debugDump();
|
||||
_stageProperties.debugDump();
|
||||
_atmosphereProperties.debugDump();
|
||||
_skyboxProperties.debugDump();
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
|
||||
#include <EnvironmentData.h>
|
||||
|
||||
#include "KeyLightPropertyGroup.h"
|
||||
#include "AtmospherePropertyGroup.h"
|
||||
#include "EntityItem.h"
|
||||
#include "EntityTree.h"
|
||||
|
@ -48,36 +49,7 @@ public:
|
|||
EntityPropertyFlags& propertyFlags, bool overwriteLocalData,
|
||||
bool& somethingChanged);
|
||||
|
||||
xColor getKeyLightColor() const { xColor color = { _keyLightColor[RED_INDEX], _keyLightColor[GREEN_INDEX], _keyLightColor[BLUE_INDEX] }; return color; }
|
||||
void setKeyLightColor(const xColor& value) {
|
||||
_keyLightColor[RED_INDEX] = value.red;
|
||||
_keyLightColor[GREEN_INDEX] = value.green;
|
||||
_keyLightColor[BLUE_INDEX] = value.blue;
|
||||
}
|
||||
|
||||
void setKeyLightColor(const rgbColor& value) {
|
||||
_keyLightColor[RED_INDEX] = value[RED_INDEX];
|
||||
_keyLightColor[GREEN_INDEX] = value[GREEN_INDEX];
|
||||
_keyLightColor[BLUE_INDEX] = value[BLUE_INDEX];
|
||||
}
|
||||
|
||||
glm::vec3 getKeyLightColorVec3() const {
|
||||
const quint8 MAX_COLOR = 255;
|
||||
glm::vec3 color = { (float)_keyLightColor[RED_INDEX] / (float)MAX_COLOR,
|
||||
(float)_keyLightColor[GREEN_INDEX] / (float)MAX_COLOR,
|
||||
(float)_keyLightColor[BLUE_INDEX] / (float)MAX_COLOR };
|
||||
return color;
|
||||
}
|
||||
|
||||
|
||||
float getKeyLightIntensity() const { return _keyLightIntensity; }
|
||||
void setKeyLightIntensity(float value) { _keyLightIntensity = value; }
|
||||
|
||||
float getKeyLightAmbientIntensity() const { return _keyLightAmbientIntensity; }
|
||||
void setKeyLightAmbientIntensity(float value) { _keyLightAmbientIntensity = value; }
|
||||
|
||||
const glm::vec3& getKeyLightDirection() const { return _keyLightDirection; }
|
||||
void setKeyLightDirection(const glm::vec3& value) { _keyLightDirection = value; }
|
||||
|
||||
static bool getZonesArePickable() { return _zonesArePickable; }
|
||||
static void setZonesArePickable(bool value) { _zonesArePickable = value; }
|
||||
|
@ -93,6 +65,8 @@ public:
|
|||
const QString getCompoundShapeURL() const { return _compoundShapeURL; }
|
||||
virtual void setCompoundShapeURL(const QString& url);
|
||||
|
||||
const KeyLightPropertyGroup& getKeyLightProperties() const { return _keyLightProperties; }
|
||||
|
||||
void setBackgroundMode(BackgroundMode value) { _backgroundMode = value; }
|
||||
BackgroundMode getBackgroundMode() const { return _backgroundMode; }
|
||||
|
||||
|
@ -109,19 +83,11 @@ public:
|
|||
|
||||
virtual void debugDump() const;
|
||||
|
||||
static const xColor DEFAULT_KEYLIGHT_COLOR;
|
||||
static const float DEFAULT_KEYLIGHT_INTENSITY;
|
||||
static const float DEFAULT_KEYLIGHT_AMBIENT_INTENSITY;
|
||||
static const glm::vec3 DEFAULT_KEYLIGHT_DIRECTION;
|
||||
static const ShapeType DEFAULT_SHAPE_TYPE;
|
||||
static const QString DEFAULT_COMPOUND_SHAPE_URL;
|
||||
|
||||
protected:
|
||||
// properties of the "sun" in the zone
|
||||
rgbColor _keyLightColor;
|
||||
float _keyLightIntensity;
|
||||
float _keyLightAmbientIntensity;
|
||||
glm::vec3 _keyLightDirection;
|
||||
KeyLightPropertyGroup _keyLightProperties;
|
||||
|
||||
ShapeType _shapeType = DEFAULT_SHAPE_TYPE;
|
||||
QString _compoundShapeURL;
|
||||
|
|
|
@ -64,7 +64,7 @@ Extents FBXGeometry::getUnscaledMeshExtents() const {
|
|||
glm::vec3 minimum = glm::vec3(offset * glm::vec4(extents.minimum, 1.0f));
|
||||
glm::vec3 maximum = glm::vec3(offset * glm::vec4(extents.maximum, 1.0f));
|
||||
Extents scaledExtents = { minimum, maximum };
|
||||
|
||||
|
||||
return scaledExtents;
|
||||
}
|
||||
|
||||
|
@ -73,7 +73,7 @@ bool FBXGeometry::convexHullContains(const glm::vec3& point) const {
|
|||
if (!getUnscaledMeshExtents().containsPoint(point)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
auto checkEachPrimitive = [=](FBXMesh& mesh, QVector<int> indices, int primitiveSize) -> bool {
|
||||
// Check whether the point is "behind" all the primitives.
|
||||
for (int j = 0; j < indices.size(); j += primitiveSize) {
|
||||
|
@ -87,11 +87,11 @@ bool FBXGeometry::convexHullContains(const glm::vec3& point) const {
|
|||
}
|
||||
return true;
|
||||
};
|
||||
|
||||
|
||||
// Check that the point is contained in at least one convex mesh.
|
||||
for (auto mesh : meshes) {
|
||||
bool insideMesh = true;
|
||||
|
||||
|
||||
// To be considered inside a convex mesh,
|
||||
// the point needs to be "behind" all the primitives respective planes.
|
||||
for (auto part : mesh.parts) {
|
||||
|
@ -108,7 +108,7 @@ bool FBXGeometry::convexHullContains(const glm::vec3& point) const {
|
|||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// It wasn't in any mesh, return false.
|
||||
return false;
|
||||
}
|
||||
|
@ -194,7 +194,7 @@ public:
|
|||
glm::vec3 rotationMax; // radians
|
||||
};
|
||||
|
||||
glm::mat4 getGlobalTransform(const QMultiHash<QString, QString>& _connectionParentMap,
|
||||
glm::mat4 getGlobalTransform(const QMultiMap<QString, QString>& _connectionParentMap,
|
||||
const QHash<QString, FBXModel>& models, QString nodeID, bool mixamoHack) {
|
||||
glm::mat4 globalTransform;
|
||||
while (!nodeID.isNull()) {
|
||||
|
@ -228,12 +228,12 @@ void printNode(const FBXNode& node, int indentLevel) {
|
|||
int indentLength = 2;
|
||||
QByteArray spaces(indentLevel * indentLength, ' ');
|
||||
QDebug nodeDebug = qDebug(modelformat);
|
||||
|
||||
|
||||
nodeDebug.nospace() << spaces.data() << node.name.data() << ": ";
|
||||
foreach (const QVariant& property, node.properties) {
|
||||
nodeDebug << property;
|
||||
}
|
||||
|
||||
|
||||
foreach (const FBXNode& child, node.children) {
|
||||
printNode(child, indentLevel + 1);
|
||||
}
|
||||
|
@ -246,7 +246,7 @@ public:
|
|||
glm::mat4 transformLink;
|
||||
};
|
||||
|
||||
void appendModelIDs(const QString& parentID, const QMultiHash<QString, QString>& connectionChildMap,
|
||||
void appendModelIDs(const QString& parentID, const QMultiMap<QString, QString>& connectionChildMap,
|
||||
QHash<QString, FBXModel>& models, QSet<QString>& remainingModels, QVector<QString>& modelIDs) {
|
||||
if (remainingModels.contains(parentID)) {
|
||||
modelIDs.append(parentID);
|
||||
|
@ -331,7 +331,7 @@ void addBlendshapes(const ExtractedBlendshape& extracted, const QList<WeightedIn
|
|||
}
|
||||
}
|
||||
|
||||
QString getTopModelID(const QMultiHash<QString, QString>& connectionParentMap,
|
||||
QString getTopModelID(const QMultiMap<QString, QString>& connectionParentMap,
|
||||
const QHash<QString, FBXModel>& models, const QString& modelID) {
|
||||
QString topID = modelID;
|
||||
forever {
|
||||
|
@ -342,7 +342,7 @@ QString getTopModelID(const QMultiHash<QString, QString>& connectionParentMap,
|
|||
}
|
||||
}
|
||||
return topID;
|
||||
|
||||
|
||||
outerContinue: ;
|
||||
}
|
||||
}
|
||||
|
@ -361,7 +361,7 @@ public:
|
|||
};
|
||||
|
||||
bool checkMaterialsHaveTextures(const QHash<QString, FBXMaterial>& materials,
|
||||
const QHash<QString, QByteArray>& textureFilenames, const QMultiHash<QString, QString>& _connectionChildMap) {
|
||||
const QHash<QString, QByteArray>& textureFilenames, const QMultiMap<QString, QString>& _connectionChildMap) {
|
||||
foreach (const QString& materialID, materials.keys()) {
|
||||
foreach (const QString& childID, _connectionChildMap.values(materialID)) {
|
||||
if (textureFilenames.contains(childID)) {
|
||||
|
@ -443,8 +443,8 @@ QByteArray fileOnUrl(const QByteArray& filenameString, const QString& url) {
|
|||
}
|
||||
|
||||
FBXGeometry* FBXReader::extractFBXGeometry(const QVariantHash& mapping, const QString& url) {
|
||||
const FBXNode& node = _fbxNode;
|
||||
QHash<QString, ExtractedMesh> meshes;
|
||||
const FBXNode& node = _fbxNode;
|
||||
QMap<QString, ExtractedMesh> meshes;
|
||||
QHash<QString, QString> modelIDsToNames;
|
||||
QHash<QString, int> meshIDsToMeshIndices;
|
||||
QHash<QString, QString> ooChildToParent;
|
||||
|
@ -497,7 +497,7 @@ FBXGeometry* FBXReader::extractFBXGeometry(const QVariantHash& mapping, const QS
|
|||
QVector<QString> humanIKJointIDs(humanIKJointNames.size());
|
||||
|
||||
QVariantHash blendshapeMappings = mapping.value("bs").toHash();
|
||||
|
||||
|
||||
QMultiHash<QByteArray, WeightedIndex> blendshapeIndices;
|
||||
for (int i = 0;; i++) {
|
||||
QByteArray blendshapeName = FACESHIFT_BLENDSHAPES[i];
|
||||
|
@ -527,7 +527,7 @@ FBXGeometry* FBXReader::extractFBXGeometry(const QVariantHash& mapping, const QS
|
|||
QString hifiGlobalNodeID;
|
||||
unsigned int meshIndex = 0;
|
||||
foreach (const FBXNode& child, node.children) {
|
||||
|
||||
|
||||
if (child.name == "FBXHeaderExtension") {
|
||||
foreach (const FBXNode& object, child.children) {
|
||||
if (object.name == "SceneInfo") {
|
||||
|
@ -537,7 +537,7 @@ FBXGeometry* FBXReader::extractFBXGeometry(const QVariantHash& mapping, const QS
|
|||
if (subsubobject.name == "Author") {
|
||||
geometry.author = subsubobject.properties.at(0).toString();
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (subobject.name == "Properties70") {
|
||||
foreach (const FBXNode& subsubobject, subobject.children) {
|
||||
if (subsubobject.name == "P" && subsubobject.properties.size() >= 5 &&
|
||||
|
@ -620,7 +620,7 @@ FBXGeometry* FBXReader::extractFBXGeometry(const QVariantHash& mapping, const QS
|
|||
if (humanIKJointIndex != -1) {
|
||||
humanIKJointIDs[humanIKJointIndex] = getID(object.properties);
|
||||
}
|
||||
|
||||
|
||||
glm::vec3 translation;
|
||||
// NOTE: the euler angles as supplied by the FBX file are in degrees
|
||||
glm::vec3 rotationOffset;
|
||||
|
@ -709,7 +709,7 @@ FBXGeometry* FBXReader::extractFBXGeometry(const QVariantHash& mapping, const QS
|
|||
// it's a mesh as well as a model
|
||||
mesh = &meshes[getID(object.properties)];
|
||||
*mesh = extractMesh(object, meshIndex);
|
||||
|
||||
|
||||
} else if (subobject.name == "Shape") {
|
||||
ExtractedBlendshape blendshape = { subobject.properties.at(0).toString(),
|
||||
extractBlendshape(subobject) };
|
||||
|
@ -720,7 +720,7 @@ FBXGeometry* FBXReader::extractFBXGeometry(const QVariantHash& mapping, const QS
|
|||
QString attributetype = subobject.properties.at(0).toString();
|
||||
if (!attributetype.empty()) {
|
||||
if (attributetype == "Light") {
|
||||
QString lightprop;
|
||||
QString lightprop;
|
||||
foreach (const QVariant& vprop, subobject.properties) {
|
||||
lightprop = vprop.toString();
|
||||
}
|
||||
|
@ -731,23 +731,23 @@ FBXGeometry* FBXReader::extractFBXGeometry(const QVariantHash& mapping, const QS
|
|||
} else {
|
||||
QString whatisthat = subobject.name;
|
||||
if (whatisthat == "Shape") {
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
// add the blendshapes included in the model, if any
|
||||
if (mesh) {
|
||||
foreach (const ExtractedBlendshape& extracted, blendshapes) {
|
||||
addBlendshapes(extracted, blendshapeIndices.values(extracted.id.toLatin1()), *mesh);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// see FBX documentation, http://download.autodesk.com/us/fbx/20112/FBX_SDK_HELP/index.html
|
||||
model.translation = translation;
|
||||
|
||||
model.preTransform = glm::translate(rotationOffset) * glm::translate(rotationPivot);
|
||||
model.preRotation = glm::quat(glm::radians(preRotation));
|
||||
model.preTransform = glm::translate(rotationOffset) * glm::translate(rotationPivot);
|
||||
model.preRotation = glm::quat(glm::radians(preRotation));
|
||||
model.rotation = glm::quat(glm::radians(rotation));
|
||||
model.postRotation = glm::quat(glm::radians(postRotation));
|
||||
|
||||
|
@ -862,7 +862,7 @@ FBXGeometry* FBXReader::extractFBXGeometry(const QVariantHash& mapping, const QS
|
|||
if (subobject.name == "RelativeFilename") {
|
||||
filename = subobject.properties.at(0).toByteArray();
|
||||
filename = fileOnUrl(filename, url);
|
||||
|
||||
|
||||
} else if (subobject.name == "Content" && !subobject.properties.isEmpty()) {
|
||||
content = subobject.properties.at(0).toByteArray();
|
||||
}
|
||||
|
@ -905,10 +905,10 @@ FBXGeometry* FBXReader::extractFBXGeometry(const QVariantHash& mapping, const QS
|
|||
|
||||
} else if (property.properties.at(0) == "Emissive") {
|
||||
material.emissiveColor = getVec3(property.properties, index);
|
||||
|
||||
|
||||
} else if (property.properties.at(0) == "Shininess") {
|
||||
material.shininess = property.properties.at(index).value<double>();
|
||||
|
||||
|
||||
} else if (property.properties.at(0) == "Opacity") {
|
||||
material.opacity = property.properties.at(index).value<double>();
|
||||
}
|
||||
|
@ -1001,7 +1001,7 @@ FBXGeometry* FBXReader::extractFBXGeometry(const QVariantHash& mapping, const QS
|
|||
}
|
||||
}
|
||||
animationCurves.insert(getID(object.properties), curve);
|
||||
|
||||
|
||||
}
|
||||
#if defined(DEBUG_FBXREADER)
|
||||
else {
|
||||
|
@ -1013,7 +1013,7 @@ FBXGeometry* FBXReader::extractFBXGeometry(const QVariantHash& mapping, const QS
|
|||
} else {
|
||||
unknown++;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
} else if (child.name == "Connections") {
|
||||
|
@ -1041,14 +1041,14 @@ FBXGeometry* FBXReader::extractFBXGeometry(const QVariantHash& mapping, const QS
|
|||
diffuseTextures.insert(getID(connection.properties, 2), getID(connection.properties, 1));
|
||||
|
||||
} else if (type.contains("transparentcolor")) { // it should be TransparentColor...
|
||||
// THis is how Maya assign a texture that affect diffuse color AND transparency ?
|
||||
// THis is how Maya assign a texture that affect diffuse color AND transparency ?
|
||||
diffuseTextures.insert(getID(connection.properties, 2), getID(connection.properties, 1));
|
||||
} else if (type.contains("bump")) {
|
||||
bumpTextures.insert(getID(connection.properties, 2), getID(connection.properties, 1));
|
||||
} else if (type.contains("normal")) {
|
||||
normalTextures.insert(getID(connection.properties, 2), getID(connection.properties, 1));
|
||||
} else if (type.contains("specular") || type.contains("reflection")) {
|
||||
specularTextures.insert(getID(connection.properties, 2), getID(connection.properties, 1));
|
||||
specularTextures.insert(getID(connection.properties, 2), getID(connection.properties, 1));
|
||||
|
||||
} else if (type == "lcl rotation") {
|
||||
localRotations.insert(getID(connection.properties, 2), getID(connection.properties, 1));
|
||||
|
@ -1097,7 +1097,7 @@ FBXGeometry* FBXReader::extractFBXGeometry(const QVariantHash& mapping, const QS
|
|||
} else {
|
||||
unknown++;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -1142,7 +1142,7 @@ FBXGeometry* FBXReader::extractFBXGeometry(const QVariantHash& mapping, const QS
|
|||
}
|
||||
}
|
||||
outerBreak:
|
||||
|
||||
|
||||
// make sure the parent is in the child map
|
||||
QString parent = _connectionParentMap.value(model.key());
|
||||
if (!_connectionChildMap.contains(parent, model.key())) {
|
||||
|
@ -1172,7 +1172,7 @@ FBXGeometry* FBXReader::extractFBXGeometry(const QVariantHash& mapping, const QS
|
|||
frame.translations.resize(modelIDs.size());
|
||||
geometry.animationFrames.append(frame);
|
||||
}
|
||||
|
||||
|
||||
// convert the models to joints
|
||||
QVariantList freeJoints = mapping.values("freeJoint");
|
||||
geometry.hasSkeletonJoints = false;
|
||||
|
@ -1181,7 +1181,7 @@ FBXGeometry* FBXReader::extractFBXGeometry(const QVariantHash& mapping, const QS
|
|||
FBXJoint joint;
|
||||
joint.isFree = freeJoints.contains(model.name);
|
||||
joint.parentIndex = model.parentIndex;
|
||||
|
||||
|
||||
// get the indices of all ancestors starting with the first free one (if any)
|
||||
int jointIndex = geometry.joints.size();
|
||||
joint.freeLineage.append(jointIndex);
|
||||
|
@ -1203,7 +1203,7 @@ FBXGeometry* FBXReader::extractFBXGeometry(const QVariantHash& mapping, const QS
|
|||
joint.rotationMax = model.rotationMax;
|
||||
glm::quat combinedRotation = joint.preRotation * joint.rotation * joint.postRotation;
|
||||
if (joint.parentIndex == -1) {
|
||||
joint.transform = geometry.offset * glm::translate(joint.translation) * joint.preTransform *
|
||||
joint.transform = geometry.offset * glm::translate(joint.translation) * joint.preTransform *
|
||||
glm::mat4_cast(combinedRotation) * joint.postTransform;
|
||||
joint.inverseDefaultRotation = glm::inverse(combinedRotation);
|
||||
joint.distanceToParent = 0.0f;
|
||||
|
@ -1272,11 +1272,11 @@ FBXGeometry* FBXReader::extractFBXGeometry(const QVariantHash& mapping, const QS
|
|||
geometry.rightHandJointIndex = modelIDs.indexOf(jointRightHandID);
|
||||
geometry.leftToeJointIndex = modelIDs.indexOf(jointLeftToeID);
|
||||
geometry.rightToeJointIndex = modelIDs.indexOf(jointRightToeID);
|
||||
|
||||
|
||||
foreach (const QString& id, humanIKJointIDs) {
|
||||
geometry.humanIKJointIndices.append(modelIDs.indexOf(id));
|
||||
}
|
||||
|
||||
|
||||
// extract the translation component of the neck transform
|
||||
if (geometry.neckJointIndex != -1) {
|
||||
const glm::mat4& transform = geometry.joints.at(geometry.neckJointIndex).transform;
|
||||
|
@ -1285,7 +1285,7 @@ FBXGeometry* FBXReader::extractFBXGeometry(const QVariantHash& mapping, const QS
|
|||
|
||||
geometry.bindExtents.reset();
|
||||
geometry.meshExtents.reset();
|
||||
|
||||
|
||||
// Create the Material Library
|
||||
consolidateFBXMaterials();
|
||||
geometry.materials = _fbxMaterials;
|
||||
|
@ -1293,9 +1293,9 @@ FBXGeometry* FBXReader::extractFBXGeometry(const QVariantHash& mapping, const QS
|
|||
// see if any materials have texture children
|
||||
bool materialsHaveTextures = checkMaterialsHaveTextures(_fbxMaterials, _textureFilenames, _connectionChildMap);
|
||||
|
||||
for (QHash<QString, ExtractedMesh>::iterator it = meshes.begin(); it != meshes.end(); it++) {
|
||||
for (QMap<QString, ExtractedMesh>::iterator it = meshes.begin(); it != meshes.end(); it++) {
|
||||
ExtractedMesh& extracted = it.value();
|
||||
|
||||
|
||||
extracted.mesh.meshExtents.reset();
|
||||
|
||||
// accumulate local transforms
|
||||
|
@ -1335,7 +1335,7 @@ FBXGeometry* FBXReader::extractFBXGeometry(const QVariantHash& mapping, const QS
|
|||
}
|
||||
|
||||
materialIndex++;
|
||||
|
||||
|
||||
} else if (_textureFilenames.contains(childID)) {
|
||||
FBXTexture texture = getTexture(childID);
|
||||
for (int j = 0; j < extracted.partMaterialTextures.size(); j++) {
|
||||
|
@ -1360,7 +1360,7 @@ FBXGeometry* FBXReader::extractFBXGeometry(const QVariantHash& mapping, const QS
|
|||
setTangents(extracted.mesh, part.quadIndices.at(i + 2), part.quadIndices.at(i + 3));
|
||||
setTangents(extracted.mesh, part.quadIndices.at(i + 3), part.quadIndices.at(i));
|
||||
}
|
||||
// <= size - 3 in order to prevent overflowing triangleIndices when (i % 3) != 0
|
||||
// <= size - 3 in order to prevent overflowing triangleIndices when (i % 3) != 0
|
||||
// This is most likely evidence of a further problem in extractMesh()
|
||||
for (int i = 0; i <= part.triangleIndices.size() - 3; i += 3) {
|
||||
setTangents(extracted.mesh, part.triangleIndices.at(i), part.triangleIndices.at(i + 1));
|
||||
|
@ -1500,7 +1500,7 @@ FBXGeometry* FBXReader::extractFBXGeometry(const QVariantHash& mapping, const QS
|
|||
glm::vec4& weights = extracted.mesh.clusterWeights[i];
|
||||
float total = weights.x + weights.y + weights.z + weights.w;
|
||||
if (total != 1.0f && total != 0.0f) {
|
||||
weights /= total;
|
||||
weights /= total;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
@ -1573,7 +1573,7 @@ FBXGeometry* FBXReader::extractFBXGeometry(const QVariantHash& mapping, const QS
|
|||
avgRadius += glm::length(offset - projection * axis);
|
||||
}
|
||||
avgRadius /= (float)points.size();
|
||||
|
||||
|
||||
// compute endpoints of capsule in joint-frame
|
||||
glm::vec3 capsuleBegin = avgPoint;
|
||||
glm::vec3 capsuleEnd = avgPoint;
|
||||
|
@ -1594,27 +1594,27 @@ FBXGeometry* FBXReader::extractFBXGeometry(const QVariantHash& mapping, const QS
|
|||
joint.shapeInfo.radius = avgRadius;
|
||||
}
|
||||
geometry.palmDirection = parseVec3(mapping.value("palmDirection", "0, -1, 0").toString());
|
||||
|
||||
|
||||
// Add sitting points
|
||||
QVariantHash sittingPoints = mapping.value("sit").toHash();
|
||||
for (QVariantHash::const_iterator it = sittingPoints.constBegin(); it != sittingPoints.constEnd(); it++) {
|
||||
SittingPoint sittingPoint;
|
||||
sittingPoint.name = it.key();
|
||||
|
||||
|
||||
QVariantList properties = it->toList();
|
||||
sittingPoint.position = parseVec3(properties.at(0).toString());
|
||||
sittingPoint.rotation = glm::quat(glm::radians(parseVec3(properties.at(1).toString())));
|
||||
|
||||
|
||||
geometry.sittingPoints.append(sittingPoint);
|
||||
}
|
||||
|
||||
|
||||
// attempt to map any meshes to a named model
|
||||
for (QHash<QString, int>::const_iterator m = meshIDsToMeshIndices.constBegin();
|
||||
for (QHash<QString, int>::const_iterator m = meshIDsToMeshIndices.constBegin();
|
||||
m != meshIDsToMeshIndices.constEnd(); m++) {
|
||||
|
||||
|
||||
const QString& meshID = m.key();
|
||||
int meshIndex = m.value();
|
||||
|
||||
|
||||
if (ooChildToParent.contains(meshID)) {
|
||||
const QString& modelID = ooChildToParent.value(meshID);
|
||||
if (modelIDsToNames.contains(modelID)) {
|
||||
|
@ -1623,7 +1623,7 @@ FBXGeometry* FBXReader::extractFBXGeometry(const QVariantHash& mapping, const QS
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return geometryPtr;
|
||||
}
|
||||
|
||||
|
@ -1641,5 +1641,3 @@ FBXGeometry* readFBX(QIODevice* device, const QVariantHash& mapping, const QStri
|
|||
|
||||
return reader.extractFBXGeometry(mapping, url);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -413,8 +413,8 @@ public:
|
|||
float _lightmapOffset = 0.0f;
|
||||
float _lightmapLevel;
|
||||
|
||||
QMultiHash<QString, QString> _connectionParentMap;
|
||||
QMultiHash<QString, QString> _connectionChildMap;
|
||||
QMultiMap<QString, QString> _connectionParentMap;
|
||||
QMultiMap<QString, QString> _connectionChildMap;
|
||||
|
||||
static glm::vec3 getVec3(const QVariantList& properties, int index);
|
||||
static QVector<glm::vec4> createVec4Vector(const QVector<double>& doubleVector);
|
||||
|
|
|
@ -38,7 +38,7 @@ PacketVersion versionForPacketType(PacketType packetType) {
|
|||
case PacketType::EntityAdd:
|
||||
case PacketType::EntityEdit:
|
||||
case PacketType::EntityData:
|
||||
return VERSION_ENTITIES_ANIMATION_PROPERTIES_GROUP;
|
||||
return VERSION_ENTITIES_KEYLIGHT_PROPERTIES_GROUP;
|
||||
case PacketType::AvatarData:
|
||||
case PacketType::BulkAvatarData:
|
||||
default:
|
||||
|
|
|
@ -143,5 +143,6 @@ const PacketVersion VERSION_ENTITIES_PROTOCOL_HEADER_SWAP = 43;
|
|||
const PacketVersion VERSION_ENTITIES_PARTICLE_ELLIPSOID_EMITTER = 44;
|
||||
const PacketVersion VERSION_ENTITIES_PROTOCOL_CHANNELS = 45;
|
||||
const PacketVersion VERSION_ENTITIES_ANIMATION_PROPERTIES_GROUP = 46;
|
||||
const PacketVersion VERSION_ENTITIES_KEYLIGHT_PROPERTIES_GROUP = 47;
|
||||
|
||||
#endif // hifi_PacketHeaders_h
|
||||
|
|
|
@ -85,11 +85,11 @@ bool ObjectAction::updateArguments(QVariantMap arguments) {
|
|||
quint64 previousExpires = _expires;
|
||||
QString previousTag = _tag;
|
||||
|
||||
bool lifetimeSet = true;
|
||||
float lifetime = EntityActionInterface::extractFloatArgument("action", arguments, "lifetime", lifetimeSet, false);
|
||||
if (lifetimeSet) {
|
||||
bool ttlSet = true;
|
||||
float ttl = EntityActionInterface::extractFloatArgument("action", arguments, "ttl", ttlSet, false);
|
||||
if (ttlSet) {
|
||||
quint64 now = usecTimestampNow();
|
||||
_expires = now + (quint64)(lifetime * USECS_PER_SECOND);
|
||||
_expires = now + (quint64)(ttl * USECS_PER_SECOND);
|
||||
} else {
|
||||
_expires = 0;
|
||||
}
|
||||
|
@ -114,10 +114,10 @@ QVariantMap ObjectAction::getArguments() {
|
|||
QVariantMap arguments;
|
||||
withReadLock([&]{
|
||||
if (_expires == 0) {
|
||||
arguments["lifetime"] = 0.0f;
|
||||
arguments["ttl"] = 0.0f;
|
||||
} else {
|
||||
quint64 now = usecTimestampNow();
|
||||
arguments["lifetime"] = (float)(_expires - now) / (float)USECS_PER_SECOND;
|
||||
arguments["ttl"] = (float)(_expires - now) / (float)USECS_PER_SECOND;
|
||||
}
|
||||
arguments["tag"] = _tag;
|
||||
});
|
||||
|
@ -245,3 +245,31 @@ bool ObjectAction::lifetimeIsOver() {
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
quint64 ObjectAction::localTimeToServerTime(quint64 timeValue) const {
|
||||
// 0 indicates no expiration
|
||||
if (timeValue == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int serverClockSkew = getEntityServerClockSkew();
|
||||
if (serverClockSkew < 0 && timeValue <= (quint64)(-serverClockSkew)) {
|
||||
return 1; // non-zero but long-expired value to avoid negative roll-over
|
||||
}
|
||||
|
||||
return timeValue + serverClockSkew;
|
||||
}
|
||||
|
||||
quint64 ObjectAction::serverTimeToLocalTime(quint64 timeValue) const {
|
||||
// 0 indicates no expiration
|
||||
if (timeValue == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int serverClockSkew = getEntityServerClockSkew();
|
||||
if (serverClockSkew > 0 && timeValue <= (quint64)serverClockSkew) {
|
||||
return 1; // non-zero but long-expired value to avoid negative roll-over
|
||||
}
|
||||
|
||||
return timeValue - serverClockSkew;
|
||||
}
|
||||
|
|
|
@ -47,11 +47,10 @@ public:
|
|||
virtual void deserialize(QByteArray serializedArguments) = 0;
|
||||
|
||||
virtual bool lifetimeIsOver();
|
||||
virtual quint64 getExpires() { return _expires; }
|
||||
|
||||
protected:
|
||||
|
||||
int getEntityServerClockSkew() const;
|
||||
|
||||
virtual btRigidBody* getRigidBody();
|
||||
virtual glm::vec3 getPosition();
|
||||
virtual void setPosition(glm::vec3 position);
|
||||
|
@ -68,6 +67,12 @@ protected:
|
|||
|
||||
quint64 _expires; // in seconds since epoch
|
||||
QString _tag;
|
||||
|
||||
quint64 localTimeToServerTime(quint64 timeValue) const;
|
||||
quint64 serverTimeToLocalTime(quint64 timeValue) const;
|
||||
|
||||
private:
|
||||
int getEntityServerClockSkew() const;
|
||||
};
|
||||
|
||||
#endif // hifi_ObjectAction_h
|
||||
|
|
|
@ -160,7 +160,7 @@ QByteArray ObjectActionOffset::serialize() const {
|
|||
dataStream << _linearDistance;
|
||||
dataStream << _linearTimeScale;
|
||||
dataStream << _positionalTargetSet;
|
||||
dataStream << _expires + getEntityServerClockSkew();
|
||||
dataStream << localTimeToServerTime(_expires);
|
||||
dataStream << _tag;
|
||||
});
|
||||
|
||||
|
@ -189,8 +189,11 @@ void ObjectActionOffset::deserialize(QByteArray serializedArguments) {
|
|||
dataStream >> _linearDistance;
|
||||
dataStream >> _linearTimeScale;
|
||||
dataStream >> _positionalTargetSet;
|
||||
dataStream >> _expires;
|
||||
_expires -= getEntityServerClockSkew();
|
||||
|
||||
quint64 serverExpires;
|
||||
dataStream >> serverExpires;
|
||||
_expires = serverTimeToLocalTime(serverExpires);
|
||||
|
||||
dataStream >> _tag;
|
||||
_active = true;
|
||||
});
|
||||
|
|
|
@ -198,7 +198,7 @@ QByteArray ObjectActionSpring::serialize() const {
|
|||
dataStream << _rotationalTarget;
|
||||
dataStream << _angularTimeScale;
|
||||
dataStream << _rotationalTargetSet;
|
||||
dataStream << _expires + getEntityServerClockSkew();
|
||||
dataStream << localTimeToServerTime(_expires);
|
||||
dataStream << _tag;
|
||||
});
|
||||
|
||||
|
@ -232,8 +232,10 @@ void ObjectActionSpring::deserialize(QByteArray serializedArguments) {
|
|||
dataStream >> _angularTimeScale;
|
||||
dataStream >> _rotationalTargetSet;
|
||||
|
||||
dataStream >> _expires;
|
||||
_expires -= getEntityServerClockSkew();
|
||||
quint64 serverExpires;
|
||||
dataStream >> serverExpires;
|
||||
_expires = serverTimeToLocalTime(serverExpires);
|
||||
|
||||
dataStream >> _tag;
|
||||
|
||||
_active = true;
|
||||
|
|
|
@ -229,7 +229,7 @@ void MeshPartPayload::bindTransform(gpu::Batch& batch, const ModelRender::Locati
|
|||
|
||||
void MeshPartPayload::render(RenderArgs* args) const {
|
||||
PerformanceTimer perfTimer("MeshPartPayload::render");
|
||||
if (!model->_readyWhenAdded) {
|
||||
if (!model->_readyWhenAdded || !model->_isVisible) {
|
||||
return; // bail asap
|
||||
}
|
||||
|
||||
|
|
|
@ -96,7 +96,7 @@ static bool hasCorrectSyntax(const QScriptProgram& program) {
|
|||
return true;
|
||||
}
|
||||
|
||||
static bool hadUncauchtExceptions(QScriptEngine& engine, const QString& fileName) {
|
||||
static bool hadUncaughtExceptions(QScriptEngine& engine, const QString& fileName) {
|
||||
if (engine.hasUncaughtException()) {
|
||||
const auto backtrace = engine.uncaughtExceptionBacktrace();
|
||||
const auto exception = engine.uncaughtException().toString();
|
||||
|
@ -616,7 +616,7 @@ QScriptValue ScriptEngine::evaluate(const QString& sourceCode, const QString& fi
|
|||
const auto result = QScriptEngine::evaluate(program);
|
||||
--_evaluatesPending;
|
||||
|
||||
const auto hadUncaughtException = hadUncauchtExceptions(*this, program.fileName());
|
||||
const auto hadUncaughtException = hadUncaughtExceptions(*this, program.fileName());
|
||||
if (_wantSignals) {
|
||||
emit evaluationFinished(result, hadUncaughtException);
|
||||
}
|
||||
|
@ -685,9 +685,8 @@ void ScriptEngine::run() {
|
|||
}
|
||||
lastUpdate = now;
|
||||
|
||||
if (hadUncauchtExceptions(*this, _fileNameString)) {
|
||||
stop();
|
||||
}
|
||||
// Debug and clear exceptions
|
||||
hadUncaughtExceptions(*this, _fileNameString);
|
||||
}
|
||||
|
||||
stopAllTimers(); // make sure all our timers are stopped if the script is ending
|
||||
|
@ -1022,7 +1021,7 @@ void ScriptEngine::entityScriptContentAvailable(const EntityItemID& entityID, co
|
|||
|
||||
QScriptEngine sandbox;
|
||||
QScriptValue testConstructor = sandbox.evaluate(program);
|
||||
if (hadUncauchtExceptions(sandbox, program.fileName())) {
|
||||
if (hadUncaughtExceptions(sandbox, program.fileName())) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
30
libraries/shared/src/ColorUtils.h
Normal file
30
libraries/shared/src/ColorUtils.h
Normal file
|
@ -0,0 +1,30 @@
|
|||
//
|
||||
// ColorUtils.h
|
||||
// libraries/shared/src
|
||||
//
|
||||
// Created by Sam Gateau on 10/24/15.
|
||||
// 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
|
||||
//
|
||||
|
||||
#ifndef hifi_ColorUtils_h
|
||||
#define hifi_ColorUtils_h
|
||||
|
||||
#include <glm/glm.hpp>
|
||||
#include <SharedUtil.h>
|
||||
|
||||
#include "DependencyManager.h"
|
||||
|
||||
class ColorUtils {
|
||||
public:
|
||||
inline static glm::vec3 toVec3(const xColor& color);
|
||||
};
|
||||
|
||||
inline glm::vec3 ColorUtils::toVec3(const xColor& color) {
|
||||
const float ONE_OVER_255 = 1.0f / 255.0f;
|
||||
return glm::vec3(color.red * ONE_OVER_255, color.green * ONE_OVER_255, color.blue * ONE_OVER_255);
|
||||
}
|
||||
|
||||
#endif // hifi_ColorUtils_h
|
111
unpublishedScripts/basketballsResetter.js
Normal file
111
unpublishedScripts/basketballsResetter.js
Normal file
|
@ -0,0 +1,111 @@
|
|||
//
|
||||
//
|
||||
// Created by James B. Pollack @imgntn on 10/26/2015
|
||||
// Copyright 2015 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
|
||||
var HIFI_PUBLIC_BUCKET = "http://s3.amazonaws.com/hifi-public/";
|
||||
|
||||
(function() {
|
||||
|
||||
var _this;
|
||||
Resetter = function() {
|
||||
_this = this;
|
||||
};
|
||||
|
||||
Resetter.prototype = {
|
||||
|
||||
startNearGrabNonColliding: function() {
|
||||
this.resetObjects();
|
||||
},
|
||||
|
||||
clickReleaseOnEntity: function() {
|
||||
this.resetObjects();
|
||||
},
|
||||
|
||||
resetObjects: function() {
|
||||
var ids = Entities.findEntities(this.initialProperties.position, 75);
|
||||
var i;
|
||||
for (i = 0; i < ids.length; i++) {
|
||||
var id = ids[i];
|
||||
var properties = Entities.getEntityProperties(id, "name");
|
||||
if (properties.name === "Hifi-Basketball") {
|
||||
Entities.deleteEntity(id);
|
||||
}
|
||||
}
|
||||
|
||||
this.createBasketballs();
|
||||
},
|
||||
|
||||
createBasketballs: function() {
|
||||
var NUMBER_OF_BALLS = 4;
|
||||
var DIAMETER = 0.30;
|
||||
var basketballURL = HIFI_PUBLIC_BUCKET + "models/content/basketball2.fbx";
|
||||
var basketballCollisionSoundURL = HIFI_PUBLIC_BUCKET + "sounds/basketball/basketball.wav";
|
||||
|
||||
var position = {
|
||||
x: 542.86,
|
||||
y: 494.84,
|
||||
z: 475.06
|
||||
};
|
||||
var collidingBalls = [];
|
||||
|
||||
var i;
|
||||
for (i = 0; i < NUMBER_OF_BALLS; i++) {
|
||||
var ballPosition = {
|
||||
x: position.x,
|
||||
y: position.y + DIAMETER * 2,
|
||||
z: position.z + (DIAMETER) - (DIAMETER * i)
|
||||
};
|
||||
var newPosition = {
|
||||
x: position.x + (DIAMETER * 2) - (DIAMETER * i),
|
||||
y: position.y + DIAMETER * 2,
|
||||
z: position.z
|
||||
};
|
||||
var collidingBall = Entities.addEntity({
|
||||
type: "Model",
|
||||
name: 'Hifi-Basketball',
|
||||
shapeType: 'Sphere',
|
||||
position: newPosition,
|
||||
dimensions: {
|
||||
x: DIAMETER,
|
||||
y: DIAMETER,
|
||||
z: DIAMETER
|
||||
},
|
||||
restitution: 1.0,
|
||||
linearDamping: 0.00001,
|
||||
gravity: {
|
||||
x: 0,
|
||||
y: -9.8,
|
||||
z: 0
|
||||
},
|
||||
collisionsWillMove: true,
|
||||
collisionsSoundURL: basketballCollisionSoundURL,
|
||||
ignoreForCollisions: false,
|
||||
modelURL: basketballURL,
|
||||
userData: JSON.stringify({
|
||||
resetMe: {
|
||||
resetMe: true
|
||||
},
|
||||
grabbableKey: {
|
||||
invertSolidWhileHeld: true
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
collidingBalls.push(collidingBall);
|
||||
|
||||
}
|
||||
},
|
||||
|
||||
preload: function(entityID) {
|
||||
this.initialProperties = Entities.getEntityProperties(entityID);
|
||||
this.entityID = entityID;
|
||||
},
|
||||
|
||||
};
|
||||
|
||||
return new Resetter();
|
||||
});
|
|
@ -22,7 +22,8 @@
|
|||
var dollScriptURL = Script.resolvePath("../examples/toybox/doll/doll.js");
|
||||
var lightsScriptURL = Script.resolvePath("../examples/toybox/lights/lightSwitch.js");
|
||||
var targetsScriptURL = Script.resolvePath('../examples/toybox/ping_pong_gun/wallTarget.js');
|
||||
|
||||
var basketballResetterScriptURL = Script.resolvePath('basketballsResetter.js');
|
||||
var targetsResetterScriptURL = Script.resolvePath('targetsResetter.js');
|
||||
|
||||
ResetSwitch = function() {
|
||||
_this = this;
|
||||
|
@ -110,9 +111,12 @@
|
|||
});
|
||||
|
||||
createPingPongBallGun();
|
||||
createTargets();
|
||||
createTargetResetter();
|
||||
|
||||
createBasketballHoop();
|
||||
createBasketballRack();
|
||||
createBasketballResetter();
|
||||
|
||||
createGates();
|
||||
|
||||
|
@ -120,8 +124,6 @@
|
|||
// Handles toggling of all sconce lights
|
||||
createLights();
|
||||
|
||||
|
||||
|
||||
createCat({
|
||||
x: 551.09,
|
||||
y: 494.98,
|
||||
|
@ -135,7 +137,6 @@
|
|||
z: 503.91
|
||||
});
|
||||
|
||||
createTargets();
|
||||
|
||||
}
|
||||
|
||||
|
@ -275,10 +276,11 @@
|
|||
})
|
||||
});
|
||||
|
||||
var collidingBalls = [];
|
||||
|
||||
|
||||
function createCollidingBalls() {
|
||||
var position = rackStartPosition;
|
||||
var collidingBalls = [];
|
||||
|
||||
var i;
|
||||
for (i = 0; i < NUMBER_OF_BALLS; i++) {
|
||||
|
@ -334,6 +336,74 @@
|
|||
|
||||
}
|
||||
|
||||
function createBasketballResetter() {
|
||||
|
||||
var position = {
|
||||
x: 543.58,
|
||||
y: 495.47,
|
||||
z: 469.59
|
||||
};
|
||||
|
||||
var dimensions = {
|
||||
x: 1.65,
|
||||
y: 1.71,
|
||||
z: 1.75
|
||||
};
|
||||
|
||||
var resetter = Entities.addEntity({
|
||||
type: "Box",
|
||||
position: position,
|
||||
name: "Basketball Resetter",
|
||||
script: basketballResetterScriptURL,
|
||||
dimensions: dimensions,
|
||||
visible: false,
|
||||
userData: JSON.stringify({
|
||||
resetMe: {
|
||||
resetMe: true
|
||||
},
|
||||
grabbableKey: {
|
||||
wantsTrigger: true
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
function createTargetResetter() {
|
||||
var dimensions = {
|
||||
x: 0.21,
|
||||
y: 0.61,
|
||||
z: 0.21
|
||||
};
|
||||
|
||||
var position = {
|
||||
x: 548.42,
|
||||
y: 496.40,
|
||||
z: 509.61
|
||||
};
|
||||
|
||||
var resetter = Entities.addEntity({
|
||||
type: "Box",
|
||||
position: position,
|
||||
name: "Target Resetter",
|
||||
script: targetsResetterScriptURL,
|
||||
dimensions: dimensions,
|
||||
visible: false,
|
||||
userData: JSON.stringify({
|
||||
resetMe: {
|
||||
resetMe: true
|
||||
},
|
||||
grabbableKey: {
|
||||
wantsTrigger: true
|
||||
}
|
||||
})
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
function createTargets() {
|
||||
|
||||
var MODEL_URL = 'http://hifi-public.s3.amazonaws.com/models/ping_pong_gun/target.fbx';
|
||||
|
|
|
@ -8,15 +8,11 @@
|
|||
|
||||
/*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, pointInExtents, vec3equal, setEntityCustomData, getEntityCustomData */
|
||||
|
||||
|
||||
var masterResetScript = Script.resolvePath("masterReset.js");
|
||||
var hiddenEntityScriptURL = Script.resolvePath("hiddenEntityReset.js");
|
||||
|
||||
|
||||
Script.include(masterResetScript);
|
||||
|
||||
|
||||
|
||||
function createHiddenMasterSwitch() {
|
||||
|
||||
var resetKey = "resetMe";
|
||||
|
@ -31,7 +27,6 @@ function createHiddenMasterSwitch() {
|
|||
});
|
||||
}
|
||||
|
||||
|
||||
var entities = Entities.findEntities(MyAvatar.position, 100);
|
||||
|
||||
entities.forEach(function(entity) {
|
||||
|
@ -41,5 +36,7 @@ entities.forEach(function(entity) {
|
|||
Entities.deleteEntity(entity);
|
||||
}
|
||||
});
|
||||
|
||||
createHiddenMasterSwitch();
|
||||
|
||||
MasterReset();
|
|
@ -14,16 +14,16 @@
|
|||
var utilitiesScript = Script.resolvePath("../examples/libraries/utils.js");
|
||||
Script.include(utilitiesScript);
|
||||
|
||||
var sprayPaintScriptURL = Script.resolvePath("../examples/toybox/spray_paint/sprayPaintCan.js");
|
||||
var catScriptURL = Script.resolvePath("../examples/toybox/cat/cat.js");
|
||||
var flashlightScriptURL = Script.resolvePath('../examples/toybox/flashlight/flashlight.js');
|
||||
var pingPongScriptURL = Script.resolvePath('../examples/toybox/ping_pong_gun/pingPongGun.js');
|
||||
var wandScriptURL = Script.resolvePath("../examples/toybox/bubblewand/wand.js");
|
||||
var dollScriptURL = Script.resolvePath("../examples/toybox/doll/doll.js");
|
||||
var lightsScriptURL = Script.resolvePath("../examples/toybox/lights/lightSwitch.js");
|
||||
var targetsScriptURL = Script.resolvePath('../examples/toybox/ping_pong_gun/wallTarget.js');
|
||||
|
||||
|
||||
var sprayPaintScriptURL = Script.resolvePath("../examples/toybox/spray_paint/sprayPaintCan.js");
|
||||
var catScriptURL = Script.resolvePath("../examples/toybox/cat/cat.js");
|
||||
var flashlightScriptURL = Script.resolvePath('../examples/toybox/flashlight/flashlight.js');
|
||||
var pingPongScriptURL = Script.resolvePath('../examples/toybox/ping_pong_gun/pingPongGun.js');
|
||||
var wandScriptURL = Script.resolvePath("../examples/toybox/bubblewand/wand.js");
|
||||
var dollScriptURL = Script.resolvePath("../examples/toybox/doll/doll.js");
|
||||
var lightsScriptURL = Script.resolvePath("../examples/toybox/lights/lightSwitch.js");
|
||||
var targetsScriptURL = Script.resolvePath('../examples/toybox/ping_pong_gun/wallTarget.js');
|
||||
var basketballResetterScriptURL = Script.resolvePath('basketballsResetter.js');
|
||||
var targetsResetterScriptURL = Script.resolvePath('targetsResetter.js');
|
||||
|
||||
MasterReset = function() {
|
||||
var resetKey = "resetMe";
|
||||
|
@ -84,9 +84,12 @@ MasterReset = function() {
|
|||
});
|
||||
|
||||
createPingPongBallGun();
|
||||
createTargets();
|
||||
createTargetResetter();
|
||||
|
||||
createBasketballHoop();
|
||||
createBasketballRack();
|
||||
createBasketballResetter();
|
||||
|
||||
createGates();
|
||||
|
||||
|
@ -109,7 +112,7 @@ MasterReset = function() {
|
|||
z: 503.91
|
||||
});
|
||||
|
||||
createTargets();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
@ -201,6 +204,7 @@ MasterReset = function() {
|
|||
});
|
||||
}
|
||||
|
||||
|
||||
function createBasketballRack() {
|
||||
var NUMBER_OF_BALLS = 4;
|
||||
var DIAMETER = 0.30;
|
||||
|
@ -249,10 +253,11 @@ MasterReset = function() {
|
|||
})
|
||||
});
|
||||
|
||||
var collidingBalls = [];
|
||||
|
||||
|
||||
function createCollidingBalls() {
|
||||
var position = rackStartPosition;
|
||||
var collidingBalls = [];
|
||||
|
||||
var i;
|
||||
for (i = 0; i < NUMBER_OF_BALLS; i++) {
|
||||
|
@ -308,6 +313,75 @@ MasterReset = function() {
|
|||
|
||||
}
|
||||
|
||||
|
||||
function createBasketballResetter() {
|
||||
|
||||
var position = {
|
||||
x: 543.58,
|
||||
y: 495.47,
|
||||
z: 469.59
|
||||
};
|
||||
|
||||
var dimensions = {
|
||||
x: 1.65,
|
||||
y: 1.71,
|
||||
z: 1.75
|
||||
};
|
||||
|
||||
var resetter = Entities.addEntity({
|
||||
type: "Box",
|
||||
position: position,
|
||||
name: "Basketball Resetter",
|
||||
script: basketballResetterScriptURL,
|
||||
dimensions: dimensions,
|
||||
visible:false,
|
||||
userData: JSON.stringify({
|
||||
resetMe: {
|
||||
resetMe: true
|
||||
},
|
||||
grabbableKey: {
|
||||
wantsTrigger: true
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
function createTargetResetter() {
|
||||
var dimensions = {
|
||||
x: 0.21,
|
||||
y: 0.61,
|
||||
z: 0.21
|
||||
};
|
||||
|
||||
var position = {
|
||||
x: 548.42,
|
||||
y: 496.40,
|
||||
z: 509.61
|
||||
};
|
||||
|
||||
var resetter = Entities.addEntity({
|
||||
type: "Box",
|
||||
position: position,
|
||||
name: "Target Resetter",
|
||||
script: targetsResetterScriptURL,
|
||||
dimensions: dimensions,
|
||||
visible:false,
|
||||
userData: JSON.stringify({
|
||||
resetMe: {
|
||||
resetMe: true
|
||||
},
|
||||
grabbableKey: {
|
||||
wantsTrigger: true
|
||||
}
|
||||
})
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
function createTargets() {
|
||||
|
||||
var MODEL_URL = 'http://hifi-public.s3.amazonaws.com/models/ping_pong_gun/target.fbx';
|
||||
|
|
128
unpublishedScripts/targetsResetter.js
Normal file
128
unpublishedScripts/targetsResetter.js
Normal file
|
@ -0,0 +1,128 @@
|
|||
//
|
||||
//
|
||||
// Created by James B. Pollack @imgntn on 10/26/2015
|
||||
// Copyright 2015 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
|
||||
|
||||
(function() {
|
||||
var targetsScriptURL = Script.resolvePath('../examples/toybox/ping_pong_gun/wallTarget.js');
|
||||
|
||||
var _this;
|
||||
Resetter = function() {
|
||||
_this = this;
|
||||
};
|
||||
|
||||
Resetter.prototype = {
|
||||
|
||||
startNearGrabNonColliding: function() {
|
||||
this.resetObjects();
|
||||
},
|
||||
|
||||
clickReleaseOnEntity: function() {
|
||||
this.resetObjects();
|
||||
},
|
||||
|
||||
resetObjects: function() {
|
||||
var ids = Entities.findEntities(this.initialProperties.position, 50);
|
||||
for (var i = 0; i < ids.length; i++) {
|
||||
var id = ids[i];
|
||||
var properties = Entities.getEntityProperties(id, "name");
|
||||
if (properties.name === "Hifi-Target") {
|
||||
Entities.deleteEntity(id);
|
||||
}
|
||||
}
|
||||
this.createTargets();
|
||||
},
|
||||
|
||||
preload: function(entityID) {
|
||||
this.initialProperties = Entities.getEntityProperties(entityID);
|
||||
this.entityID = entityID;
|
||||
},
|
||||
|
||||
createTargets: function() {
|
||||
|
||||
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 MINIMUM_MOVE_LENGTH = 0.05;
|
||||
var RESET_DISTANCE = 0.5;
|
||||
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 targets = [];
|
||||
|
||||
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);
|
||||
|
||||
var targetProperties = {
|
||||
name: 'Hifi-Target',
|
||||
type: 'Model',
|
||||
modelURL: MODEL_URL,
|
||||
shapeType: 'compound',
|
||||
collisionsWillMove: true,
|
||||
dimensions: TARGET_DIMENSIONS,
|
||||
compoundShapeURL: COLLISION_HULL_URL,
|
||||
position: position,
|
||||
rotation: rotation,
|
||||
script: targetsScriptURL,
|
||||
userData: JSON.stringify({
|
||||
originalPositionKey: {
|
||||
originalPosition: position
|
||||
},
|
||||
resetMe: {
|
||||
resetMe: true
|
||||
},
|
||||
grabbableKey: {
|
||||
grabbable: false
|
||||
}
|
||||
})
|
||||
};
|
||||
|
||||
var target = Entities.addEntity(targetProperties);
|
||||
targets.push(target);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
addTargets();
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
return new Resetter();
|
||||
});
|
Loading…
Reference in a new issue