1 package tim.prune.threedee;
3 import java.awt.BorderLayout;
4 import java.awt.FlowLayout;
6 import java.awt.GraphicsConfiguration;
7 import java.awt.GraphicsEnvironment;
8 import java.awt.event.ActionEvent;
9 import java.awt.event.ActionListener;
10 import java.awt.event.WindowAdapter;
11 import java.awt.event.WindowEvent;
12 import java.awt.geom.GeneralPath;
14 import javax.media.j3d.AmbientLight;
15 import javax.media.j3d.Appearance;
16 import javax.media.j3d.BoundingSphere;
17 import javax.media.j3d.BranchGroup;
18 import javax.media.j3d.Canvas3D;
19 import javax.media.j3d.Font3D;
20 import javax.media.j3d.FontExtrusion;
21 import javax.media.j3d.GeometryArray;
22 import javax.media.j3d.GraphicsConfigTemplate3D;
23 import javax.media.j3d.Group;
24 import javax.media.j3d.Material;
25 import javax.media.j3d.PointLight;
26 import javax.media.j3d.QuadArray;
27 import javax.media.j3d.Shape3D;
28 import javax.media.j3d.Text3D;
29 import javax.media.j3d.Texture;
30 import javax.media.j3d.TextureAttributes;
31 import javax.media.j3d.Transform3D;
32 import javax.media.j3d.TransformGroup;
33 import javax.swing.JButton;
34 import javax.swing.JFrame;
35 import javax.swing.JOptionPane;
36 import javax.swing.JPanel;
37 import javax.vecmath.Color3f;
38 import javax.vecmath.Matrix3d;
39 import javax.vecmath.Point3d;
40 import javax.vecmath.Point3f;
41 import javax.vecmath.TexCoord2f;
42 import javax.vecmath.Vector3d;
44 import tim.prune.DataStatus;
45 import tim.prune.FunctionLibrary;
46 import tim.prune.I18nManager;
47 import tim.prune.data.Track;
48 import tim.prune.function.Export3dFunction;
49 import tim.prune.function.srtm.LookupSrtmFunction;
50 import tim.prune.gui.map.MapSourceLibrary;
51 import tim.prune.save.GroutedImage;
52 import tim.prune.save.MapGrouter;
54 import com.sun.j3d.utils.behaviors.vp.OrbitBehavior;
55 import com.sun.j3d.utils.geometry.Box;
56 import com.sun.j3d.utils.geometry.Cylinder;
57 import com.sun.j3d.utils.geometry.GeometryInfo;
58 import com.sun.j3d.utils.geometry.NormalGenerator;
59 import com.sun.j3d.utils.geometry.Sphere;
60 import com.sun.j3d.utils.image.TextureLoader;
61 import com.sun.j3d.utils.universe.SimpleUniverse;
65 * Class to hold main window for java3d view of data
67 public class Java3DWindow implements ThreeDWindow
69 private Track _track = null;
70 private JFrame _parentFrame = null;
71 private JFrame _frame = null;
72 private ThreeDModel _model = null;
73 private OrbitBehavior _orbit = null;
74 private double _altFactor = -1.0;
75 private ImageDefinition _imageDefinition = null;
76 private GroutedImage _baseImage = null;
77 private TerrainDefinition _terrainDefinition = null;
78 private DataStatus _dataStatus = null;
80 /** only prompt about big track size once */
81 private static boolean TRACK_SIZE_WARNING_GIVEN = false;
84 private static final double INITIAL_Y_ROTATION = -25.0;
85 private static final double INITIAL_X_ROTATION = 15.0;
86 private static final String CARDINALS_FONT = "Arial";
87 private static final int MAX_TRACK_SIZE = 2500; // threshold for warning
88 private static final double MODEL_SCALE_FACTOR = 20.0;
93 * @param inFrame parent frame
95 public Java3DWindow(JFrame inFrame)
97 _parentFrame = inFrame;
102 * Set the track object
103 * @param inTrack Track object
105 public void setTrack(Track inTrack)
111 * @param inFactor altitude factor to use
113 public void setAltitudeFactor(double inFactor)
115 _altFactor = inFactor;
119 * Set the parameters for the base image and do the grouting already
120 * (setTrack should already be called by now)
122 public void setBaseImageParameters(ImageDefinition inDefinition)
124 _imageDefinition = inDefinition;
125 if (inDefinition != null && inDefinition.getUseImage())
127 _baseImage = new MapGrouter().createMapImage(_track, MapSourceLibrary.getSource(inDefinition.getSourceIndex()),
128 inDefinition.getZoom());
130 else _baseImage = null;
134 * Set the terrain parameters
136 public void setTerrainParameters(TerrainDefinition inDefinition)
138 _terrainDefinition = inDefinition;
142 * Set the current data status
144 public void setDataStatus(DataStatus inStatus)
146 _dataStatus = inStatus;
152 public void show() throws ThreeDException
154 // Make sure altitude exaggeration is positive
155 if (_altFactor < 0.0) {_altFactor = 1.0;}
157 // Set up the graphics config
158 GraphicsConfiguration config = SimpleUniverse.getPreferredConfiguration();
161 // Config shouldn't be null, but we can try to create a new one as a workaround
162 GraphicsConfigTemplate3D gc = new GraphicsConfigTemplate3D();
164 config = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getBestConfiguration(gc);
169 // Second attempt also failed, going to have to give up here.
170 throw new ThreeDException("Couldn't create graphics config");
173 // Check number of points in model isn't too big, and suggest compression
174 Object[] buttonTexts = {I18nManager.getText("button.continue"), I18nManager.getText("button.cancel")};
175 if (_track.getNumPoints() > MAX_TRACK_SIZE && !TRACK_SIZE_WARNING_GIVEN)
177 if (JOptionPane.showOptionDialog(_parentFrame,
178 I18nManager.getText("dialog.3d.warningtracksize"),
179 I18nManager.getText("function.show3d"), JOptionPane.OK_CANCEL_OPTION,
180 JOptionPane.WARNING_MESSAGE, null, buttonTexts, buttonTexts[1])
181 == JOptionPane.OK_OPTION)
183 // opted to continue, don't show warning again
184 TRACK_SIZE_WARNING_GIVEN = true;
187 // opted to cancel - show warning again next time
192 Canvas3D canvas = new Canvas3D(config);
193 canvas.setSize(400, 300);
195 // Create the scene and attach it to the virtual universe
196 BranchGroup scene = createSceneGraph();
197 SimpleUniverse u = new SimpleUniverse(canvas);
199 // This will move the ViewPlatform back a bit so the
200 // objects in the scene can be viewed.
201 u.getViewingPlatform().setNominalViewingTransform();
203 // Add behaviour to rotate using mouse
204 _orbit = new OrbitBehavior(canvas, OrbitBehavior.REVERSE_ALL | OrbitBehavior.STOP_ZOOM);
205 BoundingSphere bounds = new BoundingSphere(new Point3d(0.0,0.0,0.0), 100.0);
206 _orbit.setSchedulingBounds(bounds);
207 u.getViewingPlatform().setViewPlatformBehavior(_orbit);
208 u.addBranchGraph(scene);
210 // Don't reuse _frame object from last time, because data and/or scale might be different
211 // Need to regenerate everything
212 _frame = new JFrame(I18nManager.getText("dialog.3d.title"));
213 _frame.getContentPane().setLayout(new BorderLayout());
214 _frame.getContentPane().add(canvas, BorderLayout.CENTER);
215 _frame.setIconImage(_parentFrame.getIconImage());
216 // Make panel for render, close buttons
217 JPanel panel = new JPanel();
218 panel.setLayout(new FlowLayout(FlowLayout.RIGHT));
219 // Add button for exporting pov
220 JButton povButton = new JButton(I18nManager.getText("function.exportpov"));
221 povButton.addActionListener(new ActionListener() {
222 /** Export pov button pressed */
223 public void actionPerformed(ActionEvent e)
225 if (_orbit != null) {
226 callbackRender(FunctionLibrary.FUNCTION_POVEXPORT);
229 panel.add(povButton);
231 JButton closeButton = new JButton(I18nManager.getText("button.close"));
232 closeButton.addActionListener(new ActionListener()
234 /** Close button pressed - clean up */
235 public void actionPerformed(ActionEvent e) {
240 panel.add(closeButton);
241 _frame.getContentPane().add(panel, BorderLayout.SOUTH);
242 _frame.setSize(500, 350);
244 // Add a listener to clean up when window closed
245 _frame.addWindowListener(new WindowAdapter() {
246 public void windowClosing(WindowEvent e) {
252 _frame.setVisible(true);
253 if (_frame.getState() == JFrame.ICONIFIED) {
254 _frame.setState(JFrame.NORMAL);
259 * Dispose of the frame and its resources
261 public void dispose()
263 if (_frame != null) {
270 * Create the whole scenery from the given track
271 * @return all objects in the scene
273 private BranchGroup createSceneGraph()
275 // Create the root of the branch graph
276 BranchGroup objRoot = new BranchGroup();
278 // Create the transform group node and initialize it.
279 // Enable the TRANSFORM_WRITE capability so it can be spun by the mouse
280 TransformGroup objTrans = new TransformGroup();
281 objTrans.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
283 // Create a translation
284 Transform3D shiftz = new Transform3D();
285 shiftz.setScale(0.055);
286 TransformGroup shiftTrans = new TransformGroup(shiftz);
288 objRoot.addChild(shiftTrans);
289 Transform3D rotTrans = new Transform3D();
290 rotTrans.rotY(Math.toRadians(INITIAL_Y_ROTATION));
291 Transform3D rot2 = new Transform3D();
292 rot2.rotX(Math.toRadians(INITIAL_X_ROTATION));
293 TransformGroup tg2 = new TransformGroup(rot2);
294 objTrans.setTransform(rotTrans);
295 shiftTrans.addChild(tg2);
296 tg2.addChild(objTrans);
299 Appearance planeAppearance = null;
301 planeAppearance = new Appearance();
302 planeAppearance.setMaterial(new Material(new Color3f(0.1f, 0.2f, 0.2f),
303 new Color3f(0.0f, 0.0f, 0.0f), new Color3f(0.3f, 0.4f, 0.4f),
304 new Color3f(0.3f, 0.3f, 0.3f), 0.0f));
305 plane = new Box(10f, 0.04f, 10f, planeAppearance);
306 objTrans.addChild(plane);
308 // Image on top of base plane, if specified
309 final boolean showTerrain = _terrainDefinition != null && _terrainDefinition.getUseTerrain();
310 if (_baseImage != null && !showTerrain)
312 QuadArray baseSquare = new QuadArray (4, QuadArray.COORDINATES | GeometryArray.TEXTURE_COORDINATE_2);
313 baseSquare.setCoordinate(0, new Point3f(-10f, 0.05f, -10f));
314 baseSquare.setCoordinate(1, new Point3f(-10f, 0.05f, 10f));
315 baseSquare.setCoordinate(2, new Point3f( 10f, 0.05f, 10f));
316 baseSquare.setCoordinate(3, new Point3f( 10f, 0.05f, -10f));
317 // and set anchor points for the texture
318 baseSquare.setTextureCoordinate(0, 0, new TexCoord2f(0.0f, 1.0f));
319 baseSquare.setTextureCoordinate(0, 1, new TexCoord2f(0.0f, 0.0f));
320 baseSquare.setTextureCoordinate(0, 2, new TexCoord2f(1.0f, 0.0f));
321 baseSquare.setTextureCoordinate(0, 3, new TexCoord2f(1.0f, 1.0f));
322 // Set appearance including image
323 Appearance baseAppearance = new Appearance();
324 Texture mapImage = new TextureLoader(_baseImage.getImage(), _frame).getTexture();
325 baseAppearance.setTexture(mapImage);
326 objTrans.addChild(new Shape3D(baseSquare, baseAppearance));
329 // Create model containing track information
330 _model = new ThreeDModel(_track);
331 _model.setAltitudeFactor(_altFactor);
335 TerrainHelper terrainHelper = new TerrainHelper(_terrainDefinition.getGridSize());
336 // See if there's a previously saved terrain track we can reuse
337 Track terrainTrack = TerrainCache.getTerrainTrack(_dataStatus, _terrainDefinition);
338 if (terrainTrack == null)
340 // Construct the terrain track according to these extents and the grid size
341 terrainTrack = terrainHelper.createGridTrack(_track);
342 // Get the altitudes from SRTM for all the points in the track
343 LookupSrtmFunction srtmLookup = (LookupSrtmFunction) FunctionLibrary.FUNCTION_LOOKUP_SRTM;
344 srtmLookup.begin(terrainTrack);
345 while (srtmLookup.isRunning())
348 Thread.sleep(750); // just polling in a wait loop isn't ideal but simple
350 catch (InterruptedException e) {}
354 terrainHelper.fixVoids(terrainTrack);
356 // Store this back in the cache, maybe we'll need it again
357 TerrainCache.storeTerrainTrack(terrainTrack, _dataStatus, _terrainDefinition);
359 // else System.out.println("Yay - reusing the cached track!");
361 // Give the terrain definition to the _model as well
362 _model.setTerrain(terrainTrack);
365 objTrans.addChild(createTerrain(_model, terrainHelper, _baseImage));
369 // No terrain, so just scale the model as it is
374 GeneralPath bevelPath = new GeneralPath();
375 bevelPath.moveTo(0.0f, 0.0f);
376 for (int i=0; i<91; i+= 5) {
377 bevelPath.lineTo((float) (0.1 - 0.1 * Math.cos(Math.toRadians(i))),
378 (float) (0.1 * Math.sin(Math.toRadians(i))));
380 for (int i=90; i>0; i-=5) {
381 bevelPath.lineTo((float) (0.3 + 0.1 * Math.cos(Math.toRadians(i))),
382 (float) (0.1 * Math.sin(Math.toRadians(i))));
384 Font3D compassFont = new Font3D(
385 new Font(CARDINALS_FONT, Font.PLAIN, 1),
386 new FontExtrusion(bevelPath));
387 objTrans.addChild(createCompassPoint(I18nManager.getText("cardinal.n"), new Point3f(0f, 0f, -10f), compassFont));
388 objTrans.addChild(createCompassPoint(I18nManager.getText("cardinal.s"), new Point3f(0f, 0f, 10f), compassFont));
389 objTrans.addChild(createCompassPoint(I18nManager.getText("cardinal.w"), new Point3f(-11f, 0f, 0f), compassFont));
390 objTrans.addChild(createCompassPoint(I18nManager.getText("cardinal.e"), new Point3f(10f, 0f, 0f), compassFont));
392 // Add points to model
393 objTrans.addChild(createDataPoints(_model));
396 BoundingSphere bounds = new BoundingSphere(new Point3d(0.0,0.0,0.0), 100.0);
397 AmbientLight aLgt = new AmbientLight(new Color3f(1.0f, 1.0f, 1.0f));
398 aLgt.setInfluencingBounds(bounds);
399 objTrans.addChild(aLgt);
401 PointLight pLgt = new PointLight(new Color3f(1.0f, 1.0f, 1.0f),
402 new Point3f(0f, 0f, 2f), new Point3f(0.25f, 0.05f, 0.0f) );
403 pLgt.setInfluencingBounds(bounds);
404 objTrans.addChild(pLgt);
406 PointLight pl2 = new PointLight(new Color3f(0.8f, 0.9f, 0.4f),
407 new Point3f(6f, 1f, 6f), new Point3f(0.2f, 0.1f, 0.05f) );
408 pl2.setInfluencingBounds(bounds);
409 objTrans.addChild(pl2);
411 PointLight pl3 = new PointLight(new Color3f(0.7f, 0.7f, 0.7f),
412 new Point3f(0.0f, 12f, -2f), new Point3f(0.1f, 0.1f, 0.0f) );
413 pl3.setInfluencingBounds(bounds);
414 objTrans.addChild(pl3);
416 // Have Java 3D perform optimizations on this scene graph.
424 * Create a text object for compass point, N S E or W
425 * @param text text to display
426 * @param locn position at which to display
427 * @param font 3d font to use
428 * @return Shape3D object
430 private Shape3D createCompassPoint(String inText, Point3f inLocn, Font3D inFont)
432 Text3D txt = new Text3D(inFont, inText, inLocn, Text3D.ALIGN_FIRST, Text3D.PATH_RIGHT);
433 Material mat = new Material(new Color3f(0.5f, 0.5f, 0.55f),
434 new Color3f(0.05f, 0.05f, 0.1f), new Color3f(0.3f, 0.4f, 0.5f),
435 new Color3f(0.4f, 0.5f, 0.7f), 70.0f);
436 mat.setLightingEnable(true);
437 Appearance app = new Appearance();
438 app.setMaterial(mat);
439 Shape3D shape = new Shape3D(txt, app);
445 * Make a Group of the data points to be added
446 * @param inModel model containing data
447 * @return Group object containing spheres, rods etc
449 private static Group createDataPoints(ThreeDModel inModel)
451 // Add points to model
452 Group group = new Group();
453 int numPoints = inModel.getNumPoints();
454 for (int i=0; i<numPoints; i++)
456 byte pointType = inModel.getPointType(i);
457 if (pointType == ThreeDModel.POINT_TYPE_WAYPOINT)
460 // Note that x, y and z are horiz, altitude, -vert
461 group.addChild(createWaypoint(new Point3d(
462 inModel.getScaledHorizValue(i) * MODEL_SCALE_FACTOR,
463 inModel.getScaledAltValue(i) * MODEL_SCALE_FACTOR,
464 -inModel.getScaledVertValue(i) * MODEL_SCALE_FACTOR)));
468 // Add colour-coded track point
469 // Note that x, y and z are horiz, altitude, -vert
470 group.addChild(createTrackpoint(new Point3d(
471 inModel.getScaledHorizValue(i) * MODEL_SCALE_FACTOR,
472 inModel.getScaledAltValue(i) * MODEL_SCALE_FACTOR,
473 -inModel.getScaledVertValue(i) * MODEL_SCALE_FACTOR), inModel.getPointHeightCode(i)));
481 * Create a waypoint sphere
482 * @param inPointPos position of point
483 * @return Group object containing sphere
485 private static Group createWaypoint(Point3d inPointPos)
487 Material mat = getWaypointMaterial();
488 // MAYBE: sort symbol scaling
489 Sphere dot = new Sphere(0.35f); // * symbolScaling / 100f);
490 return createBall(inPointPos, dot, mat);
495 * @return a new Material object to define waypoint colour / shine etc
497 private static Material getWaypointMaterial()
499 return new Material(new Color3f(0.1f, 0.1f, 0.4f),
500 new Color3f(0.0f, 0.0f, 0.0f), new Color3f(0.0f, 0.2f, 0.7f),
501 new Color3f(1.0f, 0.6f, 0.6f), 40.0f);
506 * @return track point object
508 private static Group createTrackpoint(Point3d inPointPos, byte inHeightCode)
510 Material mat = getTrackpointMaterial(inHeightCode);
511 // MAYBE: sort symbol scaling
512 Sphere dot = new Sphere(0.2f);
513 return createBall(inPointPos, dot, mat);
518 * @return Material object for track points with the appropriate colour for the height
520 private static Material getTrackpointMaterial(byte inHeightCode)
522 // create default material
523 Material mat = new Material(new Color3f(0.3f, 0.2f, 0.1f),
524 new Color3f(0.0f, 0.0f, 0.0f), new Color3f(0.0f, 0.6f, 0.0f),
525 new Color3f(1.0f, 0.6f, 0.6f), 70.0f);
526 // change colour according to height code
527 if (inHeightCode == 1) mat.setDiffuseColor(new Color3f(0.4f, 0.9f, 0.2f));
528 else if (inHeightCode == 2) mat.setDiffuseColor(new Color3f(0.7f, 0.8f, 0.2f));
529 else if (inHeightCode == 3) mat.setDiffuseColor(new Color3f(0.3f, 0.6f, 0.4f));
530 else if (inHeightCode == 4) mat.setDiffuseColor(new Color3f(0.1f, 0.9f, 0.9f));
531 else if (inHeightCode >= 5) mat.setDiffuseColor(new Color3f(1.0f, 1.0f, 1.0f));
538 * Create a ball at the given point
539 * @param inPosition scaled position of point
540 * @param inSphere sphere object
541 * @param inMaterial material object
542 * @return Group containing sphere
544 private static Group createBall(Point3d inPosition, Sphere inSphere, Material inMaterial)
546 Group group = new Group();
547 // Create ball and add to group
548 Transform3D ballShift = new Transform3D();
549 ballShift.setTranslation(new Vector3d(inPosition));
550 TransformGroup ballShiftTrans = new TransformGroup(ballShift);
551 inMaterial.setLightingEnable(true);
552 Appearance ballApp = new Appearance();
553 ballApp.setMaterial(inMaterial);
554 inSphere.setAppearance(ballApp);
555 ballShiftTrans.addChild(inSphere);
556 group.addChild(ballShiftTrans);
557 // Also create rod for ball to sit on
558 Cylinder rod = new Cylinder(0.1f, (float) inPosition.y);
559 Material rodMat = new Material(new Color3f(0.2f, 0.2f, 0.2f),
560 new Color3f(0.0f, 0.0f, 0.0f), new Color3f(0.2f, 0.2f, 0.2f),
561 new Color3f(0.05f, 0.05f, 0.05f), 0.4f);
562 rodMat.setLightingEnable(true);
563 Appearance rodApp = new Appearance();
564 rodApp.setMaterial(rodMat);
565 rod.setAppearance(rodApp);
566 Transform3D rodShift = new Transform3D();
567 rodShift.setTranslation(new Vector3d(inPosition.x, inPosition.y/2.0, inPosition.z));
568 TransformGroup rodShiftTrans = new TransformGroup(rodShift);
569 rodShiftTrans.addChild(rod);
570 group.addChild(rodShiftTrans);
576 * Create a java3d Shape for the terrain
577 * @param inModel threedModel
578 * @param inHelper terrain helper
579 * @param inBaseImage base image for shape, or null for no image
580 * @return Shape3D object
582 private static Shape3D createTerrain(ThreeDModel inModel, TerrainHelper inHelper, GroutedImage inBaseImage)
584 final int numNodes = inHelper.getGridSize();
585 final int RESULT_SIZE = numNodes * (numNodes * 2 - 2);
586 int[] stripData = inHelper.getStripLengths();
588 // Get the scaled terrainTrack coordinates (or just heights) from the model
589 final int nSquared = numNodes * numNodes;
590 Point3d[] rawPoints = new Point3d[nSquared];
591 for (int i=0; i<nSquared; i++)
593 double height = inModel.getScaledTerrainValue(i) * MODEL_SCALE_FACTOR;
594 rawPoints[i] = new Point3d(inModel.getScaledTerrainHorizValue(i) * MODEL_SCALE_FACTOR,
595 Math.max(height, 0.05), // make sure it's above the box
596 -inModel.getScaledTerrainVertValue(i) * MODEL_SCALE_FACTOR);
599 GeometryInfo gi = new GeometryInfo(GeometryInfo.TRIANGLE_STRIP_ARRAY);
600 gi.setCoordinates(inHelper.getTerrainCoordinates(rawPoints));
601 gi.setStripCounts(stripData);
603 Appearance tAppearance = new Appearance();
604 if (inBaseImage != null)
606 gi.setTextureCoordinateParams(1, 2); // one coord set of two dimensions
607 gi.setTextureCoordinates(0, inHelper.getTextureCoordinates());
608 Texture mapImage = new TextureLoader(inBaseImage.getImage()).getTexture();
609 tAppearance.setTexture(mapImage);
610 TextureAttributes texAttr = new TextureAttributes();
611 texAttr.setTextureMode(TextureAttributes.MODULATE);
612 tAppearance.setTextureAttributes(texAttr);
616 Color3f[] colours = new Color3f[RESULT_SIZE];
617 Color3f terrainColour = new Color3f(0.1f, 0.2f, 0.2f);
618 for (int i=0; i<RESULT_SIZE; i++) {colours[i] = terrainColour;}
619 gi.setColors(colours);
621 new NormalGenerator().generateNormals(gi);
622 Material terrnMat = new Material(new Color3f(0.4f, 0.4f, 0.4f), // ambient colour
623 new Color3f(0f, 0f, 0f), // emissive (none)
624 new Color3f(0.8f, 0.8f, 0.8f), // diffuse
625 new Color3f(0.2f, 0.2f, 0.2f), //specular
627 tAppearance.setMaterial(terrnMat);
628 return new Shape3D(gi.getGeometryArray(), tAppearance);
632 * Calculate the angles and call them back to the app
633 * @param inFunction function to call for export
635 private void callbackRender(Export3dFunction inFunction)
637 Transform3D trans3d = new Transform3D();
638 _orbit.getViewingPlatform().getViewPlatformTransform().getTransform(trans3d);
639 Matrix3d matrix = new Matrix3d();
641 Point3d point = new Point3d(0.0, 0.0, 1.0);
642 matrix.transform(point);
643 // Set up initial rotations
644 Transform3D firstTran = new Transform3D();
645 firstTran.rotY(Math.toRadians(-INITIAL_Y_ROTATION));
646 Transform3D secondTran = new Transform3D();
647 secondTran.rotX(Math.toRadians(-INITIAL_X_ROTATION));
648 // Apply inverse rotations in reverse order to the test point
649 Point3d result = new Point3d();
650 secondTran.transform(point, result);
651 firstTran.transform(result);
653 // Give the settings to the rendering function
654 inFunction.setCameraCoordinates(result.x, result.y, result.z);
655 inFunction.setAltitudeExaggeration(_altFactor);
656 inFunction.setTerrainDefinition(_terrainDefinition);
657 inFunction.setImageDefinition(_imageDefinition);