1 /* 2 Copyright (c) 2008-2009 NetAllied Systems GmbH 3 4 This file is part of COLLADASaxFrameworkLoader. 5 6 Licensed under the MIT Open Source License, 7 for details please see LICENSE file or the website 8 http://www.opensource.org/licenses/mit-license.php 9 */ 10 11 #include "COLLADASaxFWLStableHeaders.h" 12 #include "COLLADASaxFWLInputUnshared.h" 13 14 using namespace COLLADAFW; 15 16 17 namespace COLLADASaxFWL 18 { 19 20 //------------------------------ InputUnshared(InputSemantic::Semantic semantic,const COLLADABU::URI & source)21 InputUnshared::InputUnshared( InputSemantic::Semantic semantic, const COLLADABU::URI& source ) 22 : mSemantic ( semantic ) 23 , mSource ( source ) 24 { 25 } 26 27 //------------------------------ InputUnshared(const String & semantic,const String & source)28 InputUnshared::InputUnshared( const String& semantic, const String& source ) 29 : mSemantic ( getSemanticFromString(semantic) ) 30 , mSource ( source ) 31 { 32 } 33 34 35 // ---------------------------- getSemanticAsString(const InputSemantic::Semantic semantic)36 const String& InputUnshared::getSemanticAsString ( const InputSemantic::Semantic semantic ) 37 { 38 switch ( semantic ) 39 { 40 case InputSemantic::BINORMAL: return Constants::SEMANTIC_BINORMAL; 41 case InputSemantic::COLOR: return Constants::SEMANTIC_COLOR; 42 case InputSemantic::CONTINUITY: return Constants::SEMANTIC_CONTINUITY; 43 case InputSemantic::IMAGE: return Constants::SEMANTIC_IMAGE; 44 case InputSemantic::INPUT: return Constants::SEMANTIC_INPUT; 45 case InputSemantic::IN_TANGENT: return Constants::SEMANTIC_IN_TANGENT; 46 case InputSemantic::INTERPOLATION: return Constants::SEMANTIC_INTERPOLATION; 47 case InputSemantic::INV_BIND_MATRIX: return Constants::SEMANTIC_INV_BIND_MATRIX; 48 case InputSemantic::JOINT: return Constants::SEMANTIC_JOINT; 49 case InputSemantic::LINEAR_STEPS: return Constants::SEMANTIC_LINEAR_STEPS; 50 case InputSemantic::MORPH_TARGET: return Constants::SEMANTIC_MORPH_TARGET; 51 case InputSemantic::MORPH_WEIGHT: return Constants::SEMANTIC_MORPH_WEIGHT; 52 case InputSemantic::NORMAL: return Constants::SEMANTIC_NORMAL; 53 case InputSemantic::OUTPUT: return Constants::SEMANTIC_OUTPUT; 54 case InputSemantic::OUT_TANGENT: return Constants::SEMANTIC_OUT_TANGENT; 55 case InputSemantic::POSITION: return Constants::SEMANTIC_POSITION; 56 case InputSemantic::TANGENT: return Constants::SEMANTIC_TANGENT; 57 case InputSemantic::TEXBINORMAL: return Constants::SEMANTIC_TEXBINORMAL; 58 case InputSemantic::TEXCOORD: return Constants::SEMANTIC_TEXCOORD; 59 case InputSemantic::TEXTANGENT: return Constants::SEMANTIC_TEXTANGENT; 60 case InputSemantic::UV: return Constants::SEMANTIC_UV; 61 case InputSemantic::VERTEX: return Constants::SEMANTIC_VERTEX; 62 case InputSemantic::WEIGHT: return Constants::SEMANTIC_WEIGHT; 63 case InputSemantic::UNKNOWN: 64 default: return Constants::EMPTY_STRING; 65 } 66 } 67 68 // ---------------------------- getSemanticFromString(const String & semanticStr)69 const InputSemantic::Semantic InputUnshared::getSemanticFromString ( const String& semanticStr ) 70 { 71 size_t hash = COLLADABU::calculateHashUpper( semanticStr ); 72 switch ( hash ) 73 { 74 case InputSemantic::BINORMAL_HASH: 75 return InputSemantic::BINORMAL; 76 case InputSemantic::COLOR_HASH: 77 return InputSemantic::COLOR; 78 case InputSemantic::CONTINUITY_HASH: 79 return InputSemantic::CONTINUITY; 80 case InputSemantic::IMAGE_HASH: 81 return InputSemantic::IMAGE; 82 case InputSemantic::INPUT_HASH: 83 return InputSemantic::INPUT; 84 case InputSemantic::IN_TANGENT_HASH: 85 return InputSemantic::IN_TANGENT; 86 case InputSemantic::INTERPOLATION_HASH: 87 return InputSemantic::INTERPOLATION; 88 case InputSemantic::INV_BIND_MATRIX_HASH: 89 return InputSemantic::INV_BIND_MATRIX; 90 case InputSemantic::JOINT_HASH: 91 return InputSemantic::JOINT; 92 case InputSemantic::LINEAR_STEPS_HASH: 93 return InputSemantic::LINEAR_STEPS; 94 case InputSemantic::MORPH_TARGET_HASH: 95 return InputSemantic::MORPH_TARGET; 96 case InputSemantic::MORPH_WEIGHT_HASH: 97 return InputSemantic::MORPH_WEIGHT; 98 case InputSemantic::NORMAL_HASH: 99 return InputSemantic::NORMAL; 100 case InputSemantic::OUTPUT_HASH: 101 return InputSemantic::OUTPUT; 102 case InputSemantic::OUT_TANGENT_HASH: 103 return InputSemantic::OUT_TANGENT; 104 case InputSemantic::POSITION_HASH: 105 return InputSemantic::POSITION; 106 case InputSemantic::TANGENT_HASH: 107 return InputSemantic::TANGENT; 108 case InputSemantic::TEXBINORMAL_HASH: 109 return InputSemantic::TEXBINORMAL; 110 case InputSemantic::TEXCOORD_HASH: 111 return InputSemantic::TEXCOORD; 112 case InputSemantic::TEXTANGENT_HASH: 113 return InputSemantic::TEXTANGENT; 114 case InputSemantic::UV_HASH: 115 return InputSemantic::UV; 116 case InputSemantic::VERTEX_HASH: 117 return InputSemantic::VERTEX; 118 case InputSemantic::WEIGHT_HASH: 119 return InputSemantic::WEIGHT; 120 } 121 122 return InputSemantic::UNKNOWN; 123 } 124 125 } 126