diff options
| -rw-r--r-- | indra/llmath/m4math.cpp | 50 | ||||
| -rw-r--r-- | indra/llmath/m4math.h | 2 | ||||
| -rwxr-xr-x | indra/llprimitive/llmodel.cpp | 1 | ||||
| -rwxr-xr-x | indra/llprimitive/llmodel.h | 3 | ||||
| -rwxr-xr-x | indra/newview/llfloatermodelpreview.cpp | 73 | ||||
| -rw-r--r-- | indra/newview/llfloatermodelpreview.h | 4 | ||||
| -rwxr-xr-x | indra/newview/llmeshrepository.cpp | 27 | ||||
| -rw-r--r-- | indra/newview/llmeshrepository.h | 4 | 
8 files changed, 162 insertions, 2 deletions
| diff --git a/indra/llmath/m4math.cpp b/indra/llmath/m4math.cpp index 8741400e52..bad4deb4de 100644 --- a/indra/llmath/m4math.cpp +++ b/indra/llmath/m4math.cpp @@ -829,4 +829,54 @@ std::ostream& operator<<(std::ostream& s, const LLMatrix4 &a)  	return s;  } +LLSD LLMatrix4::getValue() const +{ +	LLSD ret; +	 +	ret[0] = mMatrix[0][0]; +	ret[1] = mMatrix[0][1]; +	ret[2] = mMatrix[0][2]; +	ret[3] = mMatrix[0][3]; + +	ret[4] = mMatrix[1][0]; +	ret[5] = mMatrix[1][1]; +	ret[6] = mMatrix[1][2]; +	ret[7] = mMatrix[1][3]; + +	ret[8] = mMatrix[2][0]; +	ret[9] = mMatrix[2][1]; +	ret[10] = mMatrix[2][2]; +	ret[11] = mMatrix[2][3]; + +	ret[12] = mMatrix[3][0]; +	ret[13] = mMatrix[3][1]; +	ret[14] = mMatrix[3][2]; +	ret[15] = mMatrix[3][3]; + +	return ret; +} + +void LLMatrix4::setValue(const LLSD& data)  +{ +	mMatrix[0][0] = data[0].asReal(); +	mMatrix[0][1] = data[1].asReal(); +	mMatrix[0][2] = data[2].asReal(); +	mMatrix[0][3] = data[3].asReal(); + +	mMatrix[1][0] = data[4].asReal(); +	mMatrix[1][1] = data[5].asReal(); +	mMatrix[1][2] = data[6].asReal(); +	mMatrix[1][3] = data[7].asReal(); + +	mMatrix[2][0] = data[8].asReal(); +	mMatrix[2][1] = data[9].asReal(); +	mMatrix[2][2] = data[10].asReal(); +	mMatrix[2][3] = data[11].asReal(); + +	mMatrix[3][0] = data[12].asReal(); +	mMatrix[3][1] = data[13].asReal(); +	mMatrix[3][2] = data[14].asReal(); +	mMatrix[3][3] = data[15].asReal(); +} + diff --git a/indra/llmath/m4math.h b/indra/llmath/m4math.h index 3588f36758..a7dce10397 100644 --- a/indra/llmath/m4math.h +++ b/indra/llmath/m4math.h @@ -119,6 +119,8 @@ public:  	~LLMatrix4(void);										// Destructor +	LLSD getValue() const; +	void setValue(const LLSD&);  	//////////////////////////////  	// diff --git a/indra/llprimitive/llmodel.cpp b/indra/llprimitive/llmodel.cpp index eed82f924b..3669fef0dc 100755 --- a/indra/llprimitive/llmodel.cpp +++ b/indra/llprimitive/llmodel.cpp @@ -60,6 +60,7 @@ LLModel::LLModel(LLVolumeParams& params, F32 detail)  	, mPelvisOffset( 0.0f )  {  	mDecompID = -1; +	mLocalID = -1;  }  LLModel::~LLModel() diff --git a/indra/llprimitive/llmodel.h b/indra/llprimitive/llmodel.h index e9e33bdee5..addf527d8d 100755 --- a/indra/llprimitive/llmodel.h +++ b/indra/llprimitive/llmodel.h @@ -205,6 +205,9 @@ public:  	std::vector<LLVector3> mHullCenter;  	U32 mHullPoints; +	//ID for storing this model in a .slm file +	S32 mLocalID; +  protected:  	void addVolumeFacesFromDomMesh(domMesh* mesh);  	virtual BOOL createVolumeFacesFromFile(const std::string& file_name); 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  | 
