mirror of
https://github.com/overte-org/overte.git
synced 2025-04-25 23:36:41 +02:00
Added rotation and scale to overlay anchers
This commit is contained in:
parent
18251d7251
commit
0edcd732fe
2 changed files with 19 additions and 3 deletions
|
@ -174,8 +174,14 @@ function controller(wichSide) {
|
||||||
}
|
}
|
||||||
|
|
||||||
this.moveLaser = function () {
|
this.moveLaser = function () {
|
||||||
var startPosition = Vec3.subtract(this.palmPosition, MyAvatar.position);
|
// the overlays here are anchored to the avatar, which means they are specified in the avatar's local frame
|
||||||
var endPosition = Vec3.sum(startPosition, Vec3.multiply(this.front, LASER_LENGTH_FACTOR));
|
|
||||||
|
var inverseRotation = Quat.inverse(MyAvatar.orientation);
|
||||||
|
var startPosition = Vec3.multiplyQbyV(inverseRotation, Vec3.subtract(this.palmPosition, MyAvatar.position));
|
||||||
|
var direction = Vec3.multiplyQbyV(inverseRotation, Vec3.subtract(this.tipPosition, this.palmPosition));
|
||||||
|
var distance = Vec3.length(direction);
|
||||||
|
direction = Vec3.multiply(direction, LASER_LENGTH_FACTOR / distance);
|
||||||
|
var endPosition = Vec3.sum(startPosition, direction);
|
||||||
|
|
||||||
Overlays.editOverlay(this.laser, {
|
Overlays.editOverlay(this.laser, {
|
||||||
position: startPosition,
|
position: startPosition,
|
||||||
|
|
|
@ -58,13 +58,23 @@ void Overlays::render2D() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Overlays::render3D() {
|
void Overlays::render3D() {
|
||||||
glm::vec3 myAvatarPosition = Application::getInstance()->getAvatar()->getPosition();
|
if (_overlays3D.size() == 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
MyAvatar* avatar = Application::getInstance()->getAvatar();
|
||||||
|
glm::quat myAvatarRotation = avatar->getOrientation();
|
||||||
|
glm::vec3 myAvatarPosition = avatar->getPosition();
|
||||||
|
float angle = glm::degrees(glm::angle(myAvatarRotation));
|
||||||
|
glm::vec3 axis = glm::axis(myAvatarRotation);
|
||||||
|
float myAvatarScale = avatar->getScale();
|
||||||
|
|
||||||
foreach(Overlay* thisOverlay, _overlays3D) {
|
foreach(Overlay* thisOverlay, _overlays3D) {
|
||||||
glPushMatrix();
|
glPushMatrix();
|
||||||
switch (thisOverlay->getAnchor()) {
|
switch (thisOverlay->getAnchor()) {
|
||||||
case Overlay::MY_AVATAR:
|
case Overlay::MY_AVATAR:
|
||||||
glTranslatef(myAvatarPosition.x, myAvatarPosition.y, myAvatarPosition.z);
|
glTranslatef(myAvatarPosition.x, myAvatarPosition.y, myAvatarPosition.z);
|
||||||
|
glRotatef(angle, axis.x, axis.y, axis.z);
|
||||||
|
glScalef(myAvatarScale, myAvatarScale, myAvatarScale);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in a new issue