<DIV>hi;</DIV>
<DIV> I changed TestCollisionDetection example,Add this code </DIV>
<DIV>"for(int i=0;i<4;i++){<BR>    renWin->Render();<BR>    actor2->AddPosition(0.5,0,0);</DIV>
<DIV>    //sphere0->SetCenter(-0.7+i*0.5,0,0);<BR>    collide->Update();<BR>    sum=collide->GetNumberOfContacts();<BR>   }<BR>." why sum is always 0,Actually two actors have been collided? </DIV>
<DIV> This is all the code.</DIV>
<DIV> </DIV>
<DIV> vtkSphereSource *sphere0=vtkSphereSource::New();<BR>  sphere0->SetPhiResolution(30);<BR>  sphere0->SetThetaResolution(30);<BR>  sphere0->SetCenter(-0.7,0,0);<BR>  sphere0->Update();<BR> vtkSphereSource *sphere1=vtkSphereSource::New();<BR>  sphere1->SetPhiResolution(30);<BR>  sphere1->SetThetaResolution(30);<BR>  sphere0->SetCenter(1.7,0,0);<BR>  sphere1->Update();  <BR> vtkMatrix4x4 *matrix0=vtkMatrix4x4::New();<BR> vtkMatrix4x4 *matrix1=vtkMatrix4x4::New();  <BR> vtkCollisionDetectionFilter *collide=vtkCollisionDetectionFilter::New();<BR>  collide->SetInput(0,sphere0->GetOutput());<BR>  collide->SetMatrix(0,matrix0);<BR>  collide->SetInput(1,sphere1->GetOutput());<BR>  collide->SetMatrix(1,matrix1);<BR>  collide->SetBoxTolerance(0.0);<BR>  collide->SetCellTolerance(0.0);<BR>  collide->SetNumberOfCellsPerBucket(2);<BR>  collide->GetCollisionModeMaxValue();<BR>  collide->GeneratePolydataOutputOn();<BR> vtkTextActor *txt=vtkTextActor::New();<BR>  txt->GetTextProperty()->SetFontFamilyToCourier();<BR>   <BR> vtkSphereSource *point=vtkSphereSource::New();<BR>   point->SetRadius(0.01);<BR> vtkPolyData *pointdata=vtkPolyData::New();<BR>   pointdata->SetPoints(collide->GetContactPoints());  <BR> vtkGlyph3D *points=vtkGlyph3D::New();<BR>   points->SetInput(pointdata);<BR>   points->SetSource(point->GetOutput());  <BR> vtkPolyDataMapper *mapper1=vtkPolyDataMapper::New();<BR>   mapper1->SetInput(collide->GetOutput(0));<BR> vtkActor *actor1=vtkActor::New();<BR>   actor1->SetMapper(mapper1);<BR>   actor1->GetProperty()->BackfaceCullingOn();<BR>   actor1->SetUserMatrix(matrix0);  <BR> vtkPolyDataMapper *mapper2=vtkPolyDataMapper::New();<BR>   mapper2->SetInput(collide->GetOutput(1));<BR> vtkActor *actor2=vtkActor::New();<BR>   actor2->SetMapper(mapper2);<BR>   actor2->GetProperty()->BackfaceCullingOn();<BR>   actor2->SetUserMatrix(matrix1);   <BR> vtkPolyDataMapper *mapper3=vtkPolyDataMapper::New();<BR>   mapper3->SetInput(points->GetOutput());<BR> vtkActor *actor3=vtkActor::New();<BR>   actor3->SetMapper(mapper3);<BR>   actor3->GetProperty()->SetColor(0,0,0);<BR> vtkRenderer *ren=vtkRenderer::New();<BR>   ren->AddActor(actor1);<BR>   ren->AddActor(actor2);<BR> ChangeOrigin *changeorigin=ChangeOrigin::New();<BR>         changeorigin->actor1=actor1;<BR>   changeorigin->actor2=actor2;<BR>   changeorigin->collide=collide;<BR>   //ren->AddObserver(vtkCommand::EndEvent,changeorigin);<BR> cbCollision *cbcollision=cbCollision::New();<BR>   cbcollision->collide=collide;<BR>   cbcollision->txt=txt;<BR>   cbcollision->points=points;<BR>   //collide->AddObserver(vtkCommand::AnyEvent,cbcollision);<BR>   ren->AddActor(txt);<BR>   ren->SetBackground(0.5,0.5,0.5);<BR>   <BR> vtkRenderWindow *renWin=vtkRenderWindow::New();<BR>   renWin->AddRenderer(ren);<BR>   int sum,j;<BR>   for(int i=0;i<4;i++){<BR>    renWin->Render();<BR>    actor2->AddPosition(0.5,0,0);</DIV>
<DIV>    //sphere0->SetCenter(-0.7+i*0.5,0,0);<BR>    collide->Update();<BR>    sum=collide->GetNumberOfContacts();<BR>   }<BR> vtkInteractorStyleJoystickActor *istyle=vtkInteractorStyleJoystickActor::New();<BR> vtkRenderWindowInteractor *iren=vtkRenderWindowInteractor::New();<BR>   iren->SetRenderWindow(renWin);<BR>   iren->SetInteractorStyle(istyle);</DIV>
<DIV>   iren->Initialize();<BR>   iren->Start();</DIV>
<DIV> </DIV>
<DIV> </DIV><SPAN ></SPAN><br><!-- footer --><br><br><br><br><br><div style="border-bottom:1px solid #999"></div><br>

        <font color="black" style="font-size:14.8px">你 知 道 中 国 每 年 耗 费 多 少 一 次 性 筷 子 吗 ?</font>
        <br>
         <font style="font-size:13px;line-height:160%;color:blue">450亿双!相当于170万立方米的木材,大约需要砍伐2500万棵大树!</font> <a href="http://www.126.com/" target="_blank" style="font-size:13px;line-height:160%;color:blue"><网易邮箱公益宣传>
</a>