[vtkusers] Problem - rotate arrow

yaarula nunit100 at walla.com
Sat May 29 08:59:42 EDT 2010


Hi,

Im a new vtk user. Im trying to add arrow to points in order to show the
direction at each point. The arrows are indeed added but they all point to
the same direction although the angles are different. I also tried to change
the angles to the extremes to see if the arrows rotate (0, pi/2...) but
still no change. 
I really cant find the problem. Could anyone please help me?

Thanks a lot.

Yaara.



Here is my code, x,y,z are coordinates i receive and a,e,r are the azimuth,
elevation and roll angles.
...

//Create point
float p[3] = {x,y,z};
vtkSmartPointer<vtkActor> actor = createPointActor(p,4);

//Create vectors
vtkSmartPointer<vtkFloatArray> vectors =
vtkSmartPointer<vtkFloatArray>::New();
vtkSmartPointer<vtkPoints> pts = vtkSmartPointer<vtkPoints>::New();
pts->InsertNextPoint(x,y,z);
vectors->SetNumberOfTuples(1);
vectors->SetNumberOfComponents(3);
	
vtkSmartPointer<vtkPolyData>  base = vtkSmartPointer<vtkPolyData>::New();
base->SetPoints(pts);
base->GetPointData()->SetVectors(vectors);

// create arrow + Transformation
vtkSmartPointer<vtkArrowSource> arrow = vtkArrowSource::New();
vtkSmartPointer<vtkTransform> arrTransform =
vtkSmartPointer<vtkTransform>::New();
arrTransform->RotateX(r);
arrTransform->RotateY(a);
arrTransform->RotateZ(e);
		
vtkSmartPointer<vtkTransformPolyDataFilter> arrTransFilter =
vtkSmartPointer<vtkTransformPolyDataFilter>::New();
arrTransFilter->SetInputConnection(arrow->GetOutputPort());
arrTransFilter->SetTransform(arrTransform);
arrTransFilter->Update();
	
//Glyph
vtkGlyph3D* glyph = vtkGlyph3D::New();
glyph->SetScaleFactor(0.8);
glyph->SetInput(base);
glyph->SetSourceConnection(arrow->GetOutputPort());
glyph->SetVectorModeToUseVector();
vtkPolyDataMapper *vectorMapper = vtkPolyDataMapper::New();
vectorMapper->SetInput(glyph->GetOutput());
vtkActor *vectorActor = vtkActor::New();
vectorActor->GetProperty()->SetColor(1.0000, 0.3, 0.2);
vectorActor->SetMapper(vectorMapper); 
ren[0]->AddActor(vectorActor);

ren[0]->AddActor(actor);
renWin->Render();
actor->GetProperty()->SetColor(1,1,0);

		
-- 
View this message in context: http://old.nabble.com/Problem---rotate-arrow-tp28714526p28714526.html
Sent from the VTK - Users mailing list archive at Nabble.com.




More information about the vtkusers mailing list