public CreatureAnimation(ref Dictionary<string, object> load_data, string name_in) { name = name_in; bones_cache = new MeshBoneCacheManager (); displacement_cache = new MeshDisplacementCacheManager (); uv_warp_cache = new MeshUVWarpCacheManager (); opacity_cache = new MeshOpacityCacheManager (); cache_pts = new List<List<float> > (); LoadFromData(name_in, ref load_data); }
public static void FillDeformationCache(Dictionary<string, object> json_obj, string key, int start_time, int end_time, ref MeshDisplacementCacheManager cache_manager) { Dictionary<string, object> base_obj = (Dictionary<string, object>)json_obj[key]; cache_manager.init(start_time, end_time); foreach (KeyValuePair<string, object> cur_node in base_obj) { int cur_time = Convert.ToInt32(cur_node.Key); List<MeshDisplacementCache> cache_list = new List<MeshDisplacementCache>(); Dictionary<string, object> node_dict = (Dictionary<string, object>)cur_node.Value; foreach (KeyValuePair<string, object> mesh_node in node_dict) { string cur_name = mesh_node.Key; Dictionary<string, object> mesh_dict = (Dictionary<string, object>)mesh_node.Value; MeshDisplacementCache cache_data = new MeshDisplacementCache(cur_name); bool use_local_displacement = Utils.ReadBoolJSON(mesh_dict, "use_local_displacements"); //GetJSONNodeFromKey(*mesh_node, "use_local_displacements")->value.toBool(); bool use_post_displacement = Utils.ReadBoolJSON(mesh_dict, "use_post_displacements"); //GetJSONNodeFromKey(*mesh_node, "use_post_displacements")->value.toBool(); if(use_local_displacement) { List<XnaGeometry.Vector2> read_pts = Utils.ReadPointsArray2DJSON(mesh_dict, "local_displacements"); //ReadJSONPoints2DVector(*mesh_node, "local_displacements"); cache_data.setLocalDisplacements(read_pts); } if(use_post_displacement) { List<XnaGeometry.Vector2> read_pts = Utils.ReadPointsArray2DJSON(mesh_dict, "post_displacements"); //ReadJSONPoints2DVector(*mesh_node, "post_displacements"); cache_data.setPostDisplacements(read_pts); } cache_list.Add(cache_data); } int set_index = cache_manager.getIndexByTime(cur_time); cache_manager.displacement_cache_table[set_index] = cache_list; } cache_manager.makeAllReady(); }