How to use IRenderNode with EntityComponent ?

Hi there!
I just want to figure out with using of IRendeNode with new EntityComponents and try to render for example the manually created `triangle of death`.

after some investigations about it, I have some code. But it's still not working.

I have false validation on (mesh->Validate):

Code: Select all

void CCustomMesh::OnResetState() { if (!inited) { if (!pStaticObject) { pStaticObject = gEnv->p3DEngine->CreateStatObj(); IIndexedMesh* idxMesh = pStaticObject->GetIndexedMesh(); CMesh* mesh = idxMesh->GetMesh(); int count = 3; mesh->SetIndexCount(count); mesh->SetVertexCount(count); mesh->SetTexCoordsCount(count); int gotElements = 0; //pos = mesh->GetStreamPtr<Vec3>(CMesh::POSITIONS, &gotElements); pos[0] = Vec3(0, 0, 0); pos[1] = Vec3(0, 100, 0); pos[2] = Vec3(0, 100, 100); mesh->SetSharedStream(CMesh::POSITIONS, &pos[0], count); //uv = mesh->GetStreamPtr<Vec2>(CMesh::TEXCOORDS, &gotElements); uv[0] = Vec2(0, 0); uv[1] = Vec2(1, 0); uv[2] = Vec2(1, 1); mesh->SetSharedStream(CMesh::TEXCOORDS, &uv[0], count); //ind = mesh->GetStreamPtr<vtx_idx>(CMesh::INDICES, &gotElements); ind[0] = 1; ind[1] = 2; ind[2] = 3; mesh->SetSharedStream(CMesh::INDICES, &ind[0], count); subset.nNumIndices = count; subset.nNumVerts = count; subset.nMatID = 0; subset.FixRanges(&ind[0]); subset.nFirstVertId = 0; subset.nFirstIndexId = 0; mesh->m_subsets.clear(); mesh->m_subsets.push_back(subset); mesh->RecomputeGeometricMeanFaceArea(); bool ret = mesh->Validate(nullptr); // make the static object update pStaticObject->SetFlags(STATIC_OBJECT_GENERATED | STATIC_OBJECT_DYNAMIC); pStaticObject->Invalidate(); pStaticObject->SetMaterial(material); } matrix = GetEntity()->GetWorldTM(); inited = true; } }
and the proc:

Code: Select all

void CCustomMesh::Render(const SRendParams & EntDrawParams, const SRenderingPassInfo & passInfo) { // create a temp render params copy to manipulate SRendParams tempParams(EntDrawParams); tempParams.pMaterial = material; tempParams.dwFObjFlags |= FOB_DYNAMIC_OBJECT; // only needed if object moved tempParams.pMatrix = &matrix; pStaticObject->Render(tempParams, passInfo); }
do not called by render at all.

so, it's will be nice to hear any ideas or see any additional examples about using this IRendeNode?

current sources of this EntityComponent: ... CustomMesh

Re: How to use IRenderNode with EntityComponent ?

Re: How to use IRenderNode with EntityComponent ?#2You should not derive from both IEntityComponent and IRenderNode, they are not related and represent a very different concepts with different life times
IRenderNode are derived classes are lower level 3d engine rendering primitives
IEntityComponent are absrtact additional functionality for the entity object,
You can assign RenderNode to an EntitySlot of the entity, and have Entity Component manage this slot,
EntityComponent allocates IRenderNode derived class, allocates a new entity slot and assign render node to it, letting internal entity code to manage the rest, they must be 2 separate classes.

Re: How to use IRenderNode with EntityComponent ?

Oh, Thanks for reply. I found some info about that you talked. ... rnode.html
Well, it's make sense.
But I don't want change the engine sources to add able render custom generated geometry( that's is sad, if for such task need to fix the engine code (in 3DEngine.cpp).

So, how then just draw generated geometry without this `hell` with modifying engine sources ?
if more clearly: I need just Vertexbuffer + IndexBuffer and push it to Render mb not so often for update, how to achieve this in easy manner ?

Who is online

Users browsing this forum: No registered users and 1 guest