mirror of
https://github.com/overte-org/overte.git
synced 2025-08-10 07:53:08 +02:00
Merge pull request #6593 from Atlante45/master
Update toys relativeRotation/Position
This commit is contained in:
commit
1512703182
5 changed files with 55 additions and 49 deletions
|
@ -202,31 +202,41 @@ function entityIsGrabbedByOther(entityID) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function getSpatialOffsetPosition(hand, spatialKey) {
|
function getSpatialOffsetPosition(hand, spatialKey) {
|
||||||
|
var position = Vec3.ZERO;
|
||||||
|
|
||||||
if (hand !== RIGHT_HAND && spatialKey.leftRelativePosition) {
|
if (hand !== RIGHT_HAND && spatialKey.leftRelativePosition) {
|
||||||
return spatialKey.leftRelativePosition;
|
position = spatialKey.leftRelativePosition;
|
||||||
}
|
}
|
||||||
if (hand === RIGHT_HAND && spatialKey.rightRelativePosition) {
|
if (hand === RIGHT_HAND && spatialKey.rightRelativePosition) {
|
||||||
return spatialKey.rightRelativePosition;
|
position = spatialKey.rightRelativePosition;
|
||||||
}
|
}
|
||||||
if (spatialKey.relativePosition) {
|
if (spatialKey.relativePosition) {
|
||||||
return spatialKey.relativePosition;
|
position = spatialKey.relativePosition;
|
||||||
}
|
}
|
||||||
|
|
||||||
return Vec3.ZERO;
|
return position;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var yFlip = Quat.angleAxis(180, Vec3.UNIT_Y);
|
||||||
function getSpatialOffsetRotation(hand, spatialKey) {
|
function getSpatialOffsetRotation(hand, spatialKey) {
|
||||||
|
var rotation = Quat.IDENTITY;
|
||||||
|
|
||||||
if (hand !== RIGHT_HAND && spatialKey.leftRelativeRotation) {
|
if (hand !== RIGHT_HAND && spatialKey.leftRelativeRotation) {
|
||||||
return spatialKey.leftRelativeRotation;
|
rotation = spatialKey.leftRelativeRotation;
|
||||||
}
|
}
|
||||||
if (hand === RIGHT_HAND && spatialKey.rightRelativeRotation) {
|
if (hand === RIGHT_HAND && spatialKey.rightRelativeRotation) {
|
||||||
return spatialKey.rightRelativeRotation;
|
rotation = spatialKey.rightRelativeRotation;
|
||||||
}
|
}
|
||||||
if (spatialKey.relativeRotation) {
|
if (spatialKey.relativeRotation) {
|
||||||
return spatialKey.relativeRotation;
|
rotation = spatialKey.relativeRotation;
|
||||||
}
|
}
|
||||||
|
|
||||||
return Quat.IDENTITY;
|
// Flip left hand
|
||||||
|
if (hand !== RIGHT_HAND) {
|
||||||
|
rotation = Quat.multiply(yFlip, rotation);
|
||||||
|
}
|
||||||
|
|
||||||
|
return rotation;
|
||||||
}
|
}
|
||||||
|
|
||||||
function MyController(hand) {
|
function MyController(hand) {
|
||||||
|
@ -254,6 +264,7 @@ function MyController(hand) {
|
||||||
|
|
||||||
this.overlayLine = null;
|
this.overlayLine = null;
|
||||||
|
|
||||||
|
this.ignoreIK = false;
|
||||||
this.offsetPosition = Vec3.ZERO;
|
this.offsetPosition = Vec3.ZERO;
|
||||||
this.offsetRotation = Quat.IDENTITY;
|
this.offsetRotation = Quat.IDENTITY;
|
||||||
|
|
||||||
|
@ -853,9 +864,12 @@ function MyController(hand) {
|
||||||
|
|
||||||
if (this.state != STATE_NEAR_GRABBING && grabbableData.spatialKey) {
|
if (this.state != STATE_NEAR_GRABBING && grabbableData.spatialKey) {
|
||||||
// if an object is "equipped" and has a spatialKey, use it.
|
// if an object is "equipped" and has a spatialKey, use it.
|
||||||
|
this.ignoreIK = grabbableData.spatialKey.ignoreIK ? grabbableData.spatialKey.ignoreIK : false;
|
||||||
this.offsetPosition = getSpatialOffsetPosition(this.hand, grabbableData.spatialKey);
|
this.offsetPosition = getSpatialOffsetPosition(this.hand, grabbableData.spatialKey);
|
||||||
this.offsetRotation = getSpatialOffsetRotation(this.hand, grabbableData.spatialKey);
|
this.offsetRotation = getSpatialOffsetRotation(this.hand, grabbableData.spatialKey);
|
||||||
} else {
|
} else {
|
||||||
|
this.ignoreIK = false;
|
||||||
|
|
||||||
var objectRotation = grabbedProperties.rotation;
|
var objectRotation = grabbedProperties.rotation;
|
||||||
this.offsetRotation = Quat.multiply(Quat.inverse(handRotation), objectRotation);
|
this.offsetRotation = Quat.multiply(Quat.inverse(handRotation), objectRotation);
|
||||||
|
|
||||||
|
@ -872,7 +886,8 @@ function MyController(hand) {
|
||||||
relativeRotation: this.offsetRotation,
|
relativeRotation: this.offsetRotation,
|
||||||
ttl: ACTION_TTL,
|
ttl: ACTION_TTL,
|
||||||
kinematic: NEAR_GRABBING_KINEMATIC,
|
kinematic: NEAR_GRABBING_KINEMATIC,
|
||||||
kinematicSetVelocity: true
|
kinematicSetVelocity: true,
|
||||||
|
ignoreIK: this.ignoreIK
|
||||||
});
|
});
|
||||||
if (this.actionID === NULL_ACTION_ID) {
|
if (this.actionID === NULL_ACTION_ID) {
|
||||||
this.actionID = null;
|
this.actionID = null;
|
||||||
|
@ -956,7 +971,8 @@ function MyController(hand) {
|
||||||
relativeRotation: this.offsetRotation,
|
relativeRotation: this.offsetRotation,
|
||||||
ttl: ACTION_TTL,
|
ttl: ACTION_TTL,
|
||||||
kinematic: NEAR_GRABBING_KINEMATIC,
|
kinematic: NEAR_GRABBING_KINEMATIC,
|
||||||
kinematicSetVelocity: true
|
kinematicSetVelocity: true,
|
||||||
|
ignoreIK: this.ignoreIK
|
||||||
});
|
});
|
||||||
this.actionTimeout = now + (ACTION_TTL * MSEC_PER_SEC);
|
this.actionTimeout = now + (ACTION_TTL * MSEC_PER_SEC);
|
||||||
}
|
}
|
||||||
|
@ -982,6 +998,7 @@ function MyController(hand) {
|
||||||
// use a spring to pull the object to where it will be when equipped
|
// use a spring to pull the object to where it will be when equipped
|
||||||
var relativeRotation = getSpatialOffsetRotation(this.hand, grabbableData.spatialKey);
|
var relativeRotation = getSpatialOffsetRotation(this.hand, grabbableData.spatialKey);
|
||||||
var relativePosition = getSpatialOffsetPosition(this.hand, grabbableData.spatialKey);
|
var relativePosition = getSpatialOffsetPosition(this.hand, grabbableData.spatialKey);
|
||||||
|
var ignoreIK = grabbableData.spatialKey.ignoreIK ? grabbableData.spatialKey.ignoreIK : false;
|
||||||
var handRotation = this.getHandRotation();
|
var handRotation = this.getHandRotation();
|
||||||
var handPosition = this.getHandPosition();
|
var handPosition = this.getHandPosition();
|
||||||
var targetRotation = Quat.multiply(handRotation, relativeRotation);
|
var targetRotation = Quat.multiply(handRotation, relativeRotation);
|
||||||
|
@ -996,7 +1013,8 @@ function MyController(hand) {
|
||||||
linearTimeScale: EQUIP_SPRING_TIMEFRAME,
|
linearTimeScale: EQUIP_SPRING_TIMEFRAME,
|
||||||
targetRotation: targetRotation,
|
targetRotation: targetRotation,
|
||||||
angularTimeScale: EQUIP_SPRING_TIMEFRAME,
|
angularTimeScale: EQUIP_SPRING_TIMEFRAME,
|
||||||
ttl: ACTION_TTL
|
ttl: ACTION_TTL,
|
||||||
|
ignoreIK: ignoreIK
|
||||||
});
|
});
|
||||||
if (this.equipSpringID === NULL_ACTION_ID) {
|
if (this.equipSpringID === NULL_ACTION_ID) {
|
||||||
this.equipSpringID = null;
|
this.equipSpringID = null;
|
||||||
|
@ -1009,7 +1027,8 @@ function MyController(hand) {
|
||||||
linearTimeScale: EQUIP_SPRING_TIMEFRAME,
|
linearTimeScale: EQUIP_SPRING_TIMEFRAME,
|
||||||
targetRotation: targetRotation,
|
targetRotation: targetRotation,
|
||||||
angularTimeScale: EQUIP_SPRING_TIMEFRAME,
|
angularTimeScale: EQUIP_SPRING_TIMEFRAME,
|
||||||
ttl: ACTION_TTL
|
ttl: ACTION_TTL,
|
||||||
|
ignoreIK: ignoreIK
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -66,21 +66,6 @@
|
||||||
max2: 15
|
max2: 15
|
||||||
}
|
}
|
||||||
|
|
||||||
var BOW_SPATIAL_KEY = {
|
|
||||||
leftRelativePosition: {
|
|
||||||
x: 0.05,
|
|
||||||
y: 0.06,
|
|
||||||
z: -0.05
|
|
||||||
},
|
|
||||||
rightRelativePosition: {
|
|
||||||
x: -0.05,
|
|
||||||
y: 0.06,
|
|
||||||
z: -0.05
|
|
||||||
},
|
|
||||||
relativeRotation: Quat.fromPitchYawRollDegrees(0, 90, -90)
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
var USE_DEBOUNCE = false;
|
var USE_DEBOUNCE = false;
|
||||||
|
|
||||||
var TRIGGER_CONTROLS = [
|
var TRIGGER_CONTROLS = [
|
||||||
|
@ -168,11 +153,9 @@
|
||||||
var handToDisable = this.initialHand === 'right' ? 'left' : 'right';
|
var handToDisable = this.initialHand === 'right' ? 'left' : 'right';
|
||||||
Messages.sendMessage('Hifi-Hand-Disabler', handToDisable);
|
Messages.sendMessage('Hifi-Hand-Disabler', handToDisable);
|
||||||
|
|
||||||
setEntityCustomData('grabbableKey', this.entityID, {
|
var data = getEntityCustomData('grabbableKey', this.entityID, {});
|
||||||
grabbable: false,
|
data.grabbable = false;
|
||||||
invertSolidWhileHeld: true,
|
setEntityCustomData('grabbableKey', this.entityID, data);
|
||||||
spatialKey: BOW_SPATIAL_KEY
|
|
||||||
});
|
|
||||||
|
|
||||||
},
|
},
|
||||||
continueNearGrab: function() {
|
continueNearGrab: function() {
|
||||||
|
@ -226,11 +209,10 @@
|
||||||
this.isGrabbed = false;
|
this.isGrabbed = false;
|
||||||
this.stringDrawn = false;
|
this.stringDrawn = false;
|
||||||
this.deleteStrings();
|
this.deleteStrings();
|
||||||
setEntityCustomData('grabbableKey', this.entityID, {
|
|
||||||
grabbable: true,
|
var data = getEntityCustomData('grabbableKey', this.entityID, {});
|
||||||
invertSolidWhileHeld: true,
|
data.grabbable = true;
|
||||||
spatialKey: BOW_SPATIAL_KEY
|
setEntityCustomData('grabbableKey', this.entityID, data);
|
||||||
});
|
|
||||||
Entities.deleteEntity(this.preNotchString);
|
Entities.deleteEntity(this.preNotchString);
|
||||||
Entities.deleteEntity(this.arrow);
|
Entities.deleteEntity(this.arrow);
|
||||||
this.aiming = false;
|
this.aiming = false;
|
||||||
|
|
|
@ -49,14 +49,14 @@ var bow = Entities.addEntity({
|
||||||
invertSolidWhileHeld: true,
|
invertSolidWhileHeld: true,
|
||||||
spatialKey: {
|
spatialKey: {
|
||||||
leftRelativePosition: {
|
leftRelativePosition: {
|
||||||
x: 0.05,
|
x: -0.02,
|
||||||
y: 0.06,
|
y: 0.08,
|
||||||
z: -0.05
|
z: 0.09
|
||||||
},
|
},
|
||||||
rightRelativePosition: {
|
relativePosition: {
|
||||||
x: -0.05,
|
x: 0.02,
|
||||||
y: 0.06,
|
y: 0.08,
|
||||||
z: -0.05
|
z: 0.09
|
||||||
},
|
},
|
||||||
relativeRotation: Quat.fromPitchYawRollDegrees(0, 90, -90)
|
relativeRotation: Quat.fromPitchYawRollDegrees(0, 90, -90)
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,8 +53,13 @@ var wand = Entities.addEntity({
|
||||||
y: 0.1,
|
y: 0.1,
|
||||||
z: 0
|
z: 0
|
||||||
},
|
},
|
||||||
relativeRotation: Quat.fromPitchYawRollDegrees(0, 0, 90)
|
relativeRotation: Quat.fromPitchYawRollDegrees(0, 0, -90)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
|
function scriptEnding() {
|
||||||
|
Entities.deleteEntity(wand);
|
||||||
|
}
|
||||||
|
Script.scriptEnding.connect(scriptEnding);
|
||||||
|
|
|
@ -28,10 +28,10 @@ var pistol = Entities.addEntity({
|
||||||
spatialKey: {
|
spatialKey: {
|
||||||
relativePosition: {
|
relativePosition: {
|
||||||
x: 0,
|
x: 0,
|
||||||
y: 0,
|
y: 0.05,
|
||||||
z: 0
|
z: -0.08
|
||||||
},
|
},
|
||||||
relativeRotation: Quat.fromPitchYawRollDegrees(45, 90, 0)
|
relativeRotation: Quat.fromPitchYawRollDegrees(90, 90, 0)
|
||||||
},
|
},
|
||||||
invertSolidWhileHeld: true
|
invertSolidWhileHeld: true
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue