[vtkusers] Rotating about the normal in a point
Van Gasse Kurt
kurt.van.gasse at student.groept.be
Mon Dec 25 11:01:51 EST 2000
Hi !
I am having some problems calculating a specific normal of a point on the surface of an object. The goal is to rotate the object about the calculated normal. I have already calculated the normals in order to apply Gouraud-shading, but now I need a normal in a specific point.
Heres a chunk of the code I wrote :
stlreader=vtkSTLReader::New();
mapper=vtkPolyDataMapper::New();
pNormals= vtkPolyDataNormals::New();
motorActor=vtkActor::New();
vtkNormals *norm=vtkNormals::New();
stlreader->SetFileName("brol.stl");
pNormals->SetInput(stlreader->GetOutput());
mapper->SetInput(pNormals->GetOutput());
motorActor->SetMapper(mapper);
motorActor->SetProperty(brolProps);
this->Props->AddItem(motorActor);
int pointID;
vtkDataSet *data;
data=motorActor->GetMapper()->GetInput();
pointID=data->FindPoint(78.9994, 73.6264, 197.831);
float *normal;
normal=norm->GetNormal(pointID);
motorActor->RotateWXYZ(90,normal[0],normal[1],normal[2]);
The problem is : the program always return 1 as pointID for the specified point. Im absolutely sure this point is on the surface of the object.
Where did it go wrong ? Is there a better way to do this ?
Can you please help me out ?
Cheers,
Kurt
More information about the vtkusers
mailing list