Exemple #1
0
        private void ModeCB_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (!IsLoaded)
            {
                return;
            }

            if (activeSkeleton.node.SkeletonU != null)
            {
                activeSkeleton.node.SkeletonU.FlagsRotation = (ResU.SkeletonFlagsRotation)rotationModeCB.SelectedItem;
                activeSkeleton.node.SkeletonU.FlagsScaling  = (ResU.SkeletonFlagsScaling)scalingModeCB.SelectedItem;

                foreach (var bone in activeSkeleton.bones)
                {
                    bone.UseSegmentScaleCompensate = activeSkeleton.node.SkeletonU.FlagsScaling.HasFlag(SkeletonFlagsScaling.Maya);
                }
                activeSkeleton.update();
            }
            else
            {
                activeSkeleton.node.Skeleton.FlagsRotation = (SkeletonFlagsRotation)rotationModeCB.SelectedItem;
                activeSkeleton.node.Skeleton.FlagsScaling  = (SkeletonFlagsScaling)scalingModeCB.SelectedItem;

                foreach (var bone in activeSkeleton.bones)
                {
                    bone.UseSegmentScaleCompensate = activeSkeleton.node.Skeleton.FlagsScaling.HasFlag(SkeletonFlagsScaling.Maya);
                }
                activeSkeleton.update();
            }
            LibraryGUI.UpdateViewport();
        }
Exemple #2
0
        private void treeViewCustom1_AfterCheck(object sender, TreeViewEventArgs e)
        {
            UpdateViewport = false;

            if (e.Node is STGenericModel)
            {
                SupressUpdateEvent = true;
                CheckChildNodes(e.Node, e.Node.Checked);
                SupressUpdateEvent = false;
            }

            if (Control.ModifierKeys == Keys.Shift && !SupressUpdateEvent)
            {
                SupressUpdateEvent = true;
                CheckChildNodes(e.Node, e.Node.Checked);
                SupressUpdateEvent = false;
            }

            if (e.Node is STGenericObject && !SupressUpdateEvent)
            {
                UpdateViewport = true;
            }
            else if (e.Node is STBone && !SupressUpdateEvent)
            {
                UpdateViewport = true;
            }

            if (UpdateViewport)
            {
                LibraryGUI.UpdateViewport();
            }
        }
Exemple #3
0
        public override void Clear()
        {
            var result = MessageBox.Show("Are you sure you want to clear this section? This cannot be undone!",
                                         "", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (result == DialogResult.Yes)
            {
                foreach (TreeNode node in Nodes)
                {
                    if (node is STGenericWrapper)
                    {
                        ((STGenericWrapper)node).Unload();
                        RemoveChild(((STGenericWrapper)node));
                    }
                }

                ResourceNodes.Clear();
                Nodes.Clear();

                if (Type == BRESGroupType.Models)
                {
                    ((BFRES)Parent).BFRESRender.UpdateModelList();
                    LibraryGUI.UpdateViewport();
                }
            }
        }
        public void OnPropertyChanged()
        {
            if (textureRefListView.SelectedIndices.Count <= 0)
            {
                return;
            }

            int        index            = textureRefListView.SelectedIndices[0];
            MatTexture ActiveMatTexture = (MatTexture)material.TextureMaps[index];

            if (ActiveMatTexture.wiiUSampler != null)
            {
                ActiveMatTexture.WrapModeS = SetWrapMode((int)ActiveMatTexture.wiiUSampler.ClampX);
                ActiveMatTexture.WrapModeT = SetWrapMode((int)ActiveMatTexture.wiiUSampler.ClampY);
                ActiveMatTexture.WrapModeW = SetWrapMode((int)ActiveMatTexture.wiiUSampler.ClampZ);

                if (ActiveMatTexture.wiiUSampler.MinFilter == ResUGX2.GX2TexXYFilterType.Point)
                {
                    ActiveMatTexture.MinFilter = STTextureMinFilter.Nearest;
                }
                if (ActiveMatTexture.wiiUSampler.MagFilter == ResUGX2.GX2TexXYFilterType.Point)
                {
                    ActiveMatTexture.MagFilter = STTextureMagFilter.Nearest;
                }
                if (ActiveMatTexture.wiiUSampler.MinFilter == ResUGX2.GX2TexXYFilterType.Bilinear)
                {
                    ActiveMatTexture.MinFilter = STTextureMinFilter.Linear;
                }
                if (ActiveMatTexture.wiiUSampler.MagFilter == ResUGX2.GX2TexXYFilterType.Bilinear)
                {
                    ActiveMatTexture.MagFilter = STTextureMagFilter.Linear;
                }
            }
            else
            {
                ActiveMatTexture.WrapModeS = SetWrapMode((int)ActiveMatTexture.switchSampler.WrapModeU);
                ActiveMatTexture.WrapModeT = SetWrapMode((int)ActiveMatTexture.switchSampler.WrapModeV);
                ActiveMatTexture.WrapModeW = SetWrapMode((int)ActiveMatTexture.switchSampler.WrapModeW);

                if (ActiveMatTexture.switchSampler.ShrinkXY == ResNX.Sampler.ShrinkFilterModes.Points)
                {
                    ActiveMatTexture.MinFilter = STTextureMinFilter.Nearest;
                }
                if (ActiveMatTexture.switchSampler.ExpandXY == ResNX.Sampler.ExpandFilterModes.Points)
                {
                    ActiveMatTexture.MagFilter = STTextureMagFilter.Nearest;
                }
                if (ActiveMatTexture.switchSampler.ShrinkXY == ResNX.Sampler.ShrinkFilterModes.Linear)
                {
                    ActiveMatTexture.MinFilter = STTextureMinFilter.Linear;
                }
                if (ActiveMatTexture.switchSampler.ExpandXY == ResNX.Sampler.ExpandFilterModes.Linear)
                {
                    ActiveMatTexture.MagFilter = STTextureMagFilter.Linear;
                }
            }

            LibraryGUI.UpdateViewport();
        }
Exemple #5
0
        public void UpdateTextureMaps()
        {
            if (!Runtime.OpenTKInitialized)
            {
                return;
            }

            LibraryGUI.UpdateViewport();
        }
Exemple #6
0
        public void UpdateVertexData(bool updateViewport)
        {
            ParentFile.Renderer.UpdateVertexData();

            if (updateViewport)
            {
                LibraryGUI.UpdateViewport();
            }
        }
Exemple #7
0
        public override void SetImageData(Bitmap bitmap, int ArrayLevel)
        {
            if (bitmap == null)
            {
                return; //Image is likely disposed and not needed to be applied
            }
            texture.Format = ConvertToGx2Format(Format);
            texture.Width  = (uint)bitmap.Width;
            texture.Height = (uint)bitmap.Height;
            uint swizzle = (texture.Swizzle >> 8) & 7;

            if (MipCount != 1)
            {
                MipCount = GenerateMipCount(bitmap.Width, bitmap.Height);
                if (MipCount == 0)
                {
                    MipCount = 1;
                }
            }

            texture.MipCount   = MipCount;
            texture.MipOffsets = new uint[MipCount];

            try
            {
                //Create image block from bitmap first
                var data = GenerateMipsAndCompress(bitmap, MipCount, Format);

                bitmap.Dispose();

                //Swizzle and create surface
                var surface = GX2.CreateGx2Texture(data, Text,
                                                   (uint)texture.TileMode,
                                                   (uint)texture.AAMode,
                                                   (uint)texture.Width,
                                                   (uint)texture.Height,
                                                   (uint)texture.Depth,
                                                   (uint)texture.Format,
                                                   (uint)swizzle,
                                                   (uint)texture.Dim,
                                                   (uint)texture.MipCount
                                                   );

                var tex = FromGx2Surface(surface, texture.Name);
                UpdateTex(tex);

                IsEdited = true;
                Read(texture);
                LoadOpenGLTexture();
                LibraryGUI.UpdateViewport();
            }
            catch (Exception ex)
            {
                STErrorDialog.Show("Failed to swizzle and compress image " + Text, "Error", ex.ToString());
            }
        }
Exemple #8
0
        private void rotModeCB_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (activeBone == null || !IsLoaded)
            {
                return;
            }

            SetBoneTransform(activeBone);
            LibraryGUI.UpdateViewport();
        }
Exemple #9
0
        public void UpdateVertexData()
        {
            if (!Runtime.OpenTKInitialized)
            {
                return;
            }

            GFLXMesh.DisplayVertex[] Vertices;
            int[] Faces;

            int poffset = 0;
            int voffset = 0;
            List <GFLXMesh.DisplayVertex> Vs = new List <GFLXMesh.DisplayVertex>();
            List <int> Ds = new List <int>();

            foreach (GFLXMesh shape in Meshes)
            {
                List <GFLXMesh.DisplayVertex> pv = shape.CreateDisplayVertices();
                Vs.AddRange(pv);

                int GroupOffset = 0;
                int groupIndex  = 0;
                foreach (var group in shape.PolygonGroups)
                {
                    group.Offset = poffset * 4;

                    for (int i = 0; i < group.displayFaceSize; i++)
                    {
                        Ds.Add(shape.display[GroupOffset + i] + voffset);
                    }

                    poffset     += group.displayFaceSize;
                    GroupOffset += group.displayFaceSize;

                    Console.WriteLine($"GroupOffset {groupIndex++} " + GroupOffset);
                }

                voffset += pv.Count;
            }

            // Binds
            Vertices = Vs.ToArray();
            Faces    = Ds.ToArray();

            // Bind only once!
            GL.BindBuffer(BufferTarget.ArrayBuffer, vbo_position);
            GL.BufferData <GFLXMesh.DisplayVertex>(BufferTarget.ArrayBuffer, (IntPtr)(Vertices.Length * GFLXMesh.DisplayVertex.Size), Vertices, BufferUsageHint.StaticDraw);

            GL.BindBuffer(BufferTarget.ElementArrayBuffer, ibo_elements);
            GL.BufferData <int>(BufferTarget.ElementArrayBuffer, (IntPtr)(Faces.Length * sizeof(int)), Faces, BufferUsageHint.StaticDraw);

            LibraryGUI.UpdateViewport();
        }
Exemple #10
0
        private void treeViewCustom1_AfterSelect(object sender, TreeViewEventArgs e)
        {
            if (SuppressAfterSelectEvent)
            {
                return;
            }

            var node = treeViewCustom1.SelectedNode;

            if (node is Animation || node is IAnimationContainer)
            {
                OnAnimationSelected(node);
            }

            //Set the current index used determine what bone is selected.
            //Update viewport for selection viewing
            if (node is STBone)
            {
                Runtime.SelectedBoneIndex = ((STBone)node).GetIndex();
            }
            else
            {
                Runtime.SelectedBoneIndex = -1;
            }

            //Set click events for custom nodes
            if (node is TreeNodeCustom)
            {
                ((TreeNodeCustom)node).OnClick(treeViewCustom1);
            }

            if (node.Tag != null && node.Tag is TreeNodeCustom)
            {
                ((TreeNodeCustom)node.Tag).OnClick(treeViewCustom1);
            }

            //Check if it is renderable for updating the viewport
            if (IsRenderable(node))
            {
                LibraryGUI.UpdateViewport();
                RenderedObjectWasSelected = true;
            }
            else
            {
                //Check if the object was previously selected
                //This will disable selection view and other things
                if (RenderedObjectWasSelected)
                {
                    LibraryGUI.UpdateViewport();
                    RenderedObjectWasSelected = false;
                }
            }
        }
        private void OnPropertyChanged()
        {
            if (ActiveMatTexture.wiiUSampler != null)
            {
                ActiveMatTexture.WrapModeS = (STTextureWrapMode)ActiveMatTexture.wiiUSampler.ClampX;
                ActiveMatTexture.WrapModeT = (STTextureWrapMode)ActiveMatTexture.wiiUSampler.ClampY;
                ActiveMatTexture.WrapModeW = (STTextureWrapMode)ActiveMatTexture.wiiUSampler.ClampZ;

                if (ActiveMatTexture.wiiUSampler.MinFilter == ResUGX2.GX2TexXYFilterType.Point)
                {
                    ActiveMatTexture.MinFilter = STTextureMinFilter.Nearest;
                }
                if (ActiveMatTexture.wiiUSampler.MagFilter == ResUGX2.GX2TexXYFilterType.Point)
                {
                    ActiveMatTexture.MagFilter = STTextureMagFilter.Nearest;
                }
                if (ActiveMatTexture.wiiUSampler.MinFilter == ResUGX2.GX2TexXYFilterType.Bilinear)
                {
                    ActiveMatTexture.MinFilter = STTextureMinFilter.Linear;
                }
                if (ActiveMatTexture.wiiUSampler.MagFilter == ResUGX2.GX2TexXYFilterType.Bilinear)
                {
                    ActiveMatTexture.MagFilter = STTextureMagFilter.Linear;
                }
            }
            else
            {
                ActiveMatTexture.WrapModeS = (STTextureWrapMode)ActiveMatTexture.switchSampler.WrapModeU;
                ActiveMatTexture.WrapModeT = (STTextureWrapMode)ActiveMatTexture.switchSampler.WrapModeV;
                ActiveMatTexture.WrapModeW = (STTextureWrapMode)ActiveMatTexture.switchSampler.WrapModeW;


                if (ActiveMatTexture.switchSampler.ShrinkXY == Sampler.ShrinkFilterModes.Points)
                {
                    ActiveMatTexture.MinFilter = STTextureMinFilter.Nearest;
                }
                if (ActiveMatTexture.switchSampler.ExpandXY == Sampler.ExpandFilterModes.Points)
                {
                    ActiveMatTexture.MagFilter = STTextureMagFilter.Nearest;
                }
                if (ActiveMatTexture.switchSampler.ShrinkXY == Sampler.ShrinkFilterModes.Linear)
                {
                    ActiveMatTexture.MinFilter = STTextureMinFilter.Linear;
                }
                if (ActiveMatTexture.switchSampler.ExpandXY == Sampler.ExpandFilterModes.Linear)
                {
                    ActiveMatTexture.MagFilter = STTextureMagFilter.Linear;
                }
            }

            LibraryGUI.UpdateViewport();
        }
        private void lodDisplayCB_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (!IsLoaded)
            {
                return;
            }

            if (lodDisplayCB.SelectedIndex != -1)
            {
                activeShape.DisplayLODIndex = lodDisplayCB.SelectedIndex;
                activeShape.UpdateVertexData();
                LibraryGUI.UpdateViewport();
            }
        }
        private void bonesCB_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (!IsLoaded)
            {
                return;
            }

            if (bonesCB.SelectedIndex >= 0 && IsBoneListLoaded)
            {
                activeShape.BoneIndex = bonesCB.SelectedIndex;
                boneIndexUD.Value     = bonesCB.SelectedIndex;
            }

            LibraryGUI.UpdateViewport();
        }
        private void materialComboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (!IsLoaded)
            {
                return;
            }

            if (materialComboBox1.SelectedIndex >= 0 && IsMatListLoaded)
            {
                activeShape.MaterialIndex = materialComboBox1.SelectedIndex;
                materialIndexUD.Value     = materialComboBox1.SelectedIndex;
            }

            LibraryGUI.UpdateViewport();
        }
Exemple #15
0
        public override void SetImageData(System.Drawing.Bitmap bitmap, int ArrayLevel)
        {
            if (bitmap == null || image == null)
            {
                return; //Image is likely disposed and not needed to be applied
            }
            MipCount = 1;
            var Gx2Format = FTEX.ConvertToGx2Format(Format);

            uint swizzle = (image.Swizzle >> 8) & 7;

            try
            {
                //Create image block from bitmap first
                var data = GenerateMipsAndCompress(bitmap, MipCount, Format);

                //Swizzle and create surface
                var surface = GX2.CreateGx2Texture(data, Text,
                                                   (uint)image.TileMode,
                                                   (uint)0,
                                                   (uint)image.Width,
                                                   (uint)image.Height,
                                                   (uint)1,
                                                   (uint)Gx2Format,
                                                   (uint)swizzle,
                                                   (uint)1,
                                                   (uint)MipCount
                                                   );

                image.Swizzle     = surface.swizzle;
                image.BflimFormat = FormatsWiiU.FirstOrDefault(x => x.Value == Format).Key;
                image.Height      = (ushort)surface.height;
                image.Width       = (ushort)surface.width;

                Width  = image.Width;
                Height = image.Height;

                ImageData = surface.data;

                IsEdited = true;
                LoadOpenGLTexture();
                LibraryGUI.UpdateViewport();
            }
            catch (Exception ex)
            {
                STErrorDialog.Show("Failed to swizzle and compress image " + Text, "Error", ex.ToString());
            }
        }
Exemple #16
0
            public override void SetImageData(Bitmap bitmap, int ArrayLevel)
            {
                if (bitmap == null)
                {
                    return; //Image is likely disposed and not needed to be applied
                }
                RedChannel   = SetChannel(surface.compSel[0]);
                GreenChannel = SetChannel(surface.compSel[1]);
                BlueChannel  = SetChannel(surface.compSel[2]);
                AlphaChannel = SetChannel(surface.compSel[3]);

                surface.format = (uint)FTEX.ConvertToGx2Format(Format);
                surface.width  = (uint)bitmap.Width;
                surface.height = (uint)bitmap.Height;

                if (MipCount != 1)
                {
                    MipCount = GenerateMipCount(bitmap.Width, bitmap.Height);
                    if (MipCount == 0)
                    {
                        MipCount = 1;
                    }
                }

                surface.numMips   = MipCount;
                surface.mipOffset = new uint[MipCount];

                //Create image block from bitmap first
                var data = GenerateMipsAndCompress(bitmap, MipCount, Format);

                //Swizzle and create surface
                var NewSurface = GX2.CreateGx2Texture(data, Text,
                                                      (uint)surface.tileMode,
                                                      (uint)surface.aa,
                                                      (uint)surface.width,
                                                      (uint)surface.height,
                                                      (uint)surface.depth,
                                                      (uint)surface.format,
                                                      (uint)0,
                                                      (uint)surface.dim,
                                                      (uint)surface.numMips
                                                      );

                ApplySurface(NewSurface);
                IsEdited = true;
                LoadOpenGLTexture();
                LibraryGUI.UpdateViewport();
            }
Exemple #17
0
        public override void SetImageData(System.Drawing.Bitmap bitmap, int ArrayLevel)
        {
            if (bitmap == null || image == null)
            {
                return; //Image is likely disposed and not needed to be applied
            }
            MipCount = 1;
            var CtrFormat = CTR_3DS.ConvertToPICAFormat(Format);

            try
            {
                //Create image block from bitmap first
                var data = GenerateMipsAndCompress(bitmap, MipCount, Format);

                //Swizzle and create surface

                /*    var surface = GX2.CreateGx2Texture(data, Text,
                 *      (uint)image.TileMode,
                 *      (uint)0,
                 *      (uint)image.Width,
                 *      (uint)image.Height,
                 *      (uint)1,
                 *      (uint)Gx2Format,
                 *      (uint)0,
                 *      (uint)1,
                 *      (uint)MipCount
                 *      );
                 *
                 *  image.Swizzle = (byte)surface.swizzle;
                 *  image.BCLIMFormat = ConvertFormatGenericToBflim(Format);
                 *  image.Height = (ushort)surface.height;
                 *  image.Width = (ushort)surface.width;*/

                Width  = image.Width;
                Height = image.Height;

                // ImageData = surface.data;

                IsEdited = true;
                LoadOpenGLTexture();
                LibraryGUI.UpdateViewport();
            }
            catch (Exception ex)
            {
                STErrorDialog.Show("Failed to swizzle and compress image " + Text, "Error", ex.ToString());
            }
        }
Exemple #18
0
        public void UpdateVertexData()
        {
            if (!Runtime.OpenTKInitialized)
            {
                return;
            }

            SOBJWrapper.DisplayVertex[] Vertices;
            int[] Faces;

            int poffset = 0;
            int voffset = 0;
            List <SOBJWrapper.DisplayVertex> Vs = new List <SOBJWrapper.DisplayVertex>();
            List <int> Ds = new List <int>();

            foreach (CMDLWrapper m in Models)
            {
                foreach (SOBJWrapper shape in m.Shapes)
                {
                    shape.Offset = poffset * 4;
                    List <SOBJWrapper.DisplayVertex> pv = shape.CreateDisplayVertices();
                    Vs.AddRange(pv);

                    for (int i = 0; i < shape.lodMeshes[shape.DisplayLODIndex].displayFaceSize; i++)
                    {
                        Ds.Add(shape.display[i] + voffset);
                    }
                    poffset += shape.lodMeshes[shape.DisplayLODIndex].displayFaceSize;
                    voffset += pv.Count;
                }
            }

            // Binds
            Vertices = Vs.ToArray();
            Faces    = Ds.ToArray();

            // Bind only once!
            GL.BindBuffer(BufferTarget.ArrayBuffer, vbo_position);
            GL.BufferData <SOBJWrapper.DisplayVertex>(BufferTarget.ArrayBuffer, (IntPtr)(Vertices.Length * SOBJWrapper.DisplayVertex.Size), Vertices, BufferUsageHint.StaticDraw);

            GL.BindBuffer(BufferTarget.ElementArrayBuffer, ibo_elements);
            GL.BufferData <int>(BufferTarget.ElementArrayBuffer, (IntPtr)(Faces.Length * sizeof(int)), Faces, BufferUsageHint.StaticDraw);

            LibraryGUI.UpdateViewport();
        }
Exemple #19
0
        private void valueUD_ValueChanged(object sender, EventArgs e)
        {
            if (activeBone == null || !IsLoaded)
            {
                return;
            }

            SetBoneTransform(activeBone);
            activeBone.skeletonParent.reset();
            activeBone.skeletonParent.update(true);

            //   var Model = ((FSKL)activeBone.skeletonParent).GetModelParent();

            //    GetBoneTransform(activeBone);
            //    for (int s = 0; s < Model.shapes.Count; s++)
            //   Model.shapes[s].TransformBindedBone(activeBone.Text);

            LibraryGUI.UpdateViewport();
        }
Exemple #20
0
        public void UpdateVertexData()
        {
            if (!Runtime.OpenTKInitialized)
            {
                return;
            }

            KCL.DisplayVertex[] Vertices;
            int[] Faces;

            int poffset = 0;
            int voffset = 0;
            List <KCL.DisplayVertex> Vs = new List <KCL.DisplayVertex>();
            List <int> Ds = new List <int>();

            foreach (KCL.KCLModel m in models)
            {
                m.Offset = poffset * 4;
                List <KCL.DisplayVertex> pv = m.CreateDisplayVertices();
                Vs.AddRange(pv);

                for (int i = 0; i < m.displayFaceSize; i++)
                {
                    Ds.Add(m.display[i] + voffset);
                }
                poffset += m.displayFaceSize;
                voffset += pv.Count;
            }

            // Binds
            Vertices = Vs.ToArray();
            Faces    = Ds.ToArray();

            // Bind only once!
            GL.BindBuffer(BufferTarget.ArrayBuffer, vbo_position);
            GL.BufferData <KCL.DisplayVertex>(BufferTarget.ArrayBuffer, (IntPtr)(Vertices.Length * KCL.DisplayVertex.Size), Vertices, BufferUsageHint.StaticDraw);

            GL.BindBuffer(BufferTarget.ElementArrayBuffer, ibo_elements);
            GL.BufferData <int>(BufferTarget.ElementArrayBuffer, (IntPtr)(Faces.Length * sizeof(int)), Faces, BufferUsageHint.StaticDraw);

            LibraryGUI.UpdateViewport();
        }
Exemple #21
0
        public void UpdateTextureMaps()
        {
            if (!Runtime.OpenTKInitialized)
            {
                return;
            }

            foreach (BCRESGroupNode bcresTexGroup in PluginRuntime.bcresTexContainers)
            {
                foreach (var tex in bcresTexGroup.ResourceNodes)
                {
                    if (!((TXOBWrapper)tex.Value).RenderableTex.GLInitialized)
                    {
                        ((TXOBWrapper)tex.Value).LoadOpenGLTexture();
                    }
                }
            }

            LibraryGUI.UpdateViewport();
        }
        private void rotModeCB_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (activeBone == null || !IsLoaded)
            {
                return;
            }

            if ((BoneFlagsRotation)rotModeCB.SelectedItem == BoneFlagsRotation.Quaternion)
            {
                activeBone.ConvertToQuaternion();
                SetBoneTransform(activeBone);
            }
            else
            {
                activeBone.ConvertToEular();
                SetBoneTransform(activeBone);
            }

            LibraryGUI.UpdateViewport();
        }
Exemple #23
0
        public void ReplaceBatch()
        {
            FolderSelectDialog ofd = new FolderSelectDialog();

            if (ofd.ShowDialog() == DialogResult.OK)
            {
                string folderPath = ofd.SelectedPath;

                foreach (var file in Directory.GetFiles(folderPath))
                {
                    string Name = Path.GetFileNameWithoutExtension(file);
                    if (((FMDL)Parent).materials.ContainsKey(Name) &&
                        (file.EndsWith(".bfmat")))
                    {
                        ((FMDL)Parent).materials[Name].Replace(file, false);
                    }
                }
            }
            LibraryGUI.UpdateViewport();
        }
Exemple #24
0
        public void UpdateSingleMaterialTextureMaps(FMAT mat)
        {
            if (!Runtime.OpenTKInitialized)
            {
                return;
            }

            foreach (BNTX bntx in PluginRuntime.bntxContainers)
            {
                foreach (var t in mat.TextureMaps)
                {
                    if (bntx.Textures.ContainsKey(t.Name))
                    {
                        if (!bntx.Textures[t.Name].RenderableTex.GLInitialized)
                        {
                            bntx.Textures[t.Name].LoadOpenGLTexture();
                        }
                    }
                }
            }

            LibraryGUI.UpdateViewport();
        }
        private void treeViewCustom1_AfterCheck(object sender, TreeViewEventArgs e)
        {
            UpdateViewport = false;

            if (e.Node is STGenericModel)
            {
                IsModelChecked = true;
                CheckChildNodes(e.Node, e.Node.Checked);
                IsModelChecked = false;
            }
            else if (e.Node is STGenericObject && !IsModelChecked)
            {
                UpdateViewport = true;
            }
            else if (e.Node is STBone && !IsModelChecked)
            {
                UpdateViewport = true;
            }

            if (UpdateViewport)
            {
                LibraryGUI.UpdateViewport();
            }
        }
Exemple #26
0
            public void ReplaceMatchingFile( )
            {
                OpenFileDialog ofd = new OpenFileDialog();

                ofd.DefaultExt = ReplaceFilter;

                if (ofd.ShowDialog() == DialogResult.OK)
                {
                    string extension = System.IO.Path.GetExtension(ofd.FileName);

                    if (extension == ".bfskl")
                    {
                        if (SkeletonU != null)
                        {
                            ResU.Skeleton SkeltonTemp = new ResU.Skeleton();
                            SkeltonTemp.Import(ofd.FileName, GetResFileU());

                            foreach (BfresBone bone in fskl.bones)
                            {
                                if (SkeltonTemp.Bones.ContainsKey(bone.Text))
                                {
                                    bone.CopyData(SkeltonTemp.Bones[bone.Text]);
                                }
                            }

                            BfresWiiU.ReadSkeleton(this, SkeletonU, fskl);
                        }
                        else
                        {
                            Skeleton SkeltonTemp = new Skeleton();
                            SkeltonTemp.Import(ofd.FileName);

                            foreach (BfresBone bone in fskl.bones)
                            {
                                if (SkeltonTemp.BoneDict.ContainsKey(bone.Text))
                                {
                                    int index = SkeltonTemp.BoneDict.GetIndex(bone.Text);
                                    bone.CopyData(SkeltonTemp.Bones[index]);
                                }
                            }

                            BfresSwitch.ReadSkeleton(this, Skeleton, fskl);
                        }
                    }
                    if (extension == ".csv")
                    {
                        using (var reader = new System.IO.StringReader(System.IO.File.ReadAllText(ofd.FileName)))
                        {
                            string value = reader.ReadLine();
                            if (value != "Bones Geometry")
                            {
                                return;
                            }

                            float X = 0;
                            float Y = 0;
                            float Z = 0;
                            float W = 0;
                            while (true)
                            {
                                string line = reader.ReadLine();
                                if (line != null)
                                {
                                    foreach (BfresBone bone in fskl.bones)
                                    {
                                        if (bone.Text == line)
                                        {
                                            string name           = line;
                                            string scaleStr       = reader.ReadLine();
                                            string rotationStr    = reader.ReadLine();
                                            string translationStr = reader.ReadLine();

                                            string[] valuesS = scaleStr.Replace("\n", "").Replace("\r", "").Split(',');
                                            string[] valuesR = rotationStr.Replace("\n", "").Replace("\r", "").Split(',');
                                            string[] valuesT = translationStr.Replace("\n", "").Replace("\r", "").Split(',');

                                            Syroot.Maths.Vector3F translate;
                                            Syroot.Maths.Vector3F scale;
                                            Syroot.Maths.Vector4F rotate;

                                            float.TryParse(valuesT[0], out X);
                                            float.TryParse(valuesT[1], out Y);
                                            float.TryParse(valuesT[2], out Z);
                                            translate = new Syroot.Maths.Vector3F(X, Y, Z);

                                            float.TryParse(valuesR[0], out X);
                                            float.TryParse(valuesR[1], out Y);
                                            float.TryParse(valuesR[2], out Z);
                                            float.TryParse(valuesR[3], out W);
                                            rotate = new Syroot.Maths.Vector4F(X, Y, Z, W);

                                            float.TryParse(valuesS[0], out X);
                                            float.TryParse(valuesS[1], out Y);
                                            float.TryParse(valuesS[2], out Z);
                                            scale = new Syroot.Maths.Vector3F(X, Y, Z);

                                            if (bone.BoneU != null)
                                            {
                                                bone.BoneU.Position = translate;
                                                bone.BoneU.Scale    = scale;
                                                bone.BoneU.Rotation = rotate;
                                            }
                                            else
                                            {
                                                bone.Bone.Position = translate;
                                                bone.Bone.Scale    = scale;
                                                bone.Bone.Rotation = rotate;
                                            }
                                        }
                                    }
                                }
                                else
                                {
                                    break;
                                }
                            }

                            if (SkeletonU != null)
                            {
                                BfresWiiU.ReadSkeleton(this, SkeletonU, fskl);
                            }
                            else
                            {
                                BfresSwitch.ReadSkeleton(this, Skeleton, fskl);
                            }

                            LibraryGUI.UpdateViewport();
                        }
                    }
                }
            }
Exemple #27
0
 private void OnPropertyEditorChanged()
 {
     imageEditor.UpdateMipDisplay();
     LibraryGUI.UpdateViewport();
 }
Exemple #28
0
        public void ReplaceTexture(string FileName, TEX_FORMAT DefaultFormat = TEX_FORMAT.UNKNOWN, uint MipMapCount = 0,
                                   uint swizzlePattern    = 0, TEX_FORMAT[] SupportedFormats = null, bool DisplayBc4AlphaSetting = false,
                                   bool IsSwizzleReadOnly = false, bool IsTileModeReadOnly   = false, bool IsFormatReadOnly      = false, bool flipTextureY = false)
        {
            string ext = System.IO.Path.GetExtension(FileName);

            ext = ext.ToLower();

            if (ext == ".bftex")
            {
                texture.Import(FileName, ((BFRESGroupNode)Parent).GetResFileU());
                texture.Name = Text;
                IsReplaced   = true;
                Read(texture);

                if (IsEditorActive())
                {
                    UpdateEditor();
                }
                return;
            }

            GTXImporterSettings setting = SetImporterSettings(FileName, DefaultFormat);

            setting.FlipY          = flipTextureY;
            setting.MipSwizzle     = Tex2Swizzle;
            setting.SwizzlePattern = swizzlePattern;

            GTXTextureImporter importer = new GTXTextureImporter();

            importer.DisplayBC4Alpha  = DisplayBc4AlphaSetting;
            importer.ReadOnlySwizzle  = IsSwizzleReadOnly;
            importer.ReadOnlyTileMode = IsSwizzleReadOnly;
            importer.ReadOnlyFormat   = IsFormatReadOnly;

            if (MipMapCount != 0)
            {
                setting.MipCount            = MipMapCount;
                importer.OverrideMipCounter = true;
            }
            if (SupportedFormats != null)
            {
                importer.LoadSupportedFormats(SupportedFormats);
            }

            importer.LoadSetting(setting);

            if (ext == ".dds")
            {
                if (setting.DataBlockOutput != null)
                {
                    var surface = GTXSwizzle.CreateGx2Texture(setting.DataBlockOutput[0], setting);
                    var tex     = FromGx2Surface(surface, setting.TexName);
                    UpdateTex(tex);
                    texture.Name = Text;
                    IsReplaced   = true;
                    Read(texture);
                    LoadOpenGLTexture();
                    LibraryGUI.UpdateViewport();
                }
            }
            else
            {
                if (importer.ShowDialog() == DialogResult.OK)
                {
                    Cursor.Current = Cursors.WaitCursor;

                    UseBc4Alpha = setting.UseBc4Alpha;
                    if (setting.GenerateMipmaps && !setting.IsFinishedCompressing)
                    {
                        setting.DataBlockOutput.Clear();
                        setting.DataBlockOutput.Add(setting.GenerateMips());
                    }

                    if (setting.DataBlockOutput != null)
                    {
                        var surface = GTXSwizzle.CreateGx2Texture(setting.DataBlockOutput[0], setting);
                        var tex     = FromGx2Surface(surface, setting.TexName);
                        UpdateTex(tex);
                        texture.Name = Text;
                        IsReplaced   = true;
                        Read(texture);
                        LoadOpenGLTexture();
                        LibraryGUI.UpdateViewport();
                    }
                    else
                    {
                        MessageBox.Show("Something went wrong???");
                    }
                }
            }
            if (IsEditorActive() && IsReplaced)
            {
                UpdateEditor();
            }
        }
Exemple #29
0
 public override void Delete()
 {
     ((BFRESGroupNode)Parent).RemoveChild(this);
     LibraryGUI.UpdateViewport(); //Update texture display
 }
Exemple #30
0
        public override void UpdateVertexData()
        {
            if (!Runtime.OpenTKInitialized)
            {
                return;
            }

            UpdateModelList();
            Loaded = false;

            DisplayVertex[] Vertices;
            int[]           Faces;

            int poffset             = 0;
            int voffset             = 0;
            List <DisplayVertex> Vs = new List <DisplayVertex>();
            List <int>           Ds = new List <int>();

            int TotalShapeCount = models.Sum(b => b.shapes.Count);

            int value = 0;

            for (int m = 0; m < models.Count; m++)
            {
                //Reset min/max
                models[m].MaxPosition = new Vector3(0);
                models[m].MinPosition = new Vector3(0);

                for (int shp = 0; shp < models[m].shapes.Count; shp++)
                {
                    //Update render pass aswell
                    CheckRenderPass(models[m].shapes[shp].GetFMAT());

                    models[m].shapes[shp].Offset = poffset * 4;
                    List <DisplayVertex> pv = models[m].shapes[shp].CreateDisplayVertices(models[m]);
                    Vs.AddRange(pv);

                    for (int i = 0; i < models[m].shapes[shp].lodMeshes[models[m].shapes[shp].DisplayLODIndex].displayFaceSize; i++)
                    {
                        Ds.Add(models[m].shapes[shp].display[i] + voffset);
                    }
                    poffset += models[m].shapes[shp].lodMeshes[models[m].shapes[shp].DisplayLODIndex].displayFaceSize;
                    voffset += pv.Count;
                }
            }

            // Binds
            Vertices = Vs.ToArray();
            Faces    = Ds.ToArray();

            // Bind only once!
            GL.BindBuffer(BufferTarget.ArrayBuffer, vbo_position);
            GL.BufferData <DisplayVertex>(BufferTarget.ArrayBuffer, (IntPtr)(Vertices.Length * DisplayVertex.Size), Vertices, BufferUsageHint.StaticDraw);

            GL.BindBuffer(BufferTarget.ElementArrayBuffer, ibo_elements);
            GL.BufferData <int>(BufferTarget.ElementArrayBuffer, (IntPtr)(Faces.Length * sizeof(int)), Faces, BufferUsageHint.StaticDraw);

            LibraryGUI.UpdateViewport();

            Loaded = true;
        }