mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-13 04:04:59 +02:00
added the code to display the alphas for the motion blends
This commit is contained in:
parent
b9701d2b7a
commit
aa92865b21
9 changed files with 2780 additions and 4 deletions
1228
interface/resources/avatar/avatar-animation1.json
Normal file
1228
interface/resources/avatar/avatar-animation1.json
Normal file
File diff suppressed because it is too large
Load diff
1228
interface/resources/avatar/new-animation.json
Normal file
1228
interface/resources/avatar/new-animation.json
Normal file
File diff suppressed because it is too large
Load diff
|
@ -167,16 +167,15 @@ Item {
|
|||
text: "Position: " + root.position.x.toFixed(1) + ", " +
|
||||
root.position.y.toFixed(1) + ", " + root.position.z.toFixed(1)
|
||||
}
|
||||
StatText {
|
||||
text: "Animation Stack: " + root.position.x.toFixed(1) + ", " +
|
||||
root.position.y.toFixed(1) + ", " + root.position.z.toFixed(1)
|
||||
}
|
||||
StatText {
|
||||
text: "Speed: " + root.speed.toFixed(1)
|
||||
}
|
||||
StatText {
|
||||
text: "Yaw: " + root.yaw.toFixed(1)
|
||||
}
|
||||
StatText {
|
||||
text: "Animation Name: " + root.animationName + " Weight: " + root.animationWeight.toFixed(1)
|
||||
}
|
||||
StatText {
|
||||
visible: root.expanded;
|
||||
text: "Avatar Mixer In: " + root.avatarMixerInKbps + " kbps, " +
|
||||
|
|
|
@ -191,6 +191,12 @@ void Stats::updateStats(bool force) {
|
|||
|
||||
// Third column, avatar stats
|
||||
auto myAvatar = avatarManager->getMyAvatar();
|
||||
auto rigCopy = myAvatar->getSkeletonModel();
|
||||
auto forwardAlpha = rigCopy->getRig().getFwdAlpha();
|
||||
auto backwardAlpha = rigCopy->getRig().getBwdAlpha();
|
||||
auto lateralAlpha = rigCopy->getRig().getLateralAlpha();
|
||||
QString animName("anim number 1");
|
||||
|
||||
glm::vec3 avatarPos = myAvatar->getWorldPosition();
|
||||
STAT_UPDATE(position, QVector3D(avatarPos.x, avatarPos.y, avatarPos.z));
|
||||
STAT_UPDATE_FLOAT(speed, glm::length(myAvatar->getWorldVelocity()), 0.01f);
|
||||
|
@ -346,6 +352,8 @@ void Stats::updateStats(bool force) {
|
|||
auto config = qApp->getRenderEngine()->getConfiguration().get();
|
||||
STAT_UPDATE(engineFrameTime, (float) config->getCPURunTime());
|
||||
STAT_UPDATE(avatarSimulationTime, (float)avatarManager->getAvatarSimulationTime());
|
||||
STAT_UPDATE(animationWeight, (float)forwardAlpha);
|
||||
STAT_UPDATE(animationName, (QString)animName);
|
||||
|
||||
|
||||
STAT_UPDATE(gpuBuffers, (int)gpu::Context::getBufferGPUCount());
|
||||
|
|
|
@ -135,6 +135,8 @@ private: \
|
|||
* @property {number} batchFrameTime - <em>Read-only.</em>
|
||||
* @property {number} engineFrameTime - <em>Read-only.</em>
|
||||
* @property {number} avatarSimulationTime - <em>Read-only.</em>
|
||||
* @property {number} animationWeight - <em>Read-only.</em>
|
||||
* @property {number} animationName - <em>Read-only.</em>
|
||||
*
|
||||
*
|
||||
* @property {number} x
|
||||
|
@ -282,6 +284,8 @@ class Stats : public QQuickItem {
|
|||
STATS_PROPERTY(float, batchFrameTime, 0)
|
||||
STATS_PROPERTY(float, engineFrameTime, 0)
|
||||
STATS_PROPERTY(float, avatarSimulationTime, 0)
|
||||
STATS_PROPERTY(float, animationWeight, 0)
|
||||
STATS_PROPERTY(QString, animationName, QString())
|
||||
|
||||
public:
|
||||
static Stats* getInstance();
|
||||
|
@ -999,6 +1003,20 @@ signals:
|
|||
*/
|
||||
void avatarSimulationTimeChanged();
|
||||
|
||||
/**jsdoc
|
||||
* Triggered when the value of the <code>animationWeight</code> property changes.
|
||||
* @function Stats.animationWeightChanged
|
||||
* @returns {Signal}
|
||||
*/
|
||||
void animationWeightChanged();
|
||||
|
||||
/**jsdoc
|
||||
* Triggered when the value of the <code>animationName</code> property changes.
|
||||
* @function Stats.animationNameChanged
|
||||
* @returns {Signal}
|
||||
*/
|
||||
void animationNameChanged();
|
||||
|
||||
/**jsdoc
|
||||
* Triggered when the value of the <code>rectifiedTextureCount</code> property changes.
|
||||
* @function Stats.rectifiedTextureCountChanged
|
||||
|
|
|
@ -563,6 +563,7 @@ bool processStateMachineNode(AnimNode::Pointer node, const QJsonObject& jsonObj,
|
|||
|
||||
auto statesArray = statesValue.toArray();
|
||||
for (const auto& stateValue : statesArray) {
|
||||
qCDebug(animation) << " state name is " << stateValue.toString();
|
||||
if (!stateValue.isObject()) {
|
||||
qCCritical(animation) << "AnimNodeLoader, bad state object in \"states\", id =" << nodeId << ", url =" << jsonUrl.toDisplayString();
|
||||
return false;
|
||||
|
|
|
@ -672,12 +672,15 @@ void Rig::computeMotionAnimationState(float deltaTime, const glm::vec3& worldPos
|
|||
|
||||
_animVars.set("moveForwardSpeed", _averageForwardSpeed.getAverage());
|
||||
_animVars.set("moveForwardAlpha", moveForwardAlpha);
|
||||
_fwdAlpha = moveForwardAlpha;
|
||||
|
||||
_animVars.set("moveBackwardSpeed", -_averageForwardSpeed.getAverage());
|
||||
_animVars.set("moveBackwardAlpha", moveBackwardAlpha);
|
||||
_bwdAlpha = moveBackwardAlpha;
|
||||
|
||||
_animVars.set("moveLateralSpeed", fabsf(_averageLateralSpeed.getAverage()));
|
||||
_animVars.set("moveLateralAlpha", moveLateralAlpha);
|
||||
_lateralAlpha = moveLateralAlpha;
|
||||
|
||||
const float MOVE_ENTER_SPEED_THRESHOLD = 0.2f; // m/sec
|
||||
const float MOVE_EXIT_SPEED_THRESHOLD = 0.07f; // m/sec
|
||||
|
|
|
@ -218,6 +218,10 @@ public:
|
|||
// input assumed to be in rig space
|
||||
void computeHeadFromHMD(const AnimPose& hmdPose, glm::vec3& headPositionOut, glm::quat& headOrientationOut) const;
|
||||
|
||||
const float getFwdAlpha() const { return _fwdAlpha; }
|
||||
const float getBwdAlpha() const { return _bwdAlpha; }
|
||||
const float getLateralAlpha() { return _lateralAlpha; }
|
||||
|
||||
signals:
|
||||
void onLoadComplete();
|
||||
|
||||
|
@ -292,6 +296,9 @@ protected:
|
|||
std::shared_ptr<AnimSkeleton> _animSkeleton;
|
||||
std::unique_ptr<AnimNodeLoader> _animLoader;
|
||||
AnimVariantMap _animVars;
|
||||
float _fwdAlpha { 0.0f };
|
||||
float _bwdAlpha { 0.0f };
|
||||
float _lateralAlpha { 0.0f };
|
||||
enum class RigRole {
|
||||
Idle = 0,
|
||||
Turn,
|
||||
|
|
284
scripts/developer/cameraControls.js
Normal file
284
scripts/developer/cameraControls.js
Normal file
|
@ -0,0 +1,284 @@
|
|||
// JavaScript source code
|
||||
|
||||
/* Vec3, MyAvatar, Camera, Quat, Mat4, Script */
|
||||
|
||||
|
||||
var controllerMappingName;
|
||||
var controllerMapping;
|
||||
|
||||
controllerMappingName = 'Hifi-AnimationTools-Mapping';
|
||||
controllerMapping = Controller.newMapping(controllerMappingName);
|
||||
|
||||
// Camera.mode = "independent";
|
||||
Camera.orientation = Quat.lookAtSimple(Camera.position, Vec3.ZERO);
|
||||
var moveUp = false;
|
||||
var moveDown = false;
|
||||
var moveRight = false;
|
||||
var moveLeft = false;
|
||||
var moveForward = false;
|
||||
var moveBack = false;
|
||||
var rotateRight = false;
|
||||
var rotateLeft = false;
|
||||
var rotateUp = false;
|
||||
var rotateDown = false;
|
||||
var rollLeft = false;
|
||||
var rollRight = false;
|
||||
var orbitLeft = false;
|
||||
var orbitRight = false;
|
||||
var orbitUp = false;
|
||||
var orbitDown = false;
|
||||
|
||||
controllerMapping.from(Controller.Hardware.Keyboard.I).to(function (value) {
|
||||
if (value !== 0) {
|
||||
Camera.mode = "third person";
|
||||
print("camera mode is independent");
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
controllerMapping.from(Controller.Hardware.Keyboard.T).to(function (value) {
|
||||
if (value !== 0) {
|
||||
orbitUp = true;
|
||||
print("orbit the camera up");
|
||||
} else {
|
||||
orbitUp = false;
|
||||
}
|
||||
});
|
||||
|
||||
controllerMapping.from(Controller.Hardware.Keyboard.G).to(function (value) {
|
||||
if (value !== 0) {
|
||||
orbitDown = true;
|
||||
print("orbit the camera down");
|
||||
} else {
|
||||
orbitDown = false;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
controllerMapping.from(Controller.Hardware.Keyboard.V).to(function (value) {
|
||||
if (value !== 0) {
|
||||
orbitLeft = true;
|
||||
print("orbit the camera left");
|
||||
} else {
|
||||
orbitLeft = false;
|
||||
}
|
||||
});
|
||||
|
||||
controllerMapping.from(Controller.Hardware.Keyboard.B).to(function (value) {
|
||||
if (value !== 0) {
|
||||
orbitRight = true;
|
||||
print("orbit the camera right");
|
||||
} else {
|
||||
orbitRight = false;
|
||||
}
|
||||
});
|
||||
|
||||
controllerMapping.from(Controller.Hardware.Keyboard.F).to(function (value) {
|
||||
if (value !== 0) {
|
||||
rollRight = true;
|
||||
print("roll the camera right");
|
||||
} else {
|
||||
rollRight = false;
|
||||
}
|
||||
});
|
||||
|
||||
controllerMapping.from(Controller.Hardware.Keyboard.R).to(function (value) {
|
||||
if (value !== 0) {
|
||||
rollLeft = true;
|
||||
print("roll the camera left");
|
||||
} else {
|
||||
rollLeft = false;
|
||||
}
|
||||
});
|
||||
|
||||
controllerMapping.from(Controller.Hardware.Keyboard.D).to(function (value) {
|
||||
if (value !== 0) {
|
||||
rotateRight = true;
|
||||
print("rotate the camera right");
|
||||
} else {
|
||||
rotateRight = false;
|
||||
}
|
||||
});
|
||||
|
||||
controllerMapping.from(Controller.Hardware.Keyboard.E).to(function (value) {
|
||||
if (value !== 0) {
|
||||
rotateLeft = true;
|
||||
print("rotate the camera left");
|
||||
} else {
|
||||
rotateLeft = false;
|
||||
}
|
||||
});
|
||||
|
||||
controllerMapping.from(Controller.Hardware.Keyboard.W).to(function (value) {
|
||||
if (value !== 0) {
|
||||
rotateUp = true;
|
||||
print("rotate the camera up");
|
||||
} else {
|
||||
rotateUp = false;
|
||||
}
|
||||
});
|
||||
|
||||
controllerMapping.from(Controller.Hardware.Keyboard.S).to(function (value) {
|
||||
if (value !== 0) {
|
||||
rotateDown = true;
|
||||
print("rotate the camera down");
|
||||
} else {
|
||||
rotateDown = false;
|
||||
}
|
||||
});
|
||||
|
||||
controllerMapping.from(Controller.Hardware.Keyboard.U).to(function (value) {
|
||||
if (value !== 0) {
|
||||
moveForward = true;
|
||||
print("move the camera forward");
|
||||
} else {
|
||||
moveForward = false;
|
||||
}
|
||||
});
|
||||
|
||||
controllerMapping.from(Controller.Hardware.Keyboard.J).to(function (value) {
|
||||
if (value !== 0) {
|
||||
moveRight = true;
|
||||
print("move the camera right");
|
||||
} else {
|
||||
moveRight = false;
|
||||
}
|
||||
});
|
||||
|
||||
controllerMapping.from(Controller.Hardware.Keyboard.H).to(function (value) {
|
||||
if (value !== 0) {
|
||||
moveLeft = true;
|
||||
print("move the camera left");
|
||||
} else {
|
||||
moveLeft = false;
|
||||
}
|
||||
});
|
||||
|
||||
controllerMapping.from(Controller.Hardware.Keyboard.N).to(function (value) {
|
||||
if (value !== 0) {
|
||||
moveBack = true;
|
||||
print("move the camera back");
|
||||
} else {
|
||||
moveBack = false;
|
||||
}
|
||||
});
|
||||
|
||||
controllerMapping.from(Controller.Hardware.Keyboard.O).to(function (value) {
|
||||
if (value !== 0) {
|
||||
moveUp = true;
|
||||
print("move the camera up");
|
||||
} else {
|
||||
moveUp = false;
|
||||
}
|
||||
});
|
||||
|
||||
controllerMapping.from(Controller.Hardware.Keyboard.L).to(function (value) {
|
||||
if (value !== 0) {
|
||||
moveDown = true;
|
||||
print("move the camera down");
|
||||
} else {
|
||||
moveDown = false;
|
||||
}
|
||||
});
|
||||
|
||||
Controller.enableMapping(controllerMappingName);
|
||||
Camera.mode = "first person";
|
||||
|
||||
Script.update.connect(function (deltaTime) {
|
||||
|
||||
if (Camera.mode === "third person") {
|
||||
print("the camera position is now " + Camera.position.x + " " + Camera.position.y + " " + Camera.position.z);
|
||||
|
||||
var METERS_PER_SECOND = 1.0;
|
||||
var DEGREES_PER_SECOND = 20.0;
|
||||
var metersTraveledThisFrame = deltaTime * METERS_PER_SECOND;
|
||||
var degreesTraveledThisFrame = deltaTime * DEGREES_PER_SECOND;
|
||||
var newPosition = { x: 0, y: 0, z: 0 };
|
||||
var newOrientation = { x: 0, y: 0, z: 0, w: 1 };
|
||||
var distanceToMyAvatar = Vec3.length(Vec3.subtract(Camera.position, MyAvatar.position));
|
||||
|
||||
if (orbitLeft) {
|
||||
Camera.position = MyAvatar.position;
|
||||
newOrientation = Quat.angleAxis(degreesTraveledThisFrame, { x: 0, y: -1, z: 0 });
|
||||
Camera.orientation = Quat.multiply(newOrientation, Camera.orientation);
|
||||
newPosition = Vec3.multiply(distanceToMyAvatar, Vec3.multiplyQbyV(Camera.orientation, { x: 0, y: 0, z: 1 }));
|
||||
Camera.position = Vec3.sum(Camera.position, newPosition);
|
||||
}
|
||||
if (orbitRight) {
|
||||
Camera.position = MyAvatar.position;
|
||||
newOrientation = Quat.angleAxis(degreesTraveledThisFrame, { x: 0, y: 1, z: 0 });
|
||||
Camera.orientation = Quat.multiply(newOrientation, Camera.orientation);
|
||||
newPosition = Vec3.multiply(distanceToMyAvatar, Vec3.multiplyQbyV(Camera.orientation, { x: 0, y: 0, z: 1 }));
|
||||
Camera.position = Vec3.sum(Camera.position, newPosition);
|
||||
}
|
||||
|
||||
if (orbitUp) {
|
||||
Camera.position = MyAvatar.position;
|
||||
newOrientation = Quat.angleAxis(degreesTraveledThisFrame, { x: -1, y: 0, z: 0 });
|
||||
Camera.orientation = Quat.multiply(Camera.orientation, newOrientation);
|
||||
newPosition = Vec3.multiply(distanceToMyAvatar, Vec3.multiplyQbyV(Camera.orientation, { x: 0, y: 0, z: 1 }));
|
||||
Camera.position = Vec3.sum(Camera.position, newPosition);
|
||||
}
|
||||
if (orbitDown) {
|
||||
Camera.position = MyAvatar.position;
|
||||
newOrientation = Quat.angleAxis(degreesTraveledThisFrame, { x: 1, y: 0, z: 0 });
|
||||
Camera.orientation = Quat.multiply(Camera.orientation, newOrientation);
|
||||
newPosition = Vec3.multiply(distanceToMyAvatar, Vec3.multiplyQbyV(Camera.orientation, { x: 0, y: 0, z: 1 }));
|
||||
Camera.position = Vec3.sum(Camera.position, newPosition);
|
||||
}
|
||||
|
||||
if (rotateLeft) {
|
||||
newOrientation = Quat.angleAxis(degreesTraveledThisFrame, { x: 0, y: 1, z: 0 });
|
||||
Camera.orientation = Quat.multiply(Camera.orientation, newOrientation);
|
||||
}
|
||||
if (rotateRight) {
|
||||
newOrientation = Quat.angleAxis(degreesTraveledThisFrame, { x: 0, y: -1, z: 0 });
|
||||
Camera.orientation = Quat.multiply(Camera.orientation, newOrientation);
|
||||
}
|
||||
if (rollLeft) {
|
||||
newOrientation = Quat.angleAxis(degreesTraveledThisFrame, { x: 0, y: 0, z: 1 });
|
||||
Camera.orientation = Quat.multiply(Camera.orientation, newOrientation);
|
||||
}
|
||||
if (rollRight) {
|
||||
newOrientation = Quat.angleAxis(degreesTraveledThisFrame, { x: 0, y: 0, z: -1 });
|
||||
Camera.orientation = Quat.multiply(Camera.orientation, newOrientation);
|
||||
}
|
||||
|
||||
if (rotateUp) {
|
||||
newOrientation = Quat.angleAxis(degreesTraveledThisFrame, { x: 1, y: 0, z: 0 });
|
||||
Camera.orientation = Quat.multiply(Camera.orientation, newOrientation);
|
||||
}
|
||||
if (rotateDown) {
|
||||
newOrientation = Quat.angleAxis(degreesTraveledThisFrame, { x: -1, y: 0, z: 0 });
|
||||
Camera.orientation = Quat.multiply(Camera.orientation, newOrientation);
|
||||
}
|
||||
if (moveForward) {
|
||||
newPosition = Vec3.multiply(metersTraveledThisFrame, Vec3.multiplyQbyV(Camera.orientation, { x: 0, y: 0, z: -1 }));
|
||||
Camera.position = Vec3.sum(Camera.position, newPosition);
|
||||
}
|
||||
if (moveBack) {
|
||||
newPosition = Vec3.multiply(metersTraveledThisFrame, Vec3.multiplyQbyV(Camera.orientation, { x: 0, y: 0, z: 1 }));
|
||||
Camera.position = Vec3.sum(Camera.position, newPosition);
|
||||
}
|
||||
if (moveLeft) {
|
||||
newPosition = Vec3.multiply(metersTraveledThisFrame, Vec3.multiplyQbyV(Camera.orientation, { x: -1, y: 0, z: 0 }));
|
||||
Camera.position = Vec3.sum(Camera.position, newPosition);
|
||||
}
|
||||
if (moveRight) {
|
||||
newPosition = Vec3.multiply(metersTraveledThisFrame, Vec3.multiplyQbyV(Camera.orientation, { x: 1, y: 0, z: 0 }));
|
||||
Camera.position = Vec3.sum(Camera.position, newPosition);
|
||||
}
|
||||
if (moveUp) {
|
||||
newPosition = Vec3.multiply(metersTraveledThisFrame, Vec3.multiplyQbyV(Camera.orientation, { x: 0, y: 1, z: 0 }));
|
||||
Camera.position = Vec3.sum(Camera.position, newPosition);
|
||||
}
|
||||
if (moveDown) {
|
||||
newPosition = Vec3.multiply(metersTraveledThisFrame, Vec3.multiplyQbyV(Camera.orientation, { x: 0, y: -1, z: 0 }));
|
||||
Camera.position = Vec3.sum(Camera.position, newPosition);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Script.scriptEnding.connect(function () {
|
||||
Controller.disableMapping(controllerMappingName);
|
||||
});// JavaScript source code
|
Loading…
Reference in a new issue