summaryrefslogtreecommitdiff
path: root/indra/newview
diff options
context:
space:
mode:
authorDave Parks <davep@lindenlab.com>2011-03-21 17:31:25 -0500
committerDave Parks <davep@lindenlab.com>2011-03-21 17:31:25 -0500
commit51a4867ae6bcf0ec71882ba77b1c995d98834126 (patch)
treefee42a26578ae8d73bb64bead703a6e2837d53f3 /indra/newview
parenta034ffd4b1af3560ae8498725bb96bd6f651ca48 (diff)
SH-1168 Export upload data to disk on upload.
Diffstat (limited to 'indra/newview')
-rwxr-xr-xindra/newview/llfloatermodelpreview.cpp73
-rw-r--r--indra/newview/llfloatermodelpreview.h4
-rwxr-xr-xindra/newview/llmeshrepository.cpp27
-rw-r--r--indra/newview/llmeshrepository.h4
4 files changed, 106 insertions, 2 deletions
diff --git a/indra/newview/llfloatermodelpreview.cpp b/indra/newview/llfloatermodelpreview.cpp
index ce977b33bb..04dfcac20b 100755
--- a/indra/newview/llfloatermodelpreview.cpp
+++ b/indra/newview/llfloatermodelpreview.cpp
@@ -90,6 +90,7 @@
#include "llbutton.h"
#include "llcheckboxctrl.h"
#include "llradiogroup.h"
+#include "llsdserialize.h"
#include "llsliderctrl.h"
#include "llspinctrl.h"
#include "lltoggleablemenu.h"
@@ -2561,6 +2562,71 @@ void LLModelPreview::rebuildUploadData()
}
+void LLModelPreview::saveUploadData(bool save_skinweights, bool save_joint_positions)
+{
+ if (!mLODFile[LLModel::LOD_HIGH].empty())
+ {
+ std::string filename = mLODFile[LLModel::LOD_HIGH];
+
+ std::string::size_type i = filename.rfind(".");
+ if (i != std::string::npos)
+ {
+ filename.replace(i, filename.size()-1, ".slm");
+ saveUploadData(filename, save_skinweights, save_joint_positions);
+ }
+ }
+}
+
+void LLModelPreview::saveUploadData(const std::string& filename, bool save_skinweights, bool save_joint_positions)
+{
+ std::set<LLPointer<LLModel> > meshes;
+ std::map<LLModel*, std::string> mesh_binary;
+
+ LLModel::hull empty_hull;
+
+ LLSD data;
+
+ S32 mesh_id = 0;
+
+ //build list of unique models and initialize local id
+ for (U32 i = 0; i < mUploadData.size(); ++i)
+ {
+ LLModelInstance& instance = mUploadData[i];
+
+ if (meshes.find(instance.mModel) == meshes.end())
+ {
+ instance.mModel->mLocalID = mesh_id++;
+ meshes.insert(instance.mModel);
+
+ std::stringstream str;
+
+ LLModel::convex_hull_decomposition& decomp =
+ instance.mLOD[LLModel::LOD_PHYSICS].notNull() ?
+ instance.mLOD[LLModel::LOD_PHYSICS]->mConvexHullDecomp :
+ instance.mModel->mConvexHullDecomp;
+
+ LLModel::writeModel(str,
+ instance.mLOD[LLModel::LOD_PHYSICS],
+ instance.mLOD[LLModel::LOD_HIGH],
+ instance.mLOD[LLModel::LOD_MEDIUM],
+ instance.mLOD[LLModel::LOD_LOW],
+ instance.mLOD[LLModel::LOD_IMPOSTOR],
+ decomp,
+ empty_hull, save_skinweights, save_joint_positions);
+
+ data["mesh"][instance.mModel->mLocalID] = str.str();
+ }
+
+ data["instance"][i] = instance.asLLSD();
+ }
+
+ llofstream out(filename, std::ios_base::out | std::ios_base::binary);
+ LLSDSerialize::toBinary(data, out);
+ out.flush();
+ out.close();
+}
+
+
void LLModelPreview::clearModel(S32 lod)
{
@@ -4317,8 +4383,13 @@ void LLFloaterModelPreview::onUpload(void* user_data)
mp->mModelPreview->rebuildUploadData();
+ bool upload_skinweights = mp->childGetValue("upload_skin").asBoolean();
+ bool upload_joint_positions = mp->childGetValue("upload_joints").asBoolean();
+
+ mp->mModelPreview->saveUploadData(upload_skinweights, upload_joint_positions);
+
gMeshRepo.uploadModel(mp->mModelPreview->mUploadData, mp->mModelPreview->mPreviewScale,
- mp->childGetValue("upload_textures").asBoolean(), mp->childGetValue("upload_skin"), mp->childGetValue("upload_joints"));
+ mp->childGetValue("upload_textures").asBoolean(), upload_skinweights, upload_joint_positions);
mp->closeFloater(false);
}
diff --git a/indra/newview/llfloatermodelpreview.h b/indra/newview/llfloatermodelpreview.h
index 910a45f9fe..5efac91ba3 100644
--- a/indra/newview/llfloatermodelpreview.h
+++ b/indra/newview/llfloatermodelpreview.h
@@ -288,6 +288,8 @@ public:
void clearMaterials();
U32 calcResourceCost();
void rebuildUploadData();
+ void saveUploadData(bool save_skinweights, bool save_joint_poisitions);
+ void saveUploadData(const std::string& filename, bool save_skinweights, bool save_joint_poisitions);
void clearIncompatible(S32 lod);
void updateStatusMessages();
void clearGLODGroup();
@@ -332,7 +334,7 @@ public:
std::string mLODFile[LLModel::NUM_LODS];
bool mLoading;
U32 mLoadState;
-
+
std::map<std::string, bool> mViewOption;
//GLOD object parameters (must rebuild object if these change)
diff --git a/indra/newview/llmeshrepository.cpp b/indra/newview/llmeshrepository.cpp
index 93e773d33b..47dc343f5e 100755
--- a/indra/newview/llmeshrepository.cpp
+++ b/indra/newview/llmeshrepository.cpp
@@ -3584,3 +3584,30 @@ void LLPhysicsDecomp::Request::setStatusMessage(const std::string& msg)
mStatusMessage = msg;
}
+LLSD LLModelInstance::asLLSD()
+{
+ LLSD ret;
+
+ ret["mesh_id"] = mModel->mLocalID;
+ ret["label"] = mLabel;
+ ret["transform"] = mTransform.getValue();
+
+ for (U32 i = 0; i < mMaterial.size(); ++i)
+ {
+ ret["material"][i] = mMaterial[i].asLLSD();
+ }
+
+ return ret;
+}
+
+LLSD LLImportMaterial::asLLSD()
+{
+ LLSD ret;
+
+ ret["diffuse"]["filename"] = mDiffuseMapFilename;
+ ret["diffuse"]["label"] = mDiffuseMapLabel;
+ ret["diffuse"]["color"] = mDiffuseColor.getValue();
+ ret["fullbright"] = mFullbright;
+
+ return ret;
+}
diff --git a/indra/newview/llmeshrepository.h b/indra/newview/llmeshrepository.h
index ccdcc03310..4d727bf1f2 100644
--- a/indra/newview/llmeshrepository.h
+++ b/indra/newview/llmeshrepository.h
@@ -101,6 +101,8 @@ public:
{
mDiffuseColor.set(1,1,1,1);
}
+
+ LLSD asLLSD();
};
class LLModelInstance
@@ -120,6 +122,8 @@ public:
: mModel(model), mLabel(label), mTransform(transform), mMaterial(materials)
{
}
+
+ LLSD asLLSD();
};
class LLMeshSkinInfo