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.test;
21
22 import camera3d.test.NodeTester;
23 import javax.media.j3d.*;
24 import com.sun.j3d.loaders.Scene;
25 import com.sun.j3d.loaders.vrml97.VrmlLoader;
26 import com.sun.j3d.loaders.vrml97.VrmlScene;
27 import java.util.Hashtable;
28 import javax.vecmath.*;
29 import java.io.*;
30
31 class BirdTest {
32
33 private Scene scene;
34 private VrmlLoader vrmlLoader;
35 private Hashtable hashtable;
36
37 private PointLight pLight = new PointLight(new Color3f(.2f, .2f, .2f), new Point3f(-5.f, 5.f, 5.f), new Point3f(0.1f,0.f,0.f));
38 private TransformGroup centerTG;
39 private TransformGroup baseTG;
40 private TransformGroup cilindroTG;
41
42 private NodeTester tester;
43
44 private Alpha alpha = new Alpha(-1, //loopcount
45 Alpha.INCREASING_ENABLE|Alpha.DECREASING_ENABLE,//mode
46 100, // triggertime
47 100, // phaseDelay Duration
48 800, // increasing alpha
49 200, // increasing alpha ramo
50 100, // alpha at one
51 800, // decreasing alpha
52 200, // decreasing alpha ramp
53 400 // alpha at zero
54 );
55
56
57 private BoundingSphere bounds = new BoundingSphere(new Point3d(), 300);
58
59 public BirdTest(){
60
61 scene = null;
62 vrmlLoader = new VrmlLoader();
63 System.out.println("Opening VRML");
64 /* Read the file */
65 try {
66 System.out.println("Parsing VRML file");
67 scene = vrmlLoader.load("WoodySmall.WRL");
68 System.out.println("VRML file parsed");
69 } catch (IOException e){
70 System.out.println("VRML file not found.");
71 }
72 /* Get a hashtable with all the named objects */
73 hashtable = scene.getNamedObjects();
74
75 pLight.setInfluencingBounds(bounds);
76
77 cilindroTG = (TransformGroup)hashtable.get("Cilindro");
78 centerTG = (TransformGroup)hashtable.get("Centro");
79 centerTG.setCapability(TransformGroup.ALLOW_TRANSFORM_READ);
80 centerTG.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
81
82 baseTG = (TransformGroup)hashtable.get("Base");
83
84 Transform3D tempT3D = new Transform3D();
85 tempT3D.rotY(Math.PI/2);
86
87 RotationInterpolator rot = new RotationInterpolator(alpha, centerTG, tempT3D, 0.f, -(float)Math.PI/3);
88 //RotationInterpolator rot = new RotationInterpolator(alpha, centerTG);
89 rot.setSchedulingBounds(bounds);
90
91 tester = new NodeTester();
92 tester.getFrame().setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
93
94 tester.add(rot);
95 tester.add(baseTG);
96 tester.add(cilindroTG);
97 tester.add(pLight);
98 }
99
100 public static void main(String[] args) {
101 BirdTest bird = new BirdTest();
102 }
103 }
This page was automatically generated by Maven