本文整理汇总了C++中RenderBatch类的典型用法代码示例。如果您正苦于以下问题:C++ RenderBatch类的具体用法?C++ RenderBatch怎么用?C++ RenderBatch使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了RenderBatch类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: appendRenderables
void Projector::appendRenderables( RenderQueue& queue, const Transform* transform )
{
if( !geometry ) return;
const Transform* geotransform = geometry->getEntity()->getTransform().get();
const Matrix4x3& absoluteTransform = geotransform->getAbsoluteTransform();
const RenderablesVector& renderables = geometry->getRenderables();
for( size_t i = 0; i < renderables.size(); i++ )
{
RenderBatch* renderable = renderables[i].get();
if( !renderable ) continue;
renderable->onPreRender.Bind(this, &Projector::onPreRender);
RenderState state;
state.renderable = renderable;
state.material = material.Resolve();
state.modelMatrix = absoluteTransform;
state.priority = renderable->getRenderPriority() + 1;
queue.pushBack(state);
}
}
示例2: EnumerateTexturesRecursive
void MipMapReplacer::EnumerateTexturesRecursive(Entity * entity, Set<Texture *> & textures)
{
if(!entity)
return;
int32 childrenCount = entity->GetChildrenCount();
for(int32 i = 0; i < childrenCount; i++)
EnumerateTexturesRecursive(entity->GetChild(i), textures);
RenderObject * ro = GetRenderObject(entity);
if(ro)
{
int32 rbCount = ro->GetRenderBatchCount();
for(int32 i = 0; i < rbCount; i++)
{
RenderBatch * rb = ro->GetRenderBatch(i);
if(rb)
{
DVASSERT(0 && "Vitaliy Borodovsky: Temporarly disabled. Need to rewrite for new materials");
NMaterial * material = rb->GetMaterial();
if(material)
{
Texture * texture = material->GetTexture(NMaterial::TEXTURE_ALBEDO);
if(texture)
textures.insert(texture);
}
}
}
}
}
示例3: GetRenerObject
int32 NodesPropertyControl::GetTrianglesForLodLayer(LodComponent::LodData *lodData)
{
int32 trianglesCount = 0;
for(int32 n = 0; n < (int32)lodData->nodes.size(); ++n)
{
Vector<Entity *> meshes;
lodData->nodes[n]->GetChildNodes(meshes);
meshes.push_back(lodData->nodes[n]);
for(int32 m = 0; m < (int32)meshes.size(); ++m)
{
RenderObject *ro = GetRenerObject(meshes[m]);
if(!ro || ro->GetType() != RenderObject::TYPE_MESH) continue;
uint32 count = ro->GetRenderBatchCount();
for(uint32 r = 0; r < count; ++r)
{
RenderBatch *batch = ro->GetRenderBatch(r);
PolygonGroup *pg = batch->GetPolygonGroup();
if(pg)
{
trianglesCount += pg->GetIndexCount() / 3;
}
}
}
}
return trianglesCount;
}
示例4: AddRenderBatch
void RenderObject::Load(KeyedArchive * archive, SceneFileV2 *sceneFile)
{
if(NULL != archive)
{
if(archive->IsKeyExists("ro.type")) type = archive->GetUInt32("ro.type");
if(archive->IsKeyExists("ro.flags")) flags = archive->GetUInt32("ro.flags");
if(archive->IsKeyExists("ro.debugflags")) debugFlags = archive->GetUInt32("ro.debugflags");
if(archive->IsKeyExists("ro.batchCount"))
{
KeyedArchive *batchesArch = archive->GetArchive("ro.batches");
for(uint32 i = 0; i < archive->GetUInt32("ro.batchCount"); ++i)
{
KeyedArchive *batchArch = batchesArch->GetArchive(KeyedArchive::GenKeyFromIndex(i));
if(NULL != batchArch)
{
RenderBatch *batch = (RenderBatch *) ObjectFactory::Instance()->New(batchArch->GetString("rb.classname"));
if(NULL != batch)
{
batch->Load(batchArch, sceneFile);
AddRenderBatch(batch);
batch->Release();
}
}
}
}
}
AnimatedObject::Load(archive);
}
示例5: DVASSERT_MSG
RenderObject* SkyboxRenderObject::Clone(RenderObject *newObject)
{
if(!newObject)
{
DVASSERT_MSG(IsPointerToExactClass<SkyboxRenderObject>(this), "Can clone only SkyboxRenderObject");
newObject = new SkyboxRenderObject();
}
SkyboxRenderObject* skyboxRenderObject = static_cast<SkyboxRenderObject*>(newObject);
skyboxRenderObject->type = type;
skyboxRenderObject->flags = flags;
skyboxRenderObject->RemoveFlag(RenderObject::TREE_NODE_NEED_UPDATE);
skyboxRenderObject->debugFlags = debugFlags;
skyboxRenderObject->ownerDebugInfo = ownerDebugInfo;
skyboxRenderObject->bbox = bbox;
skyboxRenderObject->texturePath = texturePath;
skyboxRenderObject->offsetZ = offsetZ;
skyboxRenderObject->rotationZ = rotationZ;
skyboxRenderObject->nonClippingDistance = nonClippingDistance;
uint32 size = GetRenderBatchCount();
for(uint32 i = 0; i < size; ++i)
{
RenderBatch *batch = GetRenderBatch(i)->Clone();
skyboxRenderObject->AddRenderBatch(batch);
batch->Release();
}
skyboxRenderObject->BuildSkybox();
skyboxRenderObject->UpdateMaterial();
return newObject;
}
示例6: EnumerateTexturesRecursive
void MipMapReplacer::EnumerateTexturesRecursive(Entity * entity, Set<Texture *> & textures)
{
if(!entity)
return;
int32 childrenCount = entity->GetChildrenCount();
for(int32 i = 0; i < childrenCount; i++)
EnumerateTexturesRecursive(entity->GetChild(i), textures);
RenderObject * ro = GetRenderObject(entity);
if(ro)
{
int32 rbCount = ro->GetRenderBatchCount();
for(int32 i = 0; i < rbCount; i++)
{
RenderBatch * rb = ro->GetRenderBatch(i);
if(rb)
{
Material * material = rb->GetMaterial();
if(material)
{
Texture * texture = material->GetTexture(Material::TEXTURE_DIFFUSE);
if(texture)
textures.insert(texture);
}
}
}
}
}
示例7: DVASSERT_MSG
RenderObject * RenderObject::Clone(RenderObject *newObject)
{
if(!newObject)
{
DVASSERT_MSG(IsPointerToExactClass<RenderObject>(this), "Can clone only RenderObject");
newObject = new RenderObject();
}
newObject->type = type;
newObject->flags = flags;
newObject->debugFlags = debugFlags;
//ro->bbox = bbox;
//ro->worldBBox = worldBBox;
uint32 size = GetRenderBatchCount();
for(uint32 i = 0; i < size; ++i)
{
RenderBatch *batch = GetRenderBatch(i)->Clone();
newObject->AddRenderBatch(batch);
batch->Release();
}
newObject->ownerDebugInfo = ownerDebugInfo;
return newObject;
}
示例8: GetRenderBatchCount
void RenderObject::Save(KeyedArchive * archive, SceneFileV2* sceneFile)
{
AnimatedObject::Save(archive);
if(NULL != archive)
{
archive->SetUInt32("ro.type", type);
archive->SetUInt32("ro.flags", flags);
archive->SetUInt32("ro.debugflags", debugFlags);
archive->SetUInt32("ro.batchCount", GetRenderBatchCount());
KeyedArchive *batchesArch = new KeyedArchive();
for(uint32 i = 0; i < GetRenderBatchCount(); ++i)
{
RenderBatch *batch = GetRenderBatch(i);
if(NULL != batch)
{
KeyedArchive *batchArch = new KeyedArchive();
batch->Save(batchArch, sceneFile);
if(batchArch->Count() > 0)
{
batchArch->SetString("rb.classname", batch->GetClassName());
}
batchesArch->SetArchive(KeyedArchive::GenKeyFromIndex(i), batchArch);
batchArch->Release();
}
}
archive->SetArchive("ro.batches", batchesArch);
batchesArch->Release();
}
}
示例9: DVASSERT
void MainForwardRenderPass::Draw(RenderSystem * renderSystem, uint32 clearBuffers)
{
Camera *mainCamera = renderSystem->GetMainCamera();
Camera *drawCamera = renderSystem->GetDrawCamera();
DVASSERT(mainCamera);
DVASSERT(drawCamera);
drawCamera->SetupDynamicParameters();
if (mainCamera!=drawCamera)
mainCamera->PrepareDynamicParameters();
if (needWaterPrepass)
{
/*water presence is cached from previous frame in optimization purpose*/
/*if on previous frame there was water - reflection and refraction textures are rendered first (it helps to avoid excessive renderPassBatchArray->PrepareVisibilityArray)*/
/* if there was no water on previous frame, and it appears on this frame - reflection and refractions textures are still to be rendered*/
PrepareReflectionRefractionTextures(renderSystem);
}
//important: FoliageSystem also using main camera for cliping vegetation cells
PrepareVisibilityArrays(mainCamera, renderSystem);
RenderLayerBatchArray *waterLayer = renderPassBatchArray->Get(RenderLayerManager::Instance()->GetLayerIDByName(LAYER_WATER));
uint32 waterBatchesCount = waterLayer->GetRenderBatchCount();
if (waterBatchesCount)
{
waterBox.Empty();
for (uint32 i=0; i<waterBatchesCount; ++i)
{
RenderBatch *batch = waterLayer->Get(i);
waterBox.AddAABBox(batch->GetRenderObject()->GetWorldBoundingBox());
}
}
if (!needWaterPrepass&&waterBatchesCount)
{
PrepareReflectionRefractionTextures(renderSystem);
/*as PrepareReflectionRefractionTextures builds render batches according to reflection/refraction camera - render batches in main pass list are not valid anymore*/
/*to avoid this happening every frame water visibility is cached from previous frame (needWaterPrepass)*/
/*however if there was no water on previous frame and there is water on this frame visibilityArray should be re-prepared*/
renderPassBatchArray->Clear();
renderPassBatchArray->PrepareVisibilityArray(&visibilityArray, mainCamera);
}
needWaterPrepass = (waterBatchesCount!=0); //for next frame;
ClearBuffers(clearBuffers);
DrawLayers(mainCamera);
}
示例10: CreateFromEntity
void BulletObject::CreateFromEntity()
{
bool wasPolygonGroup = false;
RenderObject * renderObject = ((RenderComponent*)entity->GetComponent(Component::RENDER_COMPONENT))->GetRenderObject();
uint32 batchesCount = renderObject->GetRenderBatchCount();
for(uint32 batchIndex = 0; batchIndex < batchesCount; ++batchIndex)
{
RenderBatch * batch = renderObject->GetRenderBatch(batchIndex);
PolygonGroup * pg = batch->GetPolygonGroup();
if(pg)
{
if(!wasPolygonGroup)
{
collisionObject = new btCollisionObject();
trimesh = new btTriangleMesh();
createdWith = entity->GetWorldTransform();
wasPolygonGroup = true;
}
for(int32 i = 0; i < pg->indexCount / 3; i++)
{
uint16 index0 = pg->indexArray[i*3];
uint16 index1 = pg->indexArray[i*3+1];
uint16 index2 = pg->indexArray[i*3+2];
Vector3 v;
pg->GetCoord(index0, v);
v = v * createdWith;
btVector3 vertex0(v.x, v.y, v.z);
pg->GetCoord(index1, v);
v = v * createdWith;
btVector3 vertex1(v.x, v.y, v.z);
pg->GetCoord(index2, v);
v = v * createdWith;
btVector3 vertex2(v.x, v.y, v.z);
trimesh->addTriangle(vertex0,vertex1,vertex2, false);
}
}
}
if(wasPolygonGroup)
{
shape = new btBvhTriangleMeshShape(trimesh, true, true);
collisionObject->setCollisionShape(shape);
collWorld->addCollisionObject(collisionObject);
}
}
示例11: renderBatch
RenderBatch* Camera::renderBatch(int queue)
{
for (int i = 0; i < m_renderBatches->count(); ++i)
{
RenderBatch* batch = (RenderBatch*)m_renderBatches->get(i);
if (batch->renderQueue() == queue)
{
return batch;
}
}
RenderBatch* batch = RenderBatch::create(this, queue);
batch->autorelease();
m_renderBatches->add(batch);
return batch;
}
示例12: MaterialCreate
RenderBatchPtr Model::createDebugRenderable() const
{
MaterialHandle handleMaterial = MaterialCreate(AllocatorGetHeap(), "SkeletonDebug");
Material* material = handleMaterial.Resolve();
material->setDepthTest(false);
GeometryBuffer* gb = AllocateHeap(GeometryBuffer);
RenderBatch* renderable = AllocateHeap(Renderable);
renderable->setPrimitiveType(PrimitiveType::Lines);
renderable->setGeometryBuffer(gb);
renderable->setMaterial(handleMaterial);
return renderable;
}
示例13:
Projector::~Projector()
{
if( !geometry ) return;
const RenderablesVector& renderables = geometry->getRenderables();
for( size_t i = 0; i < renderables.size(); i++ )
{
RenderBatch* renderable = renderables[i].get();
renderable->onPreRender.clear();
const UniformBufferPtr& ub = renderable->getUniformBuffer();
ub->removeUniform("vp_TextureProjection");
ub->removeUniform("vp_TextureView");
}
}
示例14: glViewport
void Camera::present()
{
// Viewport
Rectf viewportRect;
if (m_renderTexture)
{
glViewport(0, 0, m_renderTexture->width(), m_renderTexture->height());
m_renderTexture->begin();
viewportRect = Rectf(0, 0, m_renderTexture->width(), m_renderTexture->height());
}
else
{
glViewport((GLint)m_viewportRect.x(), (GLint)m_viewportRect.y(), (GLsizei)m_viewportRect.width(), (GLsizei)m_viewportRect.height());
viewportRect = m_viewportRect;
}
// Prepare matrices
if (m_isProjectionDirty)
{
if (m_projectType == Orthographic)
{
buildOrthographicProjectionMatrix(m_projection, viewportRect, m_orthoSize, m_zNear, m_zFar, m_renderTexture != NULL);
}
m_isProjectionDirty = false;
}
m_worldviewprojection = m_projection * m_view;
// Clear
if (m_clearType != NONE)
{
glClearColor(m_backgroundColor.red, m_backgroundColor.green, m_backgroundColor.blue, m_backgroundColor.alpha);
glClear(m_clearType);
}
for (int i = 0; i < m_renderBatches->count(); ++i)
{
RenderBatch* batch = (RenderBatch*)m_renderBatches->get(i);
batch->draw();
batch->clear();
}
if (m_renderTexture)
{
m_renderTexture->end();
}
}
示例15: EnumerateTextures
void TextureHelper::EnumerateTextures(DAVA::Entity *forNode, Map<String, Texture *> &textures)
{
if(!forNode) return;
Vector<Entity *> nodes;
forNode->GetChildNodes(nodes);
nodes.push_back(forNode);
for(int32 n = 0; n < (int32)nodes.size(); ++n)
{
RenderComponent *rc = static_cast<RenderComponent *>(nodes[n]->GetComponent(Component::RENDER_COMPONENT));
if(!rc) continue;
RenderObject *ro = rc->GetRenderObject();
if(!ro) continue;
uint32 count = ro->GetRenderBatchCount();
for(uint32 b = 0; b < count; ++b)
{
RenderBatch *renderBatch = ro->GetRenderBatch(b);
NMaterial *material = renderBatch->GetMaterial();
if(material)
{
for(int32 t = 0; t < material->GetTextureCount(); ++t)
{
Texture* tx = material->GetTexture(t);
CollectTexture(textures, tx->GetPathname(), tx);
}
}
/*InstanceMaterialState *instanceMaterial = renderBatch->GetMaterialInstance();
if(instanceMaterial)
{
CollectTexture(textures, instanceMaterial->GetLightmapName(), instanceMaterial->GetLightmap());
}*/
}
Landscape *land = dynamic_cast<Landscape *>(ro);
if(land)
{
CollectLandscapeTextures(textures, land);
}
}
}