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


C++ MeshRenderer::GetMaterial方法代码示例

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


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

示例1: Reflect

void DirectusMaterial::Reflect(weak_ptr<GameObject> gameobject)
{
    m_inspectedMaterial = weak_ptr<Material>();

    // Catch the evil case
    if (gameobject.expired())
    {
        this->hide();
        return;
    }

    MeshRenderer* meshRenderer = gameobject.lock()->GetComponent<MeshRenderer>().lock().get();
    if (!meshRenderer)
    {
        this->hide();
        return;
    }



    m_inspectedMaterial = meshRenderer->GetMaterial();
    if (m_inspectedMaterial.expired())
    {
        this->hide();
        return;
    }

    // Do the actual reflection
    ReflectName();
    ReflectShader();
    ReflectAlbedo();
    ReflectRoughness();
    ReflectMetallic();
    ReflectNormal();
    ReflectHeight();
    ReflectOcclusion();
    ReflectEmission();
    ReflectMask();
    ReflectTiling();
    ReflectOffset();

    SetPropertiesVisible(m_inspectedMaterial.lock()->IsEditable() ? true : false);

    // Make this widget visible
    this->show();
}
开发者ID:PanosK92,项目名称:Directus3D,代码行数:46,代码来源:DirectusMaterial.cpp

示例2: Render

void Scene::Render( RenderPass renderPass, Viewport* viewport )
{
	static Mesh* skyboxMesh = ResourceManager::GetGenMesh(GenMeshes::Cube);

	std::string viewportName = viewport != NULL ? viewport->GetName() : "";

	bool ignoreShadowCast = true;
	if (renderPass == RenderPass::ShadowPass)
	{
		ignoreShadowCast = false;
	}

	for (uint rank = 0; rank < m_layers.size(); rank++)
	{
		if ( !m_layers[rank]->IsEnabled() )	continue;

		RenderManager::UseNewLayer(renderPass);

		if (rank == 0)
		{
			if ( m_skyboxMaterial != NULL && renderPass != RenderPass::PickingPass )
			{
				Transform transform(NULL);
				transform.SetPositionWorld( RenderManager::GetRenderCamera()->GetComponent<Transform>()->GetPositionWorld() );
				transform.SetScaleWorld( Vector3(m_skyboxSize) );

				MeshRenderer renderer;
				renderer.SetMaterial(m_skyboxMaterial);
				renderer.SetMesh(skyboxMesh);
				renderer.SetFaceCulling( FaceCulling::CULL_FRONT );

				RenderManager::ObjectToRender objectToRender;
				objectToRender.transform = &transform;
				objectToRender.meshRenderer = &renderer;
				objectToRender.renderPass = renderPass;

				RenderManager::RenderObject( objectToRender );
			}

			GizmoManager::RenderGrid( renderPass );
		}

#if (ME3D_SHADING_MODE == ME3D_CLASSIC_SHADING)
	
		if (viewport != NULL && viewport->HasEnableLights() && renderPass != RenderPass::PickingPass)
		{
			for (uint j = 0; j < m_layers[rank]->GetObjectsCount(); j++)
			{
				GameObject* obj = m_layers[rank]->GetObjectAt(j);

				if (obj->IsFullyActive())
				{
					Light* lightComp = obj->GetComponent<Light>();
					if (lightComp != NULL && lightComp->IsEnabled())
					{
						RenderManager::ActiveLight activeLight;
						activeLight.light = lightComp;
						activeLight.transform = obj->GetComponent<Transform>();

						RenderManager::AddActiveLight( activeLight );
					}
				}
			}
		}
#endif


		for (uint j = 0; j < m_layers[rank]->GetObjectsCount(); j++)
		{
			GameObject* obj = m_layers[rank]->GetObjectAt(j);

			if ( !obj->IsIgnoringViewport(viewportName)
				&& obj->IsFullyActive() )
			{
				GizmoManager::RenderFollower( obj, renderPass );

				MeshRenderer* renderer = obj->GetComponent<MeshRenderer>();
				GuiTexture* guiTexture = obj->GetComponent<GuiTexture>();

				glEnable(GL_DEPTH_TEST);
				glDepthMask(GL_TRUE);

				glEnable(GL_BLEND);
				glBlendEquation(GL_FUNC_ADD);
				glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

				if (renderer != NULL &&
					renderer->GetMaterial() != NULL &&
					renderer->GetMesh() != NULL &&
					(ignoreShadowCast || renderer->IsCastingShadows()) )
				{
					RenderManager::ObjectToRender objectToRender;
					objectToRender.uniqueIndex = obj->GetUniqueIndex();
					objectToRender.transform = obj->GetComponent<Transform>();
					objectToRender.meshRenderer = renderer;
					objectToRender.renderPass = renderPass;

					RenderManager::RenderObject( objectToRender );
				}

//.........这里部分代码省略.........
开发者ID:MorcoFreeCode,项目名称:2015__MorcoEngine3D,代码行数:101,代码来源:Scene.cpp


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