本文整理汇总了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);
}