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


C++ TriangleBuffer::add方法代码示例

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


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

示例1: demonstrate

void DamBreakSample::demonstrate(const int width, const int height, const Crystal::Graphics::ICamera<float>& camera)
{
	this->width = width;
	this->height = height;
	this->rotationMatrix = camera.getRotationMatrix();
	glEnable(GL_DEPTH_TEST);

	interaction.simulate(1.0f / 60.0f);


	PointLight<float> light;
	light.setPos(Vector3d<float>(10.0f, 10.0f, -10.0f));
	light.setDiffuse(ColorRGBA<float>(1.0f, 0.0f, 0.0f, 1.0f));

	glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

	for (auto r : rigids) {
		const auto matrix = r->getTransformMatrix();
		auto p = r->getShape()->clone(r->getShape()->getId());
		p->transform(matrix);

		glViewport(0, 0, width, height);

		TriangleBuffer triangleBuffer;
		triangleBuffer.add(*p);
		//renderer.render(camera, lineBuffer);
		Material material;
		material.setAmbient(ColorRGBA<float>(0.2, 0.2, 0.2, 0.0));
		smoothRenderer.render(camera, triangleBuffer, light, material);

		glViewport(0, 0, fb.getWidth(), fb.getHeight());
		fb.bind();
		idRenderer.render(camera, triangleBuffer);
		fb.unbind();

		delete p;
	}

	glClearColor(0.7f, 0.7f, 0.7f, 1.0f);
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

	for (auto r : rigids) {
		const auto matrix = r->getTransformMatrix();
		auto p = r->getShape()->clone(r->getShape()->getId());
		p->transform(matrix);

		glViewport(0, 0, width, height);

		TriangleBuffer triangleBuffer;
		triangleBuffer.add(*p);
		//renderer.render(camera, lineBuffer);
		Material material;
		smoothRenderer.render(camera, triangleBuffer, light, material);

		//glViewport(0, 0, fb.getWidth(), fb.getHeight());

		delete p;
	}

	glViewport(0, 0, width, height);

	const auto& particles = fluid->getParticles();
	float minPressure = +FLT_MAX;
	float maxPressure = -FLT_MAX;
	for (auto p : particles) {
		minPressure = std::min<float>(minPressure, p->getDensity());
		maxPressure = std::max<float>(maxPressure, p->getDensity());
	}
	colorMap.setMinMax(900.0f, 1400.0f);

	//colorMap.setMinMax(800.0f, 2000.0f);
	PointBuffer buffer;
	for (auto p : particles) {
		const auto pos = p->getPosition();
		auto color = colorMap.getColor(p->getDensity());
		color.setAlpha(0.5f);
		Crystal::Graphics::Point point(pos, color, 500.0f);
		buffer.add(point);
	}
	pointRenderer.render(camera, buffer);

}
开发者ID:SatoshiMabuchi,项目名称:CGLib,代码行数:83,代码来源:DamBreakSample.cpp


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