public List <Tuple35 <Value.PathForImage, bool> > GetTextures(Utl.MaterialInformation info) { var ret = new List <Tuple35 <Value.PathForImage, bool> >(); foreach (var texture in info.Textures) { var key = CreateKey(texture); if (texture.IsValueTexture) { if (keyToValues.ContainsKey(key)) { ret.Add(Tuple35.Create(keyToValues[key] as Value.PathForImage, true)); } else { ret.Add(Tuple35.Create((Value.PathForImage)(null), true)); } } else { if (keyToValues.ContainsKey(key)) { ret.Add(Tuple35.Create(keyToValues[key] as Value.PathForImage, false)); } else { ret.Add(Tuple35.Create((Value.PathForImage)(null), false)); } } } return(ret); }
private void Path_OnChanged(object sender, ChangedValueEventArgs e) { // Apply values Utl.MaterialInformation info = new Utl.MaterialInformation(); info.Load(Path.GetAbsolutePath()); ApplyMaterial(info); if (info.CustomData.Count() > 0) { rcValues.CustomData1.Name = info.CustomData[0].Summaries[Core.Language]; rcValues.CustomData1.Desc = info.CustomData[0].Descriptions[Core.Language]; } else { rcValues.CustomData1.Name = string.Empty; rcValues.CustomData1.Desc = string.Empty; } if (info.CustomData.Count() > 1) { rcValues.CustomData2.Name = info.CustomData[1].Summaries[Core.Language]; rcValues.CustomData2.Desc = info.CustomData[1].Descriptions[Core.Language]; } else { rcValues.CustomData2.Name = string.Empty; rcValues.CustomData2.Desc = string.Empty; } rcValues.CustomData1.Changed(); rcValues.CustomData2.Changed(); }
private void Path_OnChanged(object sender, ChangedValueEventArgs e) { // Apply values Utl.MaterialInformation info = new Utl.MaterialInformation(); info.Load(Path.GetAbsolutePath()); ApplyMaterial(info); }
public Utl.MaterialInformation LoadMaterialInformation(string path) { path = path.Replace('\\', '/'); if (materials.ContainsKey(path)) { return(materials[path]); } var info = new Utl.MaterialInformation(); if (info.Load(path)) { materials.Add(path, info); } return(info); }
public List <object> GetUniforms(Utl.MaterialInformation info) { var ret = new List <object>(); foreach (var uniform in info.Uniforms) { var key = CreateKey(uniform); if (keyToValues.ContainsKey(key)) { ret.Add(keyToValues[key]); } else { ret.Add(null); } } return(ret); }
void UpdateInformation() { if (binding == null || string.IsNullOrEmpty(binding.GetAbsolutePath())) { matInfo = null; compiledMatInfo = null; return; } matInfo = new Utl.MaterialInformation(); matInfo.Load(binding.GetAbsolutePath()); if (System.IO.File.Exists(CreateBinaryFilePath())) { compiledMatInfo = new Utl.CompiledMaterialInformation(); compiledMatInfo.Load(CreateBinaryFilePath()); } else { compiledMatInfo = null; } }
void UpdateInformation() { if (binding == null || string.IsNullOrEmpty(binding.GetAbsolutePath())) { matInfo = null; compiledMatInfo = null; return; } matInfo = new Utl.MaterialInformation(); matInfo.Load(binding.GetAbsolutePath()); var binaryPath = IO.MaterialCacheGenerator.CreateBinaryFilePath(binding.GetAbsolutePath()); if (System.IO.File.Exists(binaryPath)) { compiledMatInfo = new Utl.CompiledMaterialInformation(); errorCode = compiledMatInfo.Load(binaryPath); } else { compiledMatInfo = null; } }
public void ApplyMaterial(Utl.MaterialInformation info) { bool isChanged = false; if (info.Names.ContainsKey(Core.Language)) { selfSummary = info.Names[Core.Language]; } else { selfSummary = ""; } if (info.Descriptions.ContainsKey(Core.Language)) { selfDetail = info.Descriptions[Core.Language]; } else { selfDetail = ""; } var textureKeys = info.Textures.Select(_ => CreateKey(_)).ToList(); foreach (var kts in keyToValues) { if (!textureKeys.Contains(kts.Key)) { var status = kts.Value as ValueStatus; if (status.IsShown) { status.IsShown = false; isChanged = true; } } } var uniformKeys = info.Uniforms.Select(_ => CreateKey(_)).ToList(); foreach (var kts in keyToValues) { if (!uniformKeys.Contains(kts.Key)) { var status = kts.Value as ValueStatus; if (status.IsShown) { status.IsShown = false; isChanged = true; } } } foreach (var texture in info.Textures) { var key = CreateKey(texture); Func <string> getName = () => { var ret = ""; if (texture.Names.ContainsKey(Core.Language)) { ret = texture.Names[Core.Language]; } if (string.IsNullOrEmpty(ret)) { ret = texture.Name; } return(ret); }; Func <string> getDesc = () => { var ret = ""; if (texture.Descriptions.ContainsKey(Core.Language)) { ret = texture.Descriptions[Core.Language]; } return(ret); }; if (keyToValues.ContainsKey(key)) { var status = keyToValues[key] as ValueStatus; if (status.IsShown != texture.IsParam) { status.IsShown = texture.IsParam; isChanged = true; } } else { var status = new ValueStatus(); var value = new Value.PathForImage(Resources.GetString("ImageFilter"), true); status.Key = key; status.Value = value; status.Name = getName(); status.Description = getDesc(); status.IsShown = texture.IsParam; status.Priority = texture.Priority; keyToValues.Add(key, status); value.SetAbsolutePathDirectly(texture.DefaultPath); isChanged = true; } } foreach (var uniform in info.Uniforms) { var key = CreateKey(uniform); Func <string> getName = () => { var ret = ""; if (uniform.Names.ContainsKey(Core.Language)) { ret = uniform.Names[Core.Language]; } if (string.IsNullOrEmpty(ret)) { ret = uniform.Name; } return(ret); }; Func <string> getDesc = () => { var ret = ""; if (uniform.Descriptions.ContainsKey(Core.Language)) { ret = uniform.Descriptions[Core.Language]; } return(ret); }; if (keyToValues.ContainsKey(key)) { var status = keyToValues[key] as ValueStatus; if (!status.IsShown) { status.IsShown = true; isChanged = true; } } else { if (uniform.Type == 0) { var value = new Value.Float(); value.SetValueDirectly(uniform.DefaultValues[0]); var status = new ValueStatus(); status.Key = key; status.Value = value; status.Name = getName(); status.Description = getDesc(); status.IsShown = true; status.Priority = uniform.Priority; keyToValues.Add(key, status); isChanged = true; } else { var value = new Value.Vector4D(); value.X.SetValueDirectly(uniform.DefaultValues[0]); value.Y.SetValueDirectly(uniform.DefaultValues[1]); value.Z.SetValueDirectly(uniform.DefaultValues[2]); value.W.SetValueDirectly(uniform.DefaultValues[3]); var status = new ValueStatus(); status.Key = key; status.Value = value; status.Name = getName(); status.Description = getDesc(); status.IsShown = true; status.Priority = uniform.Priority; keyToValues.Add(key, status); isChanged = true; } } } if (isChanged && OnChanged != null) { OnChanged(this, null); } }
public List <Tuple35 <ValueStatus, Utl.MaterialInformation.UniformInformation> > GetUniforms(Utl.MaterialInformation info) { var ret = new List <Tuple35 <ValueStatus, Utl.MaterialInformation.UniformInformation> >(); foreach (var uniform in info.Uniforms) { var key = CreateKey(uniform); if (keyToValues.ContainsKey(key)) { ret.Add(Tuple35.Create(keyToValues[key] as ValueStatus, uniform)); } else { ret.Add(Tuple35.Create((ValueStatus)(null), uniform)); } } return(ret); }
public void ApplyMaterial(Utl.MaterialInformation info) { bool isChanged = false; var textureKeys = info.Textures.Select(_ => CreateKey(_)).ToList(); foreach (var kts in keyToValues) { if (!textureKeys.Contains(kts.Key)) { var status = valueToStatus[kts.Value]; if (status.IsShown) { status.IsShown = false; isChanged = true; } } } var uniformKeys = info.Uniforms.Select(_ => CreateKey(_)).ToList(); foreach (var kts in keyToValues) { if (!uniformKeys.Contains(kts.Key)) { var status = valueToStatus[kts.Value]; if (status.IsShown) { status.IsShown = false; isChanged = true; } } } foreach (var texture in info.Textures) { var key = CreateKey(texture); if (keyToValues.ContainsKey(key)) { var value = keyToValues[key]; var status = valueToStatus[value]; if (status.IsShown != texture.IsParam) { status.IsShown = texture.IsParam; isChanged = true; } } else { var status = new ValueStatus(); var value = new Value.PathForImage(".png", false); status.Name = texture.Name; status.Description = ""; status.IsShown = texture.IsParam; keyToValues.Add(key, value); valueToStatus.Add(value, status); value.SetAbsolutePathDirectly(texture.DefaultPath); TextureValues.Add(value); isChanged = true; } } foreach (var uniform in info.Uniforms) { var key = CreateKey(uniform); if (keyToValues.ContainsKey(key)) { var value = keyToValues[key]; var status = valueToStatus[value]; if (!status.IsShown) { status.IsShown = true; isChanged = true; } } else { if (uniform.Type == 0) { var status = new ValueStatus(); var value = new Value.Float(); status.Name = uniform.Name; status.Description = ""; status.IsShown = true; keyToValues.Add(key, value); valueToStatus.Add(value, status); UniformValues.Add(value); isChanged = true; } else { var status = new ValueStatus(); var value = new Value.Vector4D(); status.Name = uniform.Name; status.Description = ""; status.IsShown = true; keyToValues.Add(key, value); valueToStatus.Add(value, status); UniformValues.Add(value); isChanged = true; } } } if (isChanged && OnChanged != null) { OnChanged(this, null); } }
public List <Tuple35 <ValueStatus, Utl.MaterialInformation.UniformInformation> > GetUniforms(Utl.MaterialInformation info) { var ret = new List <Tuple35 <ValueStatus, Utl.MaterialInformation.UniformInformation> >(); foreach (var uniform in info.Uniforms) { var key = StatusKey.From(uniform); var value = FindValue(key.ToString()); if (value != null) { ret.Add(Tuple35.Create(value, uniform)); } else { ret.Add(Tuple35.Create((ValueStatus)(null), uniform)); } } return(ret); }
public List <Tuple35 <ValueStatus, Utl.MaterialInformation.TextureInformation> > GetTextures(Utl.MaterialInformation info) { var ret = new List <Tuple35 <ValueStatus, Utl.MaterialInformation.TextureInformation> >(); HashSet <ValueStatus> usedValueStatuses = new HashSet <ValueStatus>(); foreach (var texture in info.Textures) { var key = StatusKey.From(texture); var value = FindValue(key.ToString(), usedValueStatuses); if (value != null) { ret.Add(Tuple35.Create(value, texture)); usedValueStatuses.Add(value); } else { ret.Add(Tuple35.Create((ValueStatus)(null), texture)); } } return(ret); }
public void ApplyMaterial(Utl.MaterialInformation info) { bool isChanged = false; var previous_selfSummary = selfSummary; var previous_selfDetail = selfDetail; if (info.Names.ContainsKey(Core.Language)) { selfSummary = info.Names[Core.Language]; } else { selfSummary = ""; } if (info.Descriptions.ContainsKey(Core.Language)) { selfDetail = info.Descriptions[Core.Language]; } else { selfDetail = ""; } if (previous_selfSummary != selfSummary) { isChanged = true; } if (previous_selfDetail != selfDetail) { isChanged = true; } HashSet <ValueStatus> usedValueStatuses = new HashSet <ValueStatus>(); HashSet <object> finished = new HashSet <object>(); foreach (var withNameFlag in new[] { false, true }) { foreach (var texture in info.Textures) { if (finished.Contains(texture)) { continue; } var key = StatusKey.From(texture); Func <string> getName = () => { var ret = ""; if (texture.Summaries.ContainsKey(Core.Language)) { ret = texture.Summaries[Core.Language]; } if (string.IsNullOrEmpty(ret)) { ret = texture.Name; } if (string.IsNullOrEmpty(ret)) { ret = texture.UniformName; } return(ret); }; Func <string> getDesc = () => { var ret = ""; if (texture.Descriptions.ContainsKey(Core.Language)) { ret = texture.Descriptions[Core.Language]; } return(ret); }; ValueStatus status = null; string defaultPath = Utils.Misc.GetAbsolutePath(Path.AbsolutePath, texture.DefaultPath); var foundValue = FindValue(key.ToString(), usedValueStatuses, withNameFlag); if (foundValue != null) { status = foundValue; if (status.IsShown != texture.IsParam) { status.IsShown = texture.IsParam; isChanged = true; } // update default path if (texture.IsParam) { if ((foundValue.Value as Value.PathForImage).AbsolutePath == string.Empty) { (foundValue.Value as Value.PathForImage).SetAbsolutePathDirectly(defaultPath); isChanged = true; } (foundValue.Value as Value.PathForImage).SetDefaultAbsolutePath(defaultPath); } else { if ((foundValue.Value as Value.PathForImage).AbsolutePath != defaultPath) { (foundValue.Value as Value.PathForImage).SetAbsolutePathDirectly(defaultPath); isChanged = true; } (foundValue.Value as Value.PathForImage).SetDefaultAbsolutePath(defaultPath); } } else { // create only when value is not found even if withName flag is true if (!withNameFlag) { continue; } status = new ValueStatus(); var value = new Value.PathForImage(rcValues.BasePath, Resources.GetString("ImageFilter"), true, texture.DefaultPath); status.Value = value; status.IsShown = texture.IsParam; status.Priority = texture.Priority; valueStatuses.Add(status); if (!string.IsNullOrEmpty(defaultPath)) { value.SetAbsolutePathDirectly(defaultPath); } isChanged = true; } if (status.Name != getName()) { isChanged = true; } if (status.Description != getDesc()) { isChanged = true; } status.Key = key; status.Name = getName(); status.Description = getDesc(); usedValueStatuses.Add(status); finished.Add(texture); } foreach (var uniform in info.Uniforms) { if (finished.Contains(uniform)) { continue; } var key = StatusKey.From(uniform); Func <string> getName = () => { var ret = ""; if (uniform.Summaries.ContainsKey(Core.Language)) { ret = uniform.Summaries[Core.Language]; } if (string.IsNullOrEmpty(ret)) { ret = uniform.Name; } if (string.IsNullOrEmpty(ret)) { ret = uniform.UniformName; } return(ret); }; Func <string> getDesc = () => { var ret = ""; if (uniform.Descriptions.ContainsKey(Core.Language)) { ret = uniform.Descriptions[Core.Language]; } return(ret); }; ValueStatus status = null; var foundValue = FindValue(key.ToString(), usedValueStatuses, withNameFlag); if (foundValue != null) { status = foundValue; status.IsShown = true; isChanged = true; if (uniform.Type == 0) { (status.Value as Value.Float).ChangeDefaultValue(uniform.DefaultValues[0]); } else if (uniform.Type == 1) { (status.Value as Value.Vector2D).ChangeDefaultValue(uniform.DefaultValues[0], uniform.DefaultValues[1]); } else if (uniform.Type == 2) { (status.Value as Value.Vector3D).ChangeDefaultValue(uniform.DefaultValues[0], uniform.DefaultValues[1], uniform.DefaultValues[2]); } else { (status.Value as Value.Vector4D).ChangeDefaultValue(uniform.DefaultValues[0], uniform.DefaultValues[1], uniform.DefaultValues[2], uniform.DefaultValues[3]); } } else { // create only when value is not found even if withName flag is true if (!withNameFlag) { continue; } if (uniform.Type == 0) { status = new ValueStatus(); var value = new Value.Float(uniform.DefaultValues[0]); value.SetValueDirectly(uniform.DefaultValues[0]); status.Value = value; status.IsShown = true; status.Priority = uniform.Priority; valueStatuses.Add(status); isChanged = true; } else if (uniform.Type == 1) { status = new ValueStatus(); var value = new Value.Vector2D(uniform.DefaultValues[0], uniform.DefaultValues[1]); value.X.SetValueDirectly(uniform.DefaultValues[0]); value.Y.SetValueDirectly(uniform.DefaultValues[1]); status.Value = value; status.IsShown = true; status.Priority = uniform.Priority; valueStatuses.Add(status); isChanged = true; } else if (uniform.Type == 2) { status = new ValueStatus(); var value = new Value.Vector3D(uniform.DefaultValues[0], uniform.DefaultValues[1], uniform.DefaultValues[2]); value.X.SetValueDirectly(uniform.DefaultValues[0]); value.Y.SetValueDirectly(uniform.DefaultValues[1]); value.Z.SetValueDirectly(uniform.DefaultValues[2]); status.Value = value; status.IsShown = true; status.Priority = uniform.Priority; valueStatuses.Add(status); isChanged = true; } else { status = new ValueStatus(); var value = new Value.Vector4D(uniform.DefaultValues[0], uniform.DefaultValues[1], uniform.DefaultValues[2], uniform.DefaultValues[3]); value.X.SetValueDirectly(uniform.DefaultValues[0]); value.Y.SetValueDirectly(uniform.DefaultValues[1]); value.Z.SetValueDirectly(uniform.DefaultValues[2]); value.W.SetValueDirectly(uniform.DefaultValues[3]); status.Value = value; status.IsShown = true; status.Priority = uniform.Priority; valueStatuses.Add(status); isChanged = true; } } if (status.Name != getName()) { isChanged = true; } if (status.Description != getDesc()) { isChanged = true; } status.Key = key; status.Name = getName(); status.Description = getDesc(); usedValueStatuses.Add(status); finished.Add(uniform); } } foreach (var kts in valueStatuses) { if (!usedValueStatuses.Contains(kts)) { var status = kts; if (status.IsShown) { status.IsShown = false; isChanged = true; } } } if (info.CustomData.Count() > 0) { rcValues.CustomData1.Fixed4.ChangeDefaultValue( info.CustomData[0].DefaultValues[0], info.CustomData[0].DefaultValues[1], info.CustomData[0].DefaultValues[2], info.CustomData[0].DefaultValues[3]); } if (info.CustomData.Count() > 1) { rcValues.CustomData2.Fixed4.ChangeDefaultValue( info.CustomData[1].DefaultValues[0], info.CustomData[1].DefaultValues[1], info.CustomData[1].DefaultValues[2], info.CustomData[1].DefaultValues[3]); } if (isChanged && OnChanged != null) { OnChanged(this, null); } }
public List <Tuple35 <ValueStatus, Utl.MaterialInformation.TextureInformation> > GetTextures(Utl.MaterialInformation info) { var ret = new List <Tuple35 <ValueStatus, Utl.MaterialInformation.TextureInformation> >(); foreach (var texture in info.Textures) { var key = CreateKey(texture); if (keyToValues.ContainsKey(key)) { ret.Add(Tuple35.Create(keyToValues[key] as ValueStatus, texture)); } else { ret.Add(Tuple35.Create((ValueStatus)(null), texture)); } } return(ret); }
public static byte[] GetBytes(Data.RendererCommonValues value, Dictionary <string, int> texture_and_index, Dictionary <string, int> distortionTexture_and_index) #endif { List <byte[]> data = new List <byte[]>(); var texInfo = new TextureInformation(); var hasTexture = true; #if MATERIAL_ENABLED data.Add(((int)value.Material.Value).GetBytes()); if (value.Material.Value == Data.RendererCommonValues.MaterialType.Default) { // テクスチャ番号 if (value.Distortion.Value) { if (value.ColorTexture.RelativePath != string.Empty && distortionTexture_and_index.ContainsKey(value.ColorTexture.RelativePath) && texInfo.Load(value.ColorTexture.AbsolutePath)) { data.Add(distortionTexture_and_index[value.ColorTexture.RelativePath].GetBytes()); hasTexture = true; } else { data.Add((-1).GetBytes()); hasTexture = false; } } else { if (value.ColorTexture.RelativePath != string.Empty && texture_and_index.ContainsKey(value.ColorTexture.RelativePath) && texInfo.Load(value.ColorTexture.AbsolutePath)) { data.Add(texture_and_index[value.ColorTexture.RelativePath].GetBytes()); hasTexture = true; } else { data.Add((-1).GetBytes()); hasTexture = false; } } } else { var materialInfo = new Utl.MaterialInformation(); materialInfo.Load(value.MaterialFile.Path.AbsolutePath); var textures = value.MaterialFile.GetTextures(materialInfo); var uniforms = value.MaterialFile.GetUniforms(materialInfo); if (material_and_index.ContainsKey(value.MaterialFile.Path.RelativePath)) { data.Add(material_and_index[value.MaterialFile.Path.RelativePath].GetBytes()); } else { data.Add((-1).GetBytes()); } data.Add(textures.Count.GetBytes()); foreach (var texture in textures) { if (texture.Item2) { if (texture.Item1.RelativePath != string.Empty && normalTexture_and_index.ContainsKey(texture.Item1.RelativePath) && texInfo.Load(texture.Item1.AbsolutePath)) { data.Add((1).GetBytes()); data.Add(normalTexture_and_index[texture.Item1.RelativePath].GetBytes()); hasTexture = true; } else { data.Add((1).GetBytes()); data.Add((-1).GetBytes()); hasTexture = false; } } else { if (texture.Item1.RelativePath != string.Empty && texture_and_index.ContainsKey(texture.Item1.RelativePath) && texInfo.Load(texture.Item1.AbsolutePath)) { data.Add((0).GetBytes()); data.Add(texture_and_index[texture.Item1.RelativePath].GetBytes()); hasTexture = true; } else { data.Add((0).GetBytes()); data.Add((-1).GetBytes()); hasTexture = false; } } } data.Add(uniforms.Count.GetBytes()); foreach (var uniform in uniforms) { float[] floats = new float[4]; if (uniform is Data.Value.Float) { floats[0] = (uniform as Data.Value.Float).Value; } if (uniform is Data.Value.Vector2D) { floats[0] = (uniform as Data.Value.Vector2D).X.Value; floats[1] = (uniform as Data.Value.Vector2D).Y.Value; } if (uniform is Data.Value.Vector3D) { floats[0] = (uniform as Data.Value.Vector3D).X.Value; floats[1] = (uniform as Data.Value.Vector3D).Y.Value; floats[2] = (uniform as Data.Value.Vector3D).Z.Value; } if (uniform is Data.Value.Vector4D) { floats[0] = (uniform as Data.Value.Vector4D).X.Value; floats[1] = (uniform as Data.Value.Vector4D).Y.Value; floats[2] = (uniform as Data.Value.Vector4D).Z.Value; floats[3] = (uniform as Data.Value.Vector4D).W.Value; } data.Add(floats[0].GetBytes()); data.Add(floats[1].GetBytes()); data.Add(floats[2].GetBytes()); data.Add(floats[3].GetBytes()); } } #else // テクスチャ番号 if (value.Distortion.Value) { if (value.ColorTexture.RelativePath != string.Empty && distortionTexture_and_index.ContainsKey(value.ColorTexture.RelativePath) && texInfo.Load(value.ColorTexture.AbsolutePath)) { data.Add(distortionTexture_and_index[value.ColorTexture.RelativePath].GetBytes()); hasTexture = true; } else { data.Add((-1).GetBytes()); hasTexture = false; } } else { if (value.ColorTexture.RelativePath != string.Empty && texture_and_index.ContainsKey(value.ColorTexture.RelativePath) && texInfo.Load(value.ColorTexture.AbsolutePath)) { data.Add(texture_and_index[value.ColorTexture.RelativePath].GetBytes()); hasTexture = true; } else { data.Add((-1).GetBytes()); hasTexture = false; } } #endif data.Add(value.AlphaBlend); data.Add(value.Filter); data.Add(value.Wrap); if (value.ZTest.GetValue()) { data.Add((1).GetBytes()); } else { data.Add((0).GetBytes()); } if (value.ZWrite.GetValue()) { data.Add((1).GetBytes()); } else { data.Add((0).GetBytes()); } data.Add(value.FadeInType); if (value.FadeInType.Value == Data.RendererCommonValues.FadeType.Use) { data.Add(value.FadeIn.Frame.GetBytes()); var easing = Utl.MathUtl.Easing((float)value.FadeIn.StartSpeed.Value, (float)value.FadeIn.EndSpeed.Value); data.Add(BitConverter.GetBytes(easing[0])); data.Add(BitConverter.GetBytes(easing[1])); data.Add(BitConverter.GetBytes(easing[2])); } data.Add(value.FadeOutType); if (value.FadeOutType.Value == Data.RendererCommonValues.FadeType.Use) { data.Add(value.FadeOut.Frame.GetBytes()); var easing = Utl.MathUtl.Easing((float)value.FadeOut.StartSpeed.Value, (float)value.FadeOut.EndSpeed.Value); data.Add(BitConverter.GetBytes(easing[0])); data.Add(BitConverter.GetBytes(easing[1])); data.Add(BitConverter.GetBytes(easing[2])); } if (hasTexture) { var width = (float)texInfo.Width; var height = (float)texInfo.Height; data.Add(value.UV); if (value.UV.Value == Data.RendererCommonValues.UVType.Default) { } else if (value.UV.Value == Data.RendererCommonValues.UVType.Fixed) { var value_ = value.UVFixed; data.Add((value_.Start.X / width).GetBytes()); data.Add((value_.Start.Y / height).GetBytes()); data.Add((value_.Size.X / width).GetBytes()); data.Add((value_.Size.Y / height).GetBytes()); } else if (value.UV.Value == Data.RendererCommonValues.UVType.Animation) { var value_ = value.UVAnimation; data.Add((value_.Start.X / width).GetBytes()); data.Add((value_.Start.Y / height).GetBytes()); data.Add((value_.Size.X / width).GetBytes()); data.Add((value_.Size.Y / height).GetBytes()); if (value_.FrameLength.Infinite) { var inf = int.MaxValue / 100; data.Add(inf.GetBytes()); } else { data.Add(value_.FrameLength.Value.Value.GetBytes()); } data.Add(value_.FrameCountX.Value.GetBytes()); data.Add(value_.FrameCountY.Value.GetBytes()); data.Add(value_.LoopType); data.Add(value_.StartSheet.Max.GetBytes()); data.Add(value_.StartSheet.Min.GetBytes()); } else if (value.UV.Value == Data.RendererCommonValues.UVType.Scroll) { var value_ = value.UVScroll; data.Add((value_.Start.X.Max / width).GetBytes()); data.Add((value_.Start.Y.Max / height).GetBytes()); data.Add((value_.Start.X.Min / width).GetBytes()); data.Add((value_.Start.Y.Min / height).GetBytes()); data.Add((value_.Size.X.Max / width).GetBytes()); data.Add((value_.Size.Y.Max / height).GetBytes()); data.Add((value_.Size.X.Min / width).GetBytes()); data.Add((value_.Size.Y.Min / height).GetBytes()); data.Add((value_.Speed.X.Max / width).GetBytes()); data.Add((value_.Speed.Y.Max / height).GetBytes()); data.Add((value_.Speed.X.Min / width).GetBytes()); data.Add((value_.Speed.Y.Min / height).GetBytes()); } else if (value.UV.Value == Data.RendererCommonValues.UVType.FCurve) { { var value_ = value.UVFCurve.Start; var bytes1 = value_.GetBytes(1.0f / width); List <byte[]> _data = new List <byte[]>(); data.Add(bytes1); } { var value_ = value.UVFCurve.Size; var bytes1 = value_.GetBytes(1.0f / height); List <byte[]> _data = new List <byte[]>(); data.Add(bytes1); } } } else { data.Add(((int)Data.RendererCommonValues.UVType.Default).GetBytes()); } // Inheritance data.Add(value.ColorInheritType.GetValueAsInt().GetBytes()); // 歪み if (value.Distortion.GetValue()) { data.Add((1).GetBytes()); } else { data.Add((0).GetBytes()); } data.Add(value.DistortionIntensity.GetBytes()); return(data.ToArray().ToArray()); }
public static byte[] GetBytes(Data.RendererCommonValues value, Dictionary <string, int> texture_and_index, Dictionary <string, int> normalTexture_and_index, Dictionary <string, int> distortionTexture_and_index, Dictionary <string, int> material_and_index) { List <byte[]> data = new List <byte[]>(); var texInfo = new TextureInformation(); data.Add(((int)value.Material.Value).GetBytes()); Func <Data.Value.PathForImage, int, Dictionary <string, int>, int> getTexIDAndStoreSize = (Data.Value.PathForImage image, int number, Dictionary <string, int> texAndInd) => { var tempTexInfo = new TextureInformation(); if (texAndInd.ContainsKey(image.RelativePath) && tempTexInfo.Load(image.AbsolutePath)) { if (value.UVTextureReferenceTarget.Value != Data.UVTextureReferenceTargetType.None && number == (int)value.UVTextureReferenceTarget.Value) { texInfo.Load(image.AbsolutePath); } return(texAndInd[image.RelativePath]); } else { return(-1); } }; if (value.Material.Value == Data.RendererCommonValues.MaterialType.Default) { // texture1 data.Add(getTexIDAndStoreSize(value.ColorTexture, 1, texture_and_index).GetBytes()); // texture2 data.Add((-1).GetBytes()); } else if (value.Material.Value == Data.RendererCommonValues.MaterialType.BackDistortion) { // texture1 data.Add(getTexIDAndStoreSize(value.ColorTexture, 1, distortionTexture_and_index).GetBytes()); // texture2 data.Add((-1).GetBytes()); } else if (value.Material.Value == Data.RendererCommonValues.MaterialType.Lighting) { // texture1 data.Add(getTexIDAndStoreSize(value.ColorTexture, 1, texture_and_index).GetBytes()); // texture2 data.Add(getTexIDAndStoreSize(value.NormalTexture, 2, normalTexture_and_index).GetBytes()); } else { var materialInfo = new Utl.MaterialInformation(); materialInfo.Load(value.MaterialFile.Path.AbsolutePath); var textures = value.MaterialFile.GetTextures(materialInfo).Where(_ => _.Item1 != null).ToArray(); var uniforms = value.MaterialFile.GetUniforms(materialInfo); // maximum slot limitation if (textures.Length > Constant.UserTextureSlotCount) { textures = textures.Take(Constant.UserTextureSlotCount).ToArray(); } if (material_and_index.ContainsKey(value.MaterialFile.Path.RelativePath)) { data.Add(material_and_index[value.MaterialFile.Path.RelativePath].GetBytes()); } else { data.Add((-1).GetBytes()); } data.Add(textures.Length.GetBytes()); foreach (var texture in textures) { var texture_ = texture.Item1.Value as Data.Value.PathForImage; if (texture.Item2.Type == TextureType.Value) { data.Add((1).GetBytes()); data.Add(getTexIDAndStoreSize(texture_, texture.Item2.Priority, normalTexture_and_index).GetBytes()); } else { data.Add((0).GetBytes()); data.Add(getTexIDAndStoreSize(texture_, texture.Item2.Priority, texture_and_index).GetBytes()); } } data.Add(uniforms.Count.GetBytes()); foreach (var uniform in uniforms) { float[] floats = new float[4]; if (uniform.Item1 == null) { floats = uniform.Item2.DefaultValues.ToArray(); } else if (uniform.Item1.Value is Data.Value.Float) { floats[0] = (uniform.Item1.Value as Data.Value.Float).Value; } else if (uniform.Item1.Value is Data.Value.Vector4D) { floats[0] = (uniform.Item1.Value as Data.Value.Vector4D).X.Value; floats[1] = (uniform.Item1.Value as Data.Value.Vector4D).Y.Value; floats[2] = (uniform.Item1.Value as Data.Value.Vector4D).Z.Value; floats[3] = (uniform.Item1.Value as Data.Value.Vector4D).W.Value; } data.Add(floats[0].GetBytes()); data.Add(floats[1].GetBytes()); data.Add(floats[2].GetBytes()); data.Add(floats[3].GetBytes()); } } data.Add(value.AlphaBlend); data.Add(value.Filter); data.Add(value.Wrap); data.Add(value.Filter2); data.Add(value.Wrap2); if (value.ZTest.GetValue()) { data.Add((1).GetBytes()); } else { data.Add((0).GetBytes()); } if (value.ZWrite.GetValue()) { data.Add((1).GetBytes()); } else { data.Add((0).GetBytes()); } data.Add(value.FadeInType); if (value.FadeInType.Value == Data.RendererCommonValues.FadeType.Use) { data.Add(value.FadeIn.Frame.GetBytes()); var easing = Utl.MathUtl.Easing((float)value.FadeIn.StartSpeed.Value, (float)value.FadeIn.EndSpeed.Value); data.Add(BitConverter.GetBytes(easing[0])); data.Add(BitConverter.GetBytes(easing[1])); data.Add(BitConverter.GetBytes(easing[2])); } data.Add(value.FadeOutType); if (value.FadeOutType.Value == Data.RendererCommonValues.FadeType.Use) { data.Add(value.FadeOut.Frame.GetBytes()); var easing = Utl.MathUtl.Easing((float)value.FadeOut.StartSpeed.Value, (float)value.FadeOut.EndSpeed.Value); data.Add(BitConverter.GetBytes(easing[0])); data.Add(BitConverter.GetBytes(easing[1])); data.Add(BitConverter.GetBytes(easing[2])); } // sprcification change(1.5) float width = 128.0f; float height = 128.0f; if (texInfo.Width > 0 && texInfo.Height > 0) { width = (float)texInfo.Width; height = (float)texInfo.Height; } data.Add(value.UV); if (value.UV.Value == Data.RendererCommonValues.UVType.Default) { } else if (value.UV.Value == Data.RendererCommonValues.UVType.Fixed) { var value_ = value.UVFixed; data.Add((value_.Start.X / width).GetBytes()); data.Add((value_.Start.Y / height).GetBytes()); data.Add((value_.Size.X / width).GetBytes()); data.Add((value_.Size.Y / height).GetBytes()); } else if (value.UV.Value == Data.RendererCommonValues.UVType.Animation) { var value_ = value.UVAnimation; data.Add((value_.Start.X / width).GetBytes()); data.Add((value_.Start.Y / height).GetBytes()); data.Add((value_.Size.X / width).GetBytes()); data.Add((value_.Size.Y / height).GetBytes()); if (value_.FrameLength.Infinite) { var inf = int.MaxValue / 100; data.Add(inf.GetBytes()); } else { data.Add(value_.FrameLength.Value.Value.GetBytes()); } data.Add(value_.FrameCountX.Value.GetBytes()); data.Add(value_.FrameCountY.Value.GetBytes()); data.Add(value_.LoopType); data.Add(value_.StartSheet.Max.GetBytes()); data.Add(value_.StartSheet.Min.GetBytes()); } else if (value.UV.Value == Data.RendererCommonValues.UVType.Scroll) { var value_ = value.UVScroll; data.Add((value_.Start.X.Max / width).GetBytes()); data.Add((value_.Start.Y.Max / height).GetBytes()); data.Add((value_.Start.X.Min / width).GetBytes()); data.Add((value_.Start.Y.Min / height).GetBytes()); data.Add((value_.Size.X.Max / width).GetBytes()); data.Add((value_.Size.Y.Max / height).GetBytes()); data.Add((value_.Size.X.Min / width).GetBytes()); data.Add((value_.Size.Y.Min / height).GetBytes()); data.Add((value_.Speed.X.Max / width).GetBytes()); data.Add((value_.Speed.Y.Max / height).GetBytes()); data.Add((value_.Speed.X.Min / width).GetBytes()); data.Add((value_.Speed.Y.Min / height).GetBytes()); } else if (value.UV.Value == Data.RendererCommonValues.UVType.FCurve) { { var value_ = value.UVFCurve.Start; var bytes1 = value_.GetBytes(1.0f / width); List <byte[]> _data = new List <byte[]>(); data.Add(bytes1); } { var value_ = value.UVFCurve.Size; var bytes1 = value_.GetBytes(1.0f / height); List <byte[]> _data = new List <byte[]>(); data.Add(bytes1); } } // Inheritance data.Add(value.ColorInheritType.GetValueAsInt().GetBytes()); // Distortion data.Add(value.DistortionIntensity.GetBytes()); // Custom data1 from 1.5 data.Add(value.CustomData1.CustomData); if (value.CustomData1.CustomData.Value == Data.CustomDataType.Fixed2D) { data.Add(BitConverter.GetBytes(value.CustomData1.Fixed.X.Value)); data.Add(BitConverter.GetBytes(value.CustomData1.Fixed.Y.Value)); } else if (value.CustomData1.CustomData.Value == Data.CustomDataType.Easing2D) { var easing = Utl.MathUtl.Easing((float)value.CustomData1.Easing.StartSpeed.Value, (float)value.CustomData1.Easing.EndSpeed.Value); List <byte[]> _data = new List <byte[]>(); _data.Add(value.CustomData1.Easing.Start.GetBytes(1.0f)); _data.Add(value.CustomData1.Easing.End.GetBytes(1.0f)); _data.Add(BitConverter.GetBytes(easing[0])); _data.Add(BitConverter.GetBytes(easing[1])); _data.Add(BitConverter.GetBytes(easing[2])); var __data = _data.ToArray().ToArray(); data.Add(__data); } else if (value.CustomData1.CustomData.Value == Data.CustomDataType.FCurve2D) { var value_ = value.CustomData1.FCurve; var bytes1 = value_.GetBytes(1.0f); data.Add(bytes1); } else if (value.CustomData1.CustomData.Value == Data.CustomDataType.Fixed4D) { data.Add(BitConverter.GetBytes(value.CustomData1.Fixed4.X.Value)); data.Add(BitConverter.GetBytes(value.CustomData1.Fixed4.Y.Value)); data.Add(BitConverter.GetBytes(value.CustomData1.Fixed4.Z.Value)); data.Add(BitConverter.GetBytes(value.CustomData1.Fixed4.W.Value)); } else if (value.CustomData1.CustomData.Value == Data.CustomDataType.FCurveColor) { var bytes = value.CustomData1.FCurveColor.GetBytes(); data.Add(bytes); } // Custom data2 from 1.5 data.Add(value.CustomData2.CustomData); if (value.CustomData2.CustomData.Value == Data.CustomDataType.Fixed2D) { data.Add(BitConverter.GetBytes(value.CustomData2.Fixed.X.Value)); data.Add(BitConverter.GetBytes(value.CustomData2.Fixed.Y.Value)); } else if (value.CustomData2.CustomData.Value == Data.CustomDataType.Easing2D) { var easing = Utl.MathUtl.Easing((float)value.CustomData2.Easing.StartSpeed.Value, (float)value.CustomData2.Easing.EndSpeed.Value); List <byte[]> _data = new List <byte[]>(); _data.Add(value.CustomData2.Easing.Start.GetBytes(1.0f)); _data.Add(value.CustomData2.Easing.End.GetBytes(1.0f)); _data.Add(BitConverter.GetBytes(easing[0])); _data.Add(BitConverter.GetBytes(easing[1])); _data.Add(BitConverter.GetBytes(easing[2])); var __data = _data.ToArray().ToArray(); data.Add(__data); } else if (value.CustomData2.CustomData.Value == Data.CustomDataType.FCurve2D) { var value_ = value.CustomData2.FCurve; var bytes1 = value_.GetBytes(1.0f); data.Add(bytes1); } else if (value.CustomData2.CustomData.Value == Data.CustomDataType.Fixed4D) { data.Add(BitConverter.GetBytes(value.CustomData2.Fixed4.X.Value)); data.Add(BitConverter.GetBytes(value.CustomData2.Fixed4.Y.Value)); data.Add(BitConverter.GetBytes(value.CustomData2.Fixed4.Z.Value)); data.Add(BitConverter.GetBytes(value.CustomData2.Fixed4.W.Value)); } else if (value.CustomData2.CustomData.Value == Data.CustomDataType.FCurveColor) { var bytes = value.CustomData2.FCurveColor.GetBytes(); data.Add(bytes); } return(data.ToArray().ToArray()); }
/// <summary> /// エフェクトデータの出力 /// </summary> /// <returns></returns> public byte[] Export(float magnification = 1.0f) { List <byte[]> data = new List <byte[]>(); // ヘッダ data.Add(Encoding.UTF8.GetBytes("SKFE")); // バージョン data.Add(BitConverter.GetBytes(Version)); // reset texture names UsedTextures = new HashSet <string>(); UsedNormalTextures = new HashSet <string>(); UsedDistortionTextures = new HashSet <string>(); Sounds = new HashSet <string>(); Models = new HashSet <string>(); #if MATERIAL_ENABLED HashSet <string> materials = new HashSet <string>(); #endif Action <Data.NodeBase> get_textures = null; get_textures = (node) => { if (node is Data.Node) { var _node = node as Data.Node; if (!_node.IsRendered) { } else { #if MATERIAL_ENABLED if (_node.RendererCommonValues.Material.Value == Data.RendererCommonValues.MaterialType.Default) { var relative_path = _node.RendererCommonValues.ColorTexture.RelativePath; if (relative_path != string.Empty) { if (_node.RendererCommonValues.Distortion.Value) { if (!UsedDistortionTextures.Contains(relative_path)) { UsedDistortionTextures.Add(relative_path); } } else { if (!UsedTextures.Contains(relative_path)) { UsedTextures.Add(relative_path); } } } } else if (_node.RendererCommonValues.Material.Value == Data.RendererCommonValues.MaterialType.File) { var materialInfo = new Utl.MaterialInformation(); materialInfo.Load(_node.RendererCommonValues.MaterialFile.Path.AbsolutePath); var textures = _node.RendererCommonValues.MaterialFile.GetTextures(materialInfo); foreach (var texture in textures) { var relative_path = texture.Item1.RelativePath; if (relative_path != string.Empty) { if (texture.Item2) { if (!UsedNormalTextures.Contains(relative_path)) { UsedNormalTextures.Add(relative_path); } } else { if (!UsedTextures.Contains(relative_path)) { UsedTextures.Add(relative_path); } } } } } #else { var relative_path = _node.RendererCommonValues.ColorTexture.RelativePath; if (relative_path != string.Empty) { if (_node.RendererCommonValues.Distortion.Value) { if (!UsedDistortionTextures.Contains(relative_path)) { UsedDistortionTextures.Add(relative_path); } } else { if (!UsedTextures.Contains(relative_path)) { UsedTextures.Add(relative_path); } } } } #endif { var relative_path = _node.DrawingValues.Model.NormalTexture.RelativePath; if (relative_path != string.Empty) { if (!UsedNormalTextures.Contains(relative_path)) { UsedNormalTextures.Add(relative_path); } } } } } for (int i = 0; i < node.Children.Count; i++) { get_textures(node.Children[i]); } }; get_textures(Core.Root); Dictionary <string, int> texture_and_index = new Dictionary <string, int>(); { int index = 0; foreach (var texture in UsedTextures.ToList().OrderBy(_ => _)) { texture_and_index.Add(texture, index); index++; } } Dictionary <string, int> normalTexture_and_index = new Dictionary <string, int>(); { int index = 0; foreach (var texture in UsedNormalTextures.ToList().OrderBy(_ => _)) { normalTexture_and_index.Add(texture, index); index++; } } Dictionary <string, int> distortionTexture_and_index = new Dictionary <string, int>(); { int index = 0; foreach (var texture in UsedDistortionTextures.ToList().OrderBy(_ => _)) { distortionTexture_and_index.Add(texture, index); index++; } } Action <Data.NodeBase> get_waves = null; get_waves = (node) => { if (node is Data.Node) { var _node = node as Data.Node; if (_node.SoundValues.Type.GetValue() == Data.SoundValues.ParamaterType.None) { } else if (_node.SoundValues.Type.GetValue() == Data.SoundValues.ParamaterType.Use) { var relative_path = _node.SoundValues.Sound.Wave.RelativePath; if (relative_path != string.Empty) { if (!Sounds.Contains(relative_path)) { Sounds.Add(relative_path); } } } } for (int i = 0; i < node.Children.Count; i++) { get_waves(node.Children[i]); } }; get_waves(Core.Root); Dictionary <string, int> wave_and_index = new Dictionary <string, int>(); { int index = 0; foreach (var wave in Sounds.ToList().OrderBy(_ => _)) { wave_and_index.Add(wave, index); index++; } } Action <Data.NodeBase> get_models = null; get_models = (node) => { if (node is Data.Node) { var _node = node as Data.Node; if (_node.IsRendered && _node.DrawingValues.Type.Value == Data.RendererValues.ParamaterType.Model) { var relative_path = _node.DrawingValues.Model.Model.RelativePath; if (!string.IsNullOrEmpty(relative_path)) { if (string.IsNullOrEmpty(System.IO.Path.GetDirectoryName(relative_path))) { relative_path = System.IO.Path.GetFileNameWithoutExtension(relative_path) + ".efkmodel"; } else { relative_path = System.IO.Path.GetDirectoryName(relative_path) + "/" + System.IO.Path.GetFileNameWithoutExtension(relative_path) + ".efkmodel"; } if (relative_path != string.Empty) { if (!Models.Contains(relative_path)) { Models.Add(relative_path); } } } } if (_node.GenerationLocationValues.Type.Value == Data.GenerationLocationValues.ParameterType.Model) { var relative_path = _node.GenerationLocationValues.Model.Model.RelativePath; if (!string.IsNullOrEmpty(relative_path)) { if (string.IsNullOrEmpty(System.IO.Path.GetDirectoryName(relative_path))) { relative_path = System.IO.Path.GetFileNameWithoutExtension(relative_path) + ".efkmodel"; } else { relative_path = System.IO.Path.GetDirectoryName(relative_path) + "/" + System.IO.Path.GetFileNameWithoutExtension(relative_path) + ".efkmodel"; } if (relative_path != string.Empty) { if (!Models.Contains(relative_path)) { Models.Add(relative_path); } } } } } for (int i = 0; i < node.Children.Count; i++) { get_models(node.Children[i]); } }; get_models(Core.Root); Dictionary <string, int> model_and_index = new Dictionary <string, int>(); { int index = 0; foreach (var model in Models.ToList().OrderBy(_ => _)) { model_and_index.Add(model, index); index++; } } #if MATERIAL_ENABLED Action <Data.NodeBase> get_materials = null; get_materials = (node) => { if (node is Data.Node) { var _node = node as Data.Node; if (_node.RendererCommonValues.Material.Value == Data.RendererCommonValues.MaterialType.File) { var relative_path = _node.RendererCommonValues.MaterialFile.Path.RelativePath; if (relative_path != string.Empty) { if (!materials.Contains(relative_path)) { materials.Add(relative_path); } } } } for (int i = 0; i < node.Children.Count; i++) { get_materials(node.Children[i]); } }; get_materials(Core.Root); Dictionary <string, int> material_and_index = new Dictionary <string, int>(); { int index = 0; foreach (var wave in materials.ToList().OrderBy(_ => _)) { material_and_index.Add(wave, index); index++; } } #endif // get all nodes var nodes = new List <Data.Node>(); Action <Data.NodeBase> get_nodes = null; get_nodes = (node) => { if (node is Data.Node) { var _node = node as Data.Node; nodes.Add(_node); } for (int i = 0; i < node.Children.Count; i++) { get_nodes(node.Children[i]); } }; get_nodes(Core.Root); var snode2ind = nodes. Select((v, i) => Tuple35.Create(v, i)). OrderBy(_ => _.Item1.DepthValues.DrawingPriority.Value * 255 + _.Item2). Select((v, i) => Tuple35.Create(v.Item1, i)).ToList(); // ファイルにテクスチャ一覧出力 data.Add(BitConverter.GetBytes(texture_and_index.Count)); foreach (var texture in texture_and_index) { var path = Encoding.Unicode.GetBytes(texture.Key); data.Add(((path.Count() + 2) / 2).GetBytes()); data.Add(path); data.Add(new byte[] { 0, 0 }); } data.Add(BitConverter.GetBytes(normalTexture_and_index.Count)); foreach (var texture in normalTexture_and_index) { var path = Encoding.Unicode.GetBytes(texture.Key); data.Add(((path.Count() + 2) / 2).GetBytes()); data.Add(path); data.Add(new byte[] { 0, 0 }); } data.Add(BitConverter.GetBytes(distortionTexture_and_index.Count)); foreach (var texture in distortionTexture_and_index) { var path = Encoding.Unicode.GetBytes(texture.Key); data.Add(((path.Count() + 2) / 2).GetBytes()); data.Add(path); data.Add(new byte[] { 0, 0 }); } // ファイルにウェーブ一覧出力 data.Add(BitConverter.GetBytes(wave_and_index.Count)); foreach (var wave in wave_and_index) { var path = Encoding.Unicode.GetBytes(wave.Key); data.Add(((path.Count() + 2) / 2).GetBytes()); data.Add(path); data.Add(new byte[] { 0, 0 }); } // ファイルにモデル一覧出力 data.Add(BitConverter.GetBytes(model_and_index.Count)); foreach (var model in model_and_index) { var path = Encoding.Unicode.GetBytes(model.Key); data.Add(((path.Count() + 2) / 2).GetBytes()); data.Add(path); data.Add(new byte[] { 0, 0 }); } #if MATERIAL_ENABLED // export materials to a file data.Add(BitConverter.GetBytes(material_and_index.Count)); foreach (var material in material_and_index) { var path = Encoding.Unicode.GetBytes(material.Key); data.Add(((path.Count() + 2) / 2).GetBytes()); data.Add(path); data.Add(new byte[] { 0, 0 }); } #endif // export dynamic parameters data.Add(BitConverter.GetBytes(Core.Dynamic.Inputs.Values.Count)); foreach (var value in Core.Dynamic.Inputs.Values) { float value_ = value.Input.Value; data.Add(BitConverter.GetBytes(value_)); } data.Add(BitConverter.GetBytes(Core.Dynamic.Equations.Values.Count)); var compiler = new InternalScript.Compiler(); foreach (var value in Core.Dynamic.Equations.Values) { var cx = compiler.Compile(value.Code.Value); var cs = new [] { cx }; foreach (var c in cs) { if (c.Bytecode != null) { data.Add(BitConverter.GetBytes((int)c.Bytecode.Length)); data.Add(c.Bytecode); } else { data.Add(BitConverter.GetBytes((int)0)); } } } // Export the number of nodes data.Add(BitConverter.GetBytes(snode2ind.Count)); var renderPriorityThreshold = snode2ind.Where(_ => _.Item1.DepthValues.DrawingPriority.Value < 0).Count(); data.Add(BitConverter.GetBytes(renderPriorityThreshold)); // Export magnification data.Add(BitConverter.GetBytes(magnification)); // Export default seed int randomSeed = Core.Global.RandomSeed.Value; data.Add(BitConverter.GetBytes(randomSeed)); // カリングを出力 data.Add(BitConverter.GetBytes((int)Core.Culling.Type.Value)); if (Core.Culling.Type.Value == Data.EffectCullingValues.ParamaterType.Sphere) { data.Add(BitConverter.GetBytes(Core.Culling.Sphere.Radius)); data.Add(BitConverter.GetBytes(Core.Culling.Sphere.Location.X)); data.Add(BitConverter.GetBytes(Core.Culling.Sphere.Location.Y)); data.Add(BitConverter.GetBytes(Core.Culling.Sphere.Location.Z)); } // ノード情報出力 Action <Data.NodeRoot> outout_rootnode = null; Action <Data.Node> outout_node = null; outout_rootnode = (n) => { data.Add(((int)NodeType.Root).GetBytes()); data.Add(n.Children.Count.GetBytes()); for (int i = 0; i < n.Children.Count; i++) { outout_node(n.Children[i]); } }; outout_node = (n) => { List <byte[]> node_data = new List <byte[]>(); var isRenderParamExported = n.IsRendered.GetValue(); for (int i = 0; i < n.Children.Count; i++) { var nc = n.Children[i]; var v = nc.RendererCommonValues.ColorInheritType.GetValue(); if (v == Data.ParentEffectType.Already || v == Data.ParentEffectType.WhenCreating) { isRenderParamExported = true; break; } } if (!isRenderParamExported) { data.Add(((int)NodeType.None).GetBytes()); } else if (n.DrawingValues.Type.Value == Data.RendererValues.ParamaterType.None) { data.Add(((int)NodeType.None).GetBytes()); } else if (n.DrawingValues.Type.Value == Data.RendererValues.ParamaterType.Sprite) { data.Add(((int)NodeType.Sprite).GetBytes()); } else if (n.DrawingValues.Type.Value == Data.RendererValues.ParamaterType.Ribbon) { data.Add(((int)NodeType.Ribbon).GetBytes()); } else if (n.DrawingValues.Type.Value == Data.RendererValues.ParamaterType.Ring) { data.Add(((int)NodeType.Ring).GetBytes()); } else if (n.DrawingValues.Type.Value == Data.RendererValues.ParamaterType.Model) { data.Add(((int)NodeType.Model).GetBytes()); } else if (n.DrawingValues.Type.Value == Data.RendererValues.ParamaterType.Track) { data.Add(((int)NodeType.Track).GetBytes()); } else { throw new Exception(); } // Whether to draw the node. if (n.IsRendered) { int v = 1; node_data.Add(BitConverter.GetBytes(v)); } else { int v = 0; node_data.Add(BitConverter.GetBytes(v)); } // render order { var s = snode2ind.FirstOrDefault(_ => _.Item1 == n); if (s.Item1 != null) { node_data.Add(BitConverter.GetBytes(s.Item2)); } else { node_data.Add(BitConverter.GetBytes(-1)); } } node_data.Add(CommonValues.GetBytes(n.CommonValues)); node_data.Add(LocationValues.GetBytes(n.LocationValues, n.CommonValues.ScaleEffectType)); node_data.Add(LocationAbsValues.GetBytes(n.LocationAbsValues, n.CommonValues.ScaleEffectType)); node_data.Add(RotationValues.GetBytes(n.RotationValues)); node_data.Add(ScaleValues.GetBytes(n.ScalingValues, n.CommonValues.ScaleEffectType)); node_data.Add(GenerationLocationValues.GetBytes(n.GenerationLocationValues, n.CommonValues.ScaleEffectType, model_and_index)); // Export depth node_data.Add(n.DepthValues.DepthOffset.Value.GetBytes()); node_data.Add(BitConverter.GetBytes(n.DepthValues.IsScaleChangedDependingOnDepthOffset.Value ? 1 : 0)); node_data.Add(BitConverter.GetBytes(n.DepthValues.IsDepthOffsetChangedDependingOnParticleScale.Value ? 1 : 0)); node_data.Add(((int)n.DepthValues.ZSort.Value).GetBytes()); node_data.Add(n.DepthValues.DrawingPriority.Value.GetBytes()); node_data.Add(n.DepthValues.SoftParticle.Value.GetBytes()); #if MATERIAL_ENABLED node_data.Add(RendererCommonValues.GetBytes(n.RendererCommonValues, texture_and_index, normalTexture_and_index, distortionTexture_and_index, material_and_index)); #else node_data.Add(RendererCommonValues.GetBytes(n.RendererCommonValues, texture_and_index, distortionTexture_and_index)); #endif if (isRenderParamExported) { node_data.Add(RendererValues.GetBytes(n.DrawingValues, texture_and_index, normalTexture_and_index, model_and_index)); } else { node_data.Add(RendererValues.GetBytes(null, texture_and_index, normalTexture_and_index, model_and_index)); } data.Add(node_data.ToArray().ToArray()); data.Add(SoundValues.GetBytes(n.SoundValues, wave_and_index)); data.Add(n.Children.Count.GetBytes()); for (int i = 0; i < n.Children.Count; i++) { outout_node(n.Children[i]); } }; outout_rootnode(Core.Root); return(data.ToArray().ToArray()); }