This archive contains answers to questions sent to Unidata support through mid-2025. Note that the archive is no longer being updated. We provide the archive for reference; many of the answers presented here remain technically correct, even if somewhat outdated. For the most up-to-date information on the use of NSF Unidata software and data services, please consult the Software Documentation first.
>From: "Stuart Wier" <address@hidden> >Organization: UCAR/Unidata >Keywords: 200407271724.i6RHObNx009806 Stu- >Institution: UNAVCO >Package Version: 1.1b3 >Operating System: Linux >Hardware Information: Intel 586 >Inquiry: In >ucar/visad/ShapeUtility.java >the following code is used to make \"shapes\" >(VisADGeometryArray-s) to mark observation locations. Can you say what is the > principle behind this code so I can make other shapes? In particular we need > a sphere or similar 3D shape. The shapes are based on the default VisAD box coordinates from -1.0 to 1.0 in all directions. In the IDV, the shapes are then scaled to an appropriate size using the ShapeUtility.setSize() method (see SelectorPoint.java or StationModelDisplayable.java for examples). The values for the coordinates are xyz triplets of the vertices. The VisADGeometryArray you use will depend on what you are trying to draw. For a sphere, you would have to figure out how many vertices you want. You might send a note to the VisAD list to see if someone has already created some shapes. That's how I got most of the ones we have. Good luck, Don >Thanks, > >Stu Wier > > } else if (s.equals(CUBE)) { > shape = new VisADQuadArray(); > shape.coordinates = new float[] { > 1.0f, 1.0f, -1.0f, 1.0f, -1.0f, -1.0f, 1.0f, -1.0f, -1.0f, > -1.0f, -1.0f, -1.0f, -1.0f, -1.0f, -1.0f, -1.0f, 1.0f, -1.0f, > -1.0f, 1.0f, -1.0f, 1.0f, 1.0f, -1.0f, 1.0f, 1.0f, 1.0f, 1.0f, > -1.0f, 1.0f, 1.0f, -1.0f, 1.0f, -1.0f, -1.0f, 1.0f, -1.0f, > -1.0f, 1.0f, -1.0f, 1.0f, 1.0f, -1.0f, 1.0f, 1.0f, 1.0f, 1.0f, > 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, -1.0f, 1.0f, 1.0f, -1.0f, > 1.0f, -1.0f, -1.0f, 1.0f, -1.0f, -1.0f, 1.0f, -1.0f, 1.0f, > 1.0f, -1.0f, 1.0f, 1.0f, 1.0f, 1.0f, -1.0f, 1.0f, 1.0f, -1.0f, > 1.0f, -1.0f, -1.0f, 1.0f, -1.0f, -1.0f, -1.0f, -1.0f, -1.0f, > -1.0f, -1.0f, -1.0f, -1.0f, 1.0f, -1.0f, -1.0f, 1.0f, -1.0f, > 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, -1.0f, 1.0f, 1.0f, > -1.0f, -1.0f, 1.0f, -1.0f, -1.0f, 1.0f, -1.0f, -1.0f, 1.0f, > 1.0f, -1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, -1.0f, 1.0f, > 1.0f, -1.0f, -1.0f, 1.0f, -1.0f, -1.0f, -1.0f, -1.0f, -1.0f, > -1.0f, -1.0f, -1.0f, -1.0f, -1.0f, 1.0f, -1.0f, -1.0f, 1.0f, > 1.0f, -1.0f, 1.0f > }; > > shape.normals = new float[144]; > for (int i = 0; i < 24; i += 3) { > shape.normals[i] = 0.0f; > shape.normals[i + 1] = 0.0f; > shape.normals[i + 2] = -1.0f; > > shape.normals[i + 24] = 0.0f; > shape.normals[i + 25] = 0.0f; > shape.normals[i + 26] = 1.0f; > > shape.normals[i + 48] = 1.0f; > shape.normals[i + 49] = 0.0f; > shape.normals[i + 50] = 0.0f; > > shape.normals[i + 72] = -1.0f; > shape.normals[i + 73] = 0.0f; > shape.normals[i + 74] = 0.0f; > > shape.normals[i + 96] = 0.0f; > shape.normals[i + 97] = 1.0f; > shape.normals[i + 98] = 0.0f; > > shape.normals[i + 120] = 0.0f; > shape.normals[i + 121] = -1.0f; > shape.normals[i + 122] = 0.0f; > } > > > } else if (s.equals(TRIANGLE)) { > shape = new VisADLineArray(); > shape.coordinates = new float[] { > -1.0f, -0.5f, 0.0f, 1.0f, -0.5f, 0.0f, 0.0f, 1.0f, 0.0f > }; > } else if (s.equals(FILLED_TRIANGLE)) { > shape = new VisADTriangleArray(); > shape.coordinates = new float[] { > -1.0f, -0.5f, 0.0f, 1.0f, -0.5f, 0.0f, 0.0f, 1.0f, 0.0f > }; > > } else if (s.equals(AIRPLANE)) { > shape = new VisADTriangleArray(); > shape.coordinates = new float[] { > 0.0f, -1.0f, 0.0f, 0.1f, 0.8f, 0.0f, -0.1f, 0.8f, 0.0f, 0.0f, > -0.9f, 0.0f, 0.1f, 0.8f, 0.0f, -0.1f, 0.8f, 0.0f, -0.025f, > -0.9f, 0.0f, 0.025f, -0.9f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, > 0.35f, 0.0f, 0.0f, 0.05f, 0.0f, 0.8f, 0.0f, 0.0f, 0.0f, 0.35f, > 0.0f, 0.0f, .05f, 0.0f, -0.8f, 0.0f, 0.0f, 0.0f, -0.75f, 0.0f, > 0.0f, -0.85f, 0.0f, .25f, -0.85f, 0.0f, 0.0f, -0.75f, 0.0f, > 0.0f, -0.85f, 0.0f, -0.25f, -0.85f, 0.0f > }; > } > > > -- NOTE: All email exchanges with Unidata User Support are recorded in the Unidata inquiry tracking system and then made publically available through the web. If you do not want to have your interactions made available in this way, you must let us know in each email you send to us.