diff options
| author | Dave Parks <davep@lindenlab.com> | 2011-03-28 23:50:23 -0500 | 
|---|---|---|
| committer | Dave Parks <davep@lindenlab.com> | 2011-03-28 23:50:23 -0500 | 
| commit | 1ff79683128f09baf6dbaf081092fda7e5f2fe65 (patch) | |
| tree | 88dcf862bc4c696b7597bc3b141bf88bc8ff23e4 /indra/newview | |
| parent | 835671f27809ce8e5ab17e6c299be35260239d51 (diff) | |
SH-1225 Add skinning info to import path of .slm files.
Diffstat (limited to 'indra/newview')
| -rwxr-xr-x | indra/newview/llfloatermodelpreview.cpp | 88 | ||||
| -rwxr-xr-x | indra/newview/llmeshrepository.cpp | 59 | ||||
| -rw-r--r-- | indra/newview/llmeshrepository.h | 12 | 
3 files changed, 62 insertions, 97 deletions
| diff --git a/indra/newview/llfloatermodelpreview.cpp b/indra/newview/llfloatermodelpreview.cpp index e440fa52d4..2204908bdf 100755 --- a/indra/newview/llfloatermodelpreview.cpp +++ b/indra/newview/llfloatermodelpreview.cpp @@ -1326,17 +1326,19 @@ bool LLModelLoader::doLoadModel()  						{ //get bind shape matrix
  							domFloat4x4& dom_value = bind_mat->getValue();
 +							LLMeshSkinInfo& skin_info = model->mSkinInfo;
 +
  							for (int i = 0; i < 4; i++)
  							{
  								for(int j = 0; j < 4; j++)
  								{
 -									model->mBindShapeMatrix.mMatrix[i][j] = dom_value[i + j*4];
 +									skin_info.mBindShapeMatrix.mMatrix[i][j] = dom_value[i + j*4];
  								}
  							}
  							LLMatrix4 trans = normalized_transformation;
 -							trans *= model->mBindShapeMatrix;
 -							model->mBindShapeMatrix = trans;
 +							trans *= skin_info.mBindShapeMatrix;
 +							skin_info.mBindShapeMatrix = trans;
  						}
 @@ -1475,7 +1477,7 @@ bool LLModelLoader::doLoadModel()  							xsNMTOKEN semantic = input->getSemantic();
  							if (strcmp(semantic, COMMON_PROFILE_INPUT_JOINT) == 0)
 -							{ //found joint source, fill model->mJointMap and model->mJointList
 +							{ //found joint source, fill model->mJointMap and model->mSkinInfo.mJointNames
  								daeElement* elem = input->getSource().getElement();
  								domSource* source = daeSafeCast<domSource>(elem);
 @@ -1496,8 +1498,8 @@ bool LLModelLoader::doLoadModel()  											{
  												name = mJointMap[name];
  											}
 -											model->mJointList.push_back(name);
 -											model->mJointMap[name] = j;
 +											model->mSkinInfo.mJointNames.push_back(name);
 +											model->mSkinInfo.mJointMap[name] = j;
  										}
  									}
  									else
 @@ -1514,8 +1516,8 @@ bool LLModelLoader::doLoadModel()  												{
  													name = mJointMap[name];
  												}
 -												model->mJointList.push_back(name);
 -												model->mJointMap[name] = j;
 +												model->mSkinInfo.mJointNames.push_back(name);
 +												model->mSkinInfo.mJointMap[name] = j;
  											}
  										}
  									}
 @@ -1544,7 +1546,7 @@ bool LLModelLoader::doLoadModel()  												}
  											}
 -											model->mInvBindMatrix.push_back(mat);
 +											model->mSkinInfo.mInvBindMatrix.push_back(mat);
  										}
  									}
  								}
 @@ -1555,8 +1557,8 @@ bool LLModelLoader::doLoadModel()  						//(which means we have all the joints that are required for an avatar versus
  						//a skinned asset attached to a node in a file that contains an entire skeleton,
  						//but does not use the skeleton).
 -						mPreview->setRigValid( doesJointArrayContainACompleteRig( model->mJointList ) );
 -							if ( !skeletonWithNoRootNode && !model->mJointList.empty() && mPreview->isRigValid() ) 
 +						mPreview->setRigValid( doesJointArrayContainACompleteRig( model->mSkinInfo.mJointNames ) );
 +							if ( !skeletonWithNoRootNode && !model->mSkinInfo.mJointNames.empty() && mPreview->isRigValid() ) 
  						{
  							mResetJoints = true;
  						}
 @@ -1596,8 +1598,8 @@ bool LLModelLoader::doLoadModel()  						//in the same order as they were stored in the joint buffer. The joints associated
  						//with the skeleton are not stored in the same order as they are in the exported joint buffer.
  						//This remaps the skeletal joints to be in the same order as the joints stored in the model.
 -						std::vector<std::string> :: const_iterator jointIt  = model->mJointList.begin();
 -						const int jointCnt = model->mJointList.size();
 +						std::vector<std::string> :: const_iterator jointIt  = model->mSkinInfo.mJointNames.begin();
 +						const int jointCnt = model->mSkinInfo.mJointNames.size();
  						for ( int i=0; i<jointCnt; ++i, ++jointIt )
  						{
  							std::string lookingForJoint = (*jointIt).c_str();
 @@ -1606,9 +1608,9 @@ bool LLModelLoader::doLoadModel()  							if ( jointTransforms.find( lookingForJoint ) != jointTransforms.end() )
  							{
  								LLMatrix4 jointTransform = jointTransforms[lookingForJoint];
 -								LLMatrix4 newInverse = model->mInvBindMatrix[i];
 +								LLMatrix4 newInverse = model->mSkinInfo.mInvBindMatrix[i];
  								newInverse.setTranslation( jointTransforms[lookingForJoint].getTranslation() );
 -								model->mAlternateBindMatrix.push_back( newInverse );
 +								model->mSkinInfo.mAlternateBindMatrix.push_back( newInverse );
  							}
  							else
  							{
 @@ -1813,10 +1815,15 @@ bool LLModelLoader::loadFromSLM(const std::string& filename)  		{
  			std::stringstream str(mesh[i].asString());
  			LLPointer<LLModel> loaded_model = new LLModel(volume_params, (F32) lod);
 -			if (loaded_model->createVolumeFacesFromStream(str))
 +			if (loaded_model->loadModel(str))
  			{
  				loaded_model->mLocalID = i;
  				model[lod].push_back(loaded_model);
 +
 +				if (lod == LLModel::LOD_HIGH && !loaded_model->mSkinInfo.mJointNames.empty())
 +				{ //check to see if rig is valid
 +					mPreview->setRigValid( doesJointArrayContainACompleteRig( loaded_model->mSkinInfo.mJointNames ) );
 +				}
  			}
  			else
  			{
 @@ -1871,7 +1878,7 @@ void LLModelLoader::loadModelCallback()  {
  	if (mPreview)
  	{
 -		mPreview->loadModelCallback(mLod);	
 +		mPreview->loadModelCallback(mLod);
  	}
  	while (!isStopped())
 @@ -2901,6 +2908,9 @@ void LLModelPreview::loadModelCallback(S32 lod)  		mBaseModel.clear();
  		mBaseScene.clear();
 +		bool skin_weights = false;
 +		bool joint_positions = false;
 +
  		for (S32 lod = 0; lod < LLModel::NUM_LODS; ++lod)
  		{ //for each LoD
 @@ -2933,12 +2943,40 @@ void LLModelPreview::loadModelCallback(S32 lod)  							mModel[lod].resize(idx+1);
  						}
 -						mModel[lod][idx] = list_iter->mModel;	
 +						mModel[lod][idx] = list_iter->mModel;
 +						if (!list_iter->mModel->mSkinWeights.empty())
 +						{
 +							skin_weights = true;
 +
 +							if (!list_iter->mModel->mSkinInfo.mAlternateBindMatrix.empty())
 +							{
 +								joint_positions = true;
 +							}
 +						}
  					}
  				}
  			}
  		}
 +		if (mFMP)
 +		{
 +			LLFloaterModelPreview* fmp = (LLFloaterModelPreview*) mFMP;
 +
 +			if (skin_weights)
 +			{ //enable uploading/previewing of skin weights if present in .slm file
 +				fmp->enableViewOption("show_skin_weight");
 +				mViewOption["show_skin_weight"] = true;
 +				fmp->childSetValue("upload_skin", true);
 +			}
 +
 +			if (joint_positions)
 +			{ 
 +				fmp->enableViewOption("show_joint_positions");
 +				mViewOption["show_joint_positions"] = true;
 +				fmp->childSetValue("upload_joints", true);
 +			}
 +		}
 +
  		//copy high lod to base scene for LoD generation
  		mBaseScene = mScene[LLModel::LOD_HIGH];
  		mBaseModel = mModel[LLModel::LOD_HIGH];
 @@ -3415,11 +3453,7 @@ void LLModelPreview::genLODs(S32 which_lod, U32 decimation, bool enforce_tri_lim  			//of an open problem).
  			target_model->mPosition = base->mPosition;
  			target_model->mSkinWeights = base->mSkinWeights;
 -			target_model->mJointMap = base->mJointMap;
 -			target_model->mJointList = base->mJointList;
 -			target_model->mInvBindMatrix = base->mInvBindMatrix;
 -			target_model->mBindShapeMatrix = base->mBindShapeMatrix;
 -			target_model->mAlternateBindMatrix = base->mAlternateBindMatrix;
 +			target_model->mSkinInfo = base->mSkinInfo;
  			//copy material list
  			target_model->mMaterialList = base->mMaterialList;
 @@ -4391,12 +4425,12 @@ BOOL LLModelPreview::render()  							//build matrix palette
  							LLMatrix4 mat[64];
 -							for (U32 j = 0; j < model->mJointList.size(); ++j)
 +							for (U32 j = 0; j < model->mSkinInfo.mJointNames.size(); ++j)
  							{
 -								LLJoint* joint = avatar->getJoint(model->mJointList[j]);
 +								LLJoint* joint = avatar->getJoint(model->mSkinInfo.mJointNames[j]);
  								if (joint)
  								{
 -									mat[j] = model->mInvBindMatrix[j];
 +									mat[j] = model->mSkinInfo.mInvBindMatrix[j];
  									mat[j] *= joint->getWorldMatrix();
  								}
  							}
 @@ -4437,7 +4471,7 @@ BOOL LLModelPreview::render()  								//VECTORIZE THIS
  								LLVector3 v(face.mPositions[j].getF32ptr());
 -								v = v * model->mBindShapeMatrix;
 +								v = v * model->mSkinInfo.mBindShapeMatrix;
  								v = v * final_mat;
  								position[j] = v;
 diff --git a/indra/newview/llmeshrepository.cpp b/indra/newview/llmeshrepository.cpp index a2792bcdc6..f5fc0de0d3 100755 --- a/indra/newview/llmeshrepository.cpp +++ b/indra/newview/llmeshrepository.cpp @@ -1111,66 +1111,9 @@ bool LLMeshRepoThread::skinInfoReceived(const LLUUID& mesh_id, U8* data, S32 dat  	}  	{ -		LLMeshSkinInfo info; +		LLMeshSkinInfo info(skin);  		info.mMeshID = mesh_id; -		if (skin.has("joint_names")) -		{ -			for (U32 i = 0; i < skin["joint_names"].size(); ++i) -			{ -				info.mJointNames.push_back(skin["joint_names"][i]); -			} -		} - -		if (skin.has("inverse_bind_matrix")) -		{ -			for (U32 i = 0; i < skin["inverse_bind_matrix"].size(); ++i) -			{ -				LLMatrix4 mat; -				for (U32 j = 0; j < 4; j++) -				{ -					for (U32 k = 0; k < 4; k++) -					{ -						mat.mMatrix[j][k] = skin["inverse_bind_matrix"][i][j*4+k].asReal(); -					} -				} - -				info.mInvBindMatrix.push_back(mat); -			} -		} - -		if (skin.has("bind_shape_matrix")) -		{ -			for (U32 j = 0; j < 4; j++) -			{ -				for (U32 k = 0; k < 4; k++) -				{ -					info.mBindShapeMatrix.mMatrix[j][k] = skin["bind_shape_matrix"][j*4+k].asReal(); -				} -			} -		} - -		if (skin.has("alt_inverse_bind_matrix")) -		{ -			for (U32 i = 0; i < skin["alt_inverse_bind_matrix"].size(); ++i) -			{ -				LLMatrix4 mat; -				for (U32 j = 0; j < 4; j++) -				{ -					for (U32 k = 0; k < 4; k++) -					{ -						mat.mMatrix[j][k] = skin["alt_inverse_bind_matrix"][i][j*4+k].asReal(); -					} -				} -				 -				info.mAlternateBindMatrix.push_back(mat); -			} -		} - -		if (skin.has("pelvis_offset")) -		{ -			info.mPelvisOffset = skin["pelvis_offset"].asReal(); -		}  		//llinfos<<"info pelvis offset"<<info.mPelvisOffset<<llendl;  		mSkinInfoQ.push(info);  	} diff --git a/indra/newview/llmeshrepository.h b/indra/newview/llmeshrepository.h index 4e349a1270..5960fe2949 100644 --- a/indra/newview/llmeshrepository.h +++ b/indra/newview/llmeshrepository.h @@ -132,18 +132,6 @@ public:  	LLSD asLLSD();  }; -class LLMeshSkinInfo  -{ -public: -	LLUUID mMeshID; -	std::vector<std::string> mJointNames; -	std::vector<LLMatrix4> mInvBindMatrix; -	std::vector<LLMatrix4> mAlternateBindMatrix; -	 -	LLMatrix4 mBindShapeMatrix; -	float mPelvisOffset; -}; -  class LLMeshDecomposition  {  public: | 
