当前位置: 首页>>代码示例>>C++>>正文


C++ Transformation::GetHomogeneous方法代码示例

本文整理汇总了C++中Transformation::GetHomogeneous方法的典型用法代码示例。如果您正苦于以下问题:C++ Transformation::GetHomogeneous方法的具体用法?C++ Transformation::GetHomogeneous怎么用?C++ Transformation::GetHomogeneous使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Transformation的用法示例。


在下文中一共展示了Transformation::GetHomogeneous方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: SetTransform

	void SetTransform(const Transformation& t){
		Mat44 mat4;
		t.GetHomogeneous(mat4);
		auto aT = FBToBullet(mat4);
		mSelf->setWorldTransform(aT);
		auto numConstraints = mSelf->getNumConstraintRefs();
		for (int i = 0; i < numConstraints; ++i){
			auto con = mSelf->getConstraintRef(i);
			if (con->isEnabled() && con->getConstraintType() == D6_SPRING_2_CONSTRAINT_TYPE){
				btFixedConstraint* fixedCon = (btFixedConstraint*)con;
				auto a = &con->getRigidBodyA();
				auto b = &con->getRigidBodyB();
				auto trA = fixedCon->getFrameOffsetA();
				auto trB = fixedCon->getFrameOffsetB();
				if (b->getUserPointer() == mSelf){
					std::swap(a, b);
					std::swap(trA, trB);
				}
				auto bT = aT * trA * trB.inverse();
				b->setWorldTransform(bT);
				auto ms = b->getMotionState();
				if (ms)
					ms->setWorldTransform(bT);
			}
		}
		mSelf->activate();
	}
开发者ID:fastbird,项目名称:fastbirdEngine_NewAPI,代码行数:27,代码来源:RigidBodyImpl.cpp

示例2: SetTransform

	void SetTransform(const Transformation& t){		
		Mat44 mat4;
		t.GetHomogeneous(mat4);
		auto aT = FBToBullet(mat4);
		VectorMap<void*, int> mSet;
		SetTransform(aT, mSet);
	}
开发者ID:wangscript,项目名称:fastbirdEngine,代码行数:7,代码来源:RigidBodyImpl.cpp

示例3: Update

	//----------------------------------------------------------------------------
	void Update()
	{
		if (mOverridingCamera){
			mOverridingCamera->Update();
		}
		// world coordinates (Blender style)
		// x: right
		// y: forward
		// z: up
		bool viewChanged = mViewPropertyChanged;
		if (mViewPropertyChanged)
		{
			mViewPropertyChanged = false;
			Vec3 right = mTransformation.GetMatrix().Column(0);
			Vec3 forward = mTransformation.GetMatrix().Column(1);
			Vec3 up = mTransformation.GetMatrix().Column(2);
			const Vec3& pos = mTransformation.GetTranslation();
			mMatrices[View] = fb::MakeViewMatrix(pos, right, forward, up);			
			mTransformation.GetHomogeneous(mMatrices[InverseView]);
			mFrustum.mOrigin = mTransformation.GetTranslation();
			mFrustum.mOrientation = mTransformation.GetRotation();
		}

		bool projChanged = mProjPropertyChanged;
		if (mProjPropertyChanged)
		{
			mAspectRatio = GetWidth() / (Real)GetHeight();
			mProjPropertyChanged = false;
			if (!mOrthogonal)
			{
				mMatrices[ProjBeforeSwap] = mMatrices[Proj] = 
					MakeProjectionMatrix(mFov, mAspectRatio, mNear, mFar);
			}
			else
			{
				mMatrices[ProjBeforeSwap] = mMatrices[Proj] = 
					MakeOrthogonalMatrix((Real)mOrthogonalData.left, (Real)mOrthogonalData.top,
					(Real)mOrthogonalData.right, (Real)mOrthogonalData.bottom,
					mNear, mFar);
			}
			if (mYZSwap)
			{
				Mat44 swapMat(
					1, 0, 0, 0,
					0, 0, 1, 0,
					0, 1, 0, 0,
					0, 0, 0, 1);
				mMatrices[Proj] = mMatrices[Proj] * swapMat;
			}
			mMatrices[InverseProj] = mMatrices[Proj].Inverse();	
			mFrustum.SetData(mNear, mFar, mFov, mAspectRatio);
		}

		if (projChanged || viewChanged)
		{
			
			mMatrices[ViewProj] = mMatrices[Proj] * mMatrices[View];
			mMatrices[InverseViewProj] = mMatrices[ViewProj].Inverse();

			UpdateFrustum();

			if (viewChanged && !mSelf->mObservers_.empty()){
				auto& observers = mSelf->mObservers_[TransformChanged];
				for (auto it = observers.begin(); it != observers.end(); /**/){
					auto observer = it->lock();
					if (!observer){
						it = observers.erase(it);
						continue;
					}
					++it;
					observer->OnViewMatrixChanged();
				}				
			}
			if (projChanged && !mSelf->mObservers_.empty()){
				auto& observers = mSelf->mObservers_[TransformChanged];
				for (auto it = observers.begin(); it != observers.end(); /**/){
					auto observer = it->lock();
					if (!observer){
						it = observers.erase(it);
						continue;
					}
					++it;
					observer->OnProjMatrixChanged();
				}
			}		
			mRayCache.clear();
		}
	}
开发者ID:wangscript,项目名称:fastbirdEngine,代码行数:89,代码来源:Camera.cpp


注:本文中的Transformation::GetHomogeneous方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。