Пример #1
0
        private void AnimationBox_ItemCheck(object sender, ItemCheckEventArgs e)
        {
            //https://social.msdn.microsoft.com/Forums/windows/en-US/5333cdf2-a669-467c-99ae-1530e91da43a/checkedlistbox-allow-only-one-item-to-be-selected?forum=winforms
            if (e.NewValue == CheckState.Checked)
            {
                for (var ix = 0; ix < animationBox.Items.Count; ++ix)
                {
                    if (e.Index != ix)
                    {
                        animationBox.ItemCheck -= AnimationBox_ItemCheck;
                        animationBox.SetItemChecked(ix, false);
                        animationBox.ItemCheck += AnimationBox_ItemCheck;
                    }
                }

                ActiveAnimation = animationBox.Items[e.Index] as Animation.Animation;
            }
            else if (e.CurrentValue == CheckState.Checked && cameraBox.CheckedItems.Count == 1)
            {
                e.NewValue = CheckState.Checked;
            }
        }
Пример #2
0
        private void MeshControl_Load(object sender, EventArgs e)
        {
            meshControl.MakeCurrent();

            Console.WriteLine("OpenGL version: " + GL.GetString(StringName.Version));
            Console.WriteLine("OpenGL vendor: " + GL.GetString(StringName.Vendor));
            Console.WriteLine("GLSL version: " + GL.GetString(StringName.ShadingLanguageVersion));

            CheckOpenGL();
            LoadBoundingBox();

            GL.Enable(EnableCap.CullFace);
            GL.Enable(EnableCap.DepthTest);

            GL.ClearColor(Settings.BackgroundColor);

            GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);

            InitializeInputTick();

            ActiveCamera = new Camera(tabs.Width, tabs.Height, MinBounds, MaxBounds);
            cameraBox.Items.Add(ActiveCamera, true);

            foreach (var cameraInfo in cameras)
            {
                var camera = new Camera(tabs.Width, tabs.Height, cameraInfo.Item2, cameraInfo.Item1);
                cameraBox.Items.Add(camera);
            }

            ActiveAnimation = Animations.Count > 0 ? Animations[0] : null;
            animationBox.Items.AddRange(Animations.ToArray());

            foreach (var obj in MeshesToRender)
            {
                obj.LoadFromResource(MaterialLoader);
            }

#if DEBUG
            Debug.Setup();
            //Skeleton.DebugDraw(Debug);
#endif

            // Create animation texture
            AnimationTexture = GL.GenTexture();
            GL.BindTexture(TextureTarget.Texture2D, AnimationTexture);
            // Set clamping to edges
            GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapS, (int)TextureWrapMode.ClampToEdge);
            GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapT, (int)TextureWrapMode.ClampToEdge);
            // Set nearest-neighbor sampling since we don't want to interpolate matrix rows
            GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (int)TextureMinFilter.Nearest);
            GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, (int)TextureMinFilter.Nearest);
            //Unbind texture again
            GL.BindTexture(TextureTarget.Texture2D, 0);

            // TODO: poor hack
            FileExtensions.ClearCache();

            Loaded = true;

            Console.WriteLine("{0} draw calls total", MeshesToRender.Sum(x => x.DrawCalls.Count));
        }
Пример #3
0
        private void MeshControl_Load(object sender, EventArgs e)
        {
            meshControl.MakeCurrent();

            Console.WriteLine("OpenGL version: " + GL.GetString(StringName.Version));
            Console.WriteLine("OpenGL vendor: " + GL.GetString(StringName.Vendor));
            Console.WriteLine("GLSL version: " + GL.GetString(StringName.ShadingLanguageVersion));

            CheckOpenGL();
            LoadBoundingBox();

            GL.Enable(EnableCap.CullFace);
            GL.Enable(EnableCap.DepthTest);

            GL.ClearColor(Settings.BackgroundColor);

            GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);

            InitializeInputTick();

            ActiveCamera = new Camera(tabs.Width, tabs.Height, MinBounds, MaxBounds);
            cameraBox.Items.Add(ActiveCamera, true);

            foreach (var cameraInfo in cameras)
            {
                var camera = new Camera(tabs.Width, tabs.Height, cameraInfo.Item2, cameraInfo.Item1);
                cameraBox.Items.Add(camera);
            }

            ActiveAnimation = Animations.Count > 0 ? Animations[0] : null;
            animationBox.Items.AddRange(Animations.ToArray());

            foreach (var obj in MeshesToRender)
            {
                obj.LoadFromResource(MaterialLoader);
            }

            #if DEBUG
            Debug.Setup();
            //Skeleton.DebugDraw(Debug);
            #endif

            // Create animation texture
            AnimationTexture = GL.GenTexture();
            GL.BindTexture(TextureTarget.Texture2D, AnimationTexture);
            // Set clamping to edges
            GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapS, (int)TextureWrapMode.ClampToEdge);
            GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapT, (int)TextureWrapMode.ClampToEdge);
            // Set nearest-neighbor sampling since we don't want to interpolate matrix rows
            GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (int)TextureMinFilter.Nearest);
            GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, (int)TextureMinFilter.Nearest);
            //Unbind texture again
            GL.BindTexture(TextureTarget.Texture2D, 0);

            // TODO: poor hack
            FileExtensions.ClearCache();

            Loaded = true;

            Console.WriteLine("{0} draw calls total", MeshesToRender.Sum(x => x.DrawCalls.Count));
        }
Пример #4
0
        private void AnimationBox_ItemCheck(object sender, ItemCheckEventArgs e)
        {
            //https://social.msdn.microsoft.com/Forums/windows/en-US/5333cdf2-a669-467c-99ae-1530e91da43a/checkedlistbox-allow-only-one-item-to-be-selected?forum=winforms
            if (e.NewValue == CheckState.Checked)
            {
                for (var ix = 0; ix < animationBox.Items.Count; ++ix)
                {
                    if (e.Index != ix)
                    {
                        animationBox.ItemCheck -= AnimationBox_ItemCheck;
                        animationBox.SetItemChecked(ix, false);
                        animationBox.ItemCheck += AnimationBox_ItemCheck;
                    }
                }

                ActiveAnimation = animationBox.Items[e.Index] as Animation.Animation;
            }
            else if (e.CurrentValue == CheckState.Checked && cameraBox.CheckedItems.Count == 1)
            {
                e.NewValue = CheckState.Checked;
            }
        }