Page 1 of 1

Run-time vegetation editing.

Posted: Thu Mar 21, 2019 4:43 pm
by MarkusGod
How is it possible to get vegetation tree instance and edit/remove/replace/spawn new it at runtime?

Re: Run-time vegetation editing.

Posted: Sat Mar 23, 2019 3:04 pm
by MarkusGod
Ok, I figured out the way to spawn new foliage and remove existing, but I'm still not sure it is correct.
Does foliage IRenderNode::GetStatObjGroupId returns id that correspond editor foliage type, first row type 1 second 2 and so on? Or is there any other way to get foliage type?

Code: Select all

//Raycast stuff here
//Spawn a new vegetation object instance.
IRenderNode* spawntedTree = gEnv->p3DEngine->GetITerrain()->AddVegetationInstance(0, hit.pt, 1, 1, 0);
//Destroy foliage object instance
if (hit.pCollider->GetiForeignData() == PHYS_FOREIGN_ID_STATIC) {
void* fData = hit.pCollider->GetForeignData(PHYS_FOREIGN_ID_STATIC);
IRenderNode* pRN = static_cast<IRenderNode*>(fData);
if (pRN->GetRenderNodeType() == EERType::eERType_Vegetation) {
//Theoriticaly foliage type.
int vegType = pRN->GetStatObjGroupId();
gEnv->p3DEngine->DeleteRenderNode(pRN);
}
}

Re: Run-time vegetation editing.

Posted: Wed Mar 27, 2019 11:55 am
by Cry-Flare
These should be the unique variants of your vegetation objects.
You should be able to get more detail via the following function;

Code: Select all

bool C3DEngine::GetStatInstGroup(int nGroupId, IStatInstGroup& siGroup)
nGroupId would correspond to your vegType variable.

Re: Run-time vegetation editing.

Posted: Sun Mar 31, 2019 8:59 am
by MarkusGod
Thanks! Maybe there is a way to get all vegetation in the level? I have some issues with TI, due to the fact that vegetation is considered as static geometry and editing it in the game leaves obsolete gi effects.
I thought I can serialize it in the editor and later spawn it on my own with changing GI mode to dynamic voxelization (https://imgur.com/a/isuNgqC). I'm also planning to use that vegeatation list to synchronize it over the network.