mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 06:57:37 +02:00
Improving headMove, added JS call for neckPosition
This commit is contained in:
parent
432622d168
commit
8c71ed3f10
4 changed files with 30 additions and 9 deletions
|
@ -45,7 +45,7 @@ var maxVelocity = 1.25;
|
||||||
var noFly = true;
|
var noFly = true;
|
||||||
|
|
||||||
//var roomLimits = { xMin: 618, xMax: 635.5, zMin: 528, zMax: 552.5 };
|
//var roomLimits = { xMin: 618, xMax: 635.5, zMin: 528, zMax: 552.5 };
|
||||||
var roomLimits = { xMin: -1, xMax: 0, zMin: 0, zMax: 0 };
|
var roomLimits = { xMin: 142.6, xMax: 153.7, zMin: 177.5, zMax: 192.0 };
|
||||||
|
|
||||||
function isInRoom(position) {
|
function isInRoom(position) {
|
||||||
var BUFFER = 2.0;
|
var BUFFER = 2.0;
|
||||||
|
@ -71,19 +71,29 @@ function moveWithHead(deltaTime) {
|
||||||
var deltaPitch = MyAvatar.getHeadDeltaPitch() - headStartDeltaPitch;
|
var deltaPitch = MyAvatar.getHeadDeltaPitch() - headStartDeltaPitch;
|
||||||
var deltaRoll = MyAvatar.getHeadFinalRoll() - headStartRoll;
|
var deltaRoll = MyAvatar.getHeadFinalRoll() - headStartRoll;
|
||||||
var velocity = MyAvatar.getVelocity();
|
var velocity = MyAvatar.getVelocity();
|
||||||
var bodyLocalCurrentHeadVector = Vec3.subtract(MyAvatar.getHeadPosition(), MyAvatar.position);
|
var position = MyAvatar.position;
|
||||||
bodyLocalCurrentHeadVector = Vec3.multiplyQbyV(Quat.angleAxis(-deltaYaw, {x:0, y: 1, z:0}), bodyLocalCurrentHeadVector);
|
var neckPosition = MyAvatar.getNeckPosition();
|
||||||
|
var bodyLocalCurrentHeadVector = Vec3.subtract(neckPosition, position);
|
||||||
|
//bodyLocalCurrentHeadVector = Vec3.multiplyQbyV(Quat.inverse(MyAvatar.orientation), bodyLocalCurrentHeadVector);
|
||||||
var headDelta = Vec3.subtract(bodyLocalCurrentHeadVector, headStartPosition);
|
var headDelta = Vec3.subtract(bodyLocalCurrentHeadVector, headStartPosition);
|
||||||
headDelta = Vec3.multiplyQbyV(Quat.inverse(Camera.getOrientation()), headDelta);
|
//headDelta = Vec3.multiplyQbyV(Quat.inverse(Camera.getOrientation()), headDelta);
|
||||||
headDelta.y = 0.0; // Don't respond to any of the vertical component of head motion
|
headDelta.y = 0.0; // Don't respond to any of the vertical component of head motion
|
||||||
|
if (Vec3.length(headDelta) > 0.005) {
|
||||||
|
Vec3.print("headDelta = ", headDelta);
|
||||||
|
Vec3.print("headStartPosition = ", headStartPosition);
|
||||||
|
Vec3.print("MyAvatar.position = ", position);
|
||||||
|
Vec3.print("MyAvatar.getNeckPosition() = ", neckPosition);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Thrust based on leaning forward and side-to-side
|
// Thrust based on leaning forward and side-to-side
|
||||||
var targetVelocity = {x:0.0, y:0.0, z:0.0};
|
var targetVelocity = {x:0.0, y:0.0, z:0.0};
|
||||||
if (Math.abs(headDelta.z) > HEAD_MOVE_DEAD_ZONE) {
|
if (Math.abs(headDelta.z) > HEAD_MOVE_DEAD_ZONE) {
|
||||||
targetVelocity = Vec3.multiply(zAxis, -headDelta.z * HEAD_VELOCITY_FWD_FACTOR);
|
targetVelocity = Vec3.multiply(zAxis, headDelta.z * HEAD_VELOCITY_FWD_FACTOR);
|
||||||
}
|
}
|
||||||
if (Math.abs(headDelta.x) > HEAD_STRAFE_DEAD_ZONE) {
|
if (Math.abs(headDelta.x) > HEAD_STRAFE_DEAD_ZONE) {
|
||||||
var deltaVelocity = Vec3.multiply(xAxis, -headDelta.x * HEAD_VELOCITY_LEFT_FACTOR);
|
var deltaVelocity = Vec3.multiply(xAxis, headDelta.x * HEAD_VELOCITY_LEFT_FACTOR);
|
||||||
targetVelocity = Vec3.sum(targetVelocity, deltaVelocity);
|
targetVelocity = Vec3.sum(targetVelocity, deltaVelocity);
|
||||||
}
|
}
|
||||||
if (Math.abs(deltaYaw) > HEAD_ROTATE_DEAD_ZONE) {
|
if (Math.abs(deltaYaw) > HEAD_ROTATE_DEAD_ZONE) {
|
||||||
|
@ -130,7 +140,10 @@ function moveWithHead(deltaTime) {
|
||||||
Controller.keyPressEvent.connect(function(event) {
|
Controller.keyPressEvent.connect(function(event) {
|
||||||
if (event.text == "SPACE" && !movingWithHead) {
|
if (event.text == "SPACE" && !movingWithHead) {
|
||||||
movingWithHead = true;
|
movingWithHead = true;
|
||||||
headStartPosition = Vec3.subtract(MyAvatar.getHeadPosition(), MyAvatar.position);
|
Vec3.print("getNeckPosition() = ", MyAvatar.getNeckPosition());
|
||||||
|
headStartPosition = Vec3.subtract(MyAvatar.getNeckPosition(), MyAvatar.position);
|
||||||
|
//headStartPosition = Vec3.multiplyQbyV(Quat.inverse(MyAvatar.orientation), headStartPosition);
|
||||||
|
Vec3.print("First HeadStartPosition = ", headStartPosition);
|
||||||
headStartDeltaPitch = MyAvatar.getHeadDeltaPitch();
|
headStartDeltaPitch = MyAvatar.getHeadDeltaPitch();
|
||||||
headStartFinalPitch = MyAvatar.getHeadFinalPitch();
|
headStartFinalPitch = MyAvatar.getHeadFinalPitch();
|
||||||
headStartRoll = MyAvatar.getHeadFinalRoll();
|
headStartRoll = MyAvatar.getHeadFinalRoll();
|
||||||
|
@ -138,7 +151,7 @@ Controller.keyPressEvent.connect(function(event) {
|
||||||
// start with disabled motor -- it will be updated shortly
|
// start with disabled motor -- it will be updated shortly
|
||||||
MyAvatar.motorTimescale = VERY_LARGE_TIMESCALE;
|
MyAvatar.motorTimescale = VERY_LARGE_TIMESCALE;
|
||||||
MyAvatar.motorVelocity = {x:0.0, y:0.0, z:0.0};
|
MyAvatar.motorVelocity = {x:0.0, y:0.0, z:0.0};
|
||||||
MyAvatar.motorReferenceFrame = "camera"; // alternatives are: "avatar" and "world"
|
MyAvatar.motorReferenceFrame = "avatar"; // alternatives are: "avatar" and "world"
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -97,6 +97,12 @@ glm::vec3 Avatar::getChestPosition() const {
|
||||||
return _skeletonModel.getNeckPosition(neckPosition) ? (_position + neckPosition) * 0.5f : _position;
|
return _skeletonModel.getNeckPosition(neckPosition) ? (_position + neckPosition) * 0.5f : _position;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
glm::vec3 Avatar::getNeckPosition() const {
|
||||||
|
glm::vec3 neckPosition;
|
||||||
|
return _skeletonModel.getNeckPosition(neckPosition) ? neckPosition : _position;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
glm::quat Avatar::getWorldAlignedOrientation () const {
|
glm::quat Avatar::getWorldAlignedOrientation () const {
|
||||||
return computeRotationFromBodyToWorldUp() * getOrientation();
|
return computeRotationFromBodyToWorldUp() * getOrientation();
|
||||||
}
|
}
|
||||||
|
|
|
@ -155,6 +155,8 @@ public:
|
||||||
Q_INVOKABLE void setJointModelPositionAndOrientation(const QString& name, const glm::vec3 position,
|
Q_INVOKABLE void setJointModelPositionAndOrientation(const QString& name, const glm::vec3 position,
|
||||||
const glm::quat& rotation);
|
const glm::quat& rotation);
|
||||||
|
|
||||||
|
Q_INVOKABLE glm::vec3 getNeckPosition() const;
|
||||||
|
|
||||||
Q_INVOKABLE glm::vec3 getVelocity() const { return _velocity; }
|
Q_INVOKABLE glm::vec3 getVelocity() const { return _velocity; }
|
||||||
Q_INVOKABLE glm::vec3 getAcceleration() const { return _acceleration; }
|
Q_INVOKABLE glm::vec3 getAcceleration() const { return _acceleration; }
|
||||||
Q_INVOKABLE glm::vec3 getAngularVelocity() const { return _angularVelocity; }
|
Q_INVOKABLE glm::vec3 getAngularVelocity() const { return _angularVelocity; }
|
||||||
|
|
|
@ -90,7 +90,7 @@ void Head::simulate(float deltaTime, bool isMine, bool billboard) {
|
||||||
_longTermAverageLoudness = glm::mix(_longTermAverageLoudness, _averageLoudness, glm::min(deltaTime / AUDIO_LONG_TERM_AVERAGING_SECS, 1.0f));
|
_longTermAverageLoudness = glm::mix(_longTermAverageLoudness, _averageLoudness, glm::min(deltaTime / AUDIO_LONG_TERM_AVERAGING_SECS, 1.0f));
|
||||||
}
|
}
|
||||||
float deltaLoudness = glm::max(0.0f, _averageLoudness - _longTermAverageLoudness);
|
float deltaLoudness = glm::max(0.0f, _averageLoudness - _longTermAverageLoudness);
|
||||||
qDebug() << "deltaLoudness: " << deltaLoudness;
|
//qDebug() << "deltaLoudness: " << deltaLoudness;
|
||||||
|
|
||||||
if (!(_isFaceshiftConnected || billboard)) {
|
if (!(_isFaceshiftConnected || billboard)) {
|
||||||
// Update eye saccades
|
// Update eye saccades
|
||||||
|
|
Loading…
Reference in a new issue