[vtkusers] transformation problem on vtkActor & vtkBoxWidget

Kevin Tiow Wee Tan twtan at cheerful.com
Tue Feb 11 12:39:59 EST 2003


Hello,
I have the following tcl code to attach vtkBoxWidget with vtkActor (with
vtkConeSource)

If I leave the vtkActor at the default position initially (0,0,0),
interacting vtkBoxWidget will manipulate vtkActor very well... No
problem...

If I position the vtkActor at certain position such as (2, 0, 0) using
SetPosition method initially, interacting on the vtkBoxWidget will
result an unexpected result on the vtkActor.  
Rotating the vtkBoxWidget will result the vtkActor move out of the
vtkBoxWidget outline.
Scaling on x-axis also seems to be on the scaling AND as well as MOVE
out towards x-axis...

I would appreciate if anyone can give me advice upon this problem...

Following is my tcl code:

#*******************************
package require vtk

vtkConeSource cone
cone SetDirection 0 1 0

vtkPolyDataMapper coneMapper
coneMapper SetInput [cone GetOutput]

vtkActor coneActor
coneActor SetMapper coneMapper
coneActor SetPosition 2 0 0

vtkRenderer ren1 
ren1 AddActor coneActor
ren1 SetBackground 0.1 0.2 0.4

vtkRenderWindow renWin
renWin AddRenderer ren1
renWin SetSize 300 300

vtkRenderWindowInteractor iren
iren SetRenderWindow renWin

vtkInteractorStyleTrackballCamera style
iren SetInteractorStyle style

vtkBoxWidget boxWidget
boxWidget SetInteractor iren
boxWidget SetPlaceFactor 1.25
boxWidget SetInput [cone GetOutput]
set bounds [coneActor GetBounds]
boxWidget PlaceWidget [lindex $bounds 0]  [lindex $bounds 1]  [lindex
$bounds 2] [lindex $bounds 3]  [lindex $bounds 4]  [lindex $bounds 5]
boxWidget AddObserver InteractionEvent TransformActor
boxWidget On

iren AddObserver UserEvent {wm deiconify .vtkInteract}

iren Initialize

wm withdraw .

vtkTransform t
proc TransformActor {} {
   boxWidget GetTransform t
   coneActor SetUserTransform t
}


#*******************************

--
Thanks
Kevin



More information about the vtkusers mailing list