Ejemplo n.º 1
0
        private TreeNode DumpTreeNode(SceneObject obj)
        {
            TreeNode node = null;
            DumpTreeNodeScript script = obj.GetScript<DumpTreeNodeScript>();
            if (script != null)
            {
                node = script.DumpTreeNode();
            }
            else
            {
                node = new TreeNode(string.Format("{0}", obj.Name));
                node.Tag = obj;
            }

            // dump children nodes.
            foreach (var item in obj.Children)
            {
                TreeNode child = DumpTreeNode(item);
                if (child != null)
                {
                    node.Nodes.Add(child);
                }
            }

            return node;
        }
Ejemplo n.º 2
0
 private void DisposeObject(SceneObject sceneObject)
 {
     sceneObject.Dispose();
     SceneObject[] array = sceneObject.Children.ToArray();
     foreach (SceneObject child in array)
     {
         DisposeObject(child);
     }
 }
 public DefaultRendererComponent(BuildInSceneObject buildIn, SceneObject bindingObject = null)
     : base(bindingObject)
 {
     var shaderCodes = new ShaderCode[2];
     shaderCodes[0] = new ShaderCode(ManifestResourceLoader.LoadTextFile(@"Resources\BuildInSceneObject.vert"), ShaderType.VertexShader);
     shaderCodes[1] = new ShaderCode(ManifestResourceLoader.LoadTextFile(@"Resources\BuildInSceneObject.frag"), ShaderType.FragmentShader);
     IBufferable bufferable = GetModel(buildIn);
     PropertyNameMap map = GetMap(buildIn);
     var renderer = new Renderer(bufferable, shaderCodes, map);
     renderer.Initialize();
     this.Renderer = renderer;
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Used in <see cref="DumpCatesianGridTreeNodeScript"/>.
 /// </summary>
 /// <param name="sceneObject"></param>
 /// <param name="property"></param>
 /// <param name="uiCodedColorBar"></param>
 public ScientificModelScript(SceneObject sceneObject, GridBlockProperty property, UIColorPaletteRenderer uiCodedColorBar)
     : base(sceneObject)
 {
     this.GridBlockProperty = property;
     this.UIColorPalette = uiCodedColorBar;
 }
Ejemplo n.º 5
0
 /// <summary>
 /// Transform model's position from model space to world space,
 /// including translation, scale and rotation.
 /// </summary>
 /// <param name="bindingObject"></param>
 public TransformComponent(SceneObject bindingObject = null)
     : base(bindingObject)
 {
     this.Scale = new vec3(1, 1, 1);
 }
Ejemplo n.º 6
0
 private void UpdateObject(SceneObject sceneObject)
 {
     if (sceneObject.Enabled)
     {
         sceneObject.Update();
         SceneObject[] array = sceneObject.Children.ToArray();
         foreach (SceneObject child in array)
         {
             UpdateObject(child);
         }
     }
 }
Ejemplo n.º 7
0
        private void mniLoadECLGrid_Click(object sender, EventArgs e)
        {
            if (openFileDialog1.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            //ModelContainer modelContainer = this.ModelContainer;

            string fileName = openFileDialog1.FileName;
            SimulationInputData inputData;
            try
            {
                inputData = this.LoadEclInputData(fileName);
            }
            catch (Exception err)
            {
                MessageBox.Show(String.Format("Load Error,{0}", err.Message), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            try
            {
                List<GridBlockProperty> gridProps = inputData.RootDataFile.GetGridProperties();
                GridBlockProperty gbp = gridProps[0];
                double axisMin, axisMax, step;
                ColorIndicatorAxisAutomator.Automate(gbp.MinValue, gbp.MaxValue, out axisMin, out axisMax, out step);
                CatesianGrid grid = inputData.DumpCatesianGrid((float)axisMin, (float)axisMax);
                var shaderCodes = new ShaderCode[2];
                shaderCodes[0] = new ShaderCode(File.ReadAllText(@"shaders\HexahedronGrid.vert"), ShaderType.VertexShader);
                shaderCodes[1] = new ShaderCode(File.ReadAllText(@"shaders\HexahedronGrid.frag"), ShaderType.FragmentShader);
                var map = new PropertyNameMap();
                map.Add("in_Position", CatesianGrid.strPosition);
                map.Add("in_uv", CatesianGrid.strColor);
                var scientificRenderer = new Renderer(grid, shaderCodes, map);
                var boundedRenderer = new BoundedRenderer(scientificRenderer,
                    grid.DataSource.SourceActiveBounds.Max - grid.DataSource.SourceActiveBounds.Min);
                boundedRenderer.Initialize();
                SceneObject sceneObject = new SceneObject();
                sceneObject.Name = typeof(CatesianGrid).Name;
                sceneObject.Renderer = new BoundedRendererComponent(boundedRenderer);
                //sceneObject.Transform.Position = grid.DataSource.TranslateMatrix;
                this.scientificCanvas.Scene.ObjectList.Add(sceneObject);
                //sceneObject.Renderer=ne
                //SimLabGrid gridder = null;
                //try
                //{
                //    gridderSource = CreateGridderSource(inputData);
                //}
                //catch (Exception err)
                //{
                //    MessageBox.Show(String.Format("Create Gridder Failed,{0}", err.Message), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                //    return;
                //}

                //if (gridderSource != null)
                //{
                //    string caseFileName = System.IO.Path.GetFileName(fileName);
                //    TreeNode gridderNode = this.objectsTreeView.Nodes.Add(caseFileName);
                //    gridderNode.ToolTipText = fileName;
                //    List<GridBlockProperty> gridProps = inputData.RootDataFile.GetGridProperties();
                //    if (gridProps.Count <= 0)
                //    {
                //        GridBlockProperty gbp = this.CreateGridSequenceGridBlockProperty(gridderSource, "INDEX");
                //        gridProps.Add(gbp);
                //    }
                //    foreach (GridBlockProperty gbp in gridProps)
                //    {
                //        TreeNode propNode = gridderNode.Nodes.Add(gbp.Name);
                //        propNode.Tag = gbp;
                //    }

                //    vec3 boundMin;
                //    vec3 boundMax;
                //    gridder = CreateGridder(gridderSource, gridProps[0], out boundMin, out boundMax);
                //    if (gridder != null)
                //    {
                //        this.objectsTreeView.ExpandAll();
                //        //modelContainer.AddChild(gridder);
                //        //modelContainer.BoundingBox.SetBounds(gridderSource.TransformedActiveBounds.Min, gridderSource.TransformedActiveBounds.Max);
                //        //this.scene.ViewType = ViewTypes.UserView;
                //        gridderNode.Tag = gridder;
                //        gridder.Tag = gridderSource;
                //        gridderSource.Tag = gridderNode.Nodes[0];
                //        gridderNode.Checked = gridder.IsEnabled;
                //        gridderNode.Nodes[0].Checked = true;
                //    }

                //List<Well> well3dList;
                //try
                //{
                //    well3dList = this.CreateWell3D(inputData, this.scene, gridderSource);
                //}
                //catch (Exception err)
                //{
                //    MessageBox.Show(String.Format("Create Well3d,{0}", err.Message), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                //    return;
                //}
                //if (well3dList != null && well3dList.Count > 0)
                //    this.AddWellNodes(gridderNode, this.scene, well3dList);
                //}
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
Ejemplo n.º 8
0
        private void RenderPickableObject(SceneObject sceneObject, RenderEventArgs arg, ref  uint renderedVertexCount, List<IPickable> pickedRendererList)
        {
            if ((sceneObject == null) || (!sceneObject.Enabled)) { return; }

            // global switches on.
            GLState[] switchArray = sceneObject.GroupStateList.ToArray();
            for (int i = 0; i < switchArray.Length; i++)
            {
                switchArray[i].On();
            }
            // render self.
            var pickable = sceneObject.Renderer as IPickable;
            if ((pickable != null) && (sceneObject.Renderer.Enabled))
            {
                pickable.PickingBaseId = renderedVertexCount;
                pickable.Render4Picking(arg);
                uint rendered = renderedVertexCount + pickable.GetVertexCount();
                if (renderedVertexCount <= rendered)
                {
                    renderedVertexCount = rendered;
                }
                else
                {
                    throw new Exception(string.Format(
                        "Too many geometries({0} + {1} > {2}) for color coded picking.",
                            renderedVertexCount, pickable.GetVertexCount(), uint.MaxValue));
                }

                pickedRendererList.Add(pickable);
            }
            // render children.
            {
                SceneObject[] array = sceneObject.Children.ToArray();
                foreach (SceneObject child in array)
                {
                    RenderPickableObject(child, arg, ref renderedVertexCount, pickedRendererList);
                }
            }
            // global switches off.
            for (int i = switchArray.Length - 1; i >= 0; i--)
            {
                switchArray[i].Off();
            }
        }
Ejemplo n.º 9
0
 public UIRendererComponent(UIRoot uiRoot, SceneObject bindingObject = null)
     : base(bindingObject)
 {
     this.UIRoot = uiRoot;
 }
Ejemplo n.º 10
0
 public RendererComponent(SceneObject bindingObject = null)
     : base(bindingObject)
 {
 }
Ejemplo n.º 11
0
 public SceneObjectTreeNode(SceneObject sceneObject)
 {
     this.sceneObject = sceneObject;
 }
Ejemplo n.º 12
0
 public Component(SceneObject bindingObject = null)
 {
     this.BindingObject = bindingObject;
 }