mirror of
https://github.com/Armored-Dragon/overte.git
synced 2025-03-11 16:13:16 +01:00
Add Set Model Properties dialog for model uploading
This commit is contained in:
parent
49e0d07ac8
commit
fcfaf6a9be
1 changed files with 67 additions and 18 deletions
|
@ -118,14 +118,19 @@ if (typeof DataView.prototype.string !== "function") {
|
||||||
var modelUploader = (function () {
|
var modelUploader = (function () {
|
||||||
var that = {},
|
var that = {},
|
||||||
urlBase = "http://public.highfidelity.io/meshes/",
|
urlBase = "http://public.highfidelity.io/meshes/",
|
||||||
|
modelFile,
|
||||||
fstBuffer,
|
fstBuffer,
|
||||||
fbxBuffer,
|
fbxBuffer,
|
||||||
svoBuffer,
|
svoBuffer,
|
||||||
mapping = {},
|
mapping,
|
||||||
NAME_FIELD = "name",
|
NAME_FIELD = "name",
|
||||||
SCALE_FIELD = "scale",
|
SCALE_FIELD = "scale",
|
||||||
FILENAME_FIELD = "filename",
|
FILENAME_FIELD = "filename",
|
||||||
TEXDIR_FIELD = "texdir",
|
TEXDIR_FIELD = "texdir",
|
||||||
|
ANIMATION_URL_FIELD = "animationurl",
|
||||||
|
PITCH_FIELD = "pitch",
|
||||||
|
YAW_FIELD = "yaw",
|
||||||
|
ROLL_FIELD = "roll",
|
||||||
fbxDataView;
|
fbxDataView;
|
||||||
|
|
||||||
function error(message) {
|
function error(message) {
|
||||||
|
@ -253,41 +258,41 @@ var modelUploader = (function () {
|
||||||
return geometry;
|
return geometry;
|
||||||
}
|
}
|
||||||
|
|
||||||
function readModel(filename) {
|
function readModel() {
|
||||||
var url,
|
var fbxFilename,
|
||||||
req,
|
|
||||||
fbxFilename,
|
|
||||||
geometry;
|
geometry;
|
||||||
|
|
||||||
print("Reading model file: " + filename);
|
print("Reading model file: " + modelFile);
|
||||||
|
|
||||||
if (filename.toLowerCase().slice(-4) === ".svo") {
|
mapping = {};
|
||||||
svoBuffer = readFile(filename);
|
|
||||||
|
if (modelFile.toLowerCase().slice(-4) === ".svo") {
|
||||||
|
svoBuffer = readFile(modelFile);
|
||||||
if (svoBuffer === null) {
|
if (svoBuffer === null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
if (filename.toLowerCase().slice(-4) === ".fst") {
|
if (modelFile.toLowerCase().slice(-4) === ".fst") {
|
||||||
fstBuffer = readFile(filename);
|
fstBuffer = readFile(modelFile);
|
||||||
if (fstBuffer === null) {
|
if (fstBuffer === null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
mapping = readMapping(fstBuffer);
|
mapping = readMapping(fstBuffer);
|
||||||
if (mapping.hasOwnProperty(FILENAME_FIELD)) {
|
if (mapping.hasOwnProperty(FILENAME_FIELD)) {
|
||||||
fbxFilename = filename.path() + "\\" + mapping[FILENAME_FIELD];
|
fbxFilename = modelFile.path() + "\\" + mapping[FILENAME_FIELD];
|
||||||
} else {
|
} else {
|
||||||
error("FBX file name not found in FST file!");
|
error("FBX file name not found in FST file!");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (filename.toLowerCase().slice(-4) === ".fbx") {
|
} else if (modelFile.toLowerCase().slice(-4) === ".fbx") {
|
||||||
fbxFilename = filename;
|
fbxFilename = modelFile;
|
||||||
mapping[FILENAME_FIELD] = filename.fileName();
|
mapping[FILENAME_FIELD] = modelFile.fileName();
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
error("Unrecognized file type: " + filename);
|
error("Unrecognized file type: " + modelFile);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -304,7 +309,7 @@ var modelUploader = (function () {
|
||||||
|
|
||||||
// Add any missing basic mappings
|
// Add any missing basic mappings
|
||||||
if (!mapping.hasOwnProperty(NAME_FIELD)) {
|
if (!mapping.hasOwnProperty(NAME_FIELD)) {
|
||||||
mapping[NAME_FIELD] = filename.fileName().slice(0, -4);
|
mapping[NAME_FIELD] = modelFile.fileName().slice(0, -4);
|
||||||
}
|
}
|
||||||
if (!mapping.hasOwnProperty(TEXDIR_FIELD)) {
|
if (!mapping.hasOwnProperty(TEXDIR_FIELD)) {
|
||||||
mapping[TEXDIR_FIELD] = ".";
|
mapping[TEXDIR_FIELD] = ".";
|
||||||
|
@ -317,7 +322,50 @@ var modelUploader = (function () {
|
||||||
}
|
}
|
||||||
|
|
||||||
function setProperties() {
|
function setProperties() {
|
||||||
print("Setting model properties");
|
var form = [],
|
||||||
|
decimals = 3,
|
||||||
|
directory,
|
||||||
|
displayAs,
|
||||||
|
validateAs;
|
||||||
|
|
||||||
|
form.push({ label: "Name:", value: mapping[NAME_FIELD] });
|
||||||
|
|
||||||
|
directory = modelFile.path() + "/" + mapping[TEXDIR_FIELD];
|
||||||
|
displayAs = new RegExp("^" + modelFile.path().replace(/[\\\\\\\/]/, "[\\\\\\\/]") + "[\\\\\\\/](.*)");
|
||||||
|
validateAs = new RegExp("^" + modelFile.path().replace(/[\\\\\\\/]/, "[\\\\\\\/]") + "([\\\\\\\/].*)?");
|
||||||
|
|
||||||
|
form.push({
|
||||||
|
label: "Texture directory:",
|
||||||
|
directory: modelFile.path() + "/" + mapping[TEXDIR_FIELD],
|
||||||
|
title: "Choose Texture Directory",
|
||||||
|
displayAs: displayAs,
|
||||||
|
validateAs: validateAs,
|
||||||
|
errorMessage: "Texture directory must be subdirectory of model directory."
|
||||||
|
});
|
||||||
|
|
||||||
|
form.push({ label: "Animation URL:", value: "" });
|
||||||
|
form.push({ label: "Pitch:", value: (0).toFixed(decimals) });
|
||||||
|
form.push({ label: "Yaw:", value: (0).toFixed(decimals) });
|
||||||
|
form.push({ label: "Roll:", value: (0).toFixed(decimals) });
|
||||||
|
form.push({ label: "Scale:", value: mapping[SCALE_FIELD].toFixed(decimals) });
|
||||||
|
form.push({ button: "Cancel" });
|
||||||
|
|
||||||
|
if (!Window.form("Set Model Properties", form)) {
|
||||||
|
print("User cancelled uploading model");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
mapping[NAME_FIELD] = form[0].value;
|
||||||
|
mapping[TEXDIR_FIELD] = form[1].directory.slice(modelFile.path().length + 1);
|
||||||
|
if (mapping[TEXDIR_FIELD] === "") {
|
||||||
|
mapping[TEXDIR_FIELD] = ".";
|
||||||
|
}
|
||||||
|
mapping[ANIMATION_URL_FIELD] = form[2].value;
|
||||||
|
mapping[PITCH_FIELD] = form[3].value;
|
||||||
|
mapping[YAW_FIELD] = form[4].value;
|
||||||
|
mapping[ROLL_FIELD] = form[5].value;
|
||||||
|
mapping[SCALE_FIELD] = form[6].value;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -356,10 +404,11 @@ var modelUploader = (function () {
|
||||||
}
|
}
|
||||||
|
|
||||||
that.upload = function (file, callback) {
|
that.upload = function (file, callback) {
|
||||||
|
modelFile = file;
|
||||||
var url = urlBase + file.fileName();
|
var url = urlBase + file.fileName();
|
||||||
|
|
||||||
// Read model content ...
|
// Read model content ...
|
||||||
if (!readModel(file)) {
|
if (!readModel()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue