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


C++ Matrix4x4::GetTranslation方法代码示例

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


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

示例1: CalculateGlobalTransform

Matrix4x4 CLevelEntity::CalculateGlobalTransform(CLevelEntity* pThis)
{
	Matrix4x4 mLocal;

	tstring sLocalOrigin = pThis->GetParameterValue("Origin");
	if (sLocalOrigin.length() && CanUnserializeString_TVector(sLocalOrigin))
		mLocal.SetTranslation(UnserializeString_TVector(sLocalOrigin));

	tstring sLocalAngles = pThis->GetParameterValue("Angles");
	if (sLocalAngles.length() && CanUnserializeString_EAngle(sLocalAngles))
		mLocal.SetAngles(UnserializeString_EAngle(sLocalAngles));

	tstring sAABB = pThis->GetParameterValue("BoundingBox");
	if (CanUnserializeString_AABB(sAABB))
	{
		AABB aabbBounds = UnserializeString_AABB(sAABB, pThis->GetName(), pThis->m_sClass, "BoundingBox");

		// Center the entity around this bounding box.
		Vector vecGlobalOrigin = aabbBounds.Center();
		mLocal.SetTranslation(mLocal.GetTranslation() + vecGlobalOrigin);

		Vector vecNewOrigin = mLocal.GetTranslation();
		pThis->SetParameterValue("Origin", pretty_float(vecNewOrigin.x) + " " + pretty_float(vecNewOrigin.y) + " " + pretty_float(vecNewOrigin.z));

		aabbBounds.m_vecMins -= vecGlobalOrigin;
		aabbBounds.m_vecMaxs -= vecGlobalOrigin;
		pThis->SetParameterValue("BoundingBox",
			pretty_float(aabbBounds.m_vecMins.x) + " " + pretty_float(aabbBounds.m_vecMins.y) + " " + pretty_float(aabbBounds.m_vecMins.z) + " "
			+ pretty_float(aabbBounds.m_vecMaxs.x) + " " + pretty_float(aabbBounds.m_vecMaxs.y) + " " + pretty_float(aabbBounds.m_vecMaxs.z));
	}

	return mLocal;
}
开发者ID:BSVino,项目名称:Digitanks,代码行数:33,代码来源:level.cpp

示例2: RenderText

void CRenderingContext::RenderText(const tstring& sText, unsigned iLength, FTFont* pFont)
{
	TAssert(m_pShader);
	if (!m_pShader)
		return;

	CRenderContext& oContext = GetContext();

	if (iLength == -1)
		iLength = sText.length();

	TAssert(m_pShader->m_iPositionAttribute >= 0);
	TAssert(m_pShader->m_aiTexCoordAttributes[0] >= 0);

	if (!oContext.m_bProjectionUpdated)
		SetUniform("mProjection", oContext.m_mProjection);

	if (!oContext.m_bViewUpdated)
		SetUniform("mView", oContext.m_mView);

	// Take the position out and let FTGL do it. It looks sharper that way.
	Matrix4x4 mTransformations = oContext.m_mTransformations;
	Vector vecPosition = mTransformations.GetTranslation();
	mTransformations.SetTranslation(Vector());
	SetUniform("mGlobal", mTransformations);

	oContext.m_bProjectionUpdated = oContext.m_bViewUpdated = oContext.m_bTransformUpdated = true;

	ftglSetAttributeLocations(m_pShader->m_iPositionAttribute, m_pShader->m_aiTexCoordAttributes[0]);

	pFont->Render(sText.c_str(), iLength, FTPoint(vecPosition.x, vecPosition.y, vecPosition.z));
}
开发者ID:BSVino,项目名称:CodenameInfinite,代码行数:32,代码来源:renderingcontext.cpp

示例3: SetTransform

void CTransform::SetTransform( Matrix4x4& transform )
{
	m_Translation.Set( transform.GetTranslation() );
	m_Euler.SetFromMatrix( transform );
	m_Scale.Set( transform.GetScale() );
	m_Transform.SetFrom4x4( transform.m );

	m_DirtyMatrix = false;
	m_DirtyQuaternion = true;
}
开发者ID:klhurley,项目名称:ElementalEngine2,代码行数:10,代码来源:CTransform.cpp

示例4: MouseInput

bool CManipulatorTool::MouseInput(int iButton, tinker_mouse_state_t iState)
{
	if (!IsActive())
		return false;

	if (!iState)
	{
		if (m_bTransforming)
		{
			m_bTransforming = false;

			m_trsTransform = GetNewTRS();

			m_pListener->ManipulatorUpdated(m_sListenerArguments);

			return true;
		}

		return false;
	}

	int x, y;
	Application()->GetMousePosition(x, y);

	Vector vecPosition = GameServer()->GetRenderer()->WorldPosition(Vector((float)x, (float)y, 1));
	Vector vecCamera = GameServer()->GetRenderer()->GetCameraPosition();

	float flClosest = -1;
	m_iLockedAxis = -1;

	Matrix4x4 mTransform = m_trsTransform.GetMatrix4x4(false, false);

	float flScale = (float)(Vector(GameServer()->GetCameraManager()->GetCameraPosition()) - mTransform.GetTranslation()).Length()/10.0f;
	Vector vecX = (Vector(1, 0, 0)*flScale);
	Vector vecY = (Vector(0, 1, 0)*flScale);
	Vector vecZ = (Vector(0, 0, 1)*flScale);

	if (DistanceToLine(m_trsTransform.m_vecTranslation, vecPosition, vecCamera) < 0.2f*flScale)
	{
		m_flOriginalDistance = (m_trsTransform.m_vecTranslation - vecCamera).Length();
		m_iLockedAxis = 0;
	}

	if (DistanceToLine(mTransform*vecX, vecPosition, vecCamera) < 0.1f*flScale)
	{
		float flDistance = (mTransform*vecX - vecCamera).Length();
		if (m_iLockedAxis < 0 || flDistance < m_flOriginalDistance)
		{
			m_flOriginalDistance = flDistance;
			m_iLockedAxis = (1<<1)|(1<<2);
		}
	}

	if (DistanceToLine(mTransform*vecY, vecPosition, vecCamera) < 0.1f*flScale)
	{
		float flDistance = (mTransform*vecY - vecCamera).Length();
		if (m_iLockedAxis < 0 || flDistance < m_flOriginalDistance)
		{
			m_flOriginalDistance = flDistance;
			m_iLockedAxis = (1<<0)|(1<<2);
		}
	}

	if (DistanceToLine(mTransform*vecZ, vecPosition, vecCamera) < 0.1f*flScale)
	{
		float flDistance = (mTransform*vecZ - vecCamera).Length();
		if (m_iLockedAxis < 0 || flDistance < m_flOriginalDistance)
		{
			m_flOriginalDistance = flDistance;
			m_iLockedAxis = (1<<0)|(1<<1);
		}
	}

	if (m_iLockedAxis >= 0)
	{
		m_flStartX = (float)x;
		m_flStartY = (float)y;
		m_bTransforming = true;

		if (m_pListener && Application()->IsShiftDown())
			m_pListener->DuplicateMove("");

		return true;
	}

	return false;
}
开发者ID:BSVino,项目名称:CodenameInfinite,代码行数:87,代码来源:manipulator.cpp

示例5: Render

void CManipulatorTool::Render()
{
	if (!IsActive())
		return;

	Matrix4x4 mTransform = GetTransform(false, false);

	float flScale = (float)(Vector(GameServer()->GetCameraManager()->GetCameraPosition()) - mTransform.GetTranslation()).Length()/10.0f;

	if (flScale < 0.001f)
		flScale = 0.001f;

	CGameRenderingContext c(GameServer()->GetRenderer(), true);

	c.ClearDepth();

	c.UseProgram("model");
	c.SetUniform("vecColor", Color(255, 255, 255, 255));
	c.SetUniform("bDiffuse", false);

	c.Transform(mTransform);
	c.Scale(flScale, flScale, flScale);

	Vector vecBox(0.1f, 0.1f, 0.1f);
	c.RenderWireBox(AABB(-vecBox, vecBox));

	c.BeginRenderLines();
		c.Vertex(Vector());
		c.Vertex(Vector(1, 0, 0));
		c.Vertex(Vector());
		c.Vertex(Vector(0, 1, 0));
		c.Vertex(Vector());
		c.Vertex(Vector(0, 0, 1));
	c.EndRender();

	Vector vecHandle(0.05f, 0.05f, 0.05f);
	c.Translate(Vector(1, 0, 0));
	c.SetUniform("vecColor", Color(255, 0, 0, 255));
	if (GetTransfromType() == MT_TRANSLATE)
		c.RenderWireBox(AABB(-vecHandle * Vector(2, 1, 1), vecHandle * Vector(2, 1, 1)));
	else if (GetTransfromType() == MT_ROTATE)
		c.RenderWireBox(AABB(-vecHandle * Vector(1, 1, 2), vecHandle * Vector(1, 1, 2)));
	else if (GetTransfromType() == MT_SCALE)
		c.RenderWireBox(AABB(-vecHandle, vecHandle));

	c.Translate(Vector(-1, 1, 0));
	c.SetUniform("vecColor", Color(0, 255, 0, 255));
	if (GetTransfromType() == MT_TRANSLATE)
		c.RenderWireBox(AABB(-vecHandle * Vector(1, 2, 1), vecHandle * Vector(1, 2, 1)));
	else if (GetTransfromType() == MT_ROTATE)
		c.RenderWireBox(AABB(-vecHandle * Vector(2, 1, 1), vecHandle * Vector(2, 1, 1)));
	else if (GetTransfromType() == MT_SCALE)
		c.RenderWireBox(AABB(-vecHandle, vecHandle));

	c.Translate(Vector(0, -1, 1));
	c.SetUniform("vecColor", Color(0, 0, 255, 255));
	if (GetTransfromType() == MT_TRANSLATE)
		c.RenderWireBox(AABB(-vecHandle * Vector(1, 1, 2), vecHandle * Vector(1, 1, 2)));
	else if (GetTransfromType() == MT_ROTATE)
		c.RenderWireBox(AABB(-vecHandle * Vector(1, 2, 1), vecHandle * Vector(1, 2, 1)));
	else if (GetTransfromType() == MT_SCALE)
		c.RenderWireBox(AABB(-vecHandle, vecHandle));

	c.SetUniform("vecColor", Color(255, 255, 255, 255));
	c.SetUniform("bDiffuse", true);
}
开发者ID:BSVino,项目名称:CodenameInfinite,代码行数:66,代码来源:manipulator.cpp


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