本文整理汇总了C++中util::Reference类的典型用法代码示例。如果您正苦于以下问题:C++ Reference类的具体用法?C++ Reference怎么用?C++ Reference使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Reference类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: drawTriangle
void drawTriangle(RenderingContext & rc, const Geometry::Vec3f & vertexA, const Geometry::Vec3f & vertexB, const Geometry::Vec3f & vertexC) {
static Util::Reference<Mesh> mesh;
if (mesh.isNull()) {
VertexDescription vertexDescription;
vertexDescription.appendPosition3D();
mesh = new Mesh(vertexDescription, 3, 3);
MeshIndexData & id = mesh->openIndexData();
uint32_t * indices = id.data();
indices[0] = 0;
indices[1] = 1;
indices[2] = 2;
id.updateIndexRange();
id.markAsChanged();
}
MeshVertexData & vd = mesh->openVertexData();
float * vertices = reinterpret_cast<float *>(vd.data());
// First vertex
*vertices++ = vertexA.getX();
*vertices++ = vertexA.getY();
*vertices++ = vertexA.getZ();
// Second vertex
*vertices++ = vertexB.getX();
*vertices++ = vertexB.getY();
*vertices++ = vertexB.getZ();
// Third vertex
*vertices++ = vertexC.getX();
*vertices++ = vertexC.getY();
*vertices++ = vertexC.getZ();
vd.updateBoundingBox();
vd.markAsChanged();
rc.displayMesh(mesh.get());
}
示例2: createMeshFromBitmaps
//! Deprecated
Mesh * MeshBuilder::createMeshFromBitmaps(const VertexDescription& vd, Util::Reference<Util::Bitmap> depth, Util::Reference<Util::Bitmap> color, Util::Reference<Util::Bitmap> normals) {
Util::Reference<Util::PixelAccessor> depthAcc = Util::PixelAccessor::create(std::move(depth));
if( depth.isNull() || depth->getPixelFormat()!=Util::PixelFormat::MONO_FLOAT ){
WARN("createMeshFromBitmaps: unsupported depth texture format");
return nullptr;
}
Util::Reference<Util::PixelAccessor> colorReader;
if(color.isNotNull()) {
colorReader = Util::PixelAccessor::create(std::move(color));
if(colorReader.isNull() || (colorReader->getPixelFormat() != Util::PixelFormat::RGBA && colorReader->getPixelFormat() != Util::PixelFormat::RGB)) {
WARN("createMeshFromBitmaps: unsupported color texture format");
return nullptr;
}
}
Util::Reference<Util::PixelAccessor> normalReader;
if(normals.isNotNull()) {
normalReader = Util::PixelAccessor::create(std::move(normals));
if(normalReader.isNull()){
WARN("createMeshFromBitmaps: unsupported normal texture format");
return nullptr;
}
}
return MeshUtils::createMeshFromBitmaps(vd,depthAcc,colorReader,normalReader);
}
示例3: update
void StatChart::update(const Statistics & fStats) {
Util::Reference<Util::PixelAccessor> pixels = Util::PixelAccessor::create(bitmap.get());
if(pixels == nullptr)
return;
pixels->fill(0, 0, bitmap->getWidth(), bitmap->getHeight(), Util::Color4f(0, 0, 0, 0));
// show grids
static const Util::Color4ub gridColor(0xa0, 0xa0, 0xa0, 0xa0);
for(float f = 10.0; f < timeRange; f += 10.0) {
const uint32_t x = static_cast<uint32_t> (bitmap->getWidth() * f / timeRange);
for (uint32_t row = 0; row < bitmap->getHeight(); ++row) {
pixels->writeColor(x, row, gridColor);
}
}
const float timeScale = getWidth() / (timeRange * 1000.0);
for(size_t i = 0; i < fStats.getNumEvents(); ++i) {
const Statistics::Event & event = fStats.getEvent(i);
const int x = static_cast<int> (event.time * timeScale);
if(x >= static_cast<int> (getWidth()))
continue;
const DataRow & dataRow = dataRows[event.type];
const int yTo = std::max(static_cast<int> (bitmap->getHeight()) - static_cast<int> (event.value * dataRow.scale), 0);
for(int y = bitmap->getHeight() - 1; y > yTo; --y)
pixels->writeColor(x, y, dataRow.color);
}
}
示例4: drawFullScreenRect
void drawFullScreenRect(RenderingContext & rc){
GET_GL_ERROR();
static Geometry::Matrix4x4f projectionMatrix(Geometry::Matrix4x4f::orthographicProjection(-1, 1, -1, 1, -1, 1));
static Geometry::Matrix4x4f modelViewMatrix;
static Util::Reference<Mesh> mesh;
if(mesh.isNull()) {
VertexDescription vertexDescription;
vertexDescription.appendPosition3D();
vertexDescription.appendTexCoord();
MeshUtils::MeshBuilder mb(vertexDescription);
mb.position(Geometry::Vec3f(-1,-1,0)); mb.texCoord0(Geometry::Vec2f(0,0)); uint32_t a = mb.addVertex();
mb.position(Geometry::Vec3f(1,-1,0)); mb.texCoord0(Geometry::Vec2f(1,0)); uint32_t b = mb.addVertex();
mb.position(Geometry::Vec3f(-1,1,0)); mb.texCoord0(Geometry::Vec2f(0,1)); uint32_t c = mb.addVertex();
mb.position(Geometry::Vec3f(1,1,0)); mb.texCoord0(Geometry::Vec2f(1,1)); uint32_t d = mb.addVertex();
mb.addTriangle(a, b, c);
mb.addTriangle(c, b, d);
mesh = mb.buildMesh();
}
rc.pushMatrix_cameraToClipping();
rc.setMatrix_cameraToClipping(projectionMatrix);
rc.pushMatrix_modelToCamera();
rc.setMatrix_modelToCamera(modelViewMatrix);
rc.displayMesh(mesh.get());
rc.popMatrix_modelToCamera();
rc.popMatrix_cameraToClipping();
GET_GL_ERROR();
}
示例5: doAddChild
void AbstractJoint::doAddChild(Util::Reference<Node> child) {
if(dynamic_cast<AbstractJoint *>(child.get()) == nullptr)
return;
if(dynamic_cast<ArmatureNode *> (child.get()) != nullptr)
return;
ListNode::doAddChild(child);
}
示例6: createAndSetId
Util::StringIdentifier createAndSetId(Util::Reference<Obj> obj){
Util::StringIdentifier id = getId(obj.get());
if(obj.isNotNull() && id.empty()) {
do { // Create a new, random identifier....
id = Util::StringIdentifier("$" + Util::StringUtils::createRandomString(6));
}while( get(id) ); // ... until an unused one is found.
setId(obj,id);
}
return id;
}
示例7: setId
void setId(Util::Reference<Obj> obj,const Util::StringIdentifier & id){
if(!id.empty()) // remove a obj possibly previously registered with the id
removeId( id );
if(obj.isNotNull()) // remove the obj's old id
removeId( obj.get() );
if(obj.isNotNull()&&!id.empty()){ // register the obj using the new id
map_objToId.emplace(obj.get(),id);
map_idToObj.emplace(id, std::move(obj));
}
}
示例8:
Util::Reference<CameraNode> PhotonRenderer::computePhotonCamera(){
Util::Reference<CameraNode> camera = new CameraNode;
float minDistance = 0.01f;
float maxDistance = 500.f;
camera->setViewport(Geometry::Rect_i(0, 0, _samplingWidth, _samplingHeight));
camera->setNearFar(minDistance, maxDistance);
camera->setAngles(-70, 70, -50, 50);
return camera;
}
示例9: doRemoveChild
bool MultiAlgoGroupNode::doRemoveChild(Util::Reference<Node> child) {
if(node.get() == child.get()) {
WARN("MultiAlgoGroupNode::doRemoveChild: don't remove direct child of MultiAlgoGroupNode");
return false;
}
return node->removeChild(child);
}
示例10: 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());
}
示例11: drawBox
void drawBox(RenderingContext & rc, const Geometry::Box & box) {
static Util::Reference<Mesh> mesh;
if (mesh.isNull()) {
VertexDescription vertexDescription;
vertexDescription.appendPosition3D();
vertexDescription.appendNormalFloat();
const Geometry::Box unitBox(Geometry::Vec3(-0.5f, -0.5f, -0.5f), Geometry::Vec3(0.5f, 0.5f, 0.5f));
mesh = MeshUtils::MeshBuilder::createBox(vertexDescription, unitBox);
}
Geometry::Matrix4x4 matrix;
matrix.translate(box.getCenter());
matrix.scale(box.getExtentX(), box.getExtentY(), box.getExtentZ());
rc.pushMatrix_modelToCamera();
rc.multMatrix_modelToCamera(matrix);
rc.displayMesh(mesh.get());
rc.popMatrix_modelToCamera();
}
示例12: 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());
}
示例13: QString
OverviewTableRow::OverviewTableRow(util::Reference<const impl::Call> call)
: call_{ call }
{
id_ = call_->getId();
idStr = QString::number(call_->getId());
for (size_t i = 0; i < 2 && i < call->matrixCount(); i++)
{
QPixmap img;
std::tie(std::ignore, img) =
qtutil::convertMatToQPixmap(call->matrixAt(i));
imgs.push_back(std::move(img));
}
description_ = QString(call_->description());
if (call_->metaData().isKnown)
{
const auto &data = call_->metaData();
line_ = data.line;
lineStr = QString::number(data.line);
fileStr = data.file;
functionStr = data.function;
}
typeStr = QString(call_->type());
}
示例14: 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());
}
示例15: 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();
}