public void Init()
        {
            Vector3[] border_positions = {
                new Vector3(0.0f, 0.0f, 0.0f), new Vector3(0.0f, 1.0f, 0.0f),
                new Vector3(0.0f, 1.0f, 0.0f), new Vector3(1.0f, 1.0f, 0.0f),
                new Vector3(1.0f, 1.0f, 0.0f), new Vector3(1.0f, 0.0f, 0.0f),
                new Vector3(1.0f, 0.0f, 0.0f), new Vector3(0.0f, 0.0f, 0.0f)
            };
            meshBorders = new GLMesh(border_positions, null, null, null, null, null, PrimitiveType.Lines);

            Vector3[] tick_positions = {
                new Vector3(0.0f, 0.2f, 0.0f),
                new Vector3(0.0f, 0.8f, 0.0f)
            };
            meshTick = new GLMesh(tick_positions, null, null, null, null, null, PrimitiveType.Lines);

            meshSlider = new GLMesh(new Vector3[] {new Vector3(-1.0f, -0.1f, 0.0f), new Vector3(-1.0f, 1.15f, 0.0f), new Vector3(1.0f, 1.15f, 0.0f), new Vector3(1.0f, -0.1f, 0.0f)}, null, null, null, null, null, PrimitiveType.TriangleFan);

            CustomControlValueChangedAction = ActionManager.CreateAction<int, float>("Called when a custom control's value has changed", "", delegate(object[] p) {
                int controlIdx = (int)p[0];
                float value = (float)p[1];
                if(CustomControlValueChanged != null)
                    CustomControlValueChanged(controlIdx, sliders[controlIdx].Value = value);
                else
                    sliders[controlIdx].Value = value;
                return null;
            });
            RemoveCustomControlsAction = ActionManager.CreateAction("Remove all custom controls", "", delegate(object[] p) {
                sliders.Clear();
                return null;
            });
            ActionManager.Do(RemoveCustomControlsAction);
        }
Exemple #2
0
 public CheckBar(Cinema.CinemaStore.Parameter parameter, GLMesh meshBorders, GLMesh meshTick, GLMesh meshCheck)
 {
     this.parameter   = parameter;
     this.meshBorders = meshBorders;
     this.meshTick    = meshTick;
     this.meshCheck   = meshCheck;
 }
Exemple #3
0
        public void Init()
        {
            Vector3[] border_positions =
            {
                new Vector3(0.0f,  0.0f, 0.0f), new Vector3(0.0f,  1.0f, 0.0f),
                new Vector3(0.0f,  1.0f, 0.0f), new Vector3(1.0f,  1.0f, 0.0f),
                new Vector3(1.0f,  1.0f, 0.0f), new Vector3(1.0f,  0.0f, 0.0f),
                new Vector3(1.0f,  0.0f, 0.0f), new Vector3(0.0f,  0.0f, 0.0f),

                new Vector3(1.01f, 0.0f, 0.0f), new Vector3(1.01f, 1.0f, 0.0f),
                new Vector3(1.01f, 1.0f, 0.0f), new Vector3(1.06f, 1.0f, 0.0f),
                new Vector3(1.06f, 1.0f, 0.0f), new Vector3(1.06f, 0.0f, 0.0f),
                new Vector3(1.06f, 0.0f, 0.0f), new Vector3(1.01f, 0.0f, 0.0f)
            };
            meshBorders = new GLMesh(border_positions, null, null, null, null, null, PrimitiveType.Lines);

            Vector3[] tick_positions =
            {
                new Vector3(0.0f, 0.2f, 0.0f),
                new Vector3(0.0f, 0.8f, 0.0f)
            };
            meshTick = new GLMesh(tick_positions, null, null, null, null, null, PrimitiveType.Lines);

            meshSelection = new GLMesh(new Vector3[] { new Vector3(-1.0f, -0.1f, 0.0f), new Vector3(-1.0f, 1.15f, 0.0f), new Vector3(1.0f, 1.15f, 0.0f), new Vector3(1.0f, -0.1f, 0.0f) }, null, null, null, null, null, PrimitiveType.TriangleFan);
        }
Exemple #4
0
        public void Init()
        {
            Vector3[] border_positions =
            {
                new Vector3(0.0f,  0.0f, 0.0f), new Vector3(0.0f,  1.0f, 0.0f),
                new Vector3(0.0f,  1.0f, 0.0f), new Vector3(1.0f,  1.0f, 0.0f),
                new Vector3(1.0f,  1.0f, 0.0f), new Vector3(1.0f,  0.0f, 0.0f),
                new Vector3(1.0f,  0.0f, 0.0f), new Vector3(0.0f,  0.0f, 0.0f),

                new Vector3(1.01f, 0.0f, 0.0f), new Vector3(1.01f, 1.0f, 0.0f),
                new Vector3(1.01f, 1.0f, 0.0f), new Vector3(1.06f, 1.0f, 0.0f),
                new Vector3(1.06f, 1.0f, 0.0f), new Vector3(1.06f, 0.0f, 0.0f),
                new Vector3(1.06f, 0.0f, 0.0f), new Vector3(1.01f, 0.0f, 0.0f)
            };
            meshBorders = new GLMesh(border_positions, null, null, null, null, null, PrimitiveType.Lines);

            Vector3[] tick_positions =
            {
                new Vector3(0.0f, 0.2f, 0.0f),
                new Vector3(0.0f, 0.8f, 0.0f)
            };
            meshTick = new GLMesh(tick_positions, null, null, null, null, null, PrimitiveType.Lines);

            meshCheck = new GLMesh(new Vector3[] { new Vector3(-1.0f, -0.1f, 0.0f), new Vector3(-1.0f, 1.15f, 0.0f), new Vector3(1.0f, 1.15f, 0.0f), new Vector3(1.0f, -0.1f, 0.0f) }, null, null, null, null, null, PrimitiveType.TriangleFan);

            ParameterChangedAction = ActionManager.CreateAction <int, bool[]>("Called when the checked states of the values of a parameter have changed", "", delegate(object[] p) {
                int paramidx     = (int)p[0];
                bool[] isChecked = (bool[])p[1];
                Array.Copy(isChecked, parameters[paramidx].isChecked, isChecked.Length);
                ParameterChanged(parameters[paramidx], paramidx);
                return(null);
            });
        }
Exemple #5
0
 public TrackBar(Cinema.CinemaArgument argument, int argidx, GLMesh meshBorders, GLMesh meshTick, GLMesh meshSelection)
 {
     this.argument      = argument;
     this.argidx        = argidx;
     this.meshBorders   = meshBorders;
     this.meshTick      = meshTick;
     this.meshSelection = meshSelection;
 }
Exemple #6
0
        public GLTextFont(string filename, Vector2 charsize, GLMesh meshquad)
        {
            this.texture  = GLTexture2D.FromFile(filename);
            this.charsize = charsize;
            this.meshquad = meshquad;

            if (fontshader == null)
            {
                fontshader = new GLShader(new string[] { FONT_SHADER.VS }, new string[] { FONT_SHADER.FS });
                fontshader_coloruniform = fontshader.GetUniformLocation("Color");
            }
        }
Exemple #7
0
        public GLNumberFont(string filename, FontDefinition fontDefinition, GLMesh meshquad, bool isFixedWidth)
        {
            this.texture    = GLTexture2D.FromFile(filename);
            this.fontdef    = fontDefinition;
            this.meshquad   = meshquad;
            this.fixedwidth = /*isFixedWidth ? fontdef[0][10] / 10 :*/ 0;

            if (fontshader == null)
            {
                fontshader = new GLShader(new string[] { FONT_SHADER.VS }, new string[] { FONT_SHADER.FS });
                fontshader_coloruniform = fontshader.GetUniformLocation("Color");
            }
        }
            public Slider(int controlIdx, float[] values, GLMesh meshBorders, GLMesh meshTick, GLMesh meshSlider)
            {
                this.controlIdx = controlIdx;

                this.values  = values;
                currentValue = values.Length > 0 ? values[0] : 0.0f;
                minValue     = float.MaxValue;
                float maxValue = float.MinValue;

                foreach (float v in values)
                {
                    minValue = Math.Min(minValue, v);
                    maxValue = Math.Max(maxValue, v);
                }
                valueRange = maxValue - minValue;

                this.meshBorders = meshBorders;
                this.meshTick    = meshTick;
                this.meshSlider  = meshSlider;
            }
Exemple #9
0
        public override void OnRender(float dt, ImageCloud.FreeView freeview)
        {
            //Common.sdrSolidColor.Bind(freeview.viewprojmatrix);
            //Common.meshLineCube.Bind(Common.sdrSolidColor, null);
            //Common.meshLineCube.Draw();

            if (meshValueLine == null)
            {
                Vector3[] positions = new Vector3[] {
                    new Vector3(1.0f, 0.0f, 1.0f), new Vector3(1.0f, 1.0f, 1.0f),
                    new Vector3(1.0f, 0.0f, 1.0f), new Vector3(1.0f, 0.0f, 0.0f),
                    new Vector3(1.0f, 0.0f, 1.0f), new Vector3(0.0f, 0.0f, 1.0f)
                };
                meshValueLine = new GLMesh(positions, null, null, null, null, null, OpenTK.Graphics.OpenGL.PrimitiveType.Lines);
            }

            //meshValueLine.Bind(Common.sdrSolidColor, null);
            //meshValueLine.Draw();

            this.freeview = freeview;
        }
Exemple #10
0
        public override void OnRender(float dt, ImageCloud.FreeView freeview)
        {
            //Common.sdrSolidColor.Bind(freeview.viewprojmatrix);
            //Common.meshLineCube.Bind(Common.sdrSolidColor, null);
            //Common.meshLineCube.Draw();

            if(meshValueLine == null)
            {
                Vector3[] positions = new Vector3[] {
                    new Vector3(1.0f, 0.0f, 1.0f), new Vector3(1.0f, 1.0f, 1.0f),
                    new Vector3(1.0f, 0.0f, 1.0f), new Vector3(1.0f, 0.0f, 0.0f),
                    new Vector3(1.0f, 0.0f, 1.0f), new Vector3(0.0f, 0.0f, 1.0f)
                };
                meshValueLine = new GLMesh(positions, null, null, null, null, null, OpenTK.Graphics.OpenGL.PrimitiveType.Lines);
            }

            //meshValueLine.Bind(Common.sdrSolidColor, null);
            //meshValueLine.Draw();

            this.freeview = freeview;
        }
        public void Load(Cinema.CinemaArgument[] arguments, Dictionary <string, HashSet <object> > valuerange)
        {
            this.arguments = arguments;

            // Create selection array and populate it with the default values
            selection = new Selection(arguments.Length, valuerange.Count, images);
            for (int i = 0; i < arguments.Length; ++i)
            {
                if (arguments[i].defaultValue != null)
                {
                    selection[i].Add(Array.IndexOf(arguments[i].values, arguments[i].defaultValue));
                }
            }

            // Load shader
            sdrColored            = new GLShader(new string[] { ARGUMENT_INDEX_SHADER.VS }, new string[] { ARGUMENT_INDEX_SHADER.FS });
            sdrColored_colorParam = sdrColored.GetUniformLocation("Color");
            sdrColored.Bind();

            meshSelection = new GLMesh(new Vector3[] { new Vector3(0.0f, -0.1f, 0.0f), new Vector3(0.0f, 1.15f, 0.0f) }, null, null, null, null, null, PrimitiveType.Lines);

            // Create track bars for each argument
            foreach (Cinema.CinemaArgument argument in arguments)
            {
                TrackBar newtrackbar = new TrackBar(argument.values.Length, meshSelection);
                newtrackbar.label = argument.label;
                trackbars.Add(newtrackbar);
            }

            // Create track bars for meta data value
            foreach (KeyValuePair <string, HashSet <object> > range in valuerange)
            {
                TrackBar newtrackbar = new TrackBar(range.Value.Count, meshSelection);
                newtrackbar.label = range.Key;
                trackbars.Add(newtrackbar);
            }

            argumentLabelBounds = new Rectangle[arguments.Length];
        }
        public void Init()
        {
            Vector3[] border_positions =
            {
                new Vector3(0.0f, 0.0f, 0.0f), new Vector3(0.0f, 1.0f, 0.0f),
                new Vector3(0.0f, 1.0f, 0.0f), new Vector3(1.0f, 1.0f, 0.0f),
                new Vector3(1.0f, 1.0f, 0.0f), new Vector3(1.0f, 0.0f, 0.0f),
                new Vector3(1.0f, 0.0f, 0.0f), new Vector3(0.0f, 0.0f, 0.0f)
            };
            meshBorders = new GLMesh(border_positions, null, null, null, null, null, PrimitiveType.Lines);

            Vector3[] tick_positions =
            {
                new Vector3(0.0f, 0.2f, 0.0f),
                new Vector3(0.0f, 0.8f, 0.0f)
            };
            meshTick = new GLMesh(tick_positions, null, null, null, null, null, PrimitiveType.Lines);

            meshSlider = new GLMesh(new Vector3[] { new Vector3(-1.0f, -0.1f, 0.0f), new Vector3(-1.0f, 1.15f, 0.0f), new Vector3(1.0f, 1.15f, 0.0f), new Vector3(1.0f, -0.1f, 0.0f) }, null, null, null, null, null, PrimitiveType.TriangleFan);

            CustomControlValueChangedAction = ActionManager.CreateAction <int, float>("Called when a custom control's value has changed", "", delegate(object[] p) {
                int controlIdx = (int)p[0];
                float value    = (float)p[1];
                if (CustomControlValueChanged != null)
                {
                    CustomControlValueChanged(controlIdx, sliders[controlIdx].Value = value);
                }
                else
                {
                    sliders[controlIdx].Value = value;
                }
                return(null);
            });
            RemoveCustomControlsAction = ActionManager.CreateAction("Remove all custom controls", "", delegate(object[] p) {
                sliders.Clear();
                return(null);
            });
            ActionManager.Do(RemoveCustomControlsAction);
        }
            public TrackBar(int numvalues, GLMesh meshSelection)
            {
                this.numvalues     = numvalues;
                this.meshSelection = meshSelection;

                // Create border mesh
                List <Vector3> border_positions = new List <Vector3>();

                Vector3[] tick_positions = new Vector3[2 * numvalues];

                /*border_positions.Add(new Vector3(1.0f, 0.0f, 0.0f));
                *  border_positions.Add(new Vector3(1.0f, 1.0f, 0.0f));
                *  border_positions.Add(new Vector3(0.0f, 1.0f, 0.0f));
                *  border_positions.Add(new Vector3(0.0f, 0.0f, 0.0f));
                *  border_positions.Add(new Vector3(1.06f, 0.0f, 0.0f));
                *  border_positions.Add(new Vector3(1.06f, 1.0f, 0.0f));
                *  border_positions.Add(new Vector3(1.0f, 1.0f, 0.0f));*/

                border_positions.Add(new Vector3(0.0f, 0.0f, 0.0f)); border_positions.Add(new Vector3(0.0f, 1.0f, 0.0f));
                border_positions.Add(new Vector3(0.0f, 1.0f, 0.0f)); border_positions.Add(new Vector3(1.0f, 1.0f, 0.0f));
                border_positions.Add(new Vector3(1.0f, 1.0f, 0.0f)); border_positions.Add(new Vector3(1.0f, 0.0f, 0.0f));
                border_positions.Add(new Vector3(1.0f, 0.0f, 0.0f)); border_positions.Add(new Vector3(0.0f, 0.0f, 0.0f));

                border_positions.Add(new Vector3(1.01f, 0.0f, 0.0f)); border_positions.Add(new Vector3(1.01f, 1.0f, 0.0f));
                border_positions.Add(new Vector3(1.01f, 1.0f, 0.0f)); border_positions.Add(new Vector3(1.06f, 1.0f, 0.0f));
                border_positions.Add(new Vector3(1.06f, 1.0f, 0.0f)); border_positions.Add(new Vector3(1.06f, 0.0f, 0.0f));
                border_positions.Add(new Vector3(1.06f, 0.0f, 0.0f)); border_positions.Add(new Vector3(1.01f, 0.0f, 0.0f));

                for (int i = 0; i < numvalues; ++i)
                {
                    float x = (float)(i + 1) / (float)(numvalues + 1);
                    tick_positions[2 * i + 0] = new Vector3(x, 0.2f, 0.0f);
                    tick_positions[2 * i + 1] = new Vector3(x, 0.8f, 0.0f);
                }

                meshBorders = new GLMesh(border_positions.ToArray(), null, null, null, null, null, PrimitiveType.Lines);
                meshTicks   = new GLMesh(tick_positions, null, null, null, null, null, PrimitiveType.Lines);
            }
Exemple #14
0
        public void Init()
        {
            Vector3[] border_positions = {
                new Vector3(0.0f, 0.0f, 0.0f), new Vector3(0.0f, 1.0f, 0.0f),
                new Vector3(0.0f, 1.0f, 0.0f), new Vector3(1.0f, 1.0f, 0.0f),
                new Vector3(1.0f, 1.0f, 0.0f), new Vector3(1.0f, 0.0f, 0.0f),
                new Vector3(1.0f, 0.0f, 0.0f), new Vector3(0.0f, 0.0f, 0.0f),

                new Vector3(1.01f, 0.0f, 0.0f), new Vector3(1.01f, 1.0f, 0.0f),
                new Vector3(1.01f, 1.0f, 0.0f), new Vector3(1.06f, 1.0f, 0.0f),
                new Vector3(1.06f, 1.0f, 0.0f), new Vector3(1.06f, 0.0f, 0.0f),
                new Vector3(1.06f, 0.0f, 0.0f), new Vector3(1.01f, 0.0f, 0.0f)
            };
            meshBorders = new GLMesh(border_positions, null, null, null, null, null, PrimitiveType.Lines);

            Vector3[] tick_positions = {
                new Vector3(0.0f, 0.2f, 0.0f),
                new Vector3(0.0f, 0.8f, 0.0f)
            };
            meshTick = new GLMesh(tick_positions, null, null, null, null, null, PrimitiveType.Lines);

            meshSelection = new GLMesh(new Vector3[] {new Vector3(-1.0f, -0.1f, 0.0f), new Vector3(-1.0f, 1.15f, 0.0f), new Vector3(1.0f, 1.15f, 0.0f), new Vector3(1.0f, -0.1f, 0.0f)}, null, null, null, null, null, PrimitiveType.TriangleFan);
        }
Exemple #15
0
        public LineGrid()
        {
            Vector3[] positions;

            positions = new Vector3[] {
                new Vector3(0.0f, 0.0f, 0.0f), new Vector3(1000.0f, 0.0f, 0.0f),
                new Vector3(0.0f, 0.0f, 0.0f), new Vector3(0.0f, 1000.0f, 0.0f),
                new Vector3(0.0f, 0.0f, 0.0f), new Vector3(0.0f, 0.0f, 1000.0f)
            };
            axismesh = new GLMesh(positions, null, null, null, null, null, PrimitiveType.Lines);

            positions = new Vector3[] {
                new Vector3(0.0f, 0.0f, 0.0f), new Vector3(0.03f, 0.0f, 0.0f),
                new Vector3(0.0f, 0.0f, 0.0f), new Vector3(0.0f, 0.0f, 0.0f),
                new Vector3(0.0f, 0.0f, 0.0f), new Vector3(0.0f, 0.03f, 0.0f),
                new Vector3(0.0f, 0.0f, 0.0f), new Vector3(0.0f, 0.0f, 0.0f)
            };
            tickmesh = new GLMesh(positions, null, null, null, null, null, PrimitiveType.Lines);

            positions = new Vector3[] {
                new Vector3(0.0f, 0.0f, -1.0f), new Vector3(0.0f, 0.0f, 1.0f)
            };
            linemesh = new GLMesh(positions, null, null, null, null, null, PrimitiveType.Lines);
        }
Exemple #16
0
        public LineGrid()
        {
            Vector3[] positions;

            positions = new Vector3[] {
                new Vector3(0.0f, 0.0f, 0.0f), new Vector3(1000.0f, 0.0f, 0.0f),
                new Vector3(0.0f, 0.0f, 0.0f), new Vector3(0.0f, 1000.0f, 0.0f),
                new Vector3(0.0f, 0.0f, 0.0f), new Vector3(0.0f, 0.0f, 1000.0f)
            };
            axismesh = new GLMesh(positions, null, null, null, null, null, PrimitiveType.Lines);

            positions = new Vector3[] {
                new Vector3(0.0f, 0.0f, 0.0f), new Vector3(0.03f, 0.0f, 0.0f),
                new Vector3(0.0f, 0.0f, 0.0f), new Vector3(0.0f, 0.0f, 0.0f),
                new Vector3(0.0f, 0.0f, 0.0f), new Vector3(0.0f, 0.03f, 0.0f),
                new Vector3(0.0f, 0.0f, 0.0f), new Vector3(0.0f, 0.0f, 0.0f)
            };
            tickmesh = new GLMesh(positions, null, null, null, null, null, PrimitiveType.Lines);

            positions = new Vector3[] {
                new Vector3(0.0f, 0.0f, -1.0f), new Vector3(0.0f, 0.0f, 1.0f)
            };
            linemesh = new GLMesh(positions, null, null, null, null, null, PrimitiveType.Lines);
        }
Exemple #17
0
		public void Init(GLWindow glcontrol, GLTextureStream.ReadImageMetaDataDelegate ReadImageMetaData)
		{
			this.glcontrol = glcontrol;
			glcontrol.GotFocus += (object sender, EventArgs e) => { glcontrol_focused = true; };
			glcontrol.LostFocus += (object sender, EventArgs e) => { glcontrol_focused = false; };
			glcontrol_focused = true;

			// Define actions
			SetViewControlAction = ActionManager.CreateAction("Set View Control", this, "SetViewControl");
			EnableDepthRenderingAction = ActionManager.CreateAction("Enable Depth Rendering", "enable depth", this, "EnableDepthRendering");
			DisableDepthRenderingAction = ActionManager.CreateAction("Disable Depth Rendering", "disable depth", this, "DisableDepthRendering");
			MoveAction = ActionManager.CreateAction("Move images", this, "Move");
			/*ActionManager.CreateAction("Select all", "all", this, "SelectAll");
			ActionManager.CreateAction("Select and focus all", "focus all", delegate(object[] parameters) {
				this.SelectAll();
				this.FocusSelection();
			});*/

			// Load shaders
			sdrAabb = new GLShader(new string[] {AABB_SHADER.VS}, new string[] {AABB_SHADER.FS});

			// Create mesh for non-depth rendering
#if USE_GS_QUAD
			mesh2D = new GLMesh(new Vector3[] {new Vector3(0.0f, 0.0f, 0.0f)}, null, null, null, null, null, PrimitiveType.Points); // Use this when rendering geometry shader quads
#else
			mesh2D = Common.meshQuad2;
#endif

			texstream = new GLTextureStream(256*1024*1024, ReadImageMetaData); // Optimize for 1GB of VRAM
			//texstream = new GLTextureStream(64*1024*1024, ReadImageMetaData); // Optimize for 256MB of VRAM
			//texstream = new GLTextureStream(8*1024*1024, ReadImageMetaData); // Optimize for 32MB of VRAM
			//texstream = new GLTextureStream(1024*1024, ReadImageMetaData); // Optimize for 4MB of VRAM
			//texstream = new GLTextureStream(128*1024, ReadImageMetaData); // Optimize for 512KB of VRAM

			#if USE_ARG_IDX
			argIndex.Bounds = new Rectangle(250, 10, Width - 250, 16);
			//argIndex.Bounds = new Rectangle(150, 10, Width - 150, 16);
			argIndex.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
			argIndex.Init();
			argIndex.SelectionChanged += SelectionChanged;//() => { SelectionChanged(); };
			//argIndex.ArgumentLabelMouseDown += ArgumentIndex_ArgumentLabelMouseDown;
			this.Controls.Add(argIndex);
			#endif

			#if USE_PARAM_IDX
			//paramIndex.Bounds = new Rectangle(200, 0, Width - 200, 16);
			//paramIndex.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
			paramIndex.Bounds = new Rectangle(16, 0, 300, 16);
			paramIndex.Anchor = AnchorStyles.Top | AnchorStyles.Right;
			paramIndex.Init();
			paramIndex.ParameterChanged += (Cinema.CinemaStore.Parameter parameter, int paramidx) => {
				foreach(TransformedImage image in images)
					image.OnParameterChanged(parameter, paramidx);
			};
			this.Controls.Add(paramIndex);
			#endif

			#if USE_CUSTOM_CONTROLS
			ccContainer.Bounds = new Rectangle(250, 10, Width - 300, 16);
			ccContainer.Anchor = AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
			ccContainer.Init();
			/*ccContainer.CustomControlValueChanged += (int controlIdx, float value) => {
				//EDIT
			};*/
			this.Controls.Add(ccContainer);
			#endif

			colorTableMgr = new ColorTableManager(glcontrol);
			colorTableMgr.Visible = false;
			this.Controls.Add(colorTableMgr);

			coordsys = new CoordinateSystem();
			grid = new LineGrid();

			ContextMenu = new ImageContextMenu();

			fragmentcounter = GL.GenQuery();

//ccContainer.CreateSlider("testSlider", new float[] { 0.0f, 0.5f, 1.0f });
		}
Exemple #18
0
        public static void CreateCommonMeshes()
        {
            Vector3[] positions;
            Vector2[] texcoords;

            // Create a simple line mesh
            positions = new Vector3[] {
                new Vector3(0.0f, 0.0f, 0.0f),
                new Vector3(0.0f, 0.0f, 1.0f)
            };
            meshLine = new GLMesh(positions, null, null, null, null, null, PrimitiveType.Lines);

            // Create a 2D quad mesh
            positions = new Vector3[] {
                new Vector3(0.0f, 1.0f, 0.0f),
                new Vector3(0.0f, 0.0f, 0.0f),
                new Vector3(1.0f, 1.0f, 0.0f),
                new Vector3(1.0f, 0.0f, 0.0f),
            };
            texcoords = new Vector2[] {
                new Vector2(0.0f, 0.0f),
                new Vector2(0.0f, 1.0f),
                new Vector2(1.0f, 0.0f),
                new Vector2(1.0f, 1.0f)
            };
            meshQuad  = new GLMesh(positions, null, null, null, texcoords);
            positions = new Vector3[] {
                new Vector3(-0.5f, 0.5f, 0.0f),
                new Vector3(-0.5f, -0.5f, 0.0f),
                new Vector3(0.5f, 0.5f, 0.0f),
                new Vector3(0.5f, -0.5f, 0.0f),
            };
            meshQuad2 = new GLMesh(positions, null, null, null, texcoords);

            // Create a 2D quad outline mesh
            positions = new Vector3[] {
                new Vector3(-1.0f, -1.0f, 0.0f),
                new Vector3(-1.0f, 1.0f, 0.0f),
                new Vector3(1.0f, 1.0f, 0.0f),
                new Vector3(1.0f, -1.0f, 0.0f),
            };
            meshLineQuad = new GLMesh(positions, null, null, null, null, null, PrimitiveType.LineLoop);
            positions    = new Vector3[] {
                new Vector3(0.0f, 0.0f, 0.0f),
                new Vector3(0.0f, 1.0f, 0.0f),
                new Vector3(1.0f, 1.0f, 0.0f),
                new Vector3(1.0f, 0.0f, 0.0f),
            };
            meshLineQuad2 = new GLMesh(positions, null, null, null, null, null, PrimitiveType.LineLoop);

            // Create a 3D cube outline mesh
            positions = new Vector3[] {
                new Vector3(-1.0f, -1.0f, -1.0f),
                new Vector3(1.0f, -1.0f, -1.0f),
                new Vector3(-1.0f, 1.0f, -1.0f),
                new Vector3(1.0f, 1.0f, -1.0f),
                new Vector3(-1.0f, -1.0f, -1.0f),
                new Vector3(-1.0f, 1.0f, -1.0f),
                new Vector3(1.0f, -1.0f, -1.0f),
                new Vector3(1.0f, 1.0f, -1.0f),

                new Vector3(-1.0f, -1.0f, 1.0f),
                new Vector3(1.0f, -1.0f, 1.0f),
                new Vector3(-1.0f, 1.0f, 1.0f),
                new Vector3(1.0f, 1.0f, 1.0f),
                new Vector3(-1.0f, -1.0f, 1.0f),
                new Vector3(-1.0f, 1.0f, 1.0f),
                new Vector3(1.0f, -1.0f, 1.0f),
                new Vector3(1.0f, 1.0f, 1.0f),

                new Vector3(-1.0f, -1.0f, -1.0f),
                new Vector3(-1.0f, -1.0f, 1.0f),
                new Vector3(1.0f, -1.0f, -1.0f),
                new Vector3(1.0f, -1.0f, 1.0f),
                new Vector3(-1.0f, 1.0f, -1.0f),
                new Vector3(-1.0f, 1.0f, 1.0f),
                new Vector3(1.0f, 1.0f, -1.0f),
                new Vector3(1.0f, 1.0f, 1.0f)
            };
            meshLineCube = new GLMesh(positions, null, null, null, null, null, PrimitiveType.Lines);

            // Create dynamic meshes
            meshD4 = new GLDynamicMesh(4);
        }
            public Slider(int controlIdx, float[] values, GLMesh meshBorders, GLMesh meshTick, GLMesh meshSlider)
            {
                this.controlIdx = controlIdx;

                this.values = values;
                currentValue = values.Length > 0 ? values[0] : 0.0f;
                minValue = float.MaxValue;
                float maxValue = float.MinValue;
                foreach(float v in values)
                {
                    minValue = Math.Min(minValue, v);
                    maxValue = Math.Max(maxValue, v);
                }
                valueRange = maxValue - minValue;

                this.meshBorders = meshBorders;
                this.meshTick = meshTick;
                this.meshSlider = meshSlider;
            }
Exemple #20
0
		public void Load(IEnumerable<TransformedImage> newimages, Dictionary<string, HashSet<object>> valuerange, Size imageSize, bool floatimages = false, bool depthimages = false)
		{
//depthimages = false;
			int i;

			this.images = Viewer.images;
			this.arguments = Global.arguments;

			if(floatimages)
			{
				colorTableMgr.Visible = true;
				colorTableMgr.OnSizeChanged(backbuffersize);
				colorTableMgr.Reset();

				//foreach(TransformedImage newimage in newimages)
				//	newimage.isFloatImage = true;
			}
			else
			{
				//foreach(TransformedImage newimage in newimages)
				//	newimage.isFloatImage = false;
			}

			if(sdr2D_default == null)
			{
#if USE_GS_QUAD
				sdr2D_default = new RenderShader(new string[] {IMAGE_CLOUD_SHADER.VS_USING_GS}, new string[] {IMAGE_CLOUD_SHADER.FS, IMAGE_CLOUD_SHADER.FS_DEFAULT_DECODER}, new string[] {IMAGE_CLOUD_SHADER.GS});
				sdr2D_cm = new RenderShader(new string[] {IMAGE_CLOUD_SHADER.VS_USING_GS}, new string[] {IMAGE_CLOUD_SHADER.FS, IMAGE_CLOUD_SHADER.FS_COLORTABLE_DECODER}, new string[] {IMAGE_CLOUD_SHADER.GS});
				sdr2D_assemble = new RenderShader(new string[] { IMAGE_CLOUD_SHADER.VS_USING_GS }, new string[] {IMAGE_CLOUD_SHADER.FS_ASSEMBLE_IMAGE}, new string[] {IMAGE_CLOUD_SHADER.GS}));
#else
				sdr2D_default = new RenderShader(new string[] { IMAGE_CLOUD_SHADER.VS_DEFAULT }, new string[] {IMAGE_CLOUD_SHADER.FS, IMAGE_CLOUD_SHADER.FS_DEFAULT_DECODER});
				sdr2D_cm = new RenderShader(new string[] { IMAGE_CLOUD_SHADER.VS_DEFAULT }, new string[] {IMAGE_CLOUD_SHADER.FS, IMAGE_CLOUD_SHADER.FS_COLORTABLE_DECODER});
				sdr2D_assemble = new RenderShader(new string[] { IMAGE_CLOUD_SHADER.VS_DEFAULT }, new string[] {IMAGE_CLOUD_SHADER.FS_DEPTH_PEELING});
#endif
				sdr3D_default = new RenderShader(new string[] { IMAGE_CLOUD_SHADER.VS_DEPTHIMAGE }, new string[] {IMAGE_CLOUD_SHADER.FS, IMAGE_CLOUD_SHADER.FS_DEFAULT_DECODER});
				sdr3D_cm = new RenderShader(new string[] { IMAGE_CLOUD_SHADER.VS_DEPTHIMAGE }, new string[] {IMAGE_CLOUD_SHADER.FS, IMAGE_CLOUD_SHADER.FS_COLORTABLE_DECODER});
				sdr3D_assemble = new RenderShader(new string[] { IMAGE_CLOUD_SHADER.VS_DEPTHIMAGE }, new string[] {IMAGE_CLOUD_SHADER.FS_DEPTH_PEELING});

				foreach(GLShader sdr in new GLShader[] {sdr2D_cm, sdr3D_cm, sdr2D_assemble, sdr3D_assemble})
				{
					sdr.Bind();
					GL.ActiveTexture(TextureUnit.Texture4);
					colorTableMgr.Colormap.Bind();
					GL.Uniform1(sdr.GetUniformLocation("Colormap"), 4);
				}
				GL.ActiveTexture(TextureUnit.Texture0);
			}

			texstream.AddImages(newimages);

			if(depthimages && mesh3D == null)
			{
				// Create mesh for depth rendering
				Size depthimagesize = new Size(imageSize.Width, imageSize.Height);
				Vector3[] positions = new Vector3[depthimagesize.Width * depthimagesize.Height];
				Vector2[] texcoords = new Vector2[depthimagesize.Width * depthimagesize.Height];
				i = 0;
				for(int y = 0; y < depthimagesize.Height; ++y)
					for(int x = 0; x < depthimagesize.Width; ++x)
					{
						positions[i] = new Vector3(2.0f * (float)x / (float)(depthimagesize.Width - 1) - 1.0f, 2.0f * (float)y / (float)(depthimagesize.Height - 1) - 1.0f, 1.0f);
						texcoords[i] = new Vector2((float)x / (float)(depthimagesize.Width - 1), 1.0f - (float)y / (float)(depthimagesize.Height - 1));
						++i;
					}
				/*int[] indices = new int[6 * (depthimagesize.Width - 1) * (depthimagesize.Height - 1)];
				i = 0;
				for(int y = 1; y < depthimagesize.Height; ++y)
					for(int x = 1; x < depthimagesize.Width; ++x)
					{
						indices[i++] = (x - 1) + depthimagesize.Width * (y - 1);
						indices[i++] = (x - 0) + depthimagesize.Width * (y - 1);
						indices[i++] = (x - 1) + depthimagesize.Width * (y - 0);

						indices[i++] = (x - 1) + depthimagesize.Width * (y - 0);
						indices[i++] = (x - 0) + depthimagesize.Width * (y - 1);
						indices[i++] = (x - 0) + depthimagesize.Width * (y - 0);
					}
				mesh3D = new GLMesh(positions, null, null, null, texcoords, indices);*/
				mesh3D = new GLMesh(positions, null, null, null, texcoords, null, PrimitiveType.Points);
				//GL.PointSize(2.0f);
			}

			int argIndexBottom = 0;
			#if USE_ARG_IDX
			argIndex.Load(valuerange);
			argIndexBottom = argIndex.Bounds.Bottom + arguments.Length * argIndex.Bounds.Height * 3 / 2;
			#endif

			#if USE_PARAM_IDX
			paramIndex.Bounds = new Rectangle(paramIndex.Bounds.X, argIndexBottom, paramIndex.Bounds.Width, paramIndex.Bounds.Height);// paramIndex.Bounds.Y = argIndexBottom;
			paramIndex.Load();
			#endif

			// Enable depth rendering by default whenever a new scene is loaded
			depthRenderingEnabled = true;
			depthRenderingEnabled_fade = 1.0f;
depthRenderingEnabled = false;
depthRenderingEnabled_fade = 0.0f;
		}
            public TrackBar(int numvalues, GLMesh meshSelection)
            {
                this.numvalues = numvalues;
                this.meshSelection = meshSelection;

                // Create border mesh
                List<Vector3> border_positions = new List<Vector3>();
                Vector3[] tick_positions = new Vector3[2 * numvalues];

                /*border_positions.Add(new Vector3(1.0f, 0.0f, 0.0f));
                border_positions.Add(new Vector3(1.0f, 1.0f, 0.0f));
                border_positions.Add(new Vector3(0.0f, 1.0f, 0.0f));
                border_positions.Add(new Vector3(0.0f, 0.0f, 0.0f));
                border_positions.Add(new Vector3(1.06f, 0.0f, 0.0f));
                border_positions.Add(new Vector3(1.06f, 1.0f, 0.0f));
                border_positions.Add(new Vector3(1.0f, 1.0f, 0.0f));*/

                border_positions.Add(new Vector3(0.0f, 0.0f, 0.0f)); border_positions.Add(new Vector3(0.0f, 1.0f, 0.0f));
                border_positions.Add(new Vector3(0.0f, 1.0f, 0.0f)); border_positions.Add(new Vector3(1.0f, 1.0f, 0.0f));
                border_positions.Add(new Vector3(1.0f, 1.0f, 0.0f)); border_positions.Add(new Vector3(1.0f, 0.0f, 0.0f));
                border_positions.Add(new Vector3(1.0f, 0.0f, 0.0f)); border_positions.Add(new Vector3(0.0f, 0.0f, 0.0f));

                border_positions.Add(new Vector3(1.01f, 0.0f, 0.0f)); border_positions.Add(new Vector3(1.01f, 1.0f, 0.0f));
                border_positions.Add(new Vector3(1.01f, 1.0f, 0.0f)); border_positions.Add(new Vector3(1.06f, 1.0f, 0.0f));
                border_positions.Add(new Vector3(1.06f, 1.0f, 0.0f)); border_positions.Add(new Vector3(1.06f, 0.0f, 0.0f));
                border_positions.Add(new Vector3(1.06f, 0.0f, 0.0f)); border_positions.Add(new Vector3(1.01f, 0.0f, 0.0f));

                for(int i = 0; i < numvalues; ++i)
                {
                    float x = (float)(i + 1) / (float)(numvalues + 1);
                    tick_positions[2 * i + 0] = new Vector3(x, 0.2f, 0.0f);
                    tick_positions[2 * i + 1] = new Vector3(x, 0.8f, 0.0f);
                }

                meshBorders = new GLMesh(border_positions.ToArray(), null, null, null, null, null, PrimitiveType.Lines);
                meshTicks = new GLMesh(tick_positions, null, null, null, null, null, PrimitiveType.Lines);
            }
Exemple #22
0
		public GLNumberFont(string filename, FontDefinition fontDefinition, GLMesh meshquad, bool isFixedWidth)
		{
			this.texture = GLTexture2D.FromFile(filename);
			this.fontdef = fontDefinition;
			this.meshquad = meshquad;
			this.fixedwidth = /*isFixedWidth ? fontdef[0][10] / 10 :*/ 0;

			if(fontshader == null)
			{
				fontshader = new GLShader(new string[] { FONT_SHADER.VS }, new string[] { FONT_SHADER.FS });
				fontshader_coloruniform = fontshader.GetUniformLocation("Color");
			}
		}
Exemple #23
0
		public GLTextFont(string filename, Vector2 charsize, GLMesh meshquad)
		{
			this.texture = GLTexture2D.FromFile(filename);
			this.charsize = charsize;
			this.meshquad = meshquad;

			if(fontshader == null)
			{
				fontshader = new GLShader(new string[] { FONT_SHADER.VS }, new string[] { FONT_SHADER.FS });
				fontshader_coloruniform = fontshader.GetUniformLocation("Color");
			}
		}
Exemple #24
0
		public void Free()
		{
			if(texstream != null)
			{
				texstream.Free();
				texstream = null;
			}
			sdrAabb = null;
			if(mesh2D != null)
				mesh2D.Free();
			mesh2D = null;
			if(colorTableMgr != null)
			{
				//colorTableMgr.Free();
				colorTableMgr = null;
			}
		}
Exemple #25
0
 public TrackBar(Cinema.CinemaArgument argument, int argidx, GLMesh meshBorders, GLMesh meshTick, GLMesh meshSelection)
 {
     this.argument = argument;
     this.argidx = argidx;
     this.meshBorders = meshBorders;
     this.meshTick = meshTick;
     this.meshSelection = meshSelection;
 }
        public void Load(Cinema.CinemaArgument[] arguments, Dictionary<string, HashSet<object>> valuerange)
        {
            this.arguments = arguments;

            // Create selection array and populate it with the default values
            selection = new Selection(arguments.Length, valuerange.Count, images);
            for(int i = 0; i < arguments.Length; ++i)
            {
                if(arguments[i].defaultValue != null)
                    selection[i].Add(Array.IndexOf(arguments[i].values, arguments[i].defaultValue));
            }

            // Load shader
            sdrColored = new GLShader(new string[] {ARGUMENT_INDEX_SHADER.VS}, new string[] {ARGUMENT_INDEX_SHADER.FS});
            sdrColored_colorParam = sdrColored.GetUniformLocation("Color");
            sdrColored.Bind();

            meshSelection = new GLMesh(new Vector3[] {new Vector3(0.0f, -0.1f, 0.0f), new Vector3(0.0f, 1.15f, 0.0f)}, null, null, null, null, null, PrimitiveType.Lines);

            // Create track bars for each argument
            foreach(Cinema.CinemaArgument argument in arguments)
            {
                TrackBar newtrackbar = new TrackBar(argument.values.Length, meshSelection);
                newtrackbar.label = argument.label;
                trackbars.Add(newtrackbar);
            }

            // Create track bars for meta data value
            foreach(KeyValuePair<string, HashSet<object>> range in valuerange)
            {
                TrackBar newtrackbar = new TrackBar(range.Value.Count, meshSelection);
                newtrackbar.label = range.Key;
                trackbars.Add(newtrackbar);
            }

            argumentLabelBounds = new Rectangle[arguments.Length];
        }
            public InputSection(ColorTableManager colorTableMgr, GLFont font)
            {
                this.colorTableMgr = colorTableMgr;
                this.font = font;

                InsertSplitterPinAction = ActionManager.CreateAction("Insert splitter pin", this, "InsertSplitterPin");
                InsertNestedPinAction = ActionManager.CreateAction("Insert nesting pin", this, "InsertNestedPin");
                MovePinAction = ActionManager.CreateAction("Move pin", this, "MovePin");
                RemovePinAction = ActionManager.CreateAction("Remove pin", this, "RemovePin");
                SetSectionColormapAction = ActionManager.CreateAction("Set colormap of section", this, "SetSectionColormap");
                ResetColorTableAction = ActionManager.CreateAction("Reset colormap", this, "ResetColorTable");

                // Create colormap
                colormapTexture = new GLTexture1D("colormap", new byte[4 * FINAL_COLORMAP_SIZE], FINAL_COLORMAP_SIZE, PixelFormat.Rgba, false);

                // Create histogram grid as line list mesh
                List<Vector3> positions = new List<Vector3>();
                /*positions.AddRange(new Vector3[] {
                    // Outline
                    new Vector3(0.0f, 0.0f, 0.0f), new Vector3(0.0f, 0.5f, 0.0f),
                    new Vector3(0.0f, 0.5f, 0.0f), new Vector3(1.0f, 0.5f, 0.0f),
                    new Vector3(1.0f, 0.5f, 0.0f), new Vector3(1.0f, 0.0f, 0.0f),
                    new Vector3(1.0f, 0.0f, 0.0f), new Vector3(0.0f, 0.0f, 0.0f)
                });*/
                for(int i = 0; i <= 10; ++i)
                {
                    float y = (float)i / 10.0f * 0.9f + 0.1f;
                    positions.Add(new Vector3(0.0f, y, 0.0f));
                    positions.Add(new Vector3(1.0f, y, 0.0f));
                }
                for(int i = 0; i <= 10; ++i)
                {
                    float x = (float)i / 10.0f;
                    positions.Add(new Vector3(x, 0.1f, 0.0f));
                    positions.Add(new Vector3(x, 1.0f, 0.0f));
                }
                meshLines = new GLMesh(positions.ToArray(), null, null, null, null, null, PrimitiveType.Lines);

                // Create textures
                texSplitter = GLTexture2D.FromFile(Global.EXE_DIR + "splitter.png", false);
                texInterjectorLeft = GLTexture2D.FromFile(Global.EXE_DIR + "interjectorLeft.png", false);
                texInterjectorRight = GLTexture2D.FromFile(Global.EXE_DIR + "interjectorRight.png", false);

                // Create number font
                //font = new GLNumberFont("HelveticaNeue_12.png", new FontDefinition(new int[] {0, 14, 26, 39, 53, 67, 80, 93, 106, 120, 133}, new int[] {0, 19}), Common.meshQuad, true);
                //font = new GLNumberFont("HelveticaNeue_16.png", new FontDefinition(new int[] {0, 18, 34, 53, 71, 89, 106, 124, 142, 160, 178}, new int[] {0, 25}), true);
                //font = new GLTextFont("fntDefault.png", new Vector2(19.0f, 32.0f), Common.meshQuad);
            }