Horde3D
http://horde3d.org/forums/

h3dNodeGetAABB Returning 0,0,0,0,0,0
http://horde3d.org/forums/viewtopic.php?f=2&t=1569
Page 1 of 1

Author:  Orm [ 25.08.2011, 18:56 ]
Post subject:  h3dNodeGetAABB Returning 0,0,0,0,0,0

Exactly what it says in the tin. Here is the code I am using.

Code:
void COLSHAPE_DetermineBounds(int node,float* min3f,float* max3f)
{
    float minx=0,miny=0,minz=0,maxx=0,maxy=0,maxz=0;
   h3dGetNodeAABB(node,&minx,&miny,&minz,&maxx,&maxy,&maxz);
    std::cout<<" DetermineBounds\n";
    std::cout<<" Min: "<<minx<<" "<<miny<<" "<<minz<<"\n";
    std::cout<<" Max: "<<maxx<<" "<<maxy<<" "<<maxz<<"\n";
}


Does it matter what kind of node I pass into GetNodeAABB? Because I never read anything about such requirements in the documentation.

As before, please, don't all rush in at once. :mrgreen:

Author:  Volker [ 26.08.2011, 07:45 ]
Post subject:  Re: h3dNodeGetAABB Returning 0,0,0,0,0,0

What type of node you are passing to getNodeAABB?

Author:  Orm [ 26.08.2011, 14:39 ]
Post subject:  Re: h3dNodeGetAABB Returning 0,0,0,0,0,0

I think I am passing in a group node, but I can't be 100% certain of that. I'm guessing it really does matter what type of node gets passed?

Author:  attila [ 27.08.2011, 07:50 ]
Post subject:  Re: h3dNodeGetAABB Returning 0,0,0,0,0,0

I had similar problem a while ago (haven't checked with the latest build)

For me the problem was that I loaded(reloaded) the geo resource after creating the node.

h3dLoadResource scenegraph
h3dAddNode scenegraph
h3dLoadResource geometry that is used by scenegraph

in this case the node's aabb was 0.

if I load the geometry before creating the node the aabb is fine.

but maybe your problem is unrelated.

Author:  Orm [ 28.08.2011, 02:08 ]
Post subject:  Re: h3dNodeGetAABB Returning 0,0,0,0,0,0

I fixed the problem by sanitizing the node that is passed in. By sanitize, I mean making sure the node passed in is a model node.

Author:  marciano [ 28.08.2011, 12:50 ]
Post subject:  Re: h3dNodeGetAABB Returning 0,0,0,0,0,0

The AABB is just available for renderable nodes - which are mainly meshes and particle systems. In an early version there used to be an AABB tree as part of the scene graph where AABBs were accumulated along the node hierarchy. But as the design was getting less scene graph centric, this is not the case any more - also as it meant quite some performance overhead. I guess the docs need to be updated to better reflect these changes.

Author:  Orm [ 28.08.2011, 19:46 ]
Post subject:  Re: h3dNodeGetAABB Returning 0,0,0,0,0,0

Thanks marciano, and by the way, here is my node sanitation function if anyone else would like to take a look. I am sure this can be written better, but meh, works for now :roll:

Code:
void H3D_FindModelNodeInHeirarchy(int& node)
{
    const int search_root = node;

    int search_result = 0;
    bool valid_node_found = false;
   
    int node_type = h3dGetNodeType(search_root);
    if(node_type != H3DNodeTypes::Model)
    {
        int searched_node = h3dGetNodeParent(search_root);

        // Search the parents of the node.
        while(!valid_node_found)
        {
           
            if(node_type == H3DNodeTypes::Model || node_type == H3DNodeTypes::Mesh)
            {
                //  we found a valid node for the operation, let's break the loop.
                valid_node_found = true;
                search_result = searched_node;
            }

            else if( searched_node == H3DRootNode )
            {
//                Log::Fatal()<<"The engine was unable to find a valid Model node up the heirarchy. Looking the other way.."<<Log::End(false);
                break;
            }

            searched_node = h3dGetNodeParent(searched_node);
            node_type = h3dGetNodeType(searched_node);

        }

        // we  didnt find a valid node searching the parents, let's search the children.
        if(!valid_node_found)
        {
            searched_node = search_root;

            int num_results = h3dFindNodes(search_root,"",H3DNodeTypes::Undefined);

            for( int i=0;i<num_results;++i)
            {
                int n =  h3dGetNodeFindResult(i);
                if( h3dGetNodeType(n) == H3DNodeTypes::Model )
                {
                    search_result = n;
                    valid_node_found = true;
                    break;
                }
            }

        }
    }

    node = search_result;
}

Page 1 of 1 All times are UTC + 1 hour
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/