2 # ***** BEGIN LICENSE BLOCK *****
3 Copyright the original author or authors.
4 Licensed under the MOZILLA PUBLIC LICENSE, Version 1.1 (the "License");
5 you may not use this file except in compliance with the License.
6 You may obtain a copy of the License at
7 http://www.mozilla.org/MPL/MPL-1.1.html
8 Unless required by applicable law or agreed to in writing, software
9 distributed under the License is distributed on an "AS IS" BASIS,
10 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 See the License for the specific language governing permissions and
12 limitations under the License.
14 # ***** END LICENSE BLOCK *****
20 * The Parser factory class creates instances of parser classes.
21 * The specific parser can be specified in the create method's second parameter.
23 * @author Thomas Pfeiffer - kiroukou
24 * @author Niel Drummond - haXe port
28 * @example To parse a 3DS file at runtime:
30 * <listing version="3.0">
31 * var parser:IParser = Parser.create( "/path/to/my/3dsfile.3ds", Parser.max );
39 * Parameter that is used to specify that the ASE (ASCII Scene Export)
40 * Parser should be used
42 public static var ASE:String = "ASE";
44 * Parameter that is used to specify that the 3DS (3D Studio) Parser
47 public static var MAX_3DS:String = "3DS";
49 * Parameter that is used to specify that the COLLADA (COLLAborative
50 * Design Activity ) Parser should be used
52 public static var COLLADA:String = "DAE";
55 * The create method chooses which parser to use. This can be done automatically
56 * by looking at the file extension or by passing the parser type String as the
59 * @example To parse a 3DS file at runtime:
61 * <listing version="3.0">
62 * var parser:IParser = Parser.create( "/path/to/my/3dsfile.3ds", Parser.MAX );
65 * @param p_sFile Can be either a string pointing to the location of the
66 * file or an instance of an embedded file
67 * @param p_sParserType The parser type string
68 * @param p_nScale The scale factor
69 * @return The parser to be used
71 public static function create( p_sFile:Dynamic, ?p_sParserType:String, ?p_nScale:Float ):IParser
73 if ( p_nScale == null ) p_nScale = 1;
75 var l_sExt:String,l_iParser:IParser = null;
77 if( Std.is( p_sFile, String ) && p_sParserType == null )
79 l_sExt = (p_sFile.split('.')).reverse()[0];
83 l_sExt = p_sParserType;
86 switch( l_sExt.toUpperCase() )
89 l_iParser = new ASEParser( p_sFile, p_nScale );
92 l_iParser = new ColladaParser( p_sFile, p_nScale );
94 l_iParser = new Parser3DS( p_sFile, p_nScale );