1 /*****************************************************************************
2 * Virtual Mockup for Machine Vision
3 * Copyright (C) 2001-2003 Fabio R. de Miranda, João E. Kogler Jr.,
4 * Carlos S. Santos.
5 * Virtual Mockup for Machine Vision Project funded by SENAC-SP
6 *
7 * Permission is granted to redistribute and/or modify this
8 * software under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * This software is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License (http://www.gnu.org/copyleft/lesser.html)
16 * for more details.
17 *
18 *****************************************************************************/
19
20 package camera3d;
21
22 import javax.vecmath.*;
23 import java.awt.GraphicsEnvironment;
24 import java.awt.Frame;
25 import javax.media.j3d.*;
26 //import com.sun.j3d.utils.*;
27 import com.sun.j3d.utils.universe.*;
28 import com.sun.j3d.loaders.vrml97.*;
29 import com.sun.j3d.loaders.*;
30 import java.io.*;
31 import com.sun.j3d.utils.behaviors.keyboard.*;
32 import java.util.Enumeration;
33 import java.net.URL;
34 import javax.media.j3d.J3DGraphics2D;
35 import java.awt.Color;
36 import java.text.NumberFormat;
37 import javax.swing.ImageIcon;
38
39 //import com.tornadolabs.j3dtree.*;
40
41
42 /***
43 * A component that provides some basic editing/camera/light
44 * functionality.
45 *
46 * @author Fábio Roberto de Miranda
47 * @version 1.0
48 */
49 class BasicScene extends Frame {
50
51 private J3DGraphics2D graphics2D;
52
53 private VirtualUniverse virtualUniverse;
54 private SaverCanvas3D canvas3d;
55 private Locale locale;
56 private View view;
57 private ViewPlatform viewPlatform;
58 static PhysicalBody physicalBody = null;
59 static PhysicalEnvironment physicalEnvironment = null;
60
61 private Color green = new Color(0,255,0);
62
63 private boolean cursor3DVisible = true;
64 private boolean helpingGridVisible = true;
65 private Cursor3D cursor3D;
66
67 private BranchGroup contentBG;
68 private BranchGroup lightingBG;
69 private BranchGroup viewBG;
70 private BranchGroup cursorBG;
71 private BranchGroup gridBG;
72 private BranchGroup bgTG;
73
74 private HelpingGrid helpingGrid;
75
76 private TransformGroup cursorTG;
77 private TransformGroup contentTG;
78 private TransformGroup vpTrans;
79
80 private Transform3D helpingGridT3D = new Transform3D();
81
82 private BranchGroup[] contentBranchGroups; // number of contentTG's children
83 final int NUMBER_OF_CONTENT_GROUPS = 5; // size contentGroups array
84 final int MAX_CONTENT_GROUPS = 1; // If adding one content group will rise number
85 // of content groups above this, one is unloaded
86 int contentGroupCount = 0;
87
88 private KeyNavigatorBehavior keyNavBeh;
89
90 private Transform3D tempT3D = new Transform3D();
91 private Transform3D tempRotT3D = new Transform3D();
92 private Transform3D tempTransT3D = new Transform3D();
93 private Transform3D tempScaleT3D = new Transform3D();
94 private Transform3D tempRotT3D2 = new Transform3D();
95 // Transform3D originalContentT3D = new Transform3D();
96
97 private Matrix3d tempRot = new Matrix3d();
98 private Vector3d tempTrans = new Vector3d();
99 private Vector3d tempVec3d = new Vector3d();
100
101 private Transform3D backupVPTransT3D = new Transform3D();
102
103 private Background background;
104 private StringBuffer strBuffer = new StringBuffer(60);
105 double contentScale = 1.0;
106
107 private String rotString;
108 private String transString;
109
110 private NumberFormat nFormat = NumberFormat.getInstance();
111
112 // Java3dTree j3dTree = null;
113
114
115 public BasicScene() {
116
117 // j3dTree = new Java3dTree();
118
119 virtualUniverse = new VirtualUniverse();
120
121 // Getting a valid GraphicsConfiguration (good for jdk 1.2)
122 GraphicsConfigTemplate3D template = new GraphicsConfigTemplate3D();
123
124 canvas3d = new SaverCanvas3D(GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getBestConfiguration( template ));
125 this.add(canvas3d);
126 this.setSize(256,256);
127 locale = new Locale(virtualUniverse);
128
129 view = new View();
130 view.setBackClipDistance(100.0);
131 view.setFrontClipDistance(0.1);
132 viewPlatform = new ViewPlatform();
133 viewBG = new BranchGroup();
134 lightingBG = new BranchGroup();
135 contentBG = new BranchGroup();
136 contentTG = new TransformGroup();
137 vpTrans = new TransformGroup();
138 tempT3D.setIdentity();
139 tempVec3d.x = 0.0;
140 tempVec3d.y = 0.0;
141 tempVec3d.z = 0.0;
142 tempT3D.setTranslation(tempVec3d);
143 vpTrans.setTransform(tempT3D);
144 tempT3D.setIdentity();
145 vpTrans.addChild(viewPlatform);
146
147 viewBG.addChild(vpTrans);
148
149
150 view.addCanvas3D(canvas3d);
151 view.attachViewPlatform(viewPlatform);
152
153 if (physicalBody == null){
154 physicalBody = new PhysicalBody();
155 }
156
157 if (physicalEnvironment == null){
158 physicalEnvironment = new PhysicalEnvironment();
159 }
160
161 contentBranchGroups = new BranchGroup[NUMBER_OF_CONTENT_GROUPS];
162
163 view.setPhysicalBody(physicalBody);
164 view.setPhysicalEnvironment(physicalEnvironment);
165 lightingBG.setCapability(BranchGroup.ALLOW_CHILDREN_WRITE);
166 lightingBG.setCapability(BranchGroup.ALLOW_CHILDREN_READ);
167
168 contentBG.setCapability(BranchGroup.ALLOW_CHILDREN_WRITE);
169 contentBG.setCapability(BranchGroup.ALLOW_CHILDREN_READ);
170 contentBG.setCapability(BranchGroup.ALLOW_CHILDREN_EXTEND);
171
172 contentTG.setCapability(TransformGroup.ALLOW_CHILDREN_WRITE);
173 contentTG.setCapability(TransformGroup.ALLOW_CHILDREN_READ);
174 contentTG.setCapability(TransformGroup.ALLOW_CHILDREN_EXTEND);
175 contentTG.setCapability(TransformGroup.ALLOW_TRANSFORM_READ);
176 contentTG.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
177
178 contentTG.setCapability(Node.ENABLE_PICK_REPORTING);
179 contentTG.setCapability(Node.ALLOW_PICKABLE_READ);
180 contentTG.setCapability(Node.ALLOW_PICKABLE_WRITE);
181 contentTG.setCapability(Node.ALLOW_BOUNDS_READ);
182 contentTG.setCapability(Node.ALLOW_BOUNDS_WRITE);
183
184
185 vpTrans.setCapability(TransformGroup.ALLOW_TRANSFORM_READ);
186 vpTrans.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
187
188 contentBG.addChild(contentTG);
189 keyNavBeh = new KeyNavigatorBehavior(vpTrans);
190 KeyNavigatorBehavior keyNavBeh = new KeyNavigatorBehavior(vpTrans);
191 keyNavBeh.setSchedulingBounds(new BoundingSphere(new Point3d(),1000));
192 viewBG.addChild(keyNavBeh);
193
194 cursor3D = new Cursor3D();
195 cursorBG = new BranchGroup();
196 cursorTG = new TransformGroup();
197
198 helpingGridT3D.setIdentity();
199 tempVec3d.set(-50, 0, 50);
200 helpingGridT3D.setTranslation(tempVec3d);
201 helpingGrid = new HelpingGrid(helpingGridT3D);
202 gridBG = new BranchGroup();
203 gridBG.setCapability(BranchGroup.ALLOW_DETACH);
204 gridBG.addChild(helpingGrid);
205
206 cursorTG.setCapability(TransformGroup.ALLOW_CHILDREN_READ);
207 cursorTG.setCapability(TransformGroup.ALLOW_CHILDREN_WRITE);
208 cursorTG.setCapability(TransformGroup.ALLOW_TRANSFORM_READ);
209 cursorTG.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
210 cursorBG.addChild(cursorTG);
211 cursorBG.setCapability(BranchGroup.ALLOW_DETACH);
212 cursorTG.addChild(cursor3D);
213
214 bgTG = new BranchGroup();
215 background = new Background(1.0f, 1.0f, 1.0f);
216 background.setCapability(Background.ALLOW_COLOR_READ);
217 background.setCapability(Background.ALLOW_COLOR_WRITE);
218 background.setApplicationBounds(new BoundingSphere(new Point3d(0.0,0.0,0.0), 1000));
219
220 bgTG.addChild(background);
221
222 // j3dTree.recursiveApplyCapability(contentBG);
223
224 locale.addBranchGraph(lightingBG);
225 locale.addBranchGraph(contentBG);
226 locale.addBranchGraph(viewBG);
227 locale.addBranchGraph(cursorBG);
228 locale.addBranchGraph(gridBG);
229 locale.addBranchGraph(bgTG);
230
231 this.setVisible(true);
232
233 // j3dTree.updateNodes(virtualUniverse);
234
235 // canvas3d.enableMessage("TESTE TESTE TESTE");
236 nFormat.setMaximumFractionDigits(2);
237
238 //Sets up icon
239 this.setIconImage((new ImageIcon("senac2.gif")).getImage());
240 }
241
242 public void loadVRMLScene(String filename){
243 this.setBackgroundColor(1.0f,1.0f,1.0f);
244 /* We'll import a VRML Scene from a file, Scene will hold it*/
245 Scene scene = null;
246 VrmlLoader vrmlLoader = new VrmlLoader();
247 debug("Base path before:"+vrmlLoader.getBasePath());
248 vrmlLoader.setBasePath(null);
249 vrmlLoader.setBaseUrl(null);
250 debug("Base path after:"+vrmlLoader.getBasePath());
251 debug("File to load:"+filename);
252 int temp = contentGroupCount + 1;
253
254 Enumeration members = contentTG.getAllChildren();
255
256 int enumCount = 0;
257 while (members.hasMoreElements()){
258 debug("Count: "+enumCount);
259 Node tempNode = (Node)members.nextElement();
260 debug("Element:");
261 debug(tempNode.toString());
262 enumCount++;
263 tempNode = null;
264 }
265
266
267 if (temp > MAX_CONTENT_GROUPS){
268 debug("Attempting to get child"+(contentGroupCount-1));
269 Node tempNode = contentTG.getChild(contentGroupCount-1);
270 debug("Node's User Data:");
271 debug(tempNode.getUserData().toString());
272 tempNode = null;
273
274 debug("Attempting to remove child"+(contentGroupCount-1));
275 contentTG.removeChild(contentGroupCount-1);
276 contentGroupCount--;
277 }
278
279
280 canvas3d.enableMessage("Please wait...");
281 /* Read the file */
282 try {
283 scene = vrmlLoader.load(new URL("file:///"+filename));
284 } catch (IOException e){
285 canvas3d.enableMessage("Unable to parse file.");
286 System.out.println("VRML file not found.");
287 }
288 BranchGroup tempGroup = scene.getSceneGroup();
289
290 // Set necessary capabilities
291 tempGroup.setCapability(BranchGroup.ALLOW_DETACH);
292 tempGroup.setCapability(Node.ENABLE_PICK_REPORTING);
293 tempGroup.setCapability(Node.ALLOW_PICKABLE_READ);
294 tempGroup.setCapability(Node.ALLOW_PICKABLE_WRITE);
295 tempGroup.setCapability(Node.ALLOW_BOUNDS_READ);
296 tempGroup.setCapability(Node.ALLOW_BOUNDS_WRITE
297 );
298
299
300 tempGroup.setUserData("Teste");
301
302 debug("Attempting to insert child at "+contentGroupCount);
303 contentTG.insertChild(tempGroup, contentGroupCount);
304
305
306 contentGroupCount++;
307 debug("ContentGroupCount now is "+contentGroupCount);
308 canvas3d.disableMessage();
309 this.setBackgroundColor(0.0f,0.0f,0.0f);
310 }
311
312 // Iterates the scene graph
313 public void traverse(){
314
315 }
316
317 // Turns on/off the 3D cursor seen at the scene (like Quake's crosshair in 3D)
318 public void set3DCursor(boolean status){
319 }
320
321 // Moves 3D cursor to the specified position
322 public void move3DCursor(double x, double y, double z){
323 }
324
325 // Gets current Transform3D above 3D cursor (it's useful to store this data for undo operations)
326 public Transform3D get3DCursorPosition(){
327 return new Transform3D();
328 }
329
330 public void captureScreenToJPGFile(String filename){
331 }
332
333
334 // Used in development for debugging purposes
335 public void debug(String s){
336 System.out.println(s);
337 }
338
339
340 // Moves the active camera, in early development stages, it will be
341 // the scene-invariant viewplatform declared in this source code (viewPlatform)
342 public void translateCamera(double x, double y, double z){
343 transFrameTitle(x,y,z);
344 canvas3d.disableMessage();
345 vpTrans.getTransform(tempT3D);
346 vpTrans.getTransform(backupVPTransT3D);
347 tempT3D.get(tempRot, tempTrans);
348 tempRotT3D.setIdentity();
349 tempRotT3D.setRotation(tempRot);
350 tempT3D.setIdentity();
351
352 tempVec3d.x = x;
353 tempVec3d.y = y;
354 tempVec3d.z = z;
355
356 tempT3D.setTranslation(tempVec3d);
357 tempT3D.mul(tempRotT3D);
358 try {
359 tempT3D.setScale(1.00000);
360 vpTrans.setTransform(tempT3D);
361 } catch (BadTransformException bt) {
362 strBuffer.append(bt.getMessage());
363 strBuffer.append("\n\rBefore {");
364 strBuffer.append(backupVPTransT3D.toString());
365 strBuffer.append("}\nAfter:{");
366 strBuffer.append(tempT3D.toString());
367 strBuffer.append("}");
368 canvas3d.enableMessage(strBuffer.toString());
369 debug(strBuffer.toString());
370 vpTrans.setTransform(backupVPTransT3D);
371 }
372 }
373
374 //Moves the named camera (use get/set userdata to read/change this name)
375 public void translateCamera(String name, double x, double y, double z){
376
377 }
378
379 public void dumpCameraCoordinates(){
380 vpTrans.getTransform(tempT3D);
381 tempT3D.get(tempRot, tempTrans);
382 msg("Printing camera coordinates:");
383 msg("x:"+tempTrans.x);
384 msg("y:"+tempTrans.y);
385 msg("z:"+tempTrans.z);
386 msg("Printing rotation matrix:");
387 msg("["+tempRot.m00+"]["+tempRot.m01 + "][" + tempRot.m02+"]");
388 msg("["+tempRot.m10+"]["+tempRot.m11 + "][" + tempRot.m12+"]");
389 msg("["+tempRot.m20+"]["+tempRot.m21 + "][" + tempRot.m22+"]");
390 }
391
392 // Intended to move camera in local coordinates
393 public void translateCameraLocal(double x, double y, double z){
394 vpTrans.getTransform(tempT3D);
395 tempVec3d.x = x;
396 tempVec3d.y = y;
397 tempVec3d.z = z;
398
399 tempTransT3D.setIdentity();
400 tempTransT3D.setTranslation(tempVec3d);
401
402 tempT3D.mul(tempTransT3D);
403
404 vpTrans.setTransform(tempT3D);
405 }
406
407 /*
408 public void rotateEuler(double x_angle, double y_angle, double z_angle){
409 // Converts degree input to radians
410 canvas3d.disableMessage();
411
412 double x = Math.toRadians(x_angle);
413 double y = Math.toRadians(y_angle);
414 double z = Math.toRadians(z_angle);
415
416 double s1 = Math.sin(x);
417 double c1 = Math.cos(x);
418 double s2 = Math.sin(y);
419 double c2 = Math.cos(y);
420 double s3 = Math.sin(z);
421 double c3 = Math.cos(z);
422
423
424 vpTrans.getTransform(tempT3D);
425 vpTrans.getTransform(backupVPTransT3D);
426 tempRot.setIdentity();
427 tempRot.m00 = c2*c3;
428 tempRot.m01 = c2*s3;
429 tempRot.m02 = -s2;
430 tempRot.m10 = s1*s2*c3-c1*s3;
431 tempRot.m11 = s1*s2*s3+c1*c3;
432 tempRot.m12 = s1*c2;
433 tempRot.m20 = c1*s2*c3 - s1*s3;
434 tempRot.m21 = c1*s2*s3 - s1*c3 ;
435 tempRot.m22 = c1*c2;
436
437 tempRotT3D.setRotation(tempRot);
438
439 tempT3D.get(tempTrans);
440 tempT3D.setIdentity();
441 tempT3D.setTranslation(tempTrans);
442 tempT3D.mul(tempRotT3D);
443 try {
444 tempT3D.setScale(1.00000);
445 vpTrans.setTransform(tempT3D);
446 }catch (BadTransformException bt){
447 strBuffer.append(bt.getMessage());
448 strBuffer.append("\n\rBefore {");
449 strBuffer.append(backupVPTransT3D.toString());
450 strBuffer.append("}\nAfter:{");
451 strBuffer.append(tempT3D.toString());
452 strBuffer.append("}");
453 canvas3d.enableMessage(strBuffer.toString());
454 debug(strBuffer.toString());
455 vpTrans.setTransform(backupVPTransT3D);
456 }
457 }
458 */
459
460 public void rotateEuler(double x_angle, double y_angle, double z_angle){
461 rotFrameTitle(x_angle,y_angle,z_angle);
462 // Converts degree input to radians
463 canvas3d.disableMessage();
464
465 double x = Math.toRadians(x_angle);
466 double y = Math.toRadians(y_angle);
467 double z = Math.toRadians(z_angle);
468
469 vpTrans.getTransform(tempT3D);
470 vpTrans.getTransform(backupVPTransT3D);
471
472 tempT3D.get(tempRot, tempTrans);
473
474 tempRotT3D.setIdentity();
475
476 tempRotT3D2.setIdentity();
477 tempRotT3D2.rotX(x);
478 tempRotT3D.mul(tempRotT3D2);
479
480 tempRotT3D2.setIdentity();
481 tempRotT3D2.rotY(y);
482 tempRotT3D.mul(tempRotT3D2);
483
484 tempRotT3D2.setIdentity();
485 tempRotT3D2.rotZ(z);
486 tempRotT3D.mul(tempRotT3D2);
487
488
489 tempT3D.setIdentity();
490 tempT3D.setTranslation(tempTrans);
491 tempT3D.mul(tempRotT3D);
492 try {
493 tempT3D.setScale(1.00000);
494 vpTrans.setTransform(tempT3D);
495 }catch (BadTransformException bt){
496 strBuffer.append(bt.getMessage());
497 strBuffer.append("\n\rBefore {");
498 strBuffer.append(backupVPTransT3D.toString());
499 strBuffer.append("}\nAfter:{");
500 strBuffer.append(tempT3D.toString());
501 strBuffer.append("}");
502 canvas3d.enableMessage(strBuffer.toString());
503 debug(strBuffer.toString());
504 vpTrans.setTransform(backupVPTransT3D);
505 }
506 }
507
508
509 public void rotateEulerLocal(double x_angle, double y_angle, double z_angle){
510 // Converts degree input to radians
511 double x = Math.toRadians(x_angle);
512 double y = Math.toRadians(y_angle);
513 double z = Math.toRadians(z_angle);
514
515 double s1 = Math.sin(x);
516 double c1 = Math.cos(x);
517 double s2 = Math.sin(y);
518 double c2 = Math.cos(y);
519 double s3 = Math.sin(z);
520 double c3 = Math.cos(z);
521
522
523 vpTrans.getTransform(tempT3D);
524 vpTrans.getTransform(backupVPTransT3D);
525 tempRot.setIdentity();
526 tempRot.m00 = c2*c3;
527 tempRot.m01 = c2*s3;
528 tempRot.m02 = -s2;
529 tempRot.m10 = s1*s2*c3-c1*s3;
530 tempRot.m11 = s1*s2*s3+c1*c3;
531 tempRot.m12 = s1*c2;
532 tempRot.m20 = c1*s2*c3 - s1*s3;
533 tempRot.m21 = c1*s2*s3 - s1*c3 ;
534 tempRot.m22 = c1*c2;
535
536 tempRotT3D.setRotation(tempRot);
537
538 // tempT3D.get(tempRot, tempTrans);
539 // tempT3D.setIdentity();
540 // tempT3D.setTranslation(tempTrans);
541 tempT3D.mul(tempRotT3D);
542
543 try {
544 tempT3D.setScale(1.00000);
545 vpTrans.setTransform(tempT3D);
546 } catch (BadTransformException btE){
547 strBuffer.append(btE.getMessage());
548 strBuffer.append("\n\rBefore {");
549 strBuffer.append(backupVPTransT3D.toString());
550 strBuffer.append("}\nAfter:{");
551 strBuffer.append(tempT3D.toString());
552 strBuffer.append("}");
553 canvas3d.enableMessage(strBuffer.toString());
554 debug(strBuffer.toString());
555 vpTrans.setTransform(backupVPTransT3D);
556 }
557 }
558
559
560
561 /***
562 * String-printing for runtime, not only debugging
563 */
564 public void msg(String s){
565 System.out.println(s);
566 }
567
568
569 /***
570 * Apply uniform scale factor to content branchGraph
571 */
572 public void setContentScale(double scale){
573 this.contentScale = scale;
574 tempT3D.setIdentity();
575 tempScaleT3D.setIdentity();
576 tempScaleT3D.setScale(scale);
577 tempT3D.mul(tempScaleT3D);
578 contentTG.setTransform(tempT3D);
579 }
580
581 public void setCursor3DScale(double scale){
582 cursorTG.getTransform(tempT3D);
583 tempT3D.get(tempTrans);
584 tempTransT3D.setIdentity();
585 tempTransT3D.setTranslation(tempTrans);
586 tempT3D.setIdentity();
587 tempT3D.setScale(scale);
588 tempTransT3D.mul(tempT3D);
589 cursorTG.setTransform(tempTransT3D);
590 }
591
592 public void translateCursor3D(double x, double y, double z){
593 cursorTG.getTransform(tempT3D);
594 tempT3D.get(tempRot, tempTrans);
595 tempRotT3D.setIdentity();
596 tempRotT3D.setRotation(tempRot);
597 tempT3D.setIdentity();
598
599 tempVec3d.x = x;
600 tempVec3d.y = y;
601 tempVec3d.z = z;
602
603 tempT3D.setTranslation(tempVec3d);
604 tempT3D.mul(tempRotT3D);
605
606 cursorTG.setTransform(tempT3D);
607 }
608
609 public double getCursor3DX(){
610 cursorTG.getTransform(tempT3D);
611 tempT3D.get(tempTrans);
612 return tempTrans.x;
613 }
614 public double getCursor3DY(){
615 cursorTG.getTransform(tempT3D);
616 tempT3D.get(tempTrans);
617 return tempTrans.y;
618 }
619 public double getCursor3DZ(){
620 cursorTG.getTransform(tempT3D);
621 tempT3D.get(tempTrans);
622 return tempTrans.z;
623 }
624
625 public void setCursorWidth(float width){
626 cursor3D.setLineWidth(width);
627 }
628
629 public void toggleCursor3D(){
630 if (cursor3DVisible){
631 // By doing this we will assume that cursorBG will contain,
632 // at most, one child, and it will have to be cursorTG when we
633 // come acroos this code
634 locale.removeBranchGraph(cursorBG);
635 cursor3DVisible = false;
636 } else {
637 locale.addBranchGraph(cursorBG);
638 cursor3DVisible = true;
639 }
640 }
641
642 public void toggleHelpingGrid(){
643 if (helpingGridVisible){
644 locale.removeBranchGraph(gridBG);
645 helpingGridVisible = false;
646 } else {
647 locale.addBranchGraph(gridBG);
648 helpingGridVisible = true;
649 }
650 }
651
652
653 public void setBackgroundColor(float r, float g, float b){
654 background.setColor(r,g,b);
655 }
656
657 public void saveJPGFile(String filename){
658 canvas3d.saveFrame(filename);
659 }
660
661 protected void rotFrameTitle(double x, double y, double z){
662 rotString = "Rot ("+nFormat.format(x)+","+nFormat.format(y)+","+nFormat.format(z)+")";
663 this.setTitle(transString + rotString);
664 }
665
666 protected void transFrameTitle(double x, double y, double z){
667 transString = "Trans ("+nFormat.format(x)+","+nFormat.format(y)+","+nFormat.format(z)+")";
668 this.setTitle(transString+rotString);
669 }
670
671 public void dispose(){
672 super.dispose();
673 System.exit(0);
674 }
675
676 public void exit(){
677 System.exit(0);
678 }
679
680 public BranchGroup getContentBG(){
681 return this.contentBG;
682 }
683
684 /*
685 * Traces a ray from center of view to the front and detects the first object
686 * at the front of the camera. Rotations will now be performed around it
687 */
688 public void setExamineMode(){
689 //traces pickray
690
691 //retrieves scenegraph path
692
693 //finds first object intersected
694
695 //computes center of mass of first object
696
697 }
698
699 public Canvas3D getCanvas3D(){
700 return this.canvas3d;
701 }
702
703 public View getView(){
704 return this.view;
705 }
706
707
708 }
This page was automatically generated by Maven