[vtkusers] Re: Simple Collision Detection between camera and object

Goodwin Lawlor goodwin.lawlor at ucd.ie
Wed Jan 31 10:50:03 EST 2007


Chris Hughes wrote:
> Hi Goodwin,
> 
> The vtkOBBTree looks like it could do exactly what I need. However I am 
> really struggling to get it to work. I have a closed polygon mesh and I 
> have ried to set up he OBBTree like this:
> 
>            vtkOBBTree *obbTree = vtkOBBTree::New();
>            obbTree->SetDataSet(vPolyDataReader->GetOutput());
>            obbTree->SetMaxLevel(10);
>            obbTree->BuildLocator();
> 
> I then have a look which runs a simulation and moves the camera around 
> and include:
> 
> ioo = obbTree->InsideOrOutside(ren1->GetActiveCamera()->GetPosition());
> 
> However this causes the application to compile but crash with a 'has 
> encountered a problem and needs to close' style error. Any suggestions?
> 
> Many thanks..
> 
> Chris

Hi Chris,

Could be a couple of things... Try:

1. vPolyDataReader->Update();

before setting it in the OBB tree.

2. Rather than passing the pointer, it's usually safer to try:

double pt[3];
ren1->GetActiveCamera()->GetPosition(pt);
ioo = obbTree->InsideOrOutside(pt);


hth

Goodwin



More information about the vtkusers mailing list