Horde3D

Next-Generation Graphics Engine
It is currently 16.04.2024, 16:02

All times are UTC + 1 hour




Post new topic Reply to topic  [ 7 posts ] 
Author Message
PostPosted: 25.08.2011, 18:56 
Offline

Joined: 09.09.2009, 18:58
Posts: 107
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:


Top
 Profile  
Reply with quote  
PostPosted: 26.08.2011, 07:45 
Offline
Tool Developer

Joined: 13.11.2007, 11:07
Posts: 1150
Location: Germany
What type of node you are passing to getNodeAABB?


Top
 Profile  
Reply with quote  
PostPosted: 26.08.2011, 14:39 
Offline

Joined: 09.09.2009, 18:58
Posts: 107
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?


Top
 Profile  
Reply with quote  
PostPosted: 27.08.2011, 07:50 
Offline

Joined: 26.08.2008, 18:48
Posts: 120
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.


Top
 Profile  
Reply with quote  
PostPosted: 28.08.2011, 02:08 
Offline

Joined: 09.09.2009, 18:58
Posts: 107
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.


Top
 Profile  
Reply with quote  
PostPosted: 28.08.2011, 12:50 
Offline
Engine Developer

Joined: 10.09.2006, 15:52
Posts: 1217
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.


Top
 Profile  
Reply with quote  
PostPosted: 28.08.2011, 19:46 
Offline

Joined: 09.09.2009, 18:58
Posts: 107
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;
}


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 17 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group