001: /*
002: * $RCSfile: Main.java,v $
003: *
004: * Copyright (c) 2007 Sun Microsystems, Inc. All rights reserved.
005: *
006: * Redistribution and use in source and binary forms, with or without
007: * modification, are permitted provided that the following conditions
008: * are met:
009: *
010: * - Redistribution of source code must retain the above copyright
011: * notice, this list of conditions and the following disclaimer.
012: *
013: * - Redistribution in binary form must reproduce the above copyright
014: * notice, this list of conditions and the following disclaimer in
015: * the documentation and/or other materials provided with the
016: * distribution.
017: *
018: * Neither the name of Sun Microsystems, Inc. or the names of
019: * contributors may be used to endorse or promote products derived
020: * from this software without specific prior written permission.
021: *
022: * This software is provided "AS IS," without a warranty of any
023: * kind. ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND
024: * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY,
025: * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY
026: * EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL
027: * NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF
028: * USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS
029: * DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR
030: * ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL,
031: * CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED AND
032: * REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF OR
033: * INABILITY TO USE THIS SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE
034: * POSSIBILITY OF SUCH DAMAGES.
035: *
036: * You acknowledge that this software is not designed, licensed or
037: * intended for use in the design, construction, operation or
038: * maintenance of any nuclear facility.
039: *
040: * $Revision: 1.1 $
041: * $Date: 2007/08/28 16:44:33 $
042: * $State: Exp $
043: */
044:
045: package org.jdesktop.j3d.loaders.collada.test;
046:
047: import java.io.File;
048: import java.util.List;
049: import java.util.logging.Logger;
050: import javax.media.j3d.BranchGroup;
051: import javax.media.j3d.Node;
052: import javax.xml.bind.JAXBContext;
053: import javax.xml.bind.JAXBException;
054: import javax.xml.bind.Unmarshaller;
055: import org.collada.colladaschema.Asset;
056: import org.collada.colladaschema.COLLADA;
057: import org.collada.colladaschema.Extra;
058: import org.collada.colladaschema.InstanceWithExtra;
059: import org.collada.colladaschema.LibraryGeometries;
060: import org.jdesktop.j3d.loaders.collada.xml_walker.LibraryGeometriesProcessor;
061: import org.jdesktop.j3d.loaders.collada.xml_walker.Processor;
062: import org.jdesktop.j3d.loaders.collada.xml_walker.ProcessorFactory;
063:
064: /**
065: * Project Looking Glass
066: *
067: * $RCSfile: Main.java,v $
068: *
069: * Copyright (c) 2007, Sun Microsystems, Inc., All Rights Reserved
070: *
071: * Redistributions in source code form must reproduce the above
072: * copyright and this condition.
073: *
074: * The contents of this file are subject to the GNU General Public
075: * License, Version 2 (the "License"); you may not use this file
076: * except in compliance with the License. A copy of the License is
077: * available at http://www.opensource.org/licenses/gpl-license.php.
078: *
079: * $Revision: 1.1 $
080: * $Date: 2007/08/28 16:44:33 $
081: * $State: Exp $
082: */
083:
084: /**
085: *
086: * @author paulby
087: */
088: public class Main {
089:
090: private Logger logger = Logger.getLogger("collada.processor");
091:
092: private BranchGroup rootBG = new BranchGroup();
093:
094: /** Creates a new instance of Main */
095: public Main() {
096: try {
097: JAXBContext jc = JAXBContext
098: .newInstance("org.collada.colladaschema");
099: Unmarshaller unmarshaller = jc.createUnmarshaller();
100: COLLADA collada = (COLLADA)
101: // unmarshaller.unmarshal(new File( "samples/basic_samples/Cube/cube_triangulate.dae"));
102: unmarshaller.unmarshal(new File(
103: "samples/basic_samples/Duck/duck_triangulate.dae"));
104: System.out.println("Base " + collada.getBase());
105: System.out.println("Version " + collada.getVersion());
106:
107: Asset asset = collada.getAsset();
108: Asset.Unit unit = asset.getUnit();
109: System.out.println("Units " + unit.getMeter() + " "
110: + unit.getName());
111:
112: List lib = collada
113: .getLibraryLightsAndLibraryGeometriesAndLibraryAnimationClips();
114: System.out.println("Library");
115: for (Object o : lib) {
116: Processor p = ProcessorFactory.createProcessor(o, null);
117: if (p != null)
118: p.createSceneGraph(rootBG);
119: }
120:
121: COLLADA.Scene scene = collada.getScene();
122: List<Extra> list = scene.getExtras();
123: StringBuilder builder = new StringBuilder();
124: for (Extra e : list)
125: builder.append(e + "; ");
126: logger.info("Extras not implemented : "
127: + builder.toString());
128:
129: InstanceWithExtra instanceVisualScene = scene
130: .getInstanceVisualScene();
131: logger.info("Visual Scene not implemented "
132: + instanceVisualScene.getName());
133:
134: List<InstanceWithExtra> in = scene
135: .getInstancePhysicsScenes();
136: for (InstanceWithExtra iwe : in)
137: logger.info("InstanceWithExtra not implemented "
138: + iwe.getName());
139: } catch (JAXBException ex) {
140: ex.printStackTrace();
141: }
142:
143: }
144:
145: public static void main(String[] args) {
146: new Main();
147: }
148:
149: }
|