| Re: Red-Blue stereo graphics in IDL [message #11059] |
Wed, 04 March 1998 00:00 |
Evilio del Rio
Messages: 17 Registered: December 1997
|
Junior Member |
|
|
Joseph Scott Stuart wrote:
>
> I have a program that uses IDL object graphics to show a couple of
> dozen 3D objects. The user can zoom in and out, rotate, and change
> various parameters (eg, turning axes on or off). I'd like to make a
> version of the program that does a red/blue or red/green stereo
> version that requires 3D glasses. Does anyone have any advice or
> existing programs that do this? A couple of initial questions:
>
> Will I run into insurmountable problems if I try to have the same
> objects contained in two different IDLgrViews? Doing so would allow
> me to create and maintain just one copy of the couple dozen objects.
> I don't know if it will create subtle internal problems to have the
> same objects in multiple views.
>
Yes, there is a problem, object graphics can only have a Parent:
oM1 = OBJ_NEW('IDLgrModel')
oM2 = OBJ_NEW('IDLgrModel')
oS = OBJ_NEW('IDLgrSurface')
oM1->Add,oS
oM2->Add,oS
% IDLGRMODEL::ADD: Objects can only have one parent at a time: OS
I would suggest you to create a Wrapper object to which you pass only
once the data and using duplicate object graphic atoms with the
SHARE_DATA set. Here is an skeleton of such an Object class:
;Init
function StereoView::Init
self.RedView = OBJ_NEW('IDLgrView')
self.BlueView = OBJ_NEW('IDLgrView')
self.RedModel = OBJ_NEW('IDLgrModel')
self.BlueModel= OBJ_NEW('IDLgrModel')
self.RedView->Add,self.RedModel
self.BlueView->Add,self.BlueModel
return,1
end
;CleanUp
pro StereoView::CleanUp
OBJ_DESTROY,[self.BlueView,self.RedView]
return
end
; Add
pro StereoView::Add,oAtom
on_error,2
ok = OBJ_VALID(oAtom)
if (ok) then ok = ok*OBJ_ISA(oAtom,'IDLGRGRAPHIC') ; Warning: This is
not a
; 'public' RSI class
if (Not(ok)) then message,'Not a valid object.'
;;;;;;; Copy with same data ;;;;;;;
class = OBJ_CLASS(oAtom)
BlueCopy = OBJ_NEW(class,SHARE_DATA=oAtom)
oAtom->GetProperty, LOCATION=redl ;,...etc
BlueCopy->SetProperty,LOCATION=redl ;,...etc
self.RedModel->Add,oAtom
self.BlueModel->Add,BlueCopy
return
end
; Define
pro StereoView__Define
StereoView__Define = { StereoView__Define ,$
RedView : OBJ_NEW() ,$
BlueView : OBJ_NEW() ,$
RedModel : OBJ_NEW() ,$
BlueModel: OBJ_NEW()
}
> If I do have just one instance of each object, how do I deal with the
> colors? As far as I can tell the color of an object has to be
> associated with the object, rather than with the view. But, I need
> the objects rendered by one view to be a different color than the
> objects rendered with the other view. I will experiment with having
> all the objects be white, and adding colored lights to the views, with
> the lights in one view being red, and the lights in the other view
> being blue or green. Are there any other suggestions for how to do
> this?
>
With my proposed solution ther is no problem with color since in fact
you have two copies of the same object (sharing data). This will also
let you control
the two different renderings (viewplanes, eye positions, etc.)
> I've generally had trouble getting the view plane rectangle set up
> correctly. In the current version of the program I used the set_view
> procedure that comes with IDL, but I'll probably need more control
> with the stereogram version. Does anyone know of any additional
> documentation for dealing with the view plane rectangle other than
> what comes with IDL in the 'Objects & Object Graphics' book?
>
The SETVIEW/GETBOUNDS procedure is a generic example (remark that is not
a part of the standard library but of the acompaining exemples). In my
opininion you need a very close control of your renderings. In fact
that's
the keypoint of your application. I always end defining a method
'MyClass::SetView' when dealing with complex graphic objects that
handles all
positions, margins, etc.
I don't know of any bibliography, but if I am not too wrong there was a
Demo that made a Blue-Red stereo rendering of a human head in older
versions of IDL, maybe you can find some ideas looking the source code.
Hope this helps.
Cheers,
____________________________________________________________ ________
Evilio Jose del Rio Silvan Institut de Ciencies del Mar
E-mail: edelrio@icm.csic.es URL: http://www.ieec.fcr.es/~evilio/
"Anywhere you choose,/ Anyway, you're gonna lose"- Mike Oldfield
|
|
|
|