mirror of
https://github.com/JulianGro/overte.git
synced 2025-08-06 18:35:50 +02:00
Merge pull request #3042 from ZappoMan/editModelFeatures
add support for changing the model URL of a model
This commit is contained in:
commit
7597191081
4 changed files with 83 additions and 11 deletions
|
@ -717,8 +717,8 @@ function rayPlaneIntersection(pickRay, point, normal) {
|
||||||
function Tooltip() {
|
function Tooltip() {
|
||||||
this.x = 285;
|
this.x = 285;
|
||||||
this.y = 115;
|
this.y = 115;
|
||||||
this.width = 110;
|
this.width = 500;
|
||||||
this.height = 115 ;
|
this.height = 145 ;
|
||||||
this.margin = 5;
|
this.margin = 5;
|
||||||
this.decimals = 3;
|
this.decimals = 3;
|
||||||
|
|
||||||
|
@ -746,6 +746,9 @@ function Tooltip() {
|
||||||
text += "yaw: " + angles.y.toFixed(this.decimals) + "\n"
|
text += "yaw: " + angles.y.toFixed(this.decimals) + "\n"
|
||||||
text += "roll: " + angles.z.toFixed(this.decimals) + "\n"
|
text += "roll: " + angles.z.toFixed(this.decimals) + "\n"
|
||||||
text += "Scale: " + 2 * properties.radius.toFixed(this.decimals) + "\n"
|
text += "Scale: " + 2 * properties.radius.toFixed(this.decimals) + "\n"
|
||||||
|
text += "ID: " + properties.id + "\n"
|
||||||
|
text += "model url: " + properties.modelURL + "\n"
|
||||||
|
text += "animation url: " + properties.animationURL + "\n"
|
||||||
|
|
||||||
Overlays.editOverlay(this.textOverlay, { text: text });
|
Overlays.editOverlay(this.textOverlay, { text: text });
|
||||||
}
|
}
|
||||||
|
@ -1019,9 +1022,11 @@ var modelMenuAddedDelete = false;
|
||||||
function setupModelMenus() {
|
function setupModelMenus() {
|
||||||
print("setupModelMenus()");
|
print("setupModelMenus()");
|
||||||
// add our menuitems
|
// add our menuitems
|
||||||
|
Menu.addMenuItem({ menuName: "Edit", menuItemName: "Models", isSeparator: true, beforeItem: "Physics" });
|
||||||
|
Menu.addMenuItem({ menuName: "Edit", menuItemName: "Edit Properties...",
|
||||||
|
shortcutKeyEvent: { text: "`" }, afterItem: "Models" });
|
||||||
if (!Menu.menuItemExists("Edit","Delete")) {
|
if (!Menu.menuItemExists("Edit","Delete")) {
|
||||||
print("no delete... adding ours");
|
print("no delete... adding ours");
|
||||||
Menu.addMenuItem({ menuName: "Edit", menuItemName: "Models", isSeparator: true, beforeItem: "Physics" });
|
|
||||||
Menu.addMenuItem({ menuName: "Edit", menuItemName: "Delete",
|
Menu.addMenuItem({ menuName: "Edit", menuItemName: "Delete",
|
||||||
shortcutKeyEvent: { text: "backspace" }, afterItem: "Models" });
|
shortcutKeyEvent: { text: "backspace" }, afterItem: "Models" });
|
||||||
modelMenuAddedDelete = true;
|
modelMenuAddedDelete = true;
|
||||||
|
@ -1031,9 +1036,10 @@ function setupModelMenus() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function cleanupModelMenus() {
|
function cleanupModelMenus() {
|
||||||
|
Menu.removeSeparator("Edit", "Models");
|
||||||
|
Menu.removeMenuItem("Edit", "Edit Properties...");
|
||||||
if (modelMenuAddedDelete) {
|
if (modelMenuAddedDelete) {
|
||||||
// delete our menuitems
|
// delete our menuitems
|
||||||
Menu.removeSeparator("Edit", "Models");
|
|
||||||
Menu.removeMenuItem("Edit", "Delete");
|
Menu.removeMenuItem("Edit", "Delete");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1054,7 +1060,8 @@ Controller.mouseMoveEvent.connect(mouseMoveEvent);
|
||||||
Controller.mouseReleaseEvent.connect(mouseReleaseEvent);
|
Controller.mouseReleaseEvent.connect(mouseReleaseEvent);
|
||||||
|
|
||||||
setupModelMenus();
|
setupModelMenus();
|
||||||
Menu.menuItemEvent.connect(function(menuItem){
|
|
||||||
|
function handeMenuEvent(menuItem){
|
||||||
print("menuItemEvent() in JS... menuItem=" + menuItem);
|
print("menuItemEvent() in JS... menuItem=" + menuItem);
|
||||||
if (menuItem == "Delete") {
|
if (menuItem == "Delete") {
|
||||||
if (leftController.grabbing) {
|
if (leftController.grabbing) {
|
||||||
|
@ -1072,8 +1079,36 @@ Menu.menuItemEvent.connect(function(menuItem){
|
||||||
} else {
|
} else {
|
||||||
print(" Delete Model.... not holding...");
|
print(" Delete Model.... not holding...");
|
||||||
}
|
}
|
||||||
|
} else if (menuItem == "Edit Properties...") {
|
||||||
|
var editModelID = -1;
|
||||||
|
if (leftController.grabbing) {
|
||||||
|
print(" Edit Properties.... leftController.modelID="+ leftController.modelID);
|
||||||
|
editModelID = leftController.modelID;
|
||||||
|
} else if (rightController.grabbing) {
|
||||||
|
print(" Edit Properties.... rightController.modelID="+ rightController.modelID);
|
||||||
|
editModelID = rightController.modelID;
|
||||||
|
} else if (modelSelected) {
|
||||||
|
print(" Edit Properties.... selectedModelID="+ selectedModelID);
|
||||||
|
editModelID = selectedModelID;
|
||||||
|
} else {
|
||||||
|
print(" Edit Properties.... not holding...");
|
||||||
|
}
|
||||||
|
if (editModelID != -1) {
|
||||||
|
print(" Edit Properties.... about to edit properties...");
|
||||||
|
var propertyName = Window.prompt("Which property would you like to change?", "modelURL");
|
||||||
|
var properties = Models.getModelProperties(editModelID);
|
||||||
|
var oldValue = properties[propertyName];
|
||||||
|
var newValue = Window.prompt("New value for: " + propertyName, oldValue);
|
||||||
|
if (newValue != NULL) {
|
||||||
|
properties[propertyName] = newValue;
|
||||||
|
Models.editModel(editModelID, properties);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
tooltip.show(false);
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
|
Menu.menuItemEvent.connect(handeMenuEvent);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// handling of inspect.js concurrence
|
// handling of inspect.js concurrence
|
||||||
|
@ -1107,4 +1142,11 @@ Controller.keyReleaseEvent.connect(function(event) {
|
||||||
xIsPressed = false;
|
xIsPressed = false;
|
||||||
somethingChanged = true;
|
somethingChanged = true;
|
||||||
}
|
}
|
||||||
|
// since sometimes our menu shortcut keys don't work, trap our menu items here also and fire the appropriate menu items
|
||||||
|
if (event.text == "`") {
|
||||||
|
handeMenuEvent("Edit Properties...");
|
||||||
|
}
|
||||||
|
if (event.text == "BACKSPACE") {
|
||||||
|
handeMenuEvent("Delete");
|
||||||
|
}
|
||||||
});
|
});
|
|
@ -22,6 +22,17 @@ ModelTreeRenderer::ModelTreeRenderer() :
|
||||||
}
|
}
|
||||||
|
|
||||||
ModelTreeRenderer::~ModelTreeRenderer() {
|
ModelTreeRenderer::~ModelTreeRenderer() {
|
||||||
|
clearModelsCache();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ModelTreeRenderer::clear() {
|
||||||
|
OctreeRenderer::clear();
|
||||||
|
clearModelsCache();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ModelTreeRenderer::clearModelsCache() {
|
||||||
|
qDebug() << "ModelTreeRenderer::clearModelsCache()...";
|
||||||
|
|
||||||
// delete the models in _knownModelsItemModels
|
// delete the models in _knownModelsItemModels
|
||||||
foreach(Model* model, _knownModelsItemModels) {
|
foreach(Model* model, _knownModelsItemModels) {
|
||||||
delete model;
|
delete model;
|
||||||
|
@ -71,24 +82,39 @@ Model* ModelTreeRenderer::getModel(const ModelItem& modelItem) {
|
||||||
if (modelItem.isKnownID()) {
|
if (modelItem.isKnownID()) {
|
||||||
if (_knownModelsItemModels.find(modelItem.getID()) != _knownModelsItemModels.end()) {
|
if (_knownModelsItemModels.find(modelItem.getID()) != _knownModelsItemModels.end()) {
|
||||||
model = _knownModelsItemModels[modelItem.getID()];
|
model = _knownModelsItemModels[modelItem.getID()];
|
||||||
} else {
|
if (QUrl(modelItem.getModelURL()) != model->getURL()) {
|
||||||
|
delete model; // delete the old model...
|
||||||
|
model = NULL;
|
||||||
|
_knownModelsItemModels.remove(modelItem.getID());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// if we don't have a model...
|
||||||
|
if (!model) {
|
||||||
// Make sure we only create new models on the thread that owns the ModelTreeRenderer
|
// Make sure we only create new models on the thread that owns the ModelTreeRenderer
|
||||||
if (QThread::currentThread() != thread()) {
|
if (QThread::currentThread() != thread()) {
|
||||||
QMetaObject::invokeMethod(this, "getModel", Qt::BlockingQueuedConnection,
|
QMetaObject::invokeMethod(this, "getModel", Qt::BlockingQueuedConnection,
|
||||||
Q_RETURN_ARG(Model*, model), Q_ARG(const ModelItem&, modelItem));
|
Q_RETURN_ARG(Model*, model), Q_ARG(const ModelItem&, modelItem));
|
||||||
return model;
|
return model;
|
||||||
}
|
}
|
||||||
|
|
||||||
model = new Model();
|
model = new Model();
|
||||||
model->init();
|
model->init();
|
||||||
model->setURL(QUrl(modelItem.getModelURL()));
|
model->setURL(QUrl(modelItem.getModelURL()));
|
||||||
_knownModelsItemModels[modelItem.getID()] = model;
|
_knownModelsItemModels[modelItem.getID()] = model;
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
if (_unknownModelsItemModels.find(modelItem.getCreatorTokenID()) != _unknownModelsItemModels.end()) {
|
if (_unknownModelsItemModels.find(modelItem.getCreatorTokenID()) != _unknownModelsItemModels.end()) {
|
||||||
model = _unknownModelsItemModels[modelItem.getCreatorTokenID()];
|
model = _unknownModelsItemModels[modelItem.getCreatorTokenID()];
|
||||||
} else {
|
if (QUrl(modelItem.getModelURL()) != model->getURL()) {
|
||||||
|
delete model; // delete the old model...
|
||||||
|
model = NULL;
|
||||||
|
_unknownModelsItemModels.remove(modelItem.getID());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!model) {
|
||||||
// Make sure we only create new models on the thread that owns the ModelTreeRenderer
|
// Make sure we only create new models on the thread that owns the ModelTreeRenderer
|
||||||
if (QThread::currentThread() != thread()) {
|
if (QThread::currentThread() != thread()) {
|
||||||
QMetaObject::invokeMethod(this, "getModel", Qt::BlockingQueuedConnection,
|
QMetaObject::invokeMethod(this, "getModel", Qt::BlockingQueuedConnection,
|
||||||
|
|
|
@ -51,7 +51,11 @@ public:
|
||||||
|
|
||||||
virtual const FBXGeometry* getGeometryForModel(const ModelItem& modelItem);
|
virtual const FBXGeometry* getGeometryForModel(const ModelItem& modelItem);
|
||||||
|
|
||||||
|
/// clears the tree
|
||||||
|
virtual void clear();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
void clearModelsCache();
|
||||||
Model* getModel(const ModelItem& modelItem);
|
Model* getModel(const ModelItem& modelItem);
|
||||||
QMap<uint32_t, Model*> _knownModelsItemModels;
|
QMap<uint32_t, Model*> _knownModelsItemModels;
|
||||||
QMap<uint32_t, Model*> _unknownModelsItemModels;
|
QMap<uint32_t, Model*> _unknownModelsItemModels;
|
||||||
|
|
|
@ -62,7 +62,7 @@ public:
|
||||||
static bool renderOperation(OctreeElement* element, void* extraData);
|
static bool renderOperation(OctreeElement* element, void* extraData);
|
||||||
|
|
||||||
/// clears the tree
|
/// clears the tree
|
||||||
void clear();
|
virtual void clear();
|
||||||
protected:
|
protected:
|
||||||
Octree* _tree;
|
Octree* _tree;
|
||||||
bool _managedTree;
|
bool _managedTree;
|
||||||
|
|
Loading…
Reference in a new issue