Render 3D Model Always On Top

#1
Hi. I‘m currently having an issue. What I want is to always render an entity „on top“. What I mean is this: it should be shown always (also if there are other 3D models between the camera and the entity.

I already looked into the entity component flags but there seems to be none that would give me such a behavior. I also looked into the docs for RenderNodes. But I don‘t really get any approach how to do this.
Does anyone have any idea?

- Jannis

Re: Render 3D Model Always On Top

#2
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.

Who is online

Users browsing this forum: No registered users and 2 guests