Exemplo n.º 1
0
Arquivo: ZMO.cpp Projeto: exjam/r3e
	void ZMO::TransformChildren(const Array<ZMD::Bone>& bindBoneList, Array<Matrix4>& matrices, unsigned int parent) const {
		for(unsigned int i = 0; i < bindBoneList.Size(); ++i){
			if(i == parent) continue;
			ZMD::Bone* bone = &bindBoneList[i];
			if(bone->mParentID != parent) continue;
			matrices[i] *= matrices[bone->mParentID];
			if(bone->mDummy) continue;
			TransformChildren(bindBoneList, matrices, i);
		}
	}
Exemplo n.º 2
0
Arquivo: ZMD.cpp Projeto: exjam/r3e
	void ZMD::TransformChildren(unsigned int parent){
		for(unsigned int i = 0; i < mBoneList.Size(); ++i){
			if(i == parent) continue;
			Bone* bone = &mBoneList[i];
			if(bone->mParentID != parent) continue;
			bone->mTransform *= mBoneList[bone->mParentID].mTransform;
			if(bone->mDummy) continue;
			TransformChildren(i);
		}
	}
Exemplo n.º 3
0
void ASmrActor::TransformChildren(UPoseableMeshComponent* mesh, SMRJoint* bone)
{
	//Recursively apply transformations to all children of this bone
	std::vector<uint32> children = skeleton.getJointChildren(bone->getName());
	for (int i = 0; i < children.size(); ++i)
	{
		TransformBone(mesh, skeleton.getJoint(children[i]));
		TransformChildren(mesh, skeleton.getJoint(children[i]));
	}
}
Exemplo n.º 4
0
void NodeSimpleShape::Transform( TransformBase& Trans )
{
	// Transform the Shape
	Trans.Transform((DocCoord*)Parallel, 4);

	// re-create the path and update its bounding rectangle
	UpdateShape();

	// Mark the bounding rect as invalid
	InvalidateBoundingRect();

	// Transform all the children...
	TransformChildren(Trans);
}
Exemplo n.º 5
0
void ASmrActor::PoseCharacterLocalSpace(UPoseableMeshComponent* mesh)
{
	//Initialize skeleton
	skeleton = m_motion.getSkeleton(m_frameIndex);
	skeleton.setRotationOrder(TRANSLATIONFIRST);
	skeleton.setMode(SMRModeType::RELATIVEMODE);

	//Transform root bone
	SMRJoint* rootJoint = skeleton.getJointByName("root");
	TransformBone(mesh, rootJoint);
    
	//Recursively transform children
	TransformChildren(mesh, rootJoint);
}
Exemplo n.º 6
0
Arquivo: ZMO.cpp Projeto: exjam/r3e
	void ZMO::CreateBoneMatrices(int frame, const Array<ZMD::Bone>& bindBoneList, Array<Matrix4>& matrices) const {
		matrices.SetSize(bindBoneList.Size());
		for(unsigned int i = 0; i < bindBoneList.Size(); ++i){
			ZMD::Bone* bone = &bindBoneList[i];
			Channel* posC = GetBoneChannel(i, CTYPE_POSITION);
			Channel* rotC = GetBoneChannel(i, CTYPE_ROTATION);

			matrices[i] = Matrix4::IDENTITY;

			if(rotC) matrices[i] = Matrix4::CreateRotation(((Quaternion*)rotC->mData)[frame]);
			else matrices[i] = Matrix4::CreateRotation(bone->mRotate);
			
			if(posC) matrices[i] *= Matrix4::CreateTranslation(((Vector3*)posC->mData)[frame]);
			else matrices[i] *= Matrix4::CreateTranslation(bone->mTranslate);
		}

		TransformChildren(bindBoneList, matrices, 0);
	}
Exemplo n.º 7
0
Arquivo: ZMD.cpp Projeto: exjam/r3e
	bool ZMD::Load(const char* path){
		ScopedPointer<File> fh(FILE_SYS()->OpenFile(path, "rb"));
		if(!fh) return false;

		char VersionHeader[7];
		fh->ReadData(VersionHeader, 7);
		if(strncmp(VersionHeader, "ZMD0003", 7) == 0){
			mVersion = 3;
		}else if(strncmp(VersionHeader, "ZMD0002", 7) == 0){
			mVersion = 2;
		}else{
			LOG("Error: '%s' invalid version '%s'", path, VersionHeader);
			fh->Close();
			return false;
		}

		unsigned int boneCount;
		fh->Read(boneCount);
		mBoneList.SetSize(boneCount);
		for(unsigned int i = 0; i < boneCount; ++i){
			Bone* bone = &mBoneList[i];
			bone->mDummy = false;
			fh->Read(bone->mParentID);
			bone->mName = fh->ReadTerminatedString();
			fh->Read(bone->mTranslate.x);
			fh->Read(bone->mTranslate.y);
			fh->Read(bone->mTranslate.z);

			fh->Read(bone->mRotate.s);
			fh->Read(bone->mRotate.x);
			fh->Read(bone->mRotate.y);
			fh->Read(bone->mRotate.z);
			bone->mTranslate /= 100.0f;

			bone->mTransform = Matrix4::CreateRotation(bone->mRotate);
			bone->mTransform *= Matrix4::CreateTranslation(bone->mTranslate);
		}

		fh->Read(boneCount);
		int offset = mBoneList.Size();
		mBoneList.SetSize(offset + boneCount);
		for(unsigned int i = 0; i < boneCount; ++i){
			Bone* bone = &mBoneList[i + offset];
			bone->mDummy = true;
			bone->mName = fh->ReadTerminatedString();
			fh->Read(bone->mParentID);
			fh->Read(bone->mTranslate);
			bone->mTranslate /= 100.0f;
			bone->mTransform = Matrix4::IDENTITY;
			if(mVersion == 3){
				bone->mTransform = Matrix4::CreateRotation(bone->mRotate);
				fh->Read(bone->mRotate.s);
				fh->Read(bone->mRotate.x);
				fh->Read(bone->mRotate.y);
				fh->Read(bone->mRotate.z);
			}

			bone->mTransform *= Matrix4::CreateTranslation(bone->mTranslate);
		}

		TransformChildren(0);

		LOG("Loaded: '%s' B: %u", path, mBoneList.Size());

		fh->Close();
		return true;
	}