void gltfWriter::TechniqueParameters (FbxNode *pNode, web::json::value &techniqueParameters, web::json::value &attributes, web::json::value &accessors) { for ( const auto &iter : attributes.as_object () ) { utility::string_t name =iter.first ; std::transform (name.begin (), name.end (), name.begin (), ::tolower) ; //std::replace (name.begin (), name.end (), U('_'), U('x')) ; name.erase (std::remove (name.begin (), name.end (), U('_')), name.end ()) ; utility::string_t upperName (iter.first) ; std::transform (upperName.begin (), upperName.end (), upperName.begin (), ::toupper) ; web::json::value accessor =accessors [iter.second.as_string ()] ; techniqueParameters [name] =web::json::value::object ({ { U("semantic"), web::json::value::string (upperName) }, { U("type"), web::json::value::number ((int)IOglTF::techniqueParameters (accessor [U("type")].as_string ().c_str (), accessor [U("componentType")].as_integer ())) } }) ; } }
void JsonPrettify::formatValue (web::json::value &val, utility::ostream_t &stream) { if ( val.is_array () ) formatArray (val.as_array (), stream) ; else if ( val.is_object () ) formatObject (val.as_object (), stream) ; else if ( val.is_string () ) format_string (val.as_string (), stream) ; else if ( val.is_boolean () ) format_boolean (val.as_bool (), stream) ; else if ( val.is_integer () ) format_integer (val.as_integer (), stream) ; else if ( val.is_double () ) format_double (val.as_double (), stream) ; else if ( val.is_null () ) format_null (stream) ; }
void display_field_map_json(web::json::value jvalue) { if (!jvalue.is_null()) { for (auto const & e : jvalue.as_object()) { std::wcout /*<< typeid(e.first).name()*/ // << e.first/*.as_string()*/ << L" : " /*<< typeid(e.second.as_string()).name()*/ // << e.second.as_string() << std::endl; // std::wcout << e.as_string() << std::endl; } } }
web::json::value gltfWriter::WriteTechnique (FbxNode *pNode, FbxSurfaceMaterial *pMaterial, web::json::value &techniqueParameters) { web::json::value commonProfile =web::json::value::object () ; // The FBX SDK does not have such attribute. At best, it is an attribute of a Shader FX, CGFX or HLSL. commonProfile [U("extras")] =web::json::value::object ({{ U("doubleSided"), web::json::value::boolean (false) }}) ; commonProfile [U("lightingModel")] =web::json::value::string (LighthingModel (pMaterial)) ; commonProfile [U("parameters")] =web::json::value::array () ; if ( _uvSets.size () ) { commonProfile [U("texcoordBindings")] =web::json::value::object () ; for ( auto iter : _uvSets ) { utility::string_t key (iter.first) ; std::string::size_type i =key.find (U("Color")) ; if ( i != std::string::npos ) key.erase (i, 5) ; std::transform (key.begin (), key.end (), key.begin (), ::tolower) ; commonProfile [U("texcoordBindings")] [key] =web::json::value::string (iter.second) ; } } for ( const auto &iter : techniqueParameters.as_object () ) { if ( ( utility::details::limitedCompareTo (iter.first, U("position")) != 0 && utility::details::limitedCompareTo (iter.first, U("normal")) != 0 && utility::details::limitedCompareTo (iter.first, U("texcoord")) != 0) || iter.first == U("normalMatrix") ) commonProfile [U("parameters")] [commonProfile [U("parameters")].size ()] =web::json::value::string (iter.first) ; web::json::value param =iter.second ; if ( param [U("type")].as_integer () == IOglTF::SAMPLER_2D ) { } } web::json::value details =web::json::value::object () ; details [U("commonProfile")] =commonProfile ; details [U("type")] =web::json::value::string (FBX_GLTF_COMMONPROFILE) ; web::json::value attributes =web::json::value::object () ; for ( const auto &iter : techniqueParameters.as_object () ) { if ( utility::details::limitedCompareTo (iter.first, U("position")) == 0 || (utility::details::limitedCompareTo (iter.first, U("normal")) == 0 && iter.first != U("normalMatrix")) || utility::details::limitedCompareTo (iter.first, U("texcoord")) == 0 ) attributes [utility::string_t (U("a_")) + iter.first] =web::json::value::string (iter.first) ; } web::json::value instanceProgram=web::json::value::object () ; instanceProgram [U("attributes")] =attributes ; instanceProgram [U("program")] =web::json::value::string (createUniqueId (utility::string_t (U("program")), 0)) ; instanceProgram [U("uniforms")] =web::json::value::object () ; for ( const auto &iter : techniqueParameters.as_object () ) { if ( ( utility::details::limitedCompareTo (iter.first, U("position")) != 0 && utility::details::limitedCompareTo (iter.first, U("normal")) != 0 && utility::details::limitedCompareTo (iter.first, U("texcoord")) != 0) || iter.first == U("normalMatrix") ) instanceProgram [U("uniforms")] [utility::string_t (U("u_")) + iter.first] =web::json::value::string (iter.first) ; } web::json::value techStatesEnable =web::json::value::array () ; if ( pNode->mCullingType != FbxNode::ECullingType::eCullingOff ) techStatesEnable [techStatesEnable.size ()] =web::json::value::number ((int)IOglTF::CULL_FACE) ; // TODO: should it always be this way? techStatesEnable [techStatesEnable.size ()] =web::json::value::number ((int)IOglTF::DEPTH_TEST) ; web::json::value techStates =web::json::value::object () ; techStates [U("enable")] =techStatesEnable ; // TODO: needs to be implemented //techStates [U("functions")] = web::json::value techniquePass =web::json::value::object () ; techniquePass [U("details")] =details ; techniquePass [U("instanceProgram")] =instanceProgram ; techniquePass [U("states")] =techStates ; web::json::value technique =web::json::value::object () ; technique [U("parameters")] =techniqueParameters ; technique [U("pass")] =web::json::value::string (U("defaultPass")) ; technique [U("passes")] =web::json::value::object ({{ U("defaultPass"), techniquePass }}) ; return (technique) ; }