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


C++ Quat::FromAxis方法代码示例

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


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

示例1: OnUpdate

	virtual void OnUpdate()
	{
		Quat q;
		q.FromAxis(Float3(0, 1, 0), 0.5f * Root::Instance()->GetFrameTime());
		
		gMesh->Rotate(q);
	}
开发者ID:MSoft1115,项目名称:Rad3D,代码行数:7,代码来源:Demo02_Mesh.cpp

示例2: _updateBuffer

	void PS_Billboard::_updateBuffer()
	{
		mRenderOp.primCount = mParent->GetParticleCount() * 2;
		if (mRenderOp.primCount == 0)
			return ;

		Camera * pCamera = World::Instance()->GetCurrentRenderContext()->GetCamera();
		const Quat & worldQ = mParent->GetParent()->GetWorldRotation();
		Mat4 worldTM;
		
		if (mParent->IsScaleAble())
			worldTM = mParent->GetParent()->GetWorldTM();
		else
			worldTM.MakeTransform(mParent->GetParent()->GetWorldPosition(), worldQ, Float3(1, 1, 1));

		pCamera->GetWorldRotation().ToAxis(mCamXAxis, mCamYAxis, mCamZAxis);
		mCamPos = pCamera->GetWorldPosition();

		mCommonDir = mParent->GetCommonDirection();
		mCommonUp = mParent->GetCommonUpVector();

		if (mParent->GetBillboardType() == PS_BillboardType::PERPENDICULAR ||
			mParent->GetBillboardType() == PS_BillboardType::PERPENDICULAR_COMMON)
		{
			mCommonDir.TransformQ(worldQ);
			mCommonUp.TransformQ(worldQ);
		}

		float width, height, asecpt = 1;
		Float3 xAxis, yAxis;
		Float3 pos, dir;
		const Float2 & center = mParent->GetBillboardCenter();

		if (mParent->IsKeepAspect())
			asecpt = mParent->_getTexture()->_getAscept();
		
		PS_Vertex * v = (PS_Vertex *)mRenderOp.vertexBuffers[0]->Lock(eLockFlag::WRITE);
		for (int i = 0; i < mParent->GetParticleCount(); ++i)
		{
			const Particle * p = mParent->GetParticle(i);

			height = Max(0.0f, p->Size.y);
			if (!mParent->IsKeepAspect())
				width = Max(0.0f, p->Size.x);
			else
				width = height * asecpt;

			pos = p->Position;
			dir = p->Direction;

			if (mParent->IsLocalSpace())
			{
				pos.TransformA(worldTM);
				dir.TransformQ(mParent->GetParent()->GetWorldRotation());
			}

			_getBillboardXYAxis(xAxis, yAxis, pos, dir);

			if (p->Rotation.x != 0)
			{
				Quat q;
				q.FromAxis(Float3::Cross(xAxis, yAxis), Math::DegreeToRadian(p->Rotation.x));

				xAxis.TransformQ(q);
				yAxis.TransformQ(q);
			}

			xAxis *= width, yAxis *= height;

			v->position = pos - xAxis * center.x + yAxis * center.y;
			v->color = p->Color;
			v->uv.x = p->UVRect.x1, v->uv.y = p->UVRect.y1;
			++v;

			v->position = pos + xAxis * (1 - center.x) + yAxis * center.y;
			v->color = p->Color;
			v->uv.x = p->UVRect.x2, v->uv.y = p->UVRect.y1;
			++v;

			v->position = pos - xAxis * center.x - yAxis * (1 - center.y);
			v->color = p->Color;
			v->uv.x = p->UVRect.x1, v->uv.y = p->UVRect.y2;
			++v;

			v->position = pos + xAxis * (1 - center.x) - yAxis * (1 - center.y);
			v->color = p->Color;
			v->uv.x = p->UVRect.x2, v->uv.y = p->UVRect.y2;
			++v;
		}
		mRenderOp.vertexBuffers[0]->Unlock();
	}
开发者ID:MSoft1115,项目名称:Rad3D,代码行数:91,代码来源:PSBillboard.cpp


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