Example #1
0
        private void CalcTansBitansAllShapes(object sender, EventArgs args)
        {
            Cursor.Current = Cursors.WaitCursor;
            foreach (FSHP shp in shapes)
            {
                bool HasTans   = shp.vertexAttributes.Any(x => x.Name == "_t0");
                bool HasBiTans = shp.vertexAttributes.Any(x => x.Name == "_b0");

                if (!shp.HasUV0())
                {
                    MessageBox.Show($"Error! {Text} does not have UVs!", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                if (!HasBiTans)
                {
                    DialogResult dialogResult2 = MessageBox.Show("Mesh does not have bitangents. Do you want to create them? (will make file size bigger)", "", MessageBoxButtons.YesNo);

                    FSHP.VertexAttribute att2 = new FSHP.VertexAttribute();
                    att2.Name   = "_b0";
                    att2.Format = ResGFX.AttribFormat.Format_10_10_10_2_SNorm;

                    if (dialogResult2 == DialogResult.Yes)
                    {
                        if (!HasBiTans)
                        {
                            shp.vertexAttributes.Add(att2);
                        }
                    }
                }

                if (!HasTans)
                {
                    DialogResult dialogResult = MessageBox.Show("Mesh does not have tangets. Do you want to create them? (will make file size bigger)", "", MessageBoxButtons.YesNo);

                    FSHP.VertexAttribute att = new FSHP.VertexAttribute();
                    att.Name   = "_t0";
                    att.Format = ResGFX.AttribFormat.Format_10_10_10_2_SNorm;


                    if (dialogResult == DialogResult.Yes)
                    {
                        if (!HasTans)
                        {
                            shp.vertexAttributes.Add(att);
                        }
                    }
                }

                shp.CalculateTangentBitangent();
                shp.SaveVertexBuffer(IsWiiU);
            }

            UpdateVertexData();
            Cursor.Current = Cursors.Default;
        }
Example #2
0
        private void CalcTansBitansAllShapes()
        {
            Cursor.Current = Cursors.WaitCursor;
            foreach (FSHP shp in shapes)
            {
                bool HasTans   = shp.vertexAttributes.Any(x => x.Name == "_t0");
                bool HasBiTans = shp.vertexAttributes.Any(x => x.Name == "_b0");

                if (!shp.HasUV0())
                {
                    MessageBox.Show($"Error! {Text} does not have UVs!", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                if (!HasBiTans)
                {
                    DialogResult dialogResult2 = MessageBox.Show("Mesh does not have bitangents. Do you want to create them? (will make file size bigger)", "", MessageBoxButtons.YesNo);

                    FSHP.VertexAttribute att2 = new FSHP.VertexAttribute();
                    att2.Name   = "_b0";
                    att2.Format = ResGFX.AttribFormat.Format_10_10_10_2_SNorm;

                    if (dialogResult2 == DialogResult.Yes)
                    {
                        if (!HasBiTans)
                        {
                            shp.vertexAttributes.Add(att2);
                        }
                    }
                }

                if (!HasTans)
                {
                    DialogResult dialogResult = MessageBox.Show("Mesh does not have tangets. Do you want to create them? (will make file size bigger)", "", MessageBoxButtons.YesNo);

                    FSHP.VertexAttribute att = new FSHP.VertexAttribute();
                    att.Name   = "_t0";
                    att.Format = ResGFX.AttribFormat.Format_10_10_10_2_SNorm;


                    if (dialogResult == DialogResult.Yes)
                    {
                        if (!HasTans)
                        {
                            shp.vertexAttributes.Add(att);
                        }
                    }
                }

                bool UseUVLayer2 = false;

                //for BOTW if it uses UV layer 2 for normal maps use second UV map
                if (shp.GetMaterial().shaderassign.options.ContainsKey("uking_texture2_texcoord"))
                {
                    float value = float.Parse(shp.GetMaterial().shaderassign.options["uking_texture2_texcoord"]);

                    if (value == 1)
                    {
                        UseUVLayer2 = true;
                    }
                }

                shp.CalculateTangentBitangent(UseUVLayer2);
                shp.SaveVertexBuffer();
            }

            UpdateVertexData();
            Cursor.Current = Cursors.Default;
        }
Example #3
0
        public void CopyUVChannels()
        {
            CopyUVChannelDialog dialog = new CopyUVChannelDialog();

            dialog.LoadUVAttributes();

            if (dialog.ShowDialog() == DialogResult.OK)
            {
                int dest   = dialog.DestIndex;
                int source = dialog.SourceIndex;

                bool CanCreateUV = false;
                bool HasDestUV   = false;
                bool ShownDialog = false;

                foreach (var shape in shapes)
                {
                    //If no source, there's nothing to copy from
                    if (!shape.vertexAttributes.Any(x => x.Name == $"_u{source}"))
                    {
                        continue;
                    }

                    if ((!shape.vertexAttributes.Any(x => x.Name == $"_u{dest}")))
                    {
                        //Only show the dialog once for creating UV channels
                        if (!CanCreateUV && !ShownDialog)
                        {
                            DialogResult dialogResult = MessageBox.Show($"Some of the objects are missing the destenation uv channel ({dest}) to copy to. Create one?", "", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                            if (dialogResult == DialogResult.Yes)
                            {
                                CanCreateUV = true;
                                ShownDialog = true;
                            }
                        }

                        if (CanCreateUV)
                        {
                            FSHP.VertexAttribute att = new FSHP.VertexAttribute();
                            att.Name   = $"_u{dest}";
                            att.Format = ResGFX.AttribFormat.Format_16_16_Single;
                            shape.vertexAttributes.Add(att);

                            HasDestUV = true;
                        }
                    }
                    else
                    {
                        HasDestUV = true;
                    }

                    if (HasDestUV)
                    {
                        Cursor.Current = Cursors.WaitCursor;
                        shape.CopyUVChannel(dialog.SourceIndex, dialog.DestIndex);
                        shape.SaveVertexBuffer();
                        UpdateVertexData();
                        Cursor.Current = Cursors.Default;
                    }

                    shape.CopyUVChannel(dialog.SourceIndex, dialog.DestIndex);
                    shape.SaveVertexBuffer();
                }
            }

            UpdateVertexData();
        }