Re: An Interactively rotating 3D animation ? [message #37921 is a reply to message #37920] |
Mon, 09 February 2004 15:06   |
Rick Towler
Messages: 821 Registered: August 1998
|
Senior Member |
|
|
"Erica Stanley" wrote in message...
> Currently, I am using XObjView to display a 3D icon (IDLgrPolygon) at
> different positions inside a volume. I take a snapshot of the icon at
> each position via XObjView_Write_Image and then stream the images
> together using XInterAnimate. The problem is I need this in the form
> of a 3D animation because I want the user to be able to interactively
> rotate the model as the icon is animating through the volume. Does
> anyone have some thoughts on how I might accomplish this?
You'll want to set up a timer event loop to animate your icon while still
processing events from the user.
You might be able to do this with XOBJVIEW by using the REFRESH keyword and
some creative event handling. An example is attached. The problem is that
as written, XOBJVIEW isn't handling button events properly. You can select
the zoom or pan tools but it still only rotates the model. Sorry, but
you'll probably have to dig around in the XOBJVIEW objects to figure this
out.
This would be easy to do in a custom built application. For example,
David's simple_surface program could be modified to do this. Simply set a
timer event on a widget that doesn't usually generate events (base or label)
and in that widget's event handler move your icon and draw. One caveat,
setting your timer events too close together will swamp IDL's event
processing queue and inhibit user input.
If both smooth animation and user feedback are important, you'll have to set
up a single timer based event loop and poll inside that loop for user input.
The downside of this approach is that it isn't portable.
-Rick
; Semi-broken XOBJVIEW example
pro test_xobj_anim_event, event
WIDGET_CONTROL, event.id, GET_UVALUE=info, /NO_COPY
xPos = SIN(info.tick * !DTOR) * 4.
zPos = COS(info.tick * !DTOR) * 4.
info.oModel -> Reset
info.oModel -> Translate, xPos, 0 , zPos
XOBJVIEW, REFRESH=info.xObjTlb
info.tick=info.tick + 1L
WIDGET_CONTROL, event.id, SET_UVALUE=info, TIMER=0.02
end
pro test_xobj_anim_cleanup, tlb
WIDGET_CONTROL, tlb, GET_UVALUE=info
OBJ_DESTROY, info.oModel
end
pro test_xobj_anim
oOrb = OBJ_NEW('orb', COLOR=[200,100,50], STYLE=1, $
RADIUS=6)
oModel = OBJ_NEW('IDLgrModel')
oModel -> Add, oOrb
XOBJVIEW, oModel, TLB=xObjTlb
oOrb -> SetProperty, RADIUS=1
wBase = WIDGET_BASE(MAP=0, GROUP_LEADER=xObjTlb, $
EVENT_PRO='test_xobj_anim_event')
info = {xObjTlb:xObjTlb, $
tick:0L, $
oModel:oModel $
}
WIDGET_CONTROL, wBase, /REALIZE
WIDGET_CONTROL, wBase, SET_UVALUE=info, TIMER=0.02
XMANAGER, 'test_xobj_anim', wBase, $
CLEANUP='test_xobj_anim_cleanup'
end
|
|
|