Thanks for the insight into this method (PickManipulationRendererJ3D). For
recall, I am looking into a way to find out what facet intersects with a
ray which is created when the user clicks somewhere on the surface of our
3D object. I can create the ray from the location of the camera and the
point clicked on in 3D space, but I'm still looking into how to determine
what facet or point is closest to that ray. It looks like it will do what
I am looking for, but I had some more questions on its implementation. Im
looking at the function checkClose() ...
public synchronized float checkClose(double origin, double direction)
int mouseModifiers = getLastMouseModifiers();
if ((mouseModifiers & mouseModifiersMask) != mouseModifiersValue)
float distance = Float.MAX_VALUE;
if (spatialValues == null) return distance;
float o_x = (float) origin;
float o_y = (float) origin;
float o_z = (float) origin;
float d_x = (float) direction;
float d_y = (float) direction;
float d_z = (float) direction;
for (int i=0; i<spatialValues.length; i++)
float x = spatialValues[i] - o_x;
float y = spatialValues[i] - o_y;
float z = spatialValues[i] - o_z;
float dot = x * d_x + y * d_y + z * d_z;
x = x - dot * d_x;
y = y - dot * d_y;
z = z - dot * d_z;
float d = (float) Math.sqrt(x * x + y * y + z * z);
if (d < distance)
distance = d;
closeIndex = i;
I can see where it parses this spatialValues float array and calculates
the distance of the ray to each point in this array and returns the closest
index in that array. My question is this: I cannot see where the values
of the spatialArray are actually set to anything. There is a
setSpatialValues() function that sets the class float array spatialValues
to an array that is passed into that function, but the setSpatialValues()
function is never called within this code. My question thus is how are
these values in the spatialValues determined?
Thanks in advance!
Bill Hibbard writes:
> Hi Greg,
> > I am working on a project in which we are using VisAd to display a 3
> > dimensional image of data points. We essentially create a 3d surface out
> > of these data points, which are made up of triangular facets, made out of
> > the data points. My question is pretty simple, but I am having a really
> > interesting time figuring out how exactly VisAd creates all of these
> > triangular facets, and how to access those facets.
> > Essentially, I want the user to be able to click on the screen somewhere
> > and be able to report what facet the user clicked on, and report any data
> > associated with that facet. What I can't figure out is how VisAd stores the
> > data associated with the facets that it is drawing.
> > I have looked into MouseHelperJ3D and I see how to get the location in
> > world space of the observer (eye_position) and how to get the location in
> > 3D space that the user clicked on (position). I can create a vector out of
> > this and this is my ray in 3D space. I want to know if that ray,
> > emminating from the observer, going out into space, intersects with any of
> > the facets in the data set we are displaying.
> > I have looked into the following classes and elucidated the following (tell
> > me where I am incorrect):
> > FlatField is a container for the entire "data model"?
> > DataReferenceJ3D setData() is a gateway of some kind in setting the data
> > for each of the facets in the 3D surface?
> Actually, FlatField is the class for Data objects that are
> finite samplings of functions, with certain simple types.
> DataReference is the interface for linking Data objects to
> Displays of Cells (computations).
> Some, but not all, Data depictions are composed of 3-D facets.
> > The confusion I encounter is that when I try to go past the
> > DataReferenceJ3D, it starts referencing an object called "Thing". I am
> > having difficulty understanding exactly what a "Thing" is. Is it in any
> > way related to how I access where the facets are in 3D space?
> > Typically in 3D graphics one uses some kind of data structure to hold all
> > of the facets in an object. I understand this could be different for
> > Java3D, but essentially, the data for displaying the facets has to be
> > stored somewhere, and there has to be a way to access it. Im just having
> > difficulty finding it.
> You might get some idea of how Data depictions are computed in
> the draft DataRenderer tutorial. However, you don't need to dig
> into all this - it is pretty complex. Rather, you might use
> visad/bom/PickManipulationRendererJ3D.java. It will tell you
> which vertex (vertex rather than facet) in the surface is closest
> to the mouse ray when the right mouse button is clicked. See
> the main() method in this class for an example of how it should
> be used.
> Good luck,