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


C++ Mat4::makeTransform方法代码示例

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


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

示例1: update

	void BoneNode::update( const AnimationTime& at , Skin& sk)
	{	
		if (_bone->id >= 0 && _bone->id < sk.boneKFs.size())
		{
			sBoneKFs& b = sk.boneKFs[_bone->id];
			//translation
			Vec3 t = b.translationKFs.getFrame(&at);

			//rotation
			Quaternion q = b.rotationKFs.getFrame(-1, &at);

			//scale
			Vec3 s = b.scaleKFs.getFrame(-1, &at);

			Mat4 dynamicMtx = Mat4::IDENTITY;
			dynamicMtx.makeTransform(t, s, q);
			//
			if(0)
			{
				Mat4 tM;
				tM.makeTrans(t);
				Mat4 tQ(q);
				dynamicMtx = tM * tQ;
			}

			//
			if (_parent)
			{
				_mtxTransform =  _parent->_fullMatrix * dynamicMtx;
			}
			else
			{
				_mtxTransform = dynamicMtx;
			}
			_fullMatrix = _mtxTransform;

			//
			_skeleton->_matricesFull[_bone->id] = _mtxTransform;
			_mtxTransform = _fullMatrix * _bone->initialMatrix.inverse();
			//
			_skeleton->_matrices[_bone->id] = _mtxTransform;
		}
		
		NameNodeMap::iterator it = _children.begin();
		for ( ; it != _children.end(); ++it)
		{
			BoneNode* n = it->second;
			n->update(at, sk);
		}
	}
开发者ID:,项目名称:,代码行数:50,代码来源:

示例2: raise

//地形圆掠过,高度变化
void Chunks::raise(Sculptor* s, bool heigher)
{
	Real radiusSquare = s->mRadius * s->mRadius;
	//遍历顶点,筛选出地形圆覆盖的顶点
	for (size_t i = 0; i != mChunks.size(); ++i)
	{
		Chunk* c = mChunks[i];
		//先过滤大部分的chunk
		{
			//如何判断一个圆是否与一个正方形有交集?
			Vec3 leftLow = mPosition + Vec3(scChunkSize * c->mPostion.x, 0.0f, -scChunkSize * c->mPostion.y);
			Vec3 center = leftLow;
			center.x += 0.5f * scChunkSize;
			center.y = 0.0f;
			center.z -= 0.5f * scChunkSize;
			Vec3 delta = center - s->mOrigion;
			if (delta.length() >= s->mRadius + scChunkSize * 0.5f * 1.414f)
			{
				continue;
			}
		}
		Mat4 m;
		m.makeTransform(mPosition + Vec3(scChunkSize * c->mPostion.x, 0.0f, -scChunkSize * c->mPostion.y), Vec3(scChunkSize, 1.0f, scChunkSize), Quaternion::IDENTITY);
		for (size_t k = 0; k != c->mVertices.size(); ++k)
		{
			Vec3 p = c->mVertices[k];
			//世界坐标系
			p = m * p;
			//在xz平面上,判断顶点是否在圆内部
			Real deltaX = p.x - s->mOrigion.x;
			Real deltaZ = p.z - s->mOrigion.z;
			Real distanceSquare = deltaX * deltaX + deltaZ * deltaZ;
			if (distanceSquare <= radiusSquare)
			{
				Real delta = Zen::Basic::Sqrt(radiusSquare - distanceSquare);
				delta *= s->mParaA;
				
				//选中,处理高度变化
				if (heigher)
				{
					c->mVertices[k].y += delta;
				}
				else
				{
					c->mVertices[k].y -= delta;
				}
			}
		}
	}
}
开发者ID:,项目名称:,代码行数:51,代码来源:

示例3: getHeight

Real Chunks::getHeight( Real x, Real z )
{
	Real height = 0.0f;
	//遍历顶点,筛选出地形圆覆盖的顶点
	for (size_t i = 0; i != mChunks.size(); ++i)
	{
		Chunk* c = mChunks[i];
		//先过滤大部分的chunk
		{
			//如何判断一个点是否在一个正方形?
			Vec3 leftLow = mPosition + Vec3(scChunkSize * c->mPostion.x, 0.0f, -scChunkSize * c->mPostion.y);
			Real maxX = leftLow.x + scChunkSize;
			Real minX = leftLow.x;
			Real maxZ = leftLow.z;
			Real minZ = leftLow.z - scChunkSize;
			if (x < minX || x > maxX || z < minZ || z > maxZ)
			{
				continue;
			}
		}
		Mat4 m;
		m.makeTransform(mPosition + Vec3(scChunkSize * c->mPostion.x, 0.0f, -scChunkSize * c->mPostion.y), Vec3(scChunkSize, 1.0f, scChunkSize), Quaternion::IDENTITY);
		std::vector<Real> ts;
		Vec3 p = Vec3(x, 0.0f, z);
		Ray r;
		r._direction = Vec3::NEGATIVE_UNIT_Y;
		r._origin = Vec3(x, 100000.0f, z);
		for (size_t k = 0; k != c->mIndices.size(); k += 3)
		{
			Vec3 p0 = m * c->mVertices[c->mIndices[k]];
			Vec3 p1 = m * c->mVertices[c->mIndices[k + 1]];
			Vec3 p2 = m * c->mVertices[c->mIndices[k + 2]];
			std::pair<bool, Real> result = Zen::intersects(r, p0, p1, p2);
			if (result.first)
			{
				height = r.getPoint(result.second).y;
				return height;
			}
		}
	}
	return height;
}
开发者ID:,项目名称:,代码行数:42,代码来源:

示例4: render

void Chunks::render()
{
	//
	if (NULL == mMaterial)
	{
		return;
	}
	Zen::Effect* fx = mMaterial->getEffect();
	if (NULL == fx)
	{
		return;
	}
	for (size_t i = 0; i != mChunks.size(); ++i)
	{
		Chunk* c = mChunks[i];
		if (c)
		{
			Mat4 m;
			m.makeTransform(mPosition + Vec3(scChunkSize * c->mPostion.x, 0.0f, -scChunkSize * c->mPostion.y), Vec3(scChunkSize, 1.0f, scChunkSize), Quaternion::IDENTITY);
			fx->setMatrix("g_mWorld", m);
			{
				// 用颜色来区分邻居chunk
				Vec4 p;
				if ((int)c->mPostion.x % 2 == 0)
				{
					p.x = 0.0f;
				}
				else
				{
					p.x = 1.0f;
				}
				
				//
				if ((int)c->mPostion.y % 2 == 0)
				{
					p.z = 0.0f;
				}
				else
				{
					p.z = 1.0f;
				}
				//
				p.y = 2 - (p.x + p.z);
				p.y /= 2.0f;
				//
				p.w = 1.0f;
				fx->setVector("gAmbient", &p);
			}

			mMaterial->apply();
			u32 passes = 0;
			fx->begin(&passes);
			for (u32 i = 0; i != passes; ++i)
			{
				fx->beginPass(i);
				if (i == 0)
				{
					c->render();
				}
				fx->endPass();
			}
			fx->end();
		}
	}
	
}
开发者ID:,项目名称:,代码行数:66,代码来源:


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