Shared tag between SceneNode and RenderablePrimitiveBase
#1
Hi,

I've started writing my own rendering step to show normals using geometry shader and an OverrideEffect. It's working fairly well, except that I need to filter the objects. For that I am using FilterObjectsFunction in the rendering step.

There I need to recognize the objects to show normals on (currently it's all using PBMaterial or MultiMapMaterial). That is easy to check, but I've noticed that RenderablePrimitiveBase has a property "Tag". This tag is always null so I was wondering how to populate this with a value (then it would be possible to filter the objects by anything I want - name, animations, selection etc.). 

I am using MeshObjectNode to render most of the objects and they also have property Tag (which I am using to set some data for raycasts and selection). Is it possible to somehow inherit the Tag from SceneNode to RenderablePrimitiveBase?

I cannot use RenderQueue filtering since I cannot set an object into multiple queues and I cannot override MeshObjectNode to extend the method CollectRenderableObjects (it's sealed). Writing custom collection seems as an overkill as well.

Thanks,
Roman Janovsky
#2
You can check the Tag on the MeshObjectNode inside your FilterObjectsFunction - for example:

Code:
private static bool FilterObjectsByTagFunction(RenderablePrimitiveBase renderablePrimitiveBase)
{
    var originalSceneNode = renderablePrimitiveBase.OriginalObject as SceneNode;
    if (originalSceneNode != null)
    {
        var tag = originalSceneNode.Tag;
        return true; // Add check
    }

    return false;
}
Andrej Benedik
#3
For some reason, the OriginalObject property is SceneNode only for lines, i.e. ScreenSpaceLineNode that is created from wire grid.

All objects created from meshes have OriginalObject set to SimpleMesh<T>.
  


Forum Jump:


Users browsing this thread:
1 Guest(s)