mirror of
https://github.com/overte-org/overte.git
synced 2025-04-20 04:44:11 +02:00
grab.js rotation sort-of works now
This commit is contained in:
parent
42f94307d5
commit
ccb2f17b33
4 changed files with 15 additions and 14 deletions
|
@ -60,7 +60,7 @@ var gMouseAtRotateStart = { x: 0, y: 0 };
|
|||
|
||||
var gBeaconHeight = 0.10;
|
||||
|
||||
var gAngularVelocity = ZERO_VEC3;
|
||||
// var gAngularVelocity = ZERO_VEC3;
|
||||
|
||||
// TODO: play sounds again when we aren't leaking AudioInjector threads
|
||||
// var grabSound = SoundCache.getSound("https://hifi-public.s3.amazonaws.com/eric/sounds/CloseClamp.wav");
|
||||
|
@ -194,7 +194,6 @@ function mousePressEvent(event) {
|
|||
var cameraPosition = Camera.getPosition();
|
||||
|
||||
gBeaconHeight = Vec3.length(entityProperties.dimensions);
|
||||
print("gBeaconHeight = " + gBeaconHeight);
|
||||
gMaxGrabDistance = gBeaconHeight / MAX_SOLID_ANGLE;
|
||||
if (Vec3.distance(objectPosition, cameraPosition) > gMaxGrabDistance) {
|
||||
// don't allow grabs of things far away
|
||||
|
@ -254,7 +253,7 @@ function mouseMoveEvent(event) {
|
|||
gOriginalGravity = entityProperties.gravity;
|
||||
}
|
||||
|
||||
var actionArgs;
|
||||
var actionArgs = {};
|
||||
|
||||
if (gGrabMode === "rotate") {
|
||||
var deltaMouse = { x: 0, y: 0 };
|
||||
|
@ -265,12 +264,13 @@ function mouseMoveEvent(event) {
|
|||
var dragOffset = Vec3.multiply(dx, Quat.getRight(orientation));
|
||||
dragOffset = Vec3.sum(dragOffset, Vec3.multiply(-dy, Quat.getUp(orientation)));
|
||||
var axis = Vec3.cross(dragOffset, Quat.getFront(orientation));
|
||||
// var axis = Vec3.normalize(axis);
|
||||
// var ROTATE_STRENGTH = 8.0; // magic number tuned by hand
|
||||
// gAngularVelocity = Vec3.multiply(ROTATE_STRENGTH, axis);
|
||||
|
||||
var targetRotation = Quat.angleAxis(Vec3.length(axis), Vec3.normalize(axis));
|
||||
actionArgs = {targetRotation: targetRotation, angularTimeScale: 1.0};
|
||||
axis = Vec3.normalize(axis);
|
||||
var ROTATE_STRENGTH = 8.0; // magic number tuned by hand
|
||||
var angle = ROTATE_STRENGTH * Math.sqrt((dx * dx) + (dy * dy));
|
||||
var deltaQ = Quat.angleAxis(angle, axis);
|
||||
var qZero = entityProperties.rotation;
|
||||
var qOne = Quat.multiply(deltaQ, qZero);
|
||||
actionArgs = {targetRotation: qOne, angularTimeScale: 0.1};
|
||||
} else {
|
||||
var newTargetPosition;
|
||||
if (gGrabMode === "verticalCylinder") {
|
||||
|
|
|
@ -131,7 +131,7 @@ glm::quat EntityActionInterface::extractQuatArgument(QString objectName, QVarian
|
|||
return glm::quat();
|
||||
}
|
||||
|
||||
return glm::quat(x, y, z, w);
|
||||
return glm::quat(w, x, y, z);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -64,8 +64,9 @@ void ObjectActionSpring::updateAction(btCollisionWorld* collisionWorld, btScalar
|
|||
glm::quat deltaQ = _rotationalTarget * qZeroInverse;
|
||||
glm::vec3 axis = glm::axis(deltaQ);
|
||||
float angle = glm::angle(deltaQ);
|
||||
glm::vec3 newAngularVelocity = (-angle / _angularTimeScale) * glm::normalize(axis);
|
||||
glm::vec3 newAngularVelocity = (angle / _angularTimeScale) * glm::normalize(axis);
|
||||
rigidBody->setAngularVelocity(glmToBullet(newAngularVelocity));
|
||||
rigidBody->activate();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -236,9 +236,9 @@ void PhysicalEntitySimulation::handleCollisionEvents(CollisionEvents& collisionE
|
|||
}
|
||||
|
||||
EntityActionPointer PhysicalEntitySimulation::actionFactory(EntityActionType type,
|
||||
QUuid id,
|
||||
EntityItemPointer ownerEntity,
|
||||
QVariantMap arguments) {
|
||||
QUuid id,
|
||||
EntityItemPointer ownerEntity,
|
||||
QVariantMap arguments) {
|
||||
EntityActionPointer action = nullptr;
|
||||
switch (type) {
|
||||
case ACTION_TYPE_NONE:
|
||||
|
|
Loading…
Reference in a new issue