I still have no idea how to do this. I've looked into some flags for entity slots and render nodes. Here is my current approach:
Code: Select all
if (std::strcmp(m_geometryPath, "") != 0) {
m_pCachedStatObj = gEnv->p3DEngine->LoadStatObj(m_geometryPath);
GetEntity()->SetStatObj(m_pCachedStatObj, GetOrMakeEntitySlotId() | ENTITY_SLOT_ACTUAL, false);
GetEntity()->SetSlotFlags(GetEntitySlotId(), GetEntity()->GetSlotFlags(GetEntitySlotId()) | ENTITY_SLOT_RENDER | ENTITY_SLOT_CAST_SHADOW | ENTITY_SLOT_IGNORE_VISAREAS | ENTITY_SLOT_RENDER_NEAREST);
if (IRenderNode* pRenderNode = m_pEntity->GetSlotRenderNode(GetEntitySlotId())) {
pRenderNode->SetRndFlags(pRenderNode->GetRndFlags() | ERF_RENDER_ALWAYS | ERF_FOB_RENDER_AFTER_POSTPROCESSING);
}
}
else {
FreeEntitySlot();
}
It seems as if the line pRenderNode->SetRndFlags(......) doesn't do anything. I tried different flags and none of them seems to do anything. Only the flags that I set on the slot by GetEntity()->SetSlotFlags(.....) seem to work. As you can see, I tried to use the flag ENTITY_SLOT_RENDER_NEAREST. This has some funny results. The geometry seems to blur as the camera moves. And the object is only "rendered on top of everything else" if the center of the geometry is inside the cameras view. Also it seems as if the geometry moves as the camera is rotated.
So still I found no good way to render an object always on top. Does anyone know how to get the pRenderNode->SetRndFlags(.....) to work properly? The Flag ERF_RENDER_ALWAYS sounds pretty promising.
By the way: I checked after pRenderNode->SetRndFlags() if the flags are really set. Seems to bee all fine. However if I set any flag on the render node directly, it doesn't have any effect. I also tried it by removing ENTITY_SLOT_RENDER_NEAREST from the slot flags and adding ERF_FOB_NEAREST to the render node flags. Only the slot flag works (and if you look into EntitySlot.cpp the slot flag doesn't really do anything else than setting the render node flag). I don't know what's going on here.
- Jannis
EDIT:
By the way: does anyone know how to properly format code here inside the forum? If I write it inside of the code BB Tag, it seems to ignore tabs. And on smaller screens (mobile devices), it looks pretty unreadable.