mirror of
https://github.com/overte-org/overte.git
synced 2025-08-07 03:50:16 +02:00
adding tool to change avatar inputs properties
This commit is contained in:
parent
584fa1f17b
commit
554a144b0e
2 changed files with 138 additions and 75 deletions
|
@ -55,6 +55,7 @@ Rectangle {
|
||||||
top: title.bottom
|
top: title.bottom
|
||||||
topMargin: 50
|
topMargin: 50
|
||||||
left: parent.left
|
left: parent.left
|
||||||
|
leftMargin: 20
|
||||||
}
|
}
|
||||||
label: "X OFFSET"
|
label: "X OFFSET"
|
||||||
maximumValue: 1.0
|
maximumValue: 1.0
|
||||||
|
@ -76,6 +77,7 @@ Rectangle {
|
||||||
top: xSlider.bottom
|
top: xSlider.bottom
|
||||||
topMargin: 50
|
topMargin: 50
|
||||||
left: parent.left
|
left: parent.left
|
||||||
|
leftMargin: 20
|
||||||
}
|
}
|
||||||
label: "Y OFFSET"
|
label: "Y OFFSET"
|
||||||
maximumValue: 1.0
|
maximumValue: 1.0
|
||||||
|
@ -92,12 +94,14 @@ Rectangle {
|
||||||
}
|
}
|
||||||
|
|
||||||
HifiControlsUit.Slider {
|
HifiControlsUit.Slider {
|
||||||
|
id: zSlider
|
||||||
anchors {
|
anchors {
|
||||||
top: ySlider.bottom
|
top: ySlider.bottom
|
||||||
topMargin: 50
|
topMargin: 50
|
||||||
left: parent.left
|
left: parent.left
|
||||||
|
leftMargin: 20
|
||||||
}
|
}
|
||||||
label: "Y OFFSET"
|
label: "Z OFFSET"
|
||||||
maximumValue: 0.0
|
maximumValue: 0.0
|
||||||
minimumValue: -1.0
|
minimumValue: -1.0
|
||||||
stepSize: 0.05
|
stepSize: 0.05
|
||||||
|
@ -112,9 +116,39 @@ Rectangle {
|
||||||
}
|
}
|
||||||
|
|
||||||
HifiControlsUit.Button {
|
HifiControlsUit.Button {
|
||||||
id: setVisibleButton
|
id: setVisibleButton;
|
||||||
|
text: setVisible ? "SET INVISIBLE" : "SET VISIBLE";
|
||||||
|
width: 300;
|
||||||
|
property bool setVisible: true;
|
||||||
|
anchors {
|
||||||
|
top: zSlider.bottom
|
||||||
|
topMargin: 50
|
||||||
|
left: parent.left
|
||||||
|
leftMargin: 20
|
||||||
|
}
|
||||||
|
onClicked: {
|
||||||
|
setVisible = !setVisible;
|
||||||
|
emitSendToScript({
|
||||||
|
"method": "setVisible",
|
||||||
|
"visible": setVisible
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
HifiControlsUit.Button {
|
HifiControlsUit.Button {
|
||||||
|
id: printButton;
|
||||||
|
text: "PRINT POSITIONS";
|
||||||
|
width: 300;
|
||||||
|
anchors {
|
||||||
|
top: setVisibleButton.bottom
|
||||||
|
topMargin: 50
|
||||||
|
left: parent.left
|
||||||
|
leftMargin: 20
|
||||||
|
}
|
||||||
|
onClicked: {
|
||||||
|
emitSendToScript({
|
||||||
|
"method": "print",
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,98 +5,127 @@
|
||||||
|
|
||||||
var ui;
|
var ui;
|
||||||
|
|
||||||
var button;
|
|
||||||
var buttonName = "AVBAR";
|
|
||||||
var onCreateAvatarInputsBarEntity = false;
|
var onCreateAvatarInputsBarEntity = false;
|
||||||
var micBarEntity, bubbleIconEntity;
|
var micBarEntity, bubbleIconEntity;
|
||||||
var tablet = Tablet.getTablet("com.highfidelity.interface.tablet.system");
|
var tablet = Tablet.getTablet("com.highfidelity.interface.tablet.system");
|
||||||
var AVATAR_INPUTS_EDIT_QML_SOURCE = "hifi/EditAvatarInputsBar.qml";
|
var AVATAR_INPUTS_EDIT_QML_SOURCE = "hifi/EditAvatarInputsBar.qml";
|
||||||
|
|
||||||
function fromQml(message) {
|
// QML NATURAL DIMENSIONS
|
||||||
print("message from QML: " + JSON.stringify(message));
|
var MIC_BAR_DIMENSIONS = {x: 0.036, y: 0.048, z: 0.3};
|
||||||
};
|
var BUBBLE_ICON_DIMENSIONS = {x: 0.036, y: 0.036, z: 0.3};
|
||||||
|
// CONSTANTS
|
||||||
|
var LOCAL_POSITION_X_OFFSET = -0.2;
|
||||||
|
var LOCAL_POSITION_Y_OFFSET = -0.125;
|
||||||
|
var LOCAL_POSITION_Z_OFFSET = -0.5;
|
||||||
|
|
||||||
function onClicked(){
|
function fromQml(message) {
|
||||||
onCreateAvatarInputsBarEntity = !onCreateAvatarInputsBarEntity;
|
if (message.method === "reposition") {
|
||||||
button.editProperties({isActive: onCreateAvatarInputsBarEntity});
|
var micBarLocalPosition = Entities.getEntityProperties(micBarEntity).localPosition;
|
||||||
// QML NATURAL DIMENSIONS
|
var bubbleIconLocalPosition = Entities.getEntityProperties(bubbleIconEntity).localPosition;
|
||||||
var MIC_BAR_DIMENSIONS = {x: 0.036, y: 0.048, z: 0.3};
|
var newMicBarLocalPosition, newBubbleIconLocalPosition;
|
||||||
var BUBBLE_ICON_DIMENSIONS = {x: 0.036, y: 0.036, z: 0.3};
|
if (message.x !== undefined) {
|
||||||
// CONSTANTS
|
newMicBarLocalPosition = { x: -((MIC_BAR_DIMENSIONS.x) / 2) - message.x, y: micBarLocalPosition.y, z: micBarLocalPosition.z };
|
||||||
var LOCAL_POSITION_X_OFFSET = -0.2;
|
newBubbleIconLocalPosition = { x: ((MIC_BAR_DIMENSIONS.x) * 1.2 / 2) - message.x, y: bubbleIconLocalPosition.y, z: bubbleIconLocalPosition.z };
|
||||||
var LOCAL_POSITION_Y_OFFSET = -0.125;
|
} else if (message.y !== undefined) {
|
||||||
var LOCAL_POSITION_Z_OFFSET = -0.5;
|
newMicBarLocalPosition = { x: micBarLocalPosition.x, y: message.y, z: micBarLocalPosition.z };
|
||||||
// POSITIONS
|
newBubbleIconLocalPosition = { x: bubbleIconLocalPosition.x, y: ((MIC_BAR_DIMENSIONS.y - BUBBLE_ICON_DIMENSIONS.y) / 2 + message.y), z: bubbleIconLocalPosition.z };
|
||||||
var micBarLocalPosition = {x: (-(MIC_BAR_DIMENSIONS.x / 2)) + LOCAL_POSITION_X_OFFSET, y: LOCAL_POSITION_Y_OFFSET, z: LOCAL_POSITION_Z_OFFSET};
|
} else if (message.z !== undefined) {
|
||||||
var bubbleIconLocalPosition = {x: (MIC_BAR_DIMENSIONS.x * 1.2 / 2) + LOCAL_POSITION_X_OFFSET, y: ((MIC_BAR_DIMENSIONS.y - BUBBLE_ICON_DIMENSIONS.y) / 2 + LOCAL_POSITION_Y_OFFSET), z: LOCAL_POSITION_Z_OFFSET};
|
newMicBarLocalPosition = { x: micBarLocalPosition.x, y: micBarLocalPosition.y, z: message.z };
|
||||||
if (onCreateAvatarInputsBarEntity) {
|
newBubbleIconLocalPosition = { x: bubbleIconLocalPosition.x, y: bubbleIconLocalPosition.y, z: message.z };
|
||||||
var props = {
|
}
|
||||||
type: "Web",
|
var micBarProps = {
|
||||||
name: "AvatarInputsMicBarEntity",
|
localPosition: newMicBarLocalPosition
|
||||||
parentID: MyAvatar.SELF_ID,
|
|
||||||
parentJointIndex: MyAvatar.getJointIndex("_CAMERA_MATRIX"),
|
|
||||||
localPosition: micBarLocalPosition,
|
|
||||||
localRotation: Quat.cancelOutRollAndPitch(Quat.lookAtSimple(Camera.orientation, micBarLocalPosition)),
|
|
||||||
sourceUrl: Script.resourcesPath() + "qml/hifi/audio/MicBarApplication.qml",
|
|
||||||
// cutoff alpha for detecting transparency
|
|
||||||
alpha: 0.98,
|
|
||||||
dimensions: MIC_BAR_DIMENSIONS,
|
|
||||||
drawInFront: true,
|
|
||||||
userData: {
|
|
||||||
grabbable: false
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
micBarEntity = Entities.addEntity(props, "local");
|
var bubbleIconProps = {
|
||||||
var props = {
|
localPosition: newBubbleIconLocalPosition
|
||||||
type: "Web",
|
|
||||||
name: "AvatarInputsBubbleIconEntity",
|
|
||||||
parentID: MyAvatar.SELF_ID,
|
|
||||||
parentJointIndex: MyAvatar.getJointIndex("_CAMERA_MATRIX"),
|
|
||||||
localPosition: bubbleIconLocalPosition,
|
|
||||||
localRotation: Quat.cancelOutRollAndPitch(Quat.lookAtSimple(Camera.orientation, bubbleIconLocalPosition)),
|
|
||||||
sourceUrl: Script.resourcesPath() + "qml/BubbleIcon.qml",
|
|
||||||
// cutoff alpha for detecting transparency
|
|
||||||
alpha: 0.98,
|
|
||||||
dimensions: BUBBLE_ICON_DIMENSIONS,
|
|
||||||
drawInFront: true,
|
|
||||||
userData: {
|
|
||||||
grabbable: false
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
bubbleIconEntity = Entities.addEntity(props, "local");
|
|
||||||
tablet.loadQMLSource(AVATAR_INPUTS_EDIT_QML_SOURCE);
|
Entities.editEntity(micBarEntity, micBarProps);
|
||||||
} else {
|
Entities.editEntity(bubbleIconEntity, bubbleIconProps);
|
||||||
|
} else if (message.method === "setVisible") {
|
||||||
|
if (message.visible !== undefined) {
|
||||||
|
var props = {
|
||||||
|
visible: message.visible
|
||||||
|
};
|
||||||
|
Entities.editEntity(micBarEntity, props);
|
||||||
|
Entities.editEntity(bubbleIconEntity, props);
|
||||||
|
}
|
||||||
|
} else if (message.method === "print") {
|
||||||
|
// prints the local position into the hifi log.
|
||||||
|
var micBarLocalPosition = Entities.getEntityProperties(micBarEntity).localPosition;
|
||||||
|
var bubbleIconLocalPosition = Entities.getEntityProperties(bubbleIconEntity).localPosition;
|
||||||
|
console.log("mic bar local position is at " + JSON.stringify(micBarLocalPosition));
|
||||||
|
console.log("bubble icon local position is at " + JSON.stringify(bubbleIconLocalPosition));
|
||||||
|
} else if (message.method === "destroy") {
|
||||||
|
console.log("destroying");
|
||||||
Entities.deleteEntity(micBarEntity);
|
Entities.deleteEntity(micBarEntity);
|
||||||
Entities.deleteEntity(bubbleIconEntity);
|
Entities.deleteEntity(bubbleIconEntity);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
function setup() {
|
function createEntities(){
|
||||||
// button = tablet.addButton({
|
// POSITIONS
|
||||||
// icon: "icons/tablet-icons/edit-i.svg",
|
var micBarLocalPosition = {x: (-(MIC_BAR_DIMENSIONS.x / 2)) + LOCAL_POSITION_X_OFFSET, y: LOCAL_POSITION_Y_OFFSET, z: LOCAL_POSITION_Z_OFFSET};
|
||||||
// activeIcon: "icons/tablet-icons/edit-a.svg",
|
var bubbleIconLocalPosition = {x: (MIC_BAR_DIMENSIONS.x * 1.2 / 2) + LOCAL_POSITION_X_OFFSET, y: ((MIC_BAR_DIMENSIONS.y - BUBBLE_ICON_DIMENSIONS.y) / 2 + LOCAL_POSITION_Y_OFFSET), z: LOCAL_POSITION_Z_OFFSET};
|
||||||
// text: buttonName
|
var props = {
|
||||||
// });
|
type: "Web",
|
||||||
ui = new AppUi({
|
name: "AvatarInputsMicBarEntity",
|
||||||
buttonName: "AVBAR",
|
parentID: MyAvatar.SELF_ID,
|
||||||
home: Script.resourcesPath() + "qml/hifi/EditAvatarInputsBar.qml",
|
parentJointIndex: MyAvatar.getJointIndex("_CAMERA_MATRIX"),
|
||||||
onMessage: fromQml,
|
localPosition: micBarLocalPosition,
|
||||||
// normalButton: "icons/tablet-icons/avatar-i.svg",
|
localRotation: Quat.cancelOutRollAndPitch(Quat.lookAtSimple(Camera.orientation, micBarLocalPosition)),
|
||||||
// activeButton: "icons/tablet-icons/avatar-a.svg",
|
sourceUrl: Script.resourcesPath() + "qml/hifi/audio/MicBarApplication.qml",
|
||||||
});
|
// cutoff alpha for detecting transparency
|
||||||
button.clicked.connect(onClicked);
|
alpha: 0.98,
|
||||||
|
dimensions: MIC_BAR_DIMENSIONS,
|
||||||
|
drawInFront: true,
|
||||||
|
userData: {
|
||||||
|
grabbable: false
|
||||||
|
},
|
||||||
|
};
|
||||||
|
micBarEntity = Entities.addEntity(props, "local");
|
||||||
|
var props = {
|
||||||
|
type: "Web",
|
||||||
|
name: "AvatarInputsBubbleIconEntity",
|
||||||
|
parentID: MyAvatar.SELF_ID,
|
||||||
|
parentJointIndex: MyAvatar.getJointIndex("_CAMERA_MATRIX"),
|
||||||
|
localPosition: bubbleIconLocalPosition,
|
||||||
|
localRotation: Quat.cancelOutRollAndPitch(Quat.lookAtSimple(Camera.orientation, bubbleIconLocalPosition)),
|
||||||
|
sourceUrl: Script.resourcesPath() + "qml/BubbleIcon.qml",
|
||||||
|
// cutoff alpha for detecting transparency
|
||||||
|
alpha: 0.98,
|
||||||
|
dimensions: BUBBLE_ICON_DIMENSIONS,
|
||||||
|
drawInFront: true,
|
||||||
|
userData: {
|
||||||
|
grabbable: false
|
||||||
|
},
|
||||||
|
};
|
||||||
|
bubbleIconEntity = Entities.addEntity(props, "local");
|
||||||
|
tablet.loadQMLSource(AVATAR_INPUTS_EDIT_QML_SOURCE);
|
||||||
};
|
};
|
||||||
|
function cleanup() {
|
||||||
setup();
|
|
||||||
|
|
||||||
Script.scriptEnding.connect(function() {
|
|
||||||
if (micBarEntity) {
|
if (micBarEntity) {
|
||||||
Entities.deleteEntity(micBarEntity);
|
Entities.deleteEntity(micBarEntity);
|
||||||
}
|
}
|
||||||
if (bubbleIconEntity) {
|
if (bubbleIconEntity) {
|
||||||
Entities.deleteEntity(bubbleIconEntity);
|
Entities.deleteEntity(bubbleIconEntity);
|
||||||
}
|
}
|
||||||
tablet.removeButton(button);
|
};
|
||||||
});
|
|
||||||
|
function setup() {
|
||||||
|
ui = new AppUi({
|
||||||
|
buttonName: "AVBAR",
|
||||||
|
home: Script.resourcesPath() + "qml/hifi/EditAvatarInputsBar.qml",
|
||||||
|
onMessage: fromQml,
|
||||||
|
onOpened: createEntities,
|
||||||
|
onClosed: cleanup,
|
||||||
|
// normalButton: "icons/tablet-icons/avatar-i.svg",
|
||||||
|
// activeButton: "icons/tablet-icons/avatar-a.svg",
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
setup();
|
||||||
|
|
||||||
|
Script.scriptEnding.connect(cleanup);
|
||||||
|
|
||||||
}());
|
}());
|
||||||
|
|
Loading…
Reference in a new issue