NOTICE: This version of the NSF Unidata web site (archive.unidata.ucar.edu) is no longer being updated.
Current content can be found at unidata.ucar.edu.
To learn about what's going on, see About the Archive Site.
Hi Greg, > 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) > { > return Float.MAX_VALUE; > } > > float distance = Float.MAX_VALUE; > if (spatialValues == null) return distance; > float o_x = (float) origin[0]; > float o_y = (float) origin[1]; > float o_z = (float) origin[2]; > float d_x = (float) direction[0]; > float d_y = (float) direction[1]; > float d_z = (float) direction[2]; > > for (int i=0; i<spatialValues[0].length; i++) > { > float x = spatialValues[0][i] - o_x; > float y = spatialValues[1][i] - o_y; > float z = spatialValues[2][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; > } > } > > return distance; > } > > 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? The setSpatialValues() method is called by the ShadowType and ShadowFunctionOrSetType classes, and possibly other subclasses of ShadowType or DataRenderer. These are values in XAxis, YAxis and ZAxis coordinates (i.e., Cartesian display spatial values), derived from Data values after a series of Data Unit conversions, Data CoordinateSystem transforms, ScalarMap scalings, and display CoordinateSystem transforms. See section 1.8 of the DataRenderer tutorial at: http://www.ssec.wisc.edu/~billh/dr_tutorial.html for more information about this. Because of the generality of the VisAD data model and the generaility of ScalarMaps, this is pretty complex. Good luck, Bill
visad
archives: