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;
}
Exemplo n.º 2
0
SkyboxRenderObject * GetSkybox(const Entity * fromEntity)
{
    RenderObject *ro = GetRenderObject(fromEntity);
    if(ro && ro->GetType() == RenderObject::TYPE_SKYBOX)
    {
        return (static_cast<SkyboxRenderObject *>(ro));
    }
    
    return NULL;
}
Exemplo n.º 3
0
Landscape * GetLandscape( Entity * fromEntity )
{
	if(NULL != fromEntity)
	{
		RenderObject * object = GetRenderObject(fromEntity);
		if(object && object->GetType() == RenderObject::TYPE_LANDSCAPE)
		{
			Landscape *landscape = static_cast<Landscape *>(object);
			return landscape;
		}
	}

	return NULL;
}
void SwitchToRenerObjectConverter::FindRenderObjectsRecursive(Entity * fromEntity, Vector<std::pair<Entity*, RenderObject*> > & entityAndObjectPairs)
{
    RenderObject * ro = GetRenderObject(fromEntity);
    if(ro && ro->GetType() == RenderObject::TYPE_MESH)
    {
        entityAndObjectPairs.push_back(std::make_pair(fromEntity, ro));
    }

    int32 size = fromEntity->GetChildrenCount();
    for(int32 i = 0; i < size; ++i)
    {
        Entity * child = fromEntity->GetChild(i);
        FindRenderObjectsRecursive(child, entityAndObjectPairs);
    }
}
Exemplo n.º 5
0
ParticleEmitter * GetEmitter(Entity * fromEntity)
{
	ParticleEmitter * emitter = 0;

	if(NULL != fromEntity)
	{
		RenderObject * object = GetRenderObject(fromEntity);
		if(object && object->GetType() == RenderObject::TYPE_PARTICLE_EMTITTER)
		{
			emitter = static_cast<ParticleEmitter*>(object);
		}
	}

	return emitter;
}
Exemplo n.º 6
0
void RecursiveProcessMeshNode(Entity * curr, void * userData, void(*process)(Entity*, void *))
{
	RenderComponent * comp = (RenderComponent*)curr->GetComponent(Component::RENDER_COMPONENT);
	if (comp)
	{
		RenderObject * renderObject = comp->GetRenderObject();
		if (renderObject->GetType() == RenderObject::TYPE_MESH)
		{
			process(curr, userData);
		}
	}
	else
	{
		for (int32 i = 0; i < curr->GetChildrenCount(); i++)
			RecursiveProcessMeshNode(curr->GetChild(i), userData, process);
	}
}
Exemplo n.º 7
0
void SceneValidator::ValidateRenderComponent(Entity *ownerNode, Set<String> &errorsLog)
{
    RenderComponent *rc = static_cast<RenderComponent *>(ownerNode->GetComponent(Component::RENDER_COMPONENT));
    if(!rc) return;
    
    RenderObject *ro = rc->GetRenderObject();
    if(!ro) return;
    
    uint32 count = ro->GetRenderBatchCount();
    for(uint32 b = 0; b < count; ++b)
    {
        RenderBatch *renderBatch = ro->GetRenderBatch(b);
        ValidateRenderBatch(ownerNode, renderBatch, errorsLog);
    }
    
	if(ro->GetType() == RenderObject::TYPE_LANDSCAPE)
    {
		Landscape *landscape = static_cast<Landscape *>(ro);
        ValidateLandscape(landscape, errorsLog);

		ValidateCustomColorsTexture(ownerNode, errorsLog);
    }
}
Exemplo n.º 8
0
void EditorScene::CheckNodes(Entity * curr)
{
	if(NULL != curr)
	{
		bool newDebugComp = false;
		DebugRenderComponent *dbgComp = NULL;

		BaseObject *bulletObject = NULL;
		BulletComponent * bulletComponent = (BulletComponent*)curr->GetComponent(Component::BULLET_COMPONENT);

		if(NULL != bulletComponent)
		{
			bulletObject = bulletComponent->GetBulletObject();
		}

		// create debug render component for all nodes
		dbgComp = (DebugRenderComponent *) curr->GetComponent(Component::DEBUG_RENDER_COMPONENT);
		if(NULL == dbgComp)
		{
			dbgComp = new DebugRenderComponent();
			newDebugComp = true;
			curr->AddComponent(dbgComp);
		}

		// check other debug settings

		// is camera?
		CameraComponent *camComp = (CameraComponent *) curr->GetComponent(Component::CAMERA_COMPONENT);
		if(NULL != camComp)
		{
			// set flags to show it
			if(newDebugComp)
			{
				dbgComp->SetDebugFlags(dbgComp->GetDebugFlags() | DebugRenderComponent::DEBUG_DRAW_CAMERA);
			}

			// create bullet object for camera (allow selecting it)
			/*
			if(NULL == bulletComponent)
			{
				bulletComponent = (BulletComponent*) curr->GetOrCreateComponent(Component::BULLET_COMPONENT);
				bulletComponent->SetBulletObject(new BulletObject(this, collisionWorld, camComp->GetCamera(), camComp->GetCamera()->GetMatrix()));
			}
			*/
		}

		// is light?
		if(NULL != curr->GetComponent(Component::LIGHT_COMPONENT))
		{
			if(newDebugComp)
			{
				dbgComp->SetDebugFlags(dbgComp->GetDebugFlags() | DebugRenderComponent::DEBUG_DRAW_LIGHT_NODE);
			}

			if(NULL == bulletComponent || NULL == bulletObject)
			{
				BulletObject *bObj = new BulletObject(this, collisionWorld, curr, AABBox3(Vector3(), 2.5f), curr->GetWorldTransform());
				bulletComponent = (BulletComponent*) curr->GetOrCreateComponent(Component::BULLET_COMPONENT);
				bulletComponent->SetBulletObject(bObj);
				SafeRelease(bObj);
			}
		}

		// is user node
		if(NULL != curr->GetComponent(Component::USER_COMPONENT))
		{
			if(newDebugComp)
			{
				dbgComp->SetDebugFlags(dbgComp->GetDebugFlags() | DebugRenderComponent::DEBUG_DRAW_USERNODE);
			}

			if(NULL == bulletComponent || NULL == bulletObject)
			{
				BulletObject *bObj = new BulletObject(this, collisionWorld, curr, AABBox3(Vector3(), 2.5f), curr->GetWorldTransform());
				bulletComponent = (BulletComponent*) curr->GetOrCreateComponent(Component::BULLET_COMPONENT);
				bulletComponent->SetBulletObject(bObj);
				SafeRelease(bObj);
			}
		}

		// is render object?
		RenderComponent * renderComponent = (RenderComponent*) curr->GetComponent(Component::RENDER_COMPONENT);
		if(NULL != renderComponent)
		{
			RenderObject *rObj = renderComponent->GetRenderObject();

			if(NULL != rObj && rObj->GetType() != RenderObject::TYPE_LANDSCAPE && curr->IsLodMain(0))
			{
				if(NULL == bulletComponent || NULL == bulletObject)
				{
					BulletObject *bObj = new BulletObject(this, collisionWorld, curr, curr->GetWorldTransform());
					bulletComponent = (BulletComponent*) curr->GetOrCreateComponent(Component::BULLET_COMPONENT);
					bulletComponent->SetBulletObject(bObj);
					SafeRelease(bObj);
				}
			}
		}
	}

	int size = curr->GetChildrenCount();
	for (int i = 0; i < size; i++)
	{
		CheckNodes(curr->GetChild(i));
	}
}