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