So, when I draw my objects with per-pixel lighting on them, I use this code:
Code: Select all
core::array<scene::ISceneNode*> nodes;
GetSceneManager()->getSceneNodesFromType(scene::ESNT_ANY, nodes);
//Update nodes
for (u32 i=0; i<nodes.size(); i++) {
if (nodes[i]->getType()==scene::ESNT_MESH ||
nodes[i]->getType()==scene::ESNT_ANIMATED_MESH ||
nodes[i]->getType()==scene::ESNT_BILLBOARD) {
if (nodes[i]->isVisible()) {
GetLightsManager()->UpdateLights(nodes[i]);
nodes[i]->OnAnimate(GetElapsedTime());
};
continue;
};
if (nodes[i]->getType()==scene::ESNT_CAMERA) {
nodes[i]->OnAnimate(GetElapsedTime());
continue;
};
};
//Update welders
GetWeldersManager()->Update();
//Update lights
for (u32 i=0; i<nodes.size(); i++) {
if (nodes[i]->getType()==scene::ESNT_LIGHT) {
nodes[i]->OnRegisterSceneNode();
};
};
//Render everything
objectsManager->GetCameraManager()->GetCameraNode()->render();
lightsManager->OnRenderPassPreRender(scene::ESNRP_SOLID);
for (u32 i=0; i<nodes.size(); i++) {
if (nodes[i]->getType()==scene::ESNT_MESH ||
nodes[i]->getType()==scene::ESNT_ANIMATED_MESH ||
nodes[i]->getType()==scene::ESNT_BILLBOARD) {
if (nodes[i]->isVisible()) {
nodes[i]->render();
};
continue;
};
};
GetWeldersManager()->Render();
std::vector<scene::ISceneNode*>* noLights = GetShadowsManager()->GetNoLights();
for (u32 i=0; i<noLights->size(); i++) {
noLights->at(i)->setVisible(true);
noLights->at(i)->OnAnimate(GetElapsedTime());
noLights->at(i)->render();
noLights->at(i)->setVisible(false);
};
return true;
Code: Select all
sceneManager->drawAll();
weldersManager->Update();
weldersManager->Render();
return true;