bool ReachIKCompiler::readJSON( const jsonxx::Object& root ) { BaseCompiler::readJSON(root); ReachResource reach; memset(&reach, 0x00, sizeof(reach)); vec3_make(reach.m_elbowAxis, 0, 1, 0); json_to_floats(root, "elbow_axis", reach.m_elbowAxis, 3); reach.m_hingeLimitAngle[0] = 0; reach.m_hingeLimitAngle[1] = 180; json_to_floats(root, "hinge_limit_angle", reach.m_hingeLimitAngle, 2); reach.m_reachGain = json_to_float(root, "reach_gain", 0.3f); reach.m_leaveGain = json_to_float(root, "leave_gain", 0.19f); reach.m_moveGain = json_to_float(root, "move_gain", 0.085f); reach.m_targetGain = json_to_float(root, "target_gain", 0.2f); reach.m_index = json_to_enum(root, "hand", left_right_names); const std::string& rigFile = root.get<std::string>("rig"); reach.m_rigName = stringid_caculate(rigFile.c_str()); addDependency("rig", name_to_file_path(rigFile, EngineNames::ANIMATION_RIG)); return write_file(m_output, &reach, sizeof(reach)); }
bool LookIKCompiler::readJSON( const jsonxx::Object& root ) { BaseCompiler::readJSON(root); LookAtResource lookat; memset(&lookat, 0x00, sizeof(lookat)); vec3_make(lookat.m_fwdLS, 0, 0, 1); json_to_floats(root, "forward_ls", lookat.m_fwdLS, 3); lookat.m_lookAtLimit = json_to_float(root, "lookat_limit", 3.1415926f/4.0f); lookat.m_gain = json_to_float(root, "gain", 0.05f); lookat.m_targetGain = json_to_float(root, "target_gain", 0.2f); const std::string& rigFile = root.get<std::string>("rig"); lookat.m_rigName = stringid_caculate(rigFile.c_str()); addDependency("rig", name_to_file_path(rigFile, EngineNames::ANIMATION_RIG)); return write_file(m_output, &lookat, sizeof(lookat)); }
bool ShadingEnviromentCompiler::readJSON(const jsonxx::Object& root) { BaseCompiler::readJSON(root); ShadingEnviroment shading; memset(&shading, 0x00, sizeof(shading)); //init shading variables float fogParams[] = {10, 40, 0, 0}; memcpy(shading.m_fog_params, fogParams, sizeof(fogParams)); vec3_make(shading.m_ambient_sky_color, 0.37f, 0.55f, 0.66f); shading.m_shadow_area_size = 30.0f; shading.m_shadow_far = 100; vec3_make(shading.m_shadow_params, 0.01f, 0.001f, 0.0f); if(root.has<jsonxx::Object>("fog")) { const jsonxx::Object& o = root.get<jsonxx::Object>("fog"); shading.m_fog_params[0] = json_to_float(o, "near", 10.0f); shading.m_fog_params[1] = json_to_float(o, "far", 40.0f); shading.m_fog_params[2] = json_to_float(o, "density", 0.0f); shading.m_fog_params[3] = json_to_float(o, "density", 0.0f); } json_to_floats(root, "ambient_sky_color", shading.m_ambient_sky_color, 3); json_to_floats(root, "ambient_ground_color", shading.m_ambient_ground_color, 3); if(root.has<jsonxx::Object>("shadow")) { const jsonxx::Object& o = root.get<jsonxx::Object>("shadow"); shading.m_shadow_area_size = json_to_float(o, "area", 1.0f); shading.m_shadow_far = json_to_float(o, "far", 1.0f); shading.m_shadow_params[0] = json_to_float(o, "offset", 1.0f); shading.m_shadow_params[1] = json_to_float(o, "bias", 1.0f); } if(root.has<jsonxx::Object>("color_grading")) { const jsonxx::Object& o = root.get<jsonxx::Object>("color_grading"); const jsonxx::Array& texturesValue = o.get<jsonxx::Array>("textures"); shading.m_num_colorgrading_textures = texturesValue.size(); for (uint32_t i=0; i<shading.m_num_colorgrading_textures; ++i) { const std::string& lutTexture = texturesValue.get<std::string>(i); shading.m_color_grading_texturenames[i] = stringid_caculate(lutTexture.c_str()); addDependency("color_grading_texture", name_to_file_path(lutTexture.c_str(), EngineNames::TEXTURE_3D)); } shading.m_colorgrading_index = json_to_int(o, "grading_index"); } return write_file(m_output, &shading, sizeof(shading)); }
struct svalue * json_to_value(json_object *ob) { enum json_type type = json_object_get_type(ob); switch (type) { case json_type_boolean: return json_to_boolean(ob); case json_type_double: return json_to_float(ob); case json_type_int: return json_to_int(ob); case json_type_string: return json_to_string(ob); case json_type_object: return json_to_mapping(ob); case json_type_array: return json_to_array(ob); case json_type_null: return json_to_null(ob); } return NULL; }
bool FootIKCompiler::readJSON( const jsonxx::Object& root ) { BaseCompiler::readJSON(root); FootResource foot; memset(&foot, 0x00, sizeof(foot)); vec3_make(foot.m_leftKneeAxisLS, 0, 0, 1); vec3_make(foot.m_rightKneeAxisLS, 0, 0, 1); vec3_make(foot.m_footEndLS, 0, 0, 0.2f); json_to_floats(root, "left_knee_axis", foot.m_leftKneeAxisLS, 3); json_to_floats(root, "right_knee_axis", foot.m_rightKneeAxisLS, 3); json_to_floats(root, "foot_end_ls", foot.m_footEndLS, 3); foot.m_orignalGroundHeightMS = json_to_float(root, "orignal_ground_height_ms"); foot.m_minAnkleHeightMS = json_to_float(root, "min_ankle_height_ms"); foot.m_maxAnkleHeightMS = json_to_float(root, "max_ankle_height_ms"); foot.m_footPlantedAnkleHeightMS = json_to_float(root, "foot_planted_ankle_height_ms"); foot.m_footRaisedAnkleHeightMS = json_to_float(root, "foot_raised_ankle_height_ms"); foot.m_cosineMaxKneeAngle = json_to_float(root, "max_consine_knee_angle", 180); foot.m_cosineMinKneeAngle = json_to_float(root, "min_consine_knee_angle", 0); foot.m_raycastDistanceUp = json_to_float(root, "raycast_dis_up", 0.5f); foot.m_raycastDistanceDown = json_to_float(root, "raycast_dis_down", 0.8f); foot.m_raycastCollisionLayer = json_to_stringid(root, "raycast_layer"); foot.m_groundAscendingGain = json_to_float(root, "ground_ascending_gain", 0.35f); foot.m_groundDescendingGain = json_to_float(root, "ground_descending_gain", 0.6f); foot.m_standAscendingGain = json_to_float(root, "ground_ascending_gain", 0.6f); foot.m_footPlantedGain = json_to_float(root, "foot_planted_gain", 1.0f); foot.m_footRaisedGain = json_to_float(root, "foot_raised_gain", 0.85f); foot.m_footOnOffGain = json_to_float(root, "foot_onoff_gain", 0.2f); foot.m_footUnLockGain = json_to_float(root, "foot_unlock_gain", 0.85f); foot.m_pelvisFeedback = json_to_float(root, "pelvis_feedback", 0.1f); foot.m_pelvisUpDownBias = json_to_float(root, "pelvis_updown_bias", 0.95f); foot.m_raycastType = json_to_enum(root, "raycast_type", raycast_type_names, 0); const std::string& rigFile = root.get<std::string>("rig"); foot.m_rigName = stringid_caculate(rigFile.c_str()); addDependency("rig", name_to_file_path(rigFile, EngineNames::ANIMATION_RIG)); return write_file(m_output, &foot, sizeof(foot)); }