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


C++ Renderable::SetTexture方法代码示例

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


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

示例1: AddRenderable

void Renderer::AddRenderable(const glm::vec3& position, const glm::vec3& rotation, const glm::vec3& scale, Mesh* mesh, GLuint texture, const Frustum& frustum)
{
	Renderable* renderable = new Renderable;

	renderable->SetMesh(mesh);
	renderable->SetModelMatrix(position, rotation, scale);
	renderable->SetTexture(texture);

	renderable->ApplyModelMatrix();

	if (ShouldDraw(renderable, frustum))
		m_Renderables.push_back(renderable);
}
开发者ID:tnam,项目名称:MGD_Game_Engine,代码行数:13,代码来源:Renderer.cpp

示例2: LoadContent


//.........这里部分代码省略.........

	//Load Renderables
	int cubeModel = m_assetManager->LoadModel("./Content/Renderables/cube.fbx");
	int sphereModel = m_assetManager->LoadModel("./Content/Renderables/cube.fbx");
	int bunnyModel = m_assetManager->LoadModel("./Content/Renderables/bunny.fbx");
	int treeModel = m_assetManager->LoadModel("./Content/Renderables/Tree/AlanTree.fbx");
	//m_assetManager->RecalculateNormals(treeModel);

	//LoadSkybox
	m_skybox = new Skybox(); 

	std::vector<std::string> faces;

	faces.push_back("./Content/Textures/skyRight.png");
	faces.push_back("./Content/Textures/skyLeft.png");
	faces.push_back("./Content/Textures/skyTop.png");
	faces.push_back("./Content/Textures/skyBottom.png");
	faces.push_back("./Content/Textures/skyFront.png");
	faces.push_back("./Content/Textures/skyBack.png");

	m_skybox->Initialize(faces);

	//Load AI
	m_world = new World(m_nodeMap);

	//Load Lights
	m_light = m_renderer->CreateLight();
	m_light->SetColour(glm::vec4(200, 255, 255, 1));
	m_light->SetFallOff(200000);
	m_light->SetPosition(glm::vec3(150, 30, 150));

	m_sunLight = m_renderer->CreateLight();
	m_sunLight->SetColour(glm::vec4(50, 50, 80, 1));
	m_sunLight->SetFallOff(1000000);
	m_sunLight->SetPosition(glm::vec3(0, 200, 0));

	//create our particle system
	PxParticleFluid* pf;
	// create particle system in PhysX SDK
	// set immutable properties.
	PxU32 maxParticles = 200;
	bool perParticleRestOffset = false;
	pf = g_Physics->createParticleFluid(maxParticles, perParticleRestOffset);
	pf->setRestParticleDistance(3.0f);
	pf->setDynamicFriction(0);
	pf->setStaticFriction(0);
	pf->setDamping(0);
	pf->setParticleMass(30);
	pf->setRestitution(0);
	//pf->setParticleReadDataFlag(PxParticleReadDataFlag::eDENSITY_BUFFER,
	// true);
	pf->setParticleBaseFlag(PxParticleBaseFlag::eCOLLISION_TWOWAY, true);
	pf->setStiffness(300);
	if (pf)
	{
		float multiplier = 10.0f;

		g_PhysicsScene->addActor(*pf);
		m_particleEmitter = new ParticleFluidEmitter(maxParticles, PxVec3(150, 120, 150), pf, .05f);
		m_particleEmitter->setStartVelocityRange(-0.001f, -6000.0f * multiplier, -0.001f, 0.001f, -6000.0f * multiplier, 0.001f);
	}

	for (int i = 0; i < 5; ++i)
	{
		m_AI[i] = new UtilityAI(m_assetManager, m_world, m_nodeMap);
		Renderable* renderBox = m_renderer->CreateRenderable();
		renderBox->SetModel(bunnyModel);
		renderBox->SetScale(glm::vec3(0.01f, 0.01f, 0.01f));
		renderBox->SetTexture(LoadTexture("./Content/Renderables/white.png"));
		m_AI[i]->SetRenderable(renderBox);
	}

	for (int i = 0; i < 50; ++i)
	{
		m_trees[i] = m_renderer->CreateRenderable();
		m_trees[i]->SetModel(treeModel);

		glm::vec3 position = m_nodeMap->GetClosestNode(glm::vec3(40 + rand() % 220, 40 + rand() % 220, 40 + rand() % 220))->GetPos();
		position.y -= 1;
		m_trees[i]->SetPosition(position);

		m_trees[i]->Rotate(glm::vec3(1, 0, 0), -(3.14159265f / 2.0f));
		m_trees[i]->Rotate(glm::vec3(0, 0, 1), rand() % 200 / 100.0f);

		float randVal = rand() % 120 / 120.f;
		m_trees[i]->SetScale(glm::vec3(0.2f + randVal, 0.2f + randVal, 0.2f + randVal));
	}
	
	//Define a Plane
	PxTransform pose = PxTransform(PxVec3(0.0f, 5, 0.0f), PxQuat(PxHalfPi*1.0f, PxVec3(0.0f, 0.0f, 1.0f)));
	PxRigidStatic* plane = PxCreateStatic(*g_Physics, pose, PxPlaneGeometry(), *g_PhysicsMaterial);

	//Add the plane to the Physx Scene
	g_PhysicsScene->addActor(*plane);
	m_terrain->AddPhysicsShape(g_PhysicsScene, g_Physics);

	//Disable the mouse
	SetCursorPos(0, 0);
	glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_DISABLED);
}
开发者ID:Milswanca,项目名称:IconicEngine,代码行数:101,代码来源:CurrentApp.cpp


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