an 3D axis
Inheritance: IBufferable
Beispiel #1
0
        /// <summary>
        /// opengl UI for Axis
        /// </summary>
        /// <param name="anchor"></param>
        /// <param name="margin"></param>
        /// <param name="size"></param>
        /// <param name="partCount">24 as default.</param>
        public UIAxis(
            System.Windows.Forms.AnchorStyles anchor, System.Windows.Forms.Padding margin,
            System.Drawing.Size size, int partCount = 24)
            : base(anchor, margin, size, -Math.Max(size.Width, size.Height), Math.Max(size.Width, size.Height))
        {
            var shaderCodes = new ShaderCode[2];
            shaderCodes[0] = new ShaderCode(ManifestResourceLoader.LoadTextFile(@"Resources\Simple.vert"), ShaderType.VertexShader);
            shaderCodes[1] = new ShaderCode(ManifestResourceLoader.LoadTextFile(@"Resources\Simple.frag"), ShaderType.FragmentShader);
            var map = new AttributeMap();
            map.Add("in_Position", Axis.strPosition);
            map.Add("in_Color", Axis.strColor);
            var axis = new Axis(partCount, 0.5f);
            var renderer = new Renderer(axis, shaderCodes, map);
            renderer.ModelSize = axis.ModelSize;

            this.Renderer = renderer;
        }
        private static IBufferable GetModel(BuildInSceneObject buildIn)
        {
            IBufferable bufferable = null;

            switch (buildIn)
            {
                case BuildInSceneObject.Cube:
                    bufferable = new Cube();
                    break;
                case BuildInSceneObject.Sphere:
                    bufferable = new Sphere();
                    break;
                case BuildInSceneObject.Ground:
                    bufferable = new Ground(1, 1000, 1000);
                    break;
                case BuildInSceneObject.Axis:
                    bufferable = new Axis();
                    break;
                default:
                    throw new NotImplementedException();
            }

            return bufferable;
        }
        private static IBufferable GetModel(BuildInSceneObject buildIn)
        {
            IBufferable model = null;

            switch (buildIn)
            {
                case BuildInSceneObject.Cube:
                    model = new Cube();
                    break;

                case BuildInSceneObject.Sphere:
                    model = new Sphere();
                    break;

                case BuildInSceneObject.Ground:
                    model = new Ground(1, groundXLength / 2, groundZLength / 2);
                    break;

                case BuildInSceneObject.Axis:
                    model = new Axis();
                    break;

                default:
                    throw new NotImplementedException();
            }

            return model;
        }