private void btnAdd_Click(object sender, EventArgs e) { if (IsWiiU) { UserData userDataNew = new UserData(); userDataNew.SetValue(new int[0]); SelectedDataU = userDataNew; bool IsEdited = EditData(); if (IsEdited) { userData.Add(SelectedDataU.Name, SelectedDataU); LoadUserData(SelectedDataU); } } else { ResNX.UserData userDataNew = new ResNX.UserData(); userDataNew.SetValue(new int[0]); SelectedDataNX = userDataNew; bool IsEdited = EditData(); if (IsEdited) { userDataNX.Add(SelectedDataNX); LoadUserData(SelectedDataNX); } } }
internal ResDict <T> LoadDictValues <T>(long dictionaryOffset, long valueOffset) where T : IResData, new() { if (dictionaryOffset == 0) { return(new ResDict <T>()); } using (TemporarySeek(dictionaryOffset, SeekOrigin.Begin)) { ResDict <T> dict = new ResDict <T>(); ((IResData)dict).Load(this); //Load data via list next to dictionary var keys = dict.Keys.ToList(); var values = LoadList <T>(dict.Count, (uint)valueOffset); dict.Clear(); for (int i = 0; i < keys.Count; i++) { dict.Add(keys[i], values[i]); } return(dict); } }
public void AddToBones(ResDict <Bone> bones, Matrix4 parentBoneMatrix, short parentBoneIndex = -1) { bones.Add(BoneName, new Bone { Name = BoneName, Position = Vector4.Transform(new Vector4(Position.ToSkeletonScale(), 1), parentBoneMatrix.Inverted()).Xyz.ToVec3F(), Rotation = new Syroot.Maths.Vector4F(0, 0, 0, 0), Scale = Syroot.Maths.Vector3F.One, ParentIndex = parentBoneIndex, FlagsRotation = BoneFlagsRotation.EulerXYZ }); Cob?.AddToBones(bones, Matrix4.CreateTranslation(Position.ToSkeletonScale()), (short)(bones.Count - 1)); }
public void AddToBones(ResDict <Bone> bones, Matrix4 parentBoneMatrix, short parentBoneIndex = -1) { bone.Name = BoneName; bone.Position = Vector4.Transform(new Vector4(Position.ToSkeletonScale(), 1), parentBoneMatrix.Inverted()).Xyz.ToVec3F(); bone.ParentIndex = parentBoneIndex; bones.Add(BoneName, bone); parentBoneIndex = (short)(bones.Count - 1); foreach (var child in Children) { child.AddToBones(bones, bone.CalculateRelativeMatrix() * parentBoneMatrix, parentBoneIndex); } }
public void AddToBones(ResDict <Bone> bones, Matrix4 parentBoneMatrix, short parentBoneIndex = -1) { int cobCount = bones.Keys.Count(x => x.StartsWith(ModelName)); string modelName = ModelName; if (cobCount > 0) { modelName = ModelName + cobCount + 1; } bones.Add(modelName, new Bone { Name = modelName, Position = Vector4.Transform(new Vector4(Position.ToSkeletonScale(), 1), parentBoneMatrix.Inverted()).Xyz.ToVec3F(), Rotation = new Syroot.Maths.Vector4F(0, 0, 0, 1), Scale = Syroot.Maths.Vector3F.One, ParentIndex = parentBoneIndex, FlagsRotation = BoneFlagsRotation.EulerXYZ }); }
public void AddToBones(ResDict <Bone> bones, Matrix4 parentBoneMatrix, short parentBoneIndex = -1) { bones.Add(Name, new Bone { Name = Name, Position = Vector4.Transform(new Vector4(0, 0, 0, 1), parentBoneMatrix.Inverted()).Xyz.ToVec3F(), Rotation = new Syroot.Maths.Vector4F(0, 0, 0, 1), Scale = Syroot.Maths.Vector3F.One, ParentIndex = parentBoneIndex, FlagsRotation = BoneFlagsRotation.EulerXYZ }); parentBoneIndex = (short)(bones.Count - 1); foreach (WorldMapPoint point in RoutePoints) { point.AddToBones(bones, parentBoneMatrix, parentBoneIndex); parentBoneMatrix = Matrix4.CreateTranslation(point.Position.ToSkeletonScale()); parentBoneIndex++; } }
public static ResDict <UserData> Convert(Dictionary <string, object> userData) { ResDict <UserData> userDataDict = new ResDict <UserData>(); foreach (var param in userData) { UserData usd = new UserData(); string type = param.Key.Split('|')[0]; string name = param.Key.Split('|')[1]; UserDataType dataType = (UserDataType)Enum.Parse(typeof(UserDataType), type); if (dataType == UserDataType.Single) { usd = SetUserData(name, ((JArray)param.Value).ToObject <float[]>()); } if (dataType == UserDataType.Int32) { usd = SetUserData(name, ((JArray)param.Value).ToObject <int[]>()); } if (dataType == UserDataType.Byte) { usd = SetUserData(name, ((JArray)param.Value).ToObject <byte[]>()); } if (dataType == UserDataType.String) { usd = SetUserData(name, ((JArray)param.Value).ToObject <string[]>()); } if (dataType == UserDataType.WString) { usd = SetUserData(name, ((JArray)param.Value).ToObject <string[]>(), true); } userDataDict.Add(usd.Name, usd); } return(userDataDict); }
public static void Render(ResDict <UserData> userDataDict) { if (ImGui.Button("Add")) { var userData = new UserData(); userData.Name = " "; Selected.Add(userData); dialogOpen = true; ImGui.OpenPopup("##user_data_dialog"); if (ActiveDialog.LoadDialog(userData, dialogOpen)) { userDataDict.Add(userData.Name, userData); } } var diabledTextColor = ImGui.GetStyle().Colors[(int)ImGuiCol.TextDisabled]; if (Selected.Count == 0) { ImGui.PushStyleColor(ImGuiCol.Text, diabledTextColor); } ImGui.SameLine(); if (ImGui.Button("Remove") && Selected.Count > 0) { foreach (var usd in Selected) { userDataDict.Remove(usd); } } ImGui.SameLine(); if (ImGui.Button("Edit") && Selected.Count > 0) { dialogOpen = true; ImGui.OpenPopup("##user_data_dialog"); } if (Selected.Count == 0) { ImGui.PopStyleColor(); } if (Selected.Count > 0 && dialogOpen) { ActiveDialog.LoadDialog(Selected.FirstOrDefault(), dialogOpen); } RenderHeader(); if (ImGui.BeginChild("USER_DATA_LIST")) { int index = 0; foreach (var userData in userDataDict.Values) { bool isSelected = Selected.Contains(userData); ImGui.Columns(2); if (ImGui.Selectable(userData.Name, isSelected)) { Selected.Clear(); Selected.Add(userData); } ImGui.NextColumn(); ImGui.Text(GetDataString(userData, ",")); ImGui.NextColumn(); if (isSelected && ImGui.IsMouseDoubleClicked(0)) { dialogOpen = true; ImGui.OpenPopup("##user_data_dialog"); } index++; ImGui.Columns(1); } } ImGui.EndChild(); }
internal override void ConvertToSwitchMaterial(Material material) { //Convert all render info if (material.ShaderAssign.ShadingModelName == "turbo_uber_xlu" || material.Name.Contains("CausticsArea")) { material.Visible = false; return; } Console.WriteLine("Converting material " + material.Name); for (int i = 0; i < 5; i++) { RemoveRenderInfo(material, $"gsys_model_fx{i}"); } material.SetRenderInfo("gsys_bake_normal_map", "default"); material.SetRenderInfo("gsys_bake_emission_map", "default"); material.SetRenderInfo("gsys_render_state_display_face", GetCullState(material.RenderState)); material.SetRenderInfo("gsys_render_state_mode", GetRenderState(material.RenderState)); material.SetRenderInfo("gsys_depth_test_enable", RenderInfoBoolString( material.RenderState.DepthControl.DepthTestEnabled)); material.SetRenderInfo("gsys_depth_test_func", CompareFunction[ material.RenderState.DepthControl.DepthFunc]); material.SetRenderInfo("gsys_depth_test_write", RenderInfoBoolString( material.RenderState.DepthControl.DepthWriteEnabled)); material.SetRenderInfo("gsys_alpha_test_enable", RenderInfoBoolString( material.RenderState.AlphaControl.AlphaTestEnabled)); material.SetRenderInfo("gsys_alpha_test_func", CompareFunction[ material.RenderState.AlphaControl.AlphaFunc]); material.SetRenderInfo("gsys_alpha_test_value", material.RenderState.AlphaRefValue); material.SetRenderInfo("gsys_render_state_blend_mode", GetBlendMode(material.RenderState)); material.SetRenderInfo("gsys_color_blend_rgb_op", BlendCombine[ material.RenderState.BlendControl.ColorCombine]); material.SetRenderInfo("gsys_color_blend_rgb_src_func", BlendFunction[ material.RenderState.BlendControl.ColorSourceBlend]); material.SetRenderInfo("gsys_color_blend_rgb_dst_func", BlendFunction[ material.RenderState.BlendControl.ColorDestinationBlend]); material.SetRenderInfo("gsys_color_blend_alpha_op", BlendCombine[ material.RenderState.BlendControl.AlphaCombine]); material.SetRenderInfo("gsys_color_blend_alpha_src_func", BlendFunction[ material.RenderState.BlendControl.AlphaSourceBlend]); material.SetRenderInfo("gsys_color_blend_alpha_dst_func", BlendFunction[ material.RenderState.BlendControl.AlphaDestinationBlend]); material.SetRenderInfo("gsys_color_blend_const_color", new float[4] { 0, 0, 0, 0 }); material.SetShaderParameter("gsys_alpha_test_ref_value", ShaderParamType.Float, material.RenderState.AlphaRefValue); material.SetShaderParameter("gsys_xlu_zprepass_alpha", ShaderParamType.Float4, new float[4] { 1, 1, 1, 1 }); material.SetShaderParameter("screen_fake_scale_begin_ratio", ShaderParamType.Float, 0.25f); material.SetShaderParameter("screen_fake_scale_factor", ShaderParamType.Float3, new float[3] { 0, 0, 0 }); if (!material.ShaderParams.ContainsKey("d_shadow_bake_l_cancel_rate")) { material.SetShaderParameter("d_shadow_bake_l_cancel_rate", ShaderParamType.Float, 0.25f); } if (!material.ShaderParams.ContainsKey("decal_trail_intensity")) { material.SetShaderParameter("decal_trail_intensity", ShaderParamType.Float, 1); } if (!material.ShaderParams.ContainsKey("indirect_magB")) { material.SetShaderParameter("indirect_magB", ShaderParamType.Float2, new float[2] { 1, 1 }); } if (!material.ShaderParams.ContainsKey("decal_trail_color")) { material.SetShaderParameter("decal_trail_color", ShaderParamType.Float2, new float[3] { 1, 1, 1 }); } material.ShaderParams.RemoveKey("effect_normal_offset"); material.ShaderParams.RemoveKey("gsys_model_fx_ratio"); material.ShaderParams.RemoveKey("gsys_specular_roughness"); material.ShaderParams.RemoveKey("zprepass_shadow_rate"); //Adjust shader params //Here we'll make a new shader param list in the same switch order List <ShaderParam> param = new List <ShaderParam>(); param.Add(material.ShaderParams["edge_light_rim_i"]); param.Add(material.ShaderParams["d_shadow_bake_l_cancel_rate"]); param.Add(material.ShaderParams["gsys_i_color_ratio0"]); param.Add(material.ShaderParams["gsys_edge_ratio0"]); param.Add(material.ShaderParams["gsys_edge_width0"]); param.Add(material.ShaderParams["bloom_intensity"]); param.Add(material.ShaderParams["gsys_outline_width"]); param.Add(material.ShaderParams["gsys_alpha_threshold"]); param.Add(material.ShaderParams["game_edge_pow"]); param.Add(material.ShaderParams["edge_alpha_scale"]); param.Add(material.ShaderParams["post_multi_texture"]); param.Add(material.ShaderParams["edge_alpha_width"]); param.Add(material.ShaderParams["edge_alpha_pow"]); param.Add(material.ShaderParams["transparency"]); param.Add(material.ShaderParams["alphat_out_start"]); param.Add(material.ShaderParams["alphat_out_end"]); param.Add(material.ShaderParams["gsys_area_env_index_diffuse"]); param.Add(material.ShaderParams["shadow_density"]); param.Add(material.ShaderParams["ao_density"]); param.Add(material.ShaderParams["transmit_intensity"]); param.Add(material.ShaderParams["edge_light_vc_intensity"]); param.Add(material.ShaderParams["specular_aniso_power"]); param.Add(material.ShaderParams["transmit_shadow_intensity"]); param.Add(material.ShaderParams["edge_light_intensity"]); param.Add(material.ShaderParams["light_pre_pass_intensity"]); param.Add(material.ShaderParams["gsys_bake_opacity"]); param.Add(material.ShaderParams["shiny_specular_intensity"]); param.Add(material.ShaderParams["specular_intensity"]); param.Add(material.ShaderParams["specular_roughness"]); param.Add(material.ShaderParams["specular_fresnel_i"]); param.Add(material.ShaderParams["specular_fresnel_s"]); param.Add(material.ShaderParams["specular_fresnel_m"]); param.Add(material.ShaderParams["shiny_specular_sharpness"]); param.Add(material.ShaderParams["emission_intensity"]); param.Add(material.ShaderParams["soft_edge_dist_inv"]); param.Add(material.ShaderParams["silhoutte_depth"]); param.Add(material.ShaderParams["refraction_intensity"]); param.Add(material.ShaderParams["normal_map_weight"]); param.Add(material.ShaderParams["shiny_specular_fresnel"]); param.Add(material.ShaderParams["silhoutte_depth_contrast"]); param.Add(material.ShaderParams["fresnel_look_depend_factor"]); param.Add(material.ShaderParams["mii_hair_specular_intensity"]); param.Add(material.ShaderParams["decal_trail_intensity"]); param.Add(material.ShaderParams["screen_fake_scale_begin_ratio"]); param.Add(material.ShaderParams["fog_emission_intensity"]); param.Add(material.ShaderParams["fog_emission_effect"]); param.Add(material.ShaderParams["fog_edge_power"]); param.Add(material.ShaderParams["fog_edge_width"]); param.Add(material.ShaderParams["gsys_alpha_test_ref_value"]); param.Add(material.ShaderParams["edge_light_sharpness"]); param.Add(material.ShaderParams["indirect_mag"]); param.Add(material.ShaderParams["indirect_magB"]); param.Add(material.ShaderParams["silhoutte_depth_color"]); param.Add(material.ShaderParams["gsys_mii_skin_color"]); param.Add(material.ShaderParams["gsys_mii_favorite_color"]); param.Add(material.ShaderParams["gsys_point_light_color"]); param.Add(material.ShaderParams["gsys_edge_color0"]); param.Add(material.ShaderParams["transmit_color"]); param.Add(material.ShaderParams["gsys_i_color0"]); param.Add(material.ShaderParams["gsys_i_color0_b"]); param.Add(material.ShaderParams["gsys_bake_light_scale"]); param.Add(material.ShaderParams["gsys_bake_light_scale1"]); param.Add(material.ShaderParams["gsys_bake_light_scale2"]); param.Add(material.ShaderParams["albedo_tex_color"]); param.Add(material.ShaderParams["decal_trail_color"]); param.Add(material.ShaderParams["fog_emission_color"]); param.Add(material.ShaderParams["screen_fake_scale_factor"]); param.Add(material.ShaderParams["edge_light_color"]); param.Add(material.ShaderParams["shiny_specular_color"]); param.Add(material.ShaderParams["specular_color"]); param.Add(material.ShaderParams["emission_color"]); param.Add(material.ShaderParams["gsys_depth_silhoutte_color"]); param.Add(material.ShaderParams["gsys_outline_color"]); param.Add(material.ShaderParams["gsys_area_env_data0"]); param.Add(material.ShaderParams["gsys_area_env_data1"]); param.Add(material.ShaderParams["gsys_bake_st0"]); param.Add(material.ShaderParams["gsys_bake_st1"]); param.Add(material.ShaderParams["multi_tex_reg0"]); param.Add(material.ShaderParams["multi_tex_reg1"]); param.Add(material.ShaderParams["multi_tex_param0"]); param.Add(material.ShaderParams["fog_edge_color"]); param.Add(material.ShaderParams["gsys_xlu_zprepass_alpha"]); param.Add(material.ShaderParams["multi_tex_reg2"]); param.Add(material.ShaderParams["gsys_sssss_color"]); param.Add(material.ShaderParams["tex_mtx1"]); param.Add(material.ShaderParams["tex_mtx2"]); param.Add(material.ShaderParams["tex_mtx0"]); material.ShaderParams.Clear(); foreach (var prm in param) { material.ShaderParams.Add(prm.Name, prm); } //Adjust shader options //gsys_alpha_test_enable //gsys_alpha_test_func //enable_screen_fake_scale var shaderAssign = material.ShaderAssign; shaderAssign.ShaderOptions.RemoveKey("enable_effect_normal_offset"); shaderAssign.ShaderOptions.RemoveKey("bake_calc_type"); ResDict <ResString> shaderOptions = new ResDict <ResString>(); var keys = shaderAssign.ShaderOptions.Keys.ToList(); var values = shaderAssign.ShaderOptions.Values.ToList(); int opIndex = 0; for (int i = 0; i < keys.Count + 3; i++) { if (i == 0) { shaderOptions.Add("gsys_alpha_test_enable", material.RenderState.AlphaControl.AlphaTestEnabled ? "0" : "0"); } else if (i == 1) { shaderOptions.Add("gsys_alpha_test_func", GetShaderOptionAlphaTestFunc( CompareFunction[material.RenderState.AlphaControl.AlphaFunc])); } else if (i == 100) { shaderOptions.Add("enable_screen_fake_scale", "0"); } else { shaderOptions.Add(keys[opIndex], values[opIndex]); opIndex++; } } shaderAssign.ShaderOptions = shaderOptions; }