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


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

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


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

示例1: size

	Boxf SphereCollider3D::ComputeAABB(const Matrix4f& offsetMatrix, const Vector3f& scale) const
	{
		Vector3f size(m_radius * NazaraSuffixMacro(M_SQRT3, f) * scale);
		Vector3f position(offsetMatrix.GetTranslation());

		return Boxf(position - size, position + size);
	}
开发者ID:DigitalPulseSoftware,项目名称:NazaraEngine,代码行数:7,代码来源:Collider3D.cpp

示例2: IntersectRayBounds

IntersectRayBoundsResult Scene::IntersectRayBounds(SceneObject *target, bool axisInWorld) {

    Matrix4f worldToModelM = target->GetMatrixWorld().Inverted();
    Matrix4f invertedCenterViewM = centerViewM.Inverted();
    Vector3f inWorldCenterViewPos = invertedCenterViewM.GetTranslation();
    Quatf centerViewRot = Quatf(invertedCenterViewM);

    const Vector3f rayStart = worldToModelM.Transform(inWorldCenterViewPos);
    const Vector3f rayDir = worldToModelM.Transform(centerViewRot.Rotate(Vector3f(0.0f, 0.0f, -1.0f))) - rayStart;
    const BoundingBoxInfo boundingBoxInfo = target->GetRenderData()->GetMesh()->GetBoundingBoxInfo();
    float t0 = 0.0f;
    float t1 = 0.0f;

    bool intersected = Intersect_RayBounds(rayStart, rayDir, boundingBoxInfo.mins, boundingBoxInfo.maxs, t0, t1);

    IntersectRayBoundsResult result;
    result.intersected = intersected && t0 > 0;

    if (intersected) {
        result.first = rayStart + t0 * rayDir;
        result.second = rayStart + t1 * rayDir;

        if (axisInWorld) {
            result.first = target->GetMatrixWorld().Transform(result.first);
            result.second = target->GetMatrixWorld().Transform(result.second);
        }
    }

    return result;
}
开发者ID:proverbface,项目名称:Meganekko,代码行数:30,代码来源:scene.cpp

示例3: SetTransformMatrix

	void Node::SetTransformMatrix(const Matrix4f& matrix)
	{
		SetPosition(matrix.GetTranslation(), CoordSys_Global);
		SetRotation(matrix.GetRotation(), CoordSys_Global);
		SetScale(matrix.GetScale(), CoordSys_Global);

		m_transformMatrix = matrix;
		m_transformMatrixUpdated = true;
	}
开发者ID:Ardakaniz,项目名称:NazaraEngine,代码行数:9,代码来源:Node.cpp

示例4: RenderEyeView

void Renderer::RenderEyeView(Scene* scene, std::vector<SceneObject*> scene_objects, OESShader* oesShader,
        const Matrix4f &eyeViewMatrix, const Matrix4f &eyeProjectionMatrix, const Matrix4f &eyeViewProjection, const int eye) {
    // there is no need to flat and sort every frame.
    // however let's keep it as is and assume we are not changed
    // This is not right way to do data conversion. However since GVRF doesn't support
    // bone/weight/joint and other assimp data, we will put general model conversion
    // on hold and do this kind of conversion fist

    std::vector<RenderData*> render_data_vector;

    // do occlusion culling, if enabled
    OcclusionCull(scene, scene_objects);

    // do frustum culling, if enabled
    FrustumCull(scene, eyeViewMatrix.GetTranslation(), scene_objects, render_data_vector,
            eyeViewProjection, oesShader);

    // do sorting based on render order
    if (!scene->GetFrustumCulling()) {
        std::sort(render_data_vector.begin(), render_data_vector.end(),
                compareRenderData);
    } else {
        std::sort(render_data_vector.begin(), render_data_vector.end(),
                compareRenderDataWithFrustumCulling);
    }

    glEnable (GL_DEPTH_TEST);
    glDepthFunc (GL_LEQUAL);
    glEnable (GL_CULL_FACE);
    glFrontFace (GL_CCW);
    glCullFace (GL_BACK);
    glEnable (GL_BLEND);
    glBlendEquation (GL_FUNC_ADD);
    glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
    glDisable (GL_POLYGON_OFFSET_FILL);

    // TODO background color as parameter
    glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
    glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT);

    for (auto it = render_data_vector.begin();
            it != render_data_vector.end(); ++it) {
        RenderRenderData(*it, eyeViewMatrix, eyeProjectionMatrix, oesShader, eye);
    }

}
开发者ID:proverbface,项目名称:Meganekko,代码行数:46,代码来源:renderer.cpp

示例5: Finish

//==============================
// VRMenuMgrLocal::Finish
void VRMenuMgrLocal::Finish( Matrix4f const & viewMatrix )
{
	if ( NumSubmitted == 0 )
	{
		return;
	}

	Matrix4f invViewMatrix = viewMatrix.Inverted(); // if the view is never scaled or sheared we could use Transposed() here instead
	Vector3f viewPos = invViewMatrix.GetTranslation();

	// sort surfaces
	SortKeys.Resize( NumSubmitted );
	for ( int i = 0; i < NumSubmitted; ++i )
	{
		// the sort key is a combination of the distance squared, reinterpreted as an integer, and the submission index
		// this sorts on distance while still allowing submission order to contribute in the equal case.
		float distSq = ( Submitted[i].Pose.Position - viewPos ).LengthSq();
		int64_t sortKey = *reinterpret_cast< unsigned* >( &distSq );
		SortKeys[i].Key = ( sortKey << 32ULL ) | i;
	}
	
	Alg::QuickSort( SortKeys );
}
开发者ID:beijingkaka,项目名称:shellspace,代码行数:25,代码来源:VRMenuMgr.cpp

示例6: IntersectRayBounds

IntersectRayBoundsResult IntersectRayBounds(const Matrix4f &centerViewMatrix,
                                            const Matrix4f &targetWorldMatrix,
                                            const GlGeometry &targetGeometry,
                                            bool axisInWorld) {

  Matrix4f worldToModelM = targetWorldMatrix.Inverted();
  Matrix4f invertedCenterViewM = centerViewMatrix.Inverted();
  Vector3f inWorldCenterViewPos = invertedCenterViewM.GetTranslation();
  Quatf centerViewRot = Quatf(invertedCenterViewM);

  const Vector3f rayStart = worldToModelM.Transform(inWorldCenterViewPos);
  const Vector3f rayDir = worldToModelM.Transform(centerViewRot.Rotate(
                              Vector3f(0.0f, 0.0f, -1.0f))) -
                          rayStart;
  const Vector3f boundingBoxMins = targetGeometry.localBounds.GetMins();
  const Vector3f boundingBoxMaxs = targetGeometry.localBounds.GetMaxs();
  float t0 = 0.0f;
  float t1 = 0.0f;

  bool intersected = Intersect_RayBounds(rayStart, rayDir, boundingBoxMins,
                                         boundingBoxMaxs, t0, t1);

  IntersectRayBoundsResult result;
  result.intersected = intersected && t0 > 0;

  if (intersected) {
    result.first = rayStart + t0 * rayDir;
    result.second = rayStart + t1 * rayDir;

    if (axisInWorld) {
      result.first = targetWorldMatrix.Transform(result.first);
      result.second = targetWorldMatrix.Transform(result.second);
    }
  }

  return result;
}
开发者ID:ejeinc,项目名称:Meganekko,代码行数:37,代码来源:LookDetector.cpp

示例7: AddMesh

	void ForwardRenderQueue::AddMesh(int renderOrder, const Material* material, const MeshData& meshData, const Boxf& meshAABB, const Matrix4f& transformMatrix)
	{
		if (material->IsEnabled(RendererParameter_Blend))
		{
			Layer& currentLayer = GetLayer(renderOrder);
			auto& transparentModels = currentLayer.transparentModels;
			auto& transparentModelData = currentLayer.transparentModelData;

			// Le matériau est transparent, nous devons rendre ce mesh d'une autre façon (après le rendu des objets opaques et en les triant)
			unsigned int index = transparentModelData.size();
			transparentModelData.resize(index+1);

			TransparentModelData& data = transparentModelData.back();
			data.material = material;
			data.meshData = meshData;
			data.squaredBoundingSphere = Spheref(transformMatrix.GetTranslation() + meshAABB.GetCenter(), meshAABB.GetSquaredRadius());
			data.transformMatrix = transformMatrix;

			transparentModels.push_back(index);
		}
		else
		{
			Layer& currentLayer = GetLayer(renderOrder);
			auto& opaqueModels = currentLayer.opaqueModels;

			auto it = opaqueModels.find(material);
			if (it == opaqueModels.end())
			{
				BatchedModelEntry entry;
				entry.materialReleaseSlot.Connect(material->OnMaterialRelease, this, &ForwardRenderQueue::OnMaterialInvalidation);

				it = opaqueModels.insert(std::make_pair(material, std::move(entry))).first;
			}

			BatchedModelEntry& entry = it->second;
			entry.enabled = true;

			auto& meshMap = entry.meshMap;

			auto it2 = meshMap.find(meshData);
			if (it2 == meshMap.end())
			{
				MeshInstanceEntry instanceEntry;
				instanceEntry.squaredBoundingSphere = meshAABB.GetSquaredBoundingSphere();

				if (meshData.indexBuffer)
					instanceEntry.indexBufferReleaseSlot.Connect(meshData.indexBuffer->OnIndexBufferRelease, this, &ForwardRenderQueue::OnIndexBufferInvalidation);

				instanceEntry.vertexBufferReleaseSlot.Connect(meshData.vertexBuffer->OnVertexBufferRelease, this, &ForwardRenderQueue::OnVertexBufferInvalidation);

				it2 = meshMap.insert(std::make_pair(meshData, std::move(instanceEntry))).first;
			}

			std::vector<Matrix4f>& instances = it2->second.instances;
			instances.push_back(transformMatrix);

			// Avons-nous suffisamment d'instances pour que le coût d'utilisation de l'instancing soit payé ?
			if (instances.size() >= NAZARA_GRAPHICS_INSTANCING_MIN_INSTANCES_COUNT)
				entry.instancingEnabled = true; // Apparemment oui, activons l'instancing avec ce matériau
		}
	}
开发者ID:GigAnon,项目名称:NazaraEngine,代码行数:61,代码来源:ForwardRenderQueue.cpp

示例8:

	SphereCollider3D::SphereCollider3D(float radius, const Matrix4f& transformMatrix) :
	SphereCollider3D(radius, transformMatrix.GetTranslation())
	{
	}
开发者ID:DigitalPulseSoftware,项目名称:NazaraEngine,代码行数:4,代码来源:Collider3D.cpp

示例9: Finish

//==============================
// BitmapFontSurfaceLocal::Finish
// transform all vertex blocks into the vertices array so they're ready to be uploaded to the VBO
// We don't have to do this for each eye because the billboarded surfaces are sorted / aligned
// based on their distance from / direction to the camera view position and not the camera direction.
void BitmapFontSurfaceLocal::Finish( Matrix4f const & viewMatrix )
{
    DROID_ASSERT( this != NULL, "BitmapFont" );

	//SPAM( "BitmapFontSurfaceLocal::Finish" );

	Matrix4f invViewMatrix = viewMatrix.Inverted(); // if the view is never scaled or sheared we could use Transposed() here instead
	Vector3f viewPos = invViewMatrix.GetTranslation();

	// sort vertex blocks indices based on distance to pivot
	int const MAX_VERTEX_BLOCKS = 256;
	vbSort_t vbSort[MAX_VERTEX_BLOCKS];
	int const n = VertexBlocks.GetSizeI();
	for ( int i = 0; i < n; ++i )
	{
		vbSort[i].VertexBlockIndex = i;
		VertexBlockType & vb = VertexBlocks[i];
		vbSort[i].DistanceSquared = ( vb.Pivot - viewPos ).LengthSq();
	}

	qsort( vbSort, n, sizeof( vbSort[0] ), VertexBlockSortFn );

	// transform the vertex blocks into the vertices array
	CurIndex = 0;
	CurVertex = 0;

	// TODO:
	// To add multiple-font-per-surface support, we need to add a 3rd component to s and t, 
	// then get the font for each vertex block, and set the texture index on each vertex in 
	// the third texture coordinate.
	for ( int i = 0; i < VertexBlocks.GetSizeI(); ++i )
	{		
		VertexBlockType & vb = VertexBlocks[vbSort[i].VertexBlockIndex];
		Matrix4f transform;
		if ( vb.Billboard )
		{
			if ( vb.TrackRoll )
			{
				transform = invViewMatrix;
			}
			else
			{
                Vector3f textNormal = viewPos - vb.Pivot;
                textNormal.Normalize();
                transform = Matrix4f::CreateFromBasisVectors( textNormal, Vector3f( 0.0f, 1.0f, 0.0f ) );
			}
			transform.SetTranslation( vb.Pivot );
		}
		else
		{
			transform.SetIdentity();
			transform.SetTranslation( vb.Pivot );
		}

		for ( int j = 0; j < vb.NumVerts; j++ )
		{
			fontVertex_t const & v = vb.Verts[j];
			Vertices[CurVertex].xyz = transform.Transform( v.xyz );
			Vertices[CurVertex].s = v.s;
			Vertices[CurVertex].t = v.t;			
			*(UInt32*)(&Vertices[CurVertex].rgba[0]) = *(UInt32*)(&v.rgba[0]);
			*(UInt32*)(&Vertices[CurVertex].fontParms[0]) = *(UInt32*)(&v.fontParms[0]);
			CurVertex++;
		}
		CurIndex += ( vb.NumVerts / 2 ) * 3;
		// free this vertex block
		vb.Free();
	}
	// remove all elements from the vertex block (but don't free the memory since it's likely to be 
	// needed on the next frame.
	VertexBlocks.Clear();

	glBindVertexArrayOES_( Geo.vertexArrayObject );
	glBindBuffer( GL_ARRAY_BUFFER, Geo.vertexBuffer );
	glBufferSubData( GL_ARRAY_BUFFER, 0, CurVertex * sizeof( fontVertex_t ), (void *)Vertices );
	glBindVertexArrayOES_( 0 );
	
    Geo.indexCount = CurIndex;
}
开发者ID:1107979819,项目名称:OculusVRStudy,代码行数:84,代码来源:BitmapFont.cpp


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