[vtkusers] vtkActor->SetUserMatrix doesn't work

Lisa Avila lisa.avila at kitware.com
Fri Feb 6 11:54:15 EST 2004


Hello Peter,

I ran your test as tcl against my VTK 4.2 and it works just fine. I've 
included the tcl below (slight modifications to the color / rotate angle 
but essentially the same). I am not sure why this does not work for you - 
this does not seem to be an issue that can be caused by a video driver, 
compiler version, operating system, etc.

Lisa

vtkRenderer ren
vtkRenderWindow renWin
vtkActor actor
vtkCubeSource cube
vtkPolyDataMapper mapper
mapper SetInput [cube GetOutput]
actor SetMapper mapper
renWin AddRenderer ren
ren AddActor actor

renWin Render

for {set i 0 } {$i < 360} {incr i 5} {
     vtkTransform t
     t RotateZ $i
     actor SetUserMatrix [t GetMatrix]
     [actor GetProperty] SetColor [expr $i/360.0] [expr (360.0-$i)/360.0] 
[expr $i/360.0]
     renWin Render
     t Delete
}

At 06:10 AM 2/6/2004, Boettcher, Dr. Peter wrote:
>Hi,
>
>once more I try to solve the vtkActor->SetUserMatrix - Problem. The first 
>time vtkActor->SetUserMatrix or vtkActor->SetUserTransform is called - it 
>works. But each time I call it again with a modified matrix nothing 
>happens.  The work around 
>(<http://vtk.org/pipermail/vtkusers/2003-January/015391.html>http://vtk.org/pipermail/vtkusers/2003-January/015391.html) 
>doesn't work for me.
>
>Is there someone who could try my code on his machine? Maybe it is a local 
>problem (WinXP, vtk4.2, VS6.0)?
>
>Regards - Peter.
>
>
>
>// Rotates a cube 360° around the z-axis
>// SetUserMatrix is called: works only the first time ;-(
>#include "vtk.h"
>void main(void)
>{
>  vtkRenderer* ren = vtkRenderer::New();
>  vtkRenderWindow* renWin = vtkRenderWindow::New();
>  vtkActor* actor = vtkActor::New();
>  vtkCubeSource * cube = vtkCubeSource::New();
>  vtkPolyDataMapper* mapper = vtkPolyDataMapper::New();
>  renWin->AddRenderer(ren);
>  ren->AddActor(actor);
>  mapper->SetInput(cube->GetOutput());
>  actor->SetMapper(mapper);
>   renWin->Render();
>
>
>// ---------- Loop Rotation over the Z-axis -----------------//
>
>  for(float i = 45; i < 360; i+=45)
>  {
>   vtkTransform* transform = vtkTransform::New();
>   transform->RotateZ(i);
>   actor->SetUserMatrix(transform->GetMatrix());
>   actor->GetProperty()->SetColor((float)i/360, (float)i/360, (float)i/360);
>   renWin->Render();
>   transform->Delete();
>   for(int ii = 0; ii<30000; ii++);
>
>  }
>}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20040206/e1f9dbab/attachment.htm>


More information about the vtkusers mailing list