WorldViz User Forum  

Go Back   WorldViz User Forum > Plug-in development

Reply
 
Thread Tools Rating: Thread Rating: 3 votes, 5.00 average. Display Modes
  #1  
Old 09-30-2009, 03:20 PM
JimC JimC is offline
Member
 
Join Date: Jun 2009
Posts: 42
Unhappy Collision detection with custom nodes?

When I add:

viz.MainView.collision(viz.ON)

to the end of testCustomNode.py (example script from the plugin API), I can still drive the viewpoint right through the middle of the polygon. What am I missing?

Thanks,
-Jim
Reply With Quote
  #2  
Old 10-02-2009, 11:54 AM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
Is your custom node using raw OpenGL command to render? If so, then collisions won't work because OpenSceneGraph will not know anything about the mesh of your object. There are two ways to handle this:

1) Use the built-in osg::Geometry class to render your object

2) Implement the following osg::Drawable methods in your custom drawable class:
Code:
virtual bool supports(osg::PrimitiveFunctor&) const;
virtual void accept(osg::PrimitiveFunctor& pf) const;
These methods allow you to pass information about your mesh to OpenSceneGraph, which will allow it to participate in collision/intersection/pick tests. Here is a very simple example showing how to implement this for a simple quad:
Code:
virtual bool supports(osg::PrimitiveFunctor&) const { return true; }

virtual void accept(osg::PrimitiveFunctor& pf) const
{
    pf.begin(GL_QUADS);
    pf.vertex(-1,1,0);
    pf.vertex(1,1,0);
    pf.vertex(1,-1,0);
    pf.vertex(-1,-1,0);
    pf.end()
}
Reply With Quote
  #3  
Old 10-02-2009, 12:49 PM
JimC JimC is offline
Member
 
Join Date: Jun 2009
Posts: 42
This is just the custom-node example plugin that comes with the plugin API. It draw a single (deforming) square.

I assumed that the Drawable's computeBound() method, which returns a BoundingBox, was used for collision detection. The overridden computeBound() method in the example plugin appears to be returning reasonable values, and it does get called by winviz. If not for collision detection, what is this method for?

-Jim
Reply With Quote
  #4  
Old 10-02-2009, 01:01 PM
JimC JimC is offline
Member
 
Join Date: Jun 2009
Posts: 42
> If not for collision detection, what is this method for?

Culling?

-Jim
Reply With Quote
  #5  
Old 10-02-2009, 01:24 PM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
The bounding box of the drawable is used for culling.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Collision detection with specific models just alex Vizard 1 02-06-2009 12:02 PM
Collision Detection and Nearest Point to Probe xabbu Vizard 2 01-06-2009 04:01 AM
Collision with child nodes rubberpimple Vizard 4 09-17-2008 05:27 PM
Collision detection with haptic pen mjabon Vizard 3 01-17-2008 07:35 PM
Walking avatars --> collision detection? sjroorda Vizard 3 10-13-2005 05:47 AM


All times are GMT -7. The time now is 05:25 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Copyright 2002-2023 WorldViz LLC