Re: An Interactively rotating 3D animation ? [message #37919] |
Mon, 09 February 2004 16:42  |
Rick Towler
Messages: 821 Registered: August 1998
|
Senior Member |
|
|
"David Fanning" wrote in message...
> Rick Towler writes:
>
>> 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.
>
> Why wouldn't this be portable?
>
Well, I should have said "The only way I know how..." since I don't know
how to actually poll for mouse input within IDL. The docs advise against
using CURSOR in draw widgets and I have to admit I haven't tried it.
Looking at the docs it looks like it blocks if you want button data which
would eliminate it as a possible kludge in this case anyways. So we're back
to capturing input via events, aren't we?
I'm sure there is a way of structuring an event-based application to provide
smooth animation and user feedback but it is much more difficult than simply
firing a timer event every n/th of a second then polling, updating and
drawing. Which is why I wrote a DLM to poll for mouse, keyboard, and game
device input in windows using directInput. But like I said, it isn't very
portable.
-Rick
|
|
|
|
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
|
|
|
Re: An Interactively rotating 3D animation ? [message #38018 is a reply to message #37919] |
Mon, 09 February 2004 18:47  |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
Rick Towler writes:
> Well, I should have said "The only way I know how..." since I don't know
> how to actually poll for mouse input within IDL. The docs advise against
> using CURSOR in draw widgets and I have to admit I haven't tried it.
> Looking at the docs it looks like it blocks if you want button data which
> would eliminate it as a possible kludge in this case anyways. So we're back
> to capturing input via events, aren't we?
I guess I thought you were talking about a "WHILE 1 DO" sort of
event loop, ala CW_DEFROI, which appears to propagate its
havoc everywhere in a device independent way. :-)
> I'm sure there is a way of structuring an event-based application to provide
> smooth animation and user feedback but it is much more difficult than simply
> firing a timer event every n/th of a second then polling, updating and
> drawing. Which is why I wrote a DLM to poll for mouse, keyboard, and game
> device input in windows using directInput. But like I said, it isn't very
> portable.
I'm not sure a DLM is necessary. I'm working on a fairly large
medical imaging application that has a cine going pretty much
all the time with a timer, and we don't have much trouble
drawing ROIs in other widget windows, etc. I guess the key is
getting through your event handlers in a timely fashion, but
this really doesn't seem to be much of a problem on today's
standard computers.
Object graphics can obviously be a bit slower, but even there,
I don't think this would be particularly difficult.
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting
Coyote's Guide to IDL Programming: http://www.dfanning.com/
|
|
|