/* ========================
* JSynoptic : a free Synoptic editor
* ========================
*
* Project Info: http://jsynoptic.sourceforge.net/index.html
*
* This program is free software; you can redistribute it and/or modify it under the terms
* of the GNU Lesser General Public License as published by the Free Software Foundation;
* either version 2.1 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with this
* program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307, USA.
*
* (C) Copyright 2001-2004, by :
* Corporate:
* Astrium SAS
* Individual:
* Claude Cazenave
*
* $Id: SceneGraphModelXith3D.java,v 1.4 2005/10/17 15:15:14 ogor Exp $
*
* Changes
* -------
* 14-Dec-2003 : Creation date (CC);
*
*/
package syn3d.ui.xith3d;
import javax.swing.JFrame;
import javax.vecmath.Color3f;
import syn3d.nodes.RootNode;
import syn3d.ui.SceneGraphModel;
import syn3d.ui.SceneGraphTree;
import com.xith3d.scenegraph.AmbientLight;
import com.xith3d.scenegraph.Appearance;
import com.xith3d.scenegraph.BranchGroup;
import com.xith3d.scenegraph.Leaf;
import com.xith3d.scenegraph.Locale;
import com.xith3d.scenegraph.PolygonAttributes;
import com.xith3d.scenegraph.Shape3D;
import com.xith3d.scenegraph.TransformGroup;
import com.xith3d.scenegraph.VirtualUniverse;
import com.xith3d.test.TestUtils;
/**
* Class description ...
*
* @author Claude CAZENAVE
*
*/
public class SceneGraphModelXith3D extends SceneGraphModel {
public SceneGraphModelXith3D(){
rootNode = new RootNode();
}
/* (non-Javadoc)
* @see javax.swing.tree.TreeModel#isLeaf(java.lang.Object)
*/
public boolean isLeaf3D(Object node) {
return node instanceof Leaf;
}
/**
* For testing purpose
* @param args
*/
public static void main(String[] args) {
JFrame f=new JFrame("Universes");
VirtualUniverse v=new VirtualUniverse();
Locale l=new Locale();
l.setName("loc1");
v.addLocale(l);
BranchGroup bg=new BranchGroup();
bg.setName("bg1");
l.addBranchGraph(bg);
Appearance a = new Appearance();
a.setPolygonAttributes(new PolygonAttributes(PolygonAttributes.POLYGON_LINE, PolygonAttributes.CULL_NONE, 0));
Shape3D sph = new Shape3D(TestUtils.createSphere(1.0f, 20), a);
sph.setName("s1");
TransformGroup sphereTrans = new TransformGroup();
sphereTrans.addChild(sph);
sphereTrans.setName("t1");
bg.addChild(sphereTrans);
AmbientLight aLgt = new AmbientLight(new Color3f(0.2f, 0.2f, 0.2f));
aLgt.setName("l1");
bg.addChild(aLgt);
VirtualUniverse v2=new VirtualUniverse();
Locale l2=new Locale();
l2.setName("loc2");
v2.addLocale(l2);
BranchGroup bg2=new BranchGroup();
bg2.setName("bg2");
l2.addBranchGraph(bg2);
SceneGraphModel tm=new SceneGraphModelXith3D();
// TODO: use factories and test them by the same occasion
//tm.insert(null, v, "v1", 0);
//tm.insert(null, v2, "v2", 0);
SceneGraphTree t=new SceneGraphTree(tm);
f.getContentPane().add(t);
f.pack();
f.show();
}
}