本文整理汇总了C++中util::Reference::setDrawMode方法的典型用法代码示例。如果您正苦于以下问题:C++ Reference::setDrawMode方法的具体用法?C++ Reference::setDrawMode怎么用?C++ Reference::setDrawMode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类util::Reference
的用法示例。
在下文中一共展示了Reference::setDrawMode方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: drawVector
void drawVector(RenderingContext & rc, const Geometry::Vec3 & from, const Geometry::Vec3 & to) {
static Util::Reference<Mesh> mesh;
if (mesh.isNull()) {
VertexDescription vertexDescription;
vertexDescription.appendPosition3D();
mesh = new Mesh(vertexDescription, 2, 2);
mesh->setDrawMode(Mesh::DRAW_LINES);
MeshIndexData & id = mesh->openIndexData();
uint32_t * indices = id.data();
indices[0] = 0;
indices[1] = 1;
id.updateIndexRange();
id.markAsChanged();
mesh->setDataStrategy(SimpleMeshDataStrategy::getPureLocalStrategy());
}
MeshVertexData & vd = mesh->openVertexData();
float * vertices = reinterpret_cast<float *> (vd.data());
*vertices++ = from.getX(); // From
*vertices++ = from.getY();
*vertices++ = from.getZ();
*vertices++ = to.getX(); // To
*vertices++ = to.getY();
*vertices++ = to.getZ();
vd.updateBoundingBox();
vd.markAsChanged();
rc.displayMesh(mesh.get());
}
示例2: drawWireframeBox
void drawWireframeBox(RenderingContext & rc, const Geometry::Box & box) {
static Util::Reference<Mesh> mesh;
if (mesh.isNull()) {
VertexDescription vertexDescription;
vertexDescription.appendPosition3D();
mesh = new Mesh(vertexDescription, 8, 16);
mesh->setDataStrategy(SimpleMeshDataStrategy::getPureLocalStrategy());
mesh->setDrawMode(Mesh::DRAW_LINE_STRIP);
MeshIndexData & id = mesh->openIndexData();
uint32_t * indices = id.data();
/*
* Corners:
* 6---------7
* /| /|
* / | / |
* 2---------3 |
* | | | |
* | 4------|--5
* | / | /
* |/ |/
* 0---------1
*/
indices[0] = 0;
indices[1] = 2;
indices[2] = 3;
indices[3] = 1;
indices[4] = 5;
indices[5] = 7;
indices[6] = 6;
indices[7] = 4;
indices[8] = 0;
indices[9] = 1;
indices[10] = 3;
indices[11] = 7;
indices[12] = 5;
indices[13] = 4;
indices[14] = 6;
indices[15] = 2;
id.updateIndexRange();
id.markAsChanged();
}
MeshVertexData & vd = mesh->openVertexData();
float * vertices = reinterpret_cast<float *>(vd.data());
for (uint_fast8_t c = 0; c < 8; ++c) {
const Geometry::Vec3 & corner = box.getCorner(static_cast<Geometry::corner_t> (c));
*vertices++ = corner.getX();
*vertices++ = corner.getY();
*vertices++ = corner.getZ();
}
vd._setBoundingBox(box);
vd.markAsChanged();
rc.displayMesh(mesh.get());
}
示例3: drawGrid
void drawGrid(RenderingContext & rc, float scale) {
static Util::Reference<Mesh> mesh;
if (mesh.isNull()) {
VertexDescription vertexDescription;
vertexDescription.appendPosition3D();
mesh = new Mesh(vertexDescription, 4 * 101, 4 * 101);
mesh->setDrawMode(Mesh::DRAW_LINES);
MeshVertexData & vd = mesh->openVertexData();
float * vertices = reinterpret_cast<float *> (vd.data());
MeshIndexData & id = mesh->openIndexData();
uint32_t * indices = id.data();
uint32_t nextIndex = 0;
const float step = 1.0f / 100.0f;
for (uint_fast8_t line = 0; line < 101; ++line) {
const float pos = -0.5f + static_cast<float> (line) * step;
*vertices++ = -0.5f;
*vertices++ = 0.0f;
*vertices++ = pos;
*vertices++ = 0.5f;
*vertices++ = 0.0f;
*vertices++ = pos;
*indices++ = nextIndex++;
*indices++ = nextIndex++;
*vertices++ = pos;
*vertices++ = 0.0f;
*vertices++ = -0.5f;
*vertices++ = pos;
*vertices++ = 0.0f;
*vertices++ = 0.5f;
*indices++ = nextIndex++;
*indices++ = nextIndex++;
}
vd.updateBoundingBox();
vd.markAsChanged();
id.updateIndexRange();
id.markAsChanged();
}
Geometry::Matrix4x4 matrix;
matrix.scale(scale);
rc.pushMatrix_modelToCamera();
rc.multMatrix_modelToCamera(matrix);
rc.displayMesh(mesh.get());
rc.popMatrix_modelToCamera();
}
示例4: drawFrustum
void drawFrustum(RenderingContext & rc, const Geometry::Frustum & frustum, const Util::Color4f & color, float lineWidth) {
static Util::Reference<Mesh> mesh;
if (mesh.isNull()) {
VertexDescription vertexDescription;
vertexDescription.appendPosition3D();
mesh = new Mesh(vertexDescription, 8, 16);
mesh->setDrawMode(Mesh::DRAW_LINE_STRIP);
MeshIndexData & id = mesh->openIndexData();
uint32_t * indices = id.data();
indices[0] = 0;
indices[1] = 2;
indices[2] = 3;
indices[3] = 1;
indices[4] = 5;
indices[5] = 7;
indices[6] = 6;
indices[7] = 4;
indices[8] = 0;
indices[9] = 1;
indices[10] = 3;
indices[11] = 7;
indices[12] = 5;
indices[13] = 4;
indices[14] = 6;
indices[15] = 2;
id.updateIndexRange();
}
MeshVertexData & vd = mesh->openVertexData();
float * vertices = reinterpret_cast<float *>(vd.data());
for (uint_fast8_t c = 0; c < 8; ++c) {
const Geometry::Vec3 & corner = frustum[static_cast<Geometry::corner_t> (c)];
*vertices++ = corner.getX();
*vertices++ = corner.getY();
*vertices++ = corner.getZ();
}
vd.updateBoundingBox();
vd.markAsChanged();
rc.pushAndSetLine(lineWidth);
rc.pushAndSetLighting(LightingParameters(false));
rc.pushAndSetColorMaterial(color);
rc.displayMesh(mesh.get());
rc.popMaterial();
rc.popLighting();
rc.popLine();
}
示例5: drawRect
void drawRect(RenderingContext & rc, const Geometry::Rect & rect) {
static Util::Reference<Mesh> mesh;
if (mesh.isNull()) {
VertexDescription vertexDescription;
vertexDescription.appendPosition2D();
mesh = new Mesh(vertexDescription, 4, 6);
mesh->setDrawMode(Mesh::DRAW_TRIANGLES);
MeshVertexData & vd = mesh->openVertexData();
float * vertices = reinterpret_cast<float *> (vd.data());
*vertices++ = 0.0f; // Bottom left
*vertices++ = 0.0f;
*vertices++ = 1.0f; // Bottom right
*vertices++ = 0.0f;
*vertices++ = 1.0f; // Top right
*vertices++ = 1.0f;
*vertices++ = 0.0f; // Top left
*vertices++ = 1.0f;
vd.updateBoundingBox();
vd.markAsChanged();
MeshIndexData & id = mesh->openIndexData();
uint32_t * indices = id.data();
indices[0] = 0;
indices[1] = 2;
indices[2] = 1;
indices[3] = 0;
indices[4] = 3;
indices[5] = 2;
id.updateIndexRange();
id.markAsChanged();
}
Geometry::Matrix4x4 matrix;
matrix.translate(rect.getX(), rect.getY(), 0.0f);
matrix.scale(rect.getWidth(), rect.getHeight(), 1.0f);
rc.pushMatrix_modelToCamera();
rc.multMatrix_modelToCamera(matrix);
rc.displayMesh(mesh.get());
rc.popMatrix_modelToCamera();
}
示例6: operator
void ParticlePointRenderer::operator()(ParticleSystemNode* psys, FrameContext & context, const RenderParam & rp /* = 0 */) {
if ( (rp.getFlag(NO_GEOMETRY)) )
return;
// render particles
std::vector<Particle> & particles = psys->getParticles();
uint32_t count = psys->getParticleCount();
Rendering::VertexDescription vertexDesc;
const Rendering::VertexAttribute & posAttrib = vertexDesc.appendPosition3D();
const Rendering::VertexAttribute & colorAttrib = vertexDesc.appendColorRGBAByte();
// The usage of a cache for the mesh has been tested. Reusing a preallocated mesh is not faster.
Util::Reference<Rendering::Mesh> mesh = new Rendering::Mesh(vertexDesc, count, count);
mesh->setDataStrategy(Rendering::SimpleMeshDataStrategy::getPureLocalStrategy());
mesh->setDrawMode(Rendering::Mesh::DRAW_POINTS);
// mesh->setUseIndexData(false);
Rendering::MeshIndexData & indexData = mesh->openIndexData();
Rendering::MeshVertexData & vertexData = mesh->openVertexData();
Util::Reference<Rendering::PositionAttributeAccessor> positionAccessor = Rendering::PositionAttributeAccessor::create(vertexData, posAttrib.getNameId());
Util::Reference<Rendering::ColorAttributeAccessor> colorAccessor = Rendering::ColorAttributeAccessor::create(vertexData, colorAttrib.getNameId());
uint32_t * indices = indexData.data();
for(uint_fast32_t index = 0; index < count; ++index) {
const Particle & p = particles[index];
colorAccessor->setColor(index, p.color);
positionAccessor->setPosition(index, p.position);
*indices++ = index;
}
indexData.markAsChanged();
indexData.updateIndexRange();
vertexData.markAsChanged();
vertexData.updateBoundingBox();
context.displayMesh(mesh.get());
}