本文整理汇总了C++中Renderable类的典型用法代码示例。如果您正苦于以下问题:C++ Renderable类的具体用法?C++ Renderable怎么用?C++ Renderable使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Renderable类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
RenderableIterator& RenderableIterator::erase( RenderableIterator& item_to_remove )
{
Renderable* pValueToErase = *item_to_remove;
RenderLayers::iterator layerElements = theWorld.GetLayers().find( pValueToErase->GetLayer() );
if (layerElements != theWorld.GetLayers().end())
{
RenderList::iterator element = (*layerElements).second.begin();
while ( element != (*layerElements).second.end() )
{
if ( *element == pValueToErase)
{
_myIterator = (*layerElements).second.erase(element);
// Have to force to next layer.
// Let our ++ operator do it's magic.
if ( _myIterator == (*layerElements).second.end() )
{
++item_to_remove;
}
else
{
_ptr = *_myIterator;
}
return *this;
}
++element;
}
}
return *this;
}
示例2: Renderable
Renderable* Renderable::Lines(const std::vector<Vec3f> &verts, Material *material) {
Renderable *renderable;
float *vertexBuffer;
unsigned int *indexBuffer;
unsigned int size;
unsigned int i;
size = (unsigned int)verts.size();
renderable = new Renderable();
vertexBuffer = new float[size * 3];
indexBuffer = new unsigned int[size];
for(i=0; i < size; i++) {
vertexBuffer[3*i ] = verts[i].x;
vertexBuffer[3*i+1] = verts[i].y;
vertexBuffer[3*i+2] = verts[i].z;
indexBuffer[i] = i;
}
renderable->setMaterial(material);
renderable->setAttribBuffer("position", size, GL_FLOAT, 3, &vertexBuffer[0]);
renderable->setIndexBuffer(size, &indexBuffer[0]);
renderable->setDrawMode(GL_LINE_STRIP);
delete vertexBuffer;
delete indexBuffer;
return renderable;
}
示例3: LOGME_CALL
void Level::loadExit(MvUint tileX, MvUint tileY)
{
LOGME_CALL("Level::loadExit");
LOGME_DEBUG("Exit at %d, %d", tileX, tileY);
auto e = mEcsContext.e();
auto c = mEcsContext.c();
EngineContext& ctx = mEngineContext;
MvAnimation::Ptr aSpawn(new MvAnimation(RepeatMode::Loop));
for (int i = 0; i < 3; ++i) {
StaticDrawable::Ptr ptr(new StaticDrawable(ctx, Tex::Blob, BlueSpawn[i]));
aSpawn->addDrawable(std::move(ptr));
aSpawn->addFrame(i, sf::milliseconds(240));
}
Entity eSpawn = createEntity();
CrawlComponents& cSpawn = c->attach<Transform, Renderable, Sensor>(eSpawn);
Renderable* cRenderable = cSpawn.get<Renderable>();
Sensor* cSensor = cSpawn.get<Sensor>();
Transform* cTransform = cSpawn.get<Transform>();
cRenderable->setLayer(def::layer::BackgroundNear);
cRenderable->setDrawable(std::move(aSpawn));
cTransform->setPosition(tileX * TW, tileY * TH);
cSensor->setShapeCircle(2.f, sf::Vector2f(tileX * TW, tileY * TH));
cSensor->setCollisionCategory(Collision::World);
cSensor->setCollisionWith(Collision::Player);
cSensor->setCategory(Category::ExitSensor);
mEcsContext.s()->get<PhysicsSystem>()->initialize(eSpawn);
}
示例4: renderImpl
bool PointCloudRenderer::renderImpl(SoSeparator *ivRoot, Renderable &renderable)
{
//Being here without a point cloud is a bug.
assert(renderable.has_pointcloud() || renderable.has_pointcloud2());
//Create the node subtree of the renderable if necessary.
if(!ivRoot->getNumChildren())
{
createNodes(ivRoot, renderable);
}
setScale(ivRoot, renderable);
//Get the nodes to insert the point data into.
SoMaterial * mat = static_cast<SoMaterial *>(ivRoot->getChild(3));
SoCoordinate3 * coord =
static_cast<SoCoordinate3 *>(ivRoot->getChild(2));
//Read the point data into Inventor structures.
std::vector<SbVec3f> points;
std::vector<SbColor> colors;
int point_size = fillPointList(renderable, points,colors);
//If points were parsed or the input meant to send no points,
//set the new point cloud points and colors.
if(points.size() || !point_size)
{
//Insert the inventor structures in to the
coord->point.setValues(0,points.size(), &points[0]);
mat->diffuseColor.setValues(0,colors.size(), &colors[0]);
}
return points.size() > 0;
}
示例5: setTarget
void RenderablePlaneProjection::setTarget(std::string body) {
if (body == "")
return;
std::vector<SceneGraphNode*> nodes = OsEng.renderEngine().scene()->allSceneGraphNodes();
Renderable* possibleTarget;
bool hasBody, found = false;
std::string targetBody;
for (auto node : nodes)
{
possibleTarget = node->renderable();
if (possibleTarget != nullptr) {
hasBody = possibleTarget->hasBody();
if (hasBody && possibleTarget->getBody(targetBody) && (targetBody == body)) {
_target.node = node->name(); // get name from propertyOwner
found = true;
break;
}
}
}
if (found) {
_target.body = body;
_target.frame = openspace::SpiceManager::ref().frameFromBody(body);
}
}
示例6: ss
void Level::ReadTee(char* tee)
{
std::stringstream ss(tee);
glm::vec3 pos;
unsigned int tileid;
ss >> tileid >> pos.x >> pos.y >> pos.z;
_tee = new Tee;
_tee->Initialize();
_tee->SetTile(tileid - 1);
// Load Renderable for circle
// Scale appropriately
// Position according to the stringstream
Renderable *r = new Renderable;
r->Initialize();
Renderable::Color(glm::vec4(0.f, 0.f, 1.f, 1.f));
r->LoadFromFile("Models/circle.obj");
r->PostLoad();
_tee->SetRenderable(r);
_tee->GetMatrix()->Position(pos + glm::vec3(0.f, .01f, 0.f));
_tee->GetMatrix()->Scale(0.075f);
}
示例7: auxPicking
std::vector<Object*> Scene::picking(const Vec2& point) const
{
//var dec
std::vector<Object*> pickedList;
std::function<void(Object* obj)> auxPicking = nullptr;
//aux fun
auxPicking=[&](Object* obj)
{
//pick
Renderable* renderable = nullptr;
if ((renderable = obj->getComponent<Renderable>()))
{
if (renderable->isVisible())
{
const AABox2& box = renderable->getBaseBox();
const AABox2& wbox = renderable->canTransform() ? box.applay(obj->getGlobalMatrix()) : box;
if (wbox.isIntersection(point)) pickedList.push_back(obj);
}
}
//rec
if (!renderable || renderable->isVisible())
for (Object* childs : *obj)
{
auxPicking(childs);
};
};
//call aux
for (Object* obj : objects) auxPicking(obj);
//return
return pickedList;
}
示例8: update
void RenderManager::update()
{
Renderable *r = m_rendlist;
while (r != NULL) {
r->update();
r = r->m_next;
}
}
示例9: setY
GLint setY(lua_State* L)
{
if(lua_isstring(L,-2))
{
Renderable* auxrender = (Core::getInstance())->getRenderable(lua_tostring(L,-2));
auxrender->move(auxrender->getX(), lua_tonumber(L,-1));
}
}
示例10: it
void GLSceneNode::draw()
{
QListIterator<Renderable*> it(this->objects);
while(it.hasNext()) {
Renderable *r = it.next();
r->render();
}
}
示例11: PositionChanged
void ClientPage::PositionChanged(const Renderable& r)
{
Packet p;
p.write(PacketType::set_entity_position);
p.write(r.getID());
p.write(r.getPosition());
sendUdpPacket(p);
}
示例12: RenderableActivate
static void RenderableActivate(unsigned int aId)
{
const RenderableTemplate &renderabletemplate = Database::renderabletemplate.Get(aId);
Renderable *renderable = new Renderable(renderabletemplate, aId);
Database::renderable.Put(aId, renderable);
renderable->SetAction(RenderDrawlist);
renderable->Show();
}
示例13: getProtoScale
float PointCloudRenderer::getProtoScale(Renderable & renderable)
{
float factor = 1.0;
if(renderable.pointcloud().has_units())
{
factor = 1000.0/renderable.pointcloud().units();
}
return factor;
}
示例14: glPushAttrib
void UiRenderPass::render(Renderer* client, const DrawContext& context)
{
sLock.lock();
myDrawTimeStat->startTiming();
if(context.task == DrawContext::SceneDrawTask)
{
client->getRenderer()->beginDraw3D(context);
glPushAttrib(GL_ALL_ATTRIB_BITS);
// This is a bit of a hack. DIsable depth testing for ui stuff. We will take care of ordering.
// This may lead to depth inconsistencies wrt the background scene when drawing 3d menus, but we want te
// menus to always be visible and unoccluded by geometry.
glDisable(GL_DEPTH_TEST);
ui::Container* ui = myUiRoot;
Renderable* uiRenderable = ui->getRenderable(client);
if(uiRenderable != NULL)
{
uiRenderable->draw(context);
}
glPopAttrib();
client->getRenderer()->endDraw();
}
else if(context.task == DrawContext::OverlayDrawTask)
{
Vector2i displaySize;
// check if the tile is part of a canvas (a multi-tile grid). If it is,
// get the canvas resolution. Otherwise simply use the tile resolution.
if(context.tile->isInGrid)
{
DisplaySystem* ds = SystemManager::instance()->getDisplaySystem();
displaySize = ds->getCanvasSize();
}
else
{
displaySize = context.tile->pixelSize;
}
client->getRenderer()->beginDraw2D(context);
glPushAttrib(GL_ALL_ATTRIB_BITS);
Renderable* uiRenderable = myUiRoot->getRenderable(client);
if(uiRenderable != NULL)
{
uiRenderable->draw(context);
}
glPopAttrib();
client->getRenderer()->endDraw();
}
myDrawTimeStat->stopTiming();
sLock.unlock();
}
示例15: check
void ClosestHud::check(const Renderable& r, Vector pos)
{
double dist = (pos - r.getPosition()).magnitudeSquared();
if (m_dDistSquared > dist || !m_bValid) {
m_dDistSquared = dist;
m_bValid = true;
m_vecPos = r.getPosition();
m_ID = r.getID();
}
}