[vtkusers] Manipulte a vtkActor through its vtkMatrix4x4

Simon DROUIN sdrouin at bic.mni.mcgill.ca
Tue Feb 3 08:37:00 EST 2004


Boettcher, Dr. Peter wrote:

> Hi,
>  
> I would like to manipulate a 3D-object (vtkActor) using vtkMatrix4x4. 
> Unfortunately once the actor has been drawn, changing the matrix 
> (actor->SetUserMatrix) results in no change. This works only once 
> before the actor has been added to the vtkRenderer. Up to now I remove 
> the actor, delete it and construct a new one with the modified 
> user-matrix each time I like to manipulate it.
>  
> Regards, Peter.

Hi Peter,

I'm not sure about this, but I think you have to make sure that the 
Modified() method has been called on your matrix for the actor's 
transformation to update. One common mistake is to modify the user 
matrix by accessing directly its elements ( matrix->Element[i][j] = x; 
for example ) without calling Modified() after. If you don't want to 
call Modified yourself, use matrix->SetElement( i, j, x ) instead.

If you look at the function SetUserMatrix() in vtkProp3d, you can see 
that it does a lot of stuff. It's probably simpler to SetUserMatrix() 
the first time (vtkProp3d doesn't create one by default) and then to 
user GetUserMatrix() to retrieve it and modify it.

Hope it helps.

Simon




More information about the vtkusers mailing list