1 /*
2     Copyright (c) 2008-2009 NetAllied Systems GmbH
3 
4     This file is part of DAE2MA.
5 
6     Portions of the code are:
7     Copyright (c) 2005-2007 Feeling Software Inc.
8     Copyright (c) 2005-2007 Sony Computer Entertainment America
9     Copyright (c) 2004-2005 Alias Systems Corp.
10 
11     Licensed under the MIT Open Source License,
12     for details please see LICENSE file or the website
13     http://www.opensource.org/licenses/mit-license.php
14 */
15 
16 #include "DAE2MAStableHeaders.h"
17 #include "DAE2MAImportOptions.h"
18 
19 namespace DAE2MA
20 {
21 
22     bool ImportOptions::mHasError = false;
23 
24     bool ImportOptions::mImportUpAxis = true;
25     bool ImportOptions::mImportUnits = true;
26     bool ImportOptions::mImportNormals = true;
27 
28 
29     /** Parse the options String */
set(String & optionsString)30     void ImportOptions::set ( String& optionsString )
31     {
32         // Default option values
33         mImportUpAxis = true;
34         mImportUnits = true;
35         mImportNormals = true;
36 
37         mHasError = false;
38 
39         // Parse option String
40         if ( optionsString.length() > 0 )
41         {
42             std::vector<String> optionList;
43             COLLADABU::Utils::split ( optionsString, String(";"), optionList );
44             size_t optionCount = optionList.size();
45 
46             for ( size_t i = 0; i < optionCount; ++i )
47             {
48                 String& currentOption = optionList[i];
49 
50                 // Process option name and values.
51                 std::vector<String> decomposedOption;
52                 COLLADABU::Utils::split ( currentOption, String("="), decomposedOption );
53                 String& optionName = decomposedOption[0];
54 
55                 // For boolean values, the value is assumed to be true if omitted.
56                 bool value = true;
57 
58                 if ( decomposedOption.size() > 1 && decomposedOption[1] != "true" && decomposedOption[1] != "1" )
59                 {
60                     value = false;
61                 }
62 
63                 // Process options.
64                 if ( optionName == "importUpAxis" ) mImportUpAxis = value;
65                 else if ( optionName == "importUnits" ) mImportUnits = value;
66                 else if ( optionName == "importNormals" ) mImportNormals = value;
67             }
68         }
69     }
70 
71 
hasError()72     bool ImportOptions::hasError()
73     {
74         return mHasError;
75     }
76 
importUpAxis()77     bool ImportOptions::importUpAxis()
78     {
79         return mImportUpAxis;
80     }
81 
importUnits()82     bool ImportOptions::importUnits()
83     {
84         return mImportUnits;
85     }
86 
importNormals()87     bool ImportOptions::importNormals()
88     {
89         return mImportNormals;
90     }
91 
setErrorFlag()92     void ImportOptions::setErrorFlag()
93     {
94         mHasError = true;
95     }
96 }