I have not used Java3D, but visualizing, rotating, scaling and translating plots made up of spherical objects is routine work for IDL Object Graphics, and can be accomplished with a very minimal number of code lines. Here, for example, is a very simple method to display a plot with spherical symbols on a mouse-interactive window:
PRO sphere_symbol_plot
; Make some dummy sine curve data
x = indgen(20)
y = sin(x/3.)
z = x
; Define the plot curve symbol to be a blue sphere
oSphere = obj_new('orb', COLOR=[0, 0, 255])
oSphere->Scale, .75, .1, .5 ; Scale the default unit sphere to a nice size for XPLOT3D
oSymbol = obj_new('IDLgrSymbol', oSphere)
xplot3d, x, y, z, THICK=2, SYMBOL=oSymbol
END
When you mention wanting to do thousands of small spheres, where a sphere represents a pixel, I actually don't picture in my head a "plot" like the one demonstrated above. I envision more an array of free-standing spheres. Here is code that makes a simple gridded array of spheres on an 800x500 window:
PRO sphere_image
; Make 1000 random RGB color tripletes
sphereColors = byte(randomu(seed, 3, 40, 25) * 256)
; Make the "sphere image" in a 40 x 25 grid
sphereImg = objarr(40,25)
for i = 0, 24 do begin
for j = 0, 39 do begin
sphereImg[j,i] = obj_new('orb', POS=[j*20+10,i*20+10,0], $
RADIUS=10.0, COLOR=sphereColors[*,j,i])
endfor
endfor
oModel = obj_new('IDLgrModel')
for i = 0, 999 do oModel->Add, sphereImg[i] ; Don't need [i,j] referencing in IDL
; Add directional light to the model to highlight the 3D shape of the spheres
oLight = obj_new('IDLgrLight', LOCATION=[799,499,12], TYPE=2)
oModel->Add, oLight
oView = obj_new('IDLgrView', LOCATION=[0,0], DIMENSIONS=[800,500], $
VIEWPLANE_RECT=[0,0,800,500], ZCLIP=[10,-10], EYE=12)
oWindow = obj_new('IDLgrWindow', DIMENSIONS=[800,500], RETAIN=2)
oView->Add, oModel
oWindow->Draw, oView
obj_destroy, oView ; Clean up
END
In this case, selecting a given sphere is easy. If the "oWindow" were an IDL draw widget (WIDGET_DRAW), then the event handler that handles the button click could run:
selectedObjs = oWindow->Select(oView, [event.x, event.y])
to get ana array of the handles of all the Objects whose images display to the point where the mouse was clicked plus or minus one pixel around that point. And, although the current 'oView' above is not optimal for viewing transformations of this grid, rotating, scaling or translating the above grid is as easy as running commands like "oModel->Rotate" or "oModel->Scale" or "oModel->Translate" followed by a reinvocation of "oWindow->Draw, oView".
Hope this helps you compare IDL to Java3D. For the details of IDL Object Programming see the topic 'Programmer's Guides -> Object Programming' in Online Help's Contents tab page.
James Jones
|