Failed to init atlas resource target
#1
Apost 
Hi!

The code below generates the following console output while failing:

Graph::SingleResourceTarget::Init(): Need exactly 1 object
Graph::PlaneSequenceGeometry::InitSelf(): Failed to init atlas resource target


Graph::INode* parameters = root->CreateNode("FixedParameters");
Graph::IPlaneSequenceGeometry* geometry = 
    dynamic_cast<Graph::IPlaneSequenceGeometry*>(root->CreateNode("PlaneSequenceGeometry"));
            
if (parameters != 0 && geometry != 0)
{
    AddChild(parameters);
    parameters->AddChild(geometry->GetNodeInterface());
                
    geometry->GetAtlasResourceTarget()->SetResourceId("particles:atlas_particles", 0);

    return true;
}
else
{
    Debug::Trace("InitSelf(): Failed to create subnodes.");
    return false;
}


However, achieving the same with XML does work.

Any ideas?

I found a similar issue with the SingleNodeTargets:

Graph::INode* node = GetCurrentNamespace()->FindNode(nodeIdToFind);
mNodeTarget.SetNode(node, 0);
if (!mNodeTarget.Init(tracker))
{
    return false;
}


Debugging the Init() method of SingleNodeTarget told me that mNumberOfNodes was still set to zero.

if ((mMinNumberOfNodes != 0) && (mNumberOfNodes == 0))
{
    Debug::Error("Graph::SingleNodeTarget::Init(): Need exactly 1 node");
    return false;
}
Reply
#2
Apost 
Hi!

You need to explicitly define the actual number of resources/nodes you want to attach, before the node gets initialized:
...
if (parameters != 0 && geometry != 0)
{
    AddChild(parameters);
    parameters->AddChild(geometry->GetNodeInterface());
                
    geometry->GetAtlasResourceTarget()->SetNumberOfResources(1);
    geometry->GetAtlasResourceTarget()->SetResourceId("particles:atlas_particles", 0);

    return true;
}
...

and
...
Graph::INode* node = GetCurrentNamespace()->FindNode(nodeIdToFind);
mNodeTarget.SetNumberOfNodes(1);
mNodeTarget.SetNode(node, 0);
if (!mNodeTarget.Init(tracker))
{
    return false;
}
...

The documentation for the index parameter in SetResourceId()/SetNode() etc. already hints in that direction, however we will update the documentation for both Graph::IGenericResourceTarget and Graph::IGenericNodeTarget to more clearly state this behavior.
Reply
#3
Apost 
That's it, thx!

Quote:The documentation for the index parameter in SetResourceId()/SetNode() etc. already hints in that direction, however we will update the documentation for both Graph::IGenericResourceTarget and Graph::IGenericNodeTarget to more clearly state this behavior.

I found out, that the node target of Graph::IReference requires the same property to be set when configuring it manually.
Reply


Forum Jump:


Copyright © 2011-2017 Spraylight GmbH.