Example #1
0
        /// <summary>
        /// 实施传统方式的投影
        /// </summary>
        /// <param name="camera"></param>
        public static void LegacyGLProjection(this IScientificCamera camera)
        {
            //	Load the projection identity matrix.
            GL.MatrixMode(GL.GL_PROJECTION);
            GL.LoadIdentity();

            //	Perform the projection.
            switch (camera.CameraType)
            {
            case CameraTypes.Perspecitive:
                IPerspectiveCamera perspectiveCamera = camera;
                GL.gluPerspective(perspectiveCamera.FieldOfView, perspectiveCamera.AspectRatio, perspectiveCamera.Near, perspectiveCamera.Far);
                break;

            case CameraTypes.Ortho:
                IOrthoCamera orthoCamera = camera;
                GL.Ortho(orthoCamera.Left, orthoCamera.Right, orthoCamera.Bottom, orthoCamera.Top, orthoCamera.Near, orthoCamera.Far);
                break;

            default:
                break;
            }

            //  Perform the look at transformation.
            GL.gluLookAt((double)camera.Position.x, (double)camera.Position.y, (double)camera.Position.z,
                         (double)camera.Target.x, (double)camera.Target.y, (double)camera.Target.z,
                         (double)camera.UpVector.x, (double)camera.UpVector.y, (double)camera.UpVector.z);

            //	Back to the modelview matrix.
            GL.MatrixMode(GL.GL_MODELVIEW);
        }
Example #2
0
        void IHasObjectSpace.PushObjectSpace(OpenGL gl)
        {
            // Update matrices.
            IScientificCamera camera = this.Camera;

            if (camera == null)
            {
                return;
            }
            if (camera.CameraType == CameraTypes.Perspecitive)
            {
                IPerspectiveViewCamera perspective = camera;
                this.projectionMatrix = perspective.GetProjectionMat4();
                this.viewMatrix       = perspective.GetViewMat4();
            }
            else if (camera.CameraType == CameraTypes.Ortho)
            {
                IOrthoViewCamera ortho = camera;
                this.projectionMatrix = ortho.GetProjectionMat4();
                this.viewMatrix       = ortho.GetViewMat4();
            }
            else
            {
                throw new NotImplementedException();
            }

            modelMatrix = mat4.identity();
        }
Example #3
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="gl">OpenGLControl.OpenGL</param>
        /// <param name="camera"></param>
        public SimLabGrid(OpenGL gl, IScientificCamera camera)
        {
            if (gl == null || camera == null) { throw new ArgumentNullException(); }

            this.gl = gl;
            this.camera = camera;
        }
Example #4
0
        private void PrepareCamera()
        {
            var camera = this.Camera;

            if (camera != null)
            {
                Vertex back  = camera.Position - camera.Target;
                Vertex right = Camera.UpVector.VectorProduct(back);
                Vertex up    = back.VectorProduct(right);
                back.Normalize();
                right.Normalize();
                up.Normalize();

                this.back  = back;
                this.right = right;
                this.up    = up;

                if (this.originalCamera == null)
                {
                    this.originalCamera = new ScientificCamera();
                }
                this.originalCamera.Position = camera.Position;
                this.originalCamera.UpVector = camera.UpVector;
            }
        }
        /// <summary>
        /// 用于渲染字符串。
        /// Rendering gridder of hexadrons.
        /// </summary>
        public PointSpriteStringElement(
            //IScientificCamera camera, string text, Vertex position, int fontSize = 32, GLColor textColor = null)
            IScientificCamera camera,
            string content, Vertex position, GLColor textColor = null, int fontSize = 32, int maxRowWidth = 256)
        {
            if (fontSize >= 256)
            {
                throw new ArgumentException();
            }

            this.camera   = camera;
            this.content  = content;
            this.position = position;
            this.fontSize = fontSize;
            if (textColor == null)
            {
                this.textColor = new vec3(1, 1, 1);
            }
            else
            {
                this.textColor = new vec3(textColor.R, textColor.G, textColor.B);
            }

            if (0 < maxRowWidth && maxRowWidth < 257)
            {
                this.maxRowWidth = maxRowWidth;
            }
            else
            {
                throw new ArgumentOutOfRangeException("max row width must between 0 and 257(not include 0 or 257)");
            }

            this.fontResource = FontResource.Instance;
        }
        void ISupportInitialize.EndInit()
        {
            CreateRenderContext();

            this.camera = new ScientificCamera(CameraTypes.Perspecitive, this.Width, this.Height);

            this.rotator = new SatelliteRotator(this.camera);

            this.MouseDown += scientificVisual3DControl1_MouseDown;
            this.MouseMove += scientificVisual3DControl1_MouseMove;
            this.MouseUp   += scientificVisual3DControl1_MouseUp;

            {
                IUILayoutParam param = new IUILayoutParam(AnchorStyles.Left | AnchorStyles.Bottom,
                                                          new Padding(10, 10, 10, 10), new Size(50, 50));
                uiAxis = new SimpleUIAxis(param);
                uiAxis.Initialize();
                this.ElementList.Add(uiAxis);
            }
            {
                IUILayoutParam param = new IUILayoutParam(AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Bottom,
                                                          new Padding(100, 30, 40, 30), new Size(30, 30));
                ColorPalette colorPalette = ColorPaletteFactory.CreateRainbow();
                uiColorIndicator = new SimpleUIColorIndicator(param, colorPalette, new Objects.GLColor(1, 1, 1, 1), -100, 100, 5);
                uiColorIndicator.Initialize();
                this.ElementList.Add(uiColorIndicator);
            }
        }
Example #7
0
        /// <summary>
        /// 蛇形管道(井)+文字显示
        /// </summary>
        /// <param name="pipe"></param>
        /// <param name="pipeRadius"></param>
        /// <param name="pipeColor"></param>
        /// <param name="name"></param>
        /// <param name="position"></param>
        /// <param name="camera"></param>
        public Well(IScientificCamera camera, List <Vertex> pipe, float pipeRadius, GLColor pipeColor, String name, Vertex position,
                    GLColor textColor = null, int fontSize = 32, int maxRowWidth = 256)
        {
            this.wellPipeElement = new WellPipe(pipe, pipeRadius, pipeColor, camera);

            this.textElement = new PointSpriteStringElement(camera, name, position, textColor, fontSize, maxRowWidth);
        }
Example #8
0
        /// <summary>
        /// support recreate the visual elements
        /// </summary>
        /// <param name="camera"></param>
        public void CreateVisualElements(IScientificCamera camera)
        {
            ClearVisualElements();

            Vertex srcTop = this.wellInitPath[0];

            srcTop.Z = this.wellPathMaxDisplayZ;
            Vertex destTop = this.Transform * srcTop;

            //create  well path dispay max z
            bool          isValid  = false;
            List <Vertex> destPath = new List <Vertex>();

            for (int i = 0; i < this.wellInitPath.Count - 1; i++)
            {
                Vertex p  = this.Transform * this.wellInitPath[i];
                Vertex p2 = this.Transform * this.wellInitPath[i + 1];
                if (!isValid)
                {
                    if (p.Z >= destTop.Z && p2.Z <= destTop.Z)
                    {
                        isValid = true;
                        p.Z     = destTop.Z;
                    }
                    else if (p.Z <= destTop.Z)
                    {
                        isValid = true;
                        p.Z     = destTop.Z;
                    }
                }
                if (isValid)
                {
                    destPath.Add(p);
                    if ((i + 1) == (this.wellInitPath.Count - 1))
                    {
                        destPath.Add(p2);
                    }
                }
            }


            if (destPath.Count < 2)
            {
                return;
            }

            float  wellRadius = this.wellInitRadius * this.radiusScale;
            Vertex wellNameAnnotationLocation = new Vertex(destPath[0].X, destPath[0].Y, destPath[0].Z + this.wellNameAnnotationSpace);

            this.wellPipeElement            = new WellPipe(destPath, wellRadius, this.wellPathColor, camera);
            this.textElement                = new PointSpriteStringElement(camera, this.wellName, wellNameAnnotationLocation, this.textColor, this.fontSize, this.maxRowWidth);
            this.wellPipeElement.ZAxisScale = this.ZAxisScale;
            this.textElement.ZAxisScale     = this.ZAxisScale;
            this.AddChild(this.wellPipeElement);
            this.AddChild(this.textElement);
        }
Example #9
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="gl">OpenGLControl.OpenGL</param>
        /// <param name="camera"></param>
        public SimLabGrid(OpenGL gl, IScientificCamera camera)
        {
            if (gl == null || camera == null)
            {
                throw new ArgumentNullException();
            }

            this.gl     = gl;
            this.camera = camera;
        }
Example #10
0
        public override HexahedronGrid GenerateGrid(OpenGL gl, IScientificCamera camera, int[] gridIndexes, float[] values, float minValue, float maxValue)
        {
            HexahedronPositionBuffer  positionBuffer = GeneratePositionBuffer(ref this.max, ref this.min);
            HexahedronTexCoordBuffer  texCoordBuffer = GenerateTexCoordBuffer(gridIndexes, values, minValue, maxValue);
            HalfHexahedronIndexBuffer indexBuffer    = GenerateIndexBuffer();

            HexahedronGrid grid = new HexahedronGrid(gl, camera);

            grid.
        }
Example #11
0
        /// <summary>
        /// 蛇形管道(井)
        /// </summary>
        /// <param textContent="pipe">管道中心点轨迹</param>
        /// <param textContent="radius">圆柱半径</param>
        /// <param textContent="color">颜色</param>
        /// <param textContent="name">井名</param>
        /// <param textContent="position">文字渲染位置,模型坐标</param>
        public WellPipe(List <Vertex> pipe, float radius, GLColor color, IScientificCamera camera)
        {
            if (pipe == null || pipe.Count < 2 || radius <= 0.0f)
            {
                throw new ArgumentException();
            }

            this.pipe = pipe; this.radius = radius; this.color = color;

            this.camera = camera;
        }
Example #12
0
        protected void BeforeRendering(OpenGL gl, RenderMode renderMode)
        {
            IScientificCamera camera = this.camera;

            if (camera != null)
            {
                if (camera.CameraType == CameraTypes.Perspecitive)
                {
                    IPerspectiveViewCamera perspective = camera;
                    this.projectionMatrix = perspective.GetProjectionMat4();
                    this.viewMatrix       = perspective.GetViewMat4();
                }
                else if (camera.CameraType == CameraTypes.Ortho)
                {
                    IOrthoViewCamera ortho = camera;
                    this.projectionMatrix = ortho.GetProjectionMat4();
                    this.viewMatrix       = ortho.GetViewMat4();
                }
                else
                {
                    throw new NotImplementedException();
                }
            }

            modelMatrix = glm.scale(mat4.identity(), new vec3(1, 1, this.ZAxisScale));

            gl.Enable(OpenGL.GL_VERTEX_PROGRAM_POINT_SIZE);
            gl.Enable(OpenGL.GL_POINT_SPRITE_ARB);
            gl.TexEnv(OpenGL.GL_POINT_SPRITE_ARB, OpenGL.GL_COORD_REPLACE_ARB, OpenGL.GL_TRUE);
            gl.Enable(OpenGL.GL_POINT_SMOOTH);
            gl.Hint(OpenGL.GL_POINT_SMOOTH_HINT, OpenGL.GL_NICEST);
            gl.Enable(OpenGL.GL_BLEND);
            gl.BlendEquation(OpenGL.GL_FUNC_ADD_EXT);
            gl.BlendFuncSeparate(OpenGL.GL_SRC_ALPHA, OpenGL.GL_ONE_MINUS_SRC_ALPHA, OpenGL.GL_ONE, OpenGL.GL_ONE);

            ShaderProgram shaderProgram = this.shaderProgram;

            int[] viewport = new int[4];
            gl.GetInteger(OpenGL.GL_VIEWPORT, viewport);

            shaderProgram.Bind(gl);
            shaderProgram.SetUniformMatrix4(gl, "projectionMatrix", projectionMatrix.to_array());
            shaderProgram.SetUniformMatrix4(gl, "viewMatrix", viewMatrix.to_array());
            shaderProgram.SetUniformMatrix4(gl, "modelMatrix", modelMatrix.to_array());
            shaderProgram.SetUniform1(gl, "canvasWidth", viewport[2] + 0.0f);
            shaderProgram.SetUniform1(gl, "canvasHeight", viewport[3] + 0.0f);
            shaderProgram.SetUniform1(gl, "opacity", this.Opacity);

            this.texture.Bind(gl);
            shaderProgram.SetUniform1(gl, "tex", this.texture.TextureName);
            shaderProgram.SetUniform1(gl, "brightness", this.Brightness);
        }
Example #13
0
        //private void GeneratePoints(out float[] vertices, out float[] colors)
        //{
        //    const int length = 256 * 3;
        //    vertices = new float[length]; colors = new float[length];

        //    Random random = new Random();

        //    int direction = this.positiveGrowth ? 1 : -1;
        //    // points
        //    for (int i = 0; i < length; i++)
        //    {
        //        vertices[i] = direction * (float)i / (float)length;
        //        colors[i] = (float)((random.NextDouble() * 2 - 1) * 1);
        //        //colors[i] = (float)i / (float)length;
        //    }

        //    //// triangles
        //    //for (int i = 0; i < length / 9; i++)
        //    //{
        //    //    var x = random.NextDouble(); var y = random.NextDouble(); var z = random.NextDouble();
        //    //    for (int j = 0; j < 3; j++)
        //    //    {
        //    //        vertices[i * 9 + j * 3] = (float)(x + random.NextDouble() / 5 - 1);
        //    //    }
        //    //    for (int j = 0; j < 3; j++)
        //    //    {
        //    //        vertices[i * 9 + j * 3 + 1] = (float)(y + random.NextDouble() / 5 - 1);
        //    //    }
        //    //    for (int j = 0; j < 3; j++)
        //    //    {
        //    //        vertices[i * 9 + j * 3 + 2] = (float)(z + random.NextDouble() / 5 - 1);
        //    //    }
        //    //}
        //}

        #region IRenderable 成员

        void IRenderable.Render(OpenGL gl, RenderMode renderMode)
        {
            // Update matrices.
            IScientificCamera camera = this.Camera;

            if (camera != null)
            {
                if (camera.CameraType == CameraTypes.Perspecitive)
                {
                    IPerspectiveViewCamera perspective = camera;
                    this.projectionMatrix = perspective.GetProjectionMat4();
                    this.viewMatrix       = perspective.GetViewMat4();
                }
                else if (camera.CameraType == CameraTypes.Ortho)
                {
                    IOrthoViewCamera ortho = camera;
                    this.projectionMatrix = ortho.GetProjectionMat4();
                    this.viewMatrix       = ortho.GetViewMat4();
                }
                else
                {
                    throw new NotImplementedException();
                }
            }

            modelMatrix = mat4.identity();

            gl.PointSize(3);

            var shader = (renderMode == RenderMode.HitTest) ? pickingShaderProgram : shaderProgram;

            //  Bind the shader, set the matrices.
            shader.Bind(gl);
            shader.SetUniformMatrix4(gl, "projectionMatrix", projectionMatrix.to_array());
            shader.SetUniformMatrix4(gl, "viewMatrix", viewMatrix.to_array());
            shader.SetUniformMatrix4(gl, "modelMatrix", modelMatrix.to_array());
            if (renderMode == RenderMode.HitTest)
            {
                shader.SetUniform1(gl, "pickingBaseID", ((IColorCodedPicking)this).PickingBaseID);
            }

            //  Bind the out vertex array.
            vertexBufferArray.Bind(gl);

            //  Draw the square.
            gl.DrawArrays((uint)this.mode, 0, positions.Length / 3);

            //  Unbind our vertex array and shader.
            vertexBufferArray.Unbind(gl);
            shader.Unbind(gl);
        }
        protected void BeforeRendering(OpenGL gl, RenderMode renderMode)
        {
            IScientificCamera camera = this.camera;

            if (camera != null)
            {
                if (camera.CameraType == CameraTypes.Perspecitive)
                {
                    IPerspectiveViewCamera perspective = camera;
                    this.projectionMatrix = perspective.GetProjectionMat4();
                    this.viewMatrix       = perspective.GetViewMat4();
                }
                else if (camera.CameraType == CameraTypes.Ortho)
                {
                    IOrthoViewCamera ortho = camera;
                    this.projectionMatrix = ortho.GetProjectionMat4();
                    this.viewMatrix       = ortho.GetViewMat4();
                }
                else
                {
                    throw new NotImplementedException();
                }
            }

            modelMatrix = mat4.identity();

            gl.Enable(OpenGL.GL_VERTEX_PROGRAM_POINT_SIZE);
            gl.Enable(OpenGL.GL_POINT_SPRITE_ARB);
            gl.TexEnv(OpenGL.GL_POINT_SPRITE_ARB, OpenGL.GL_COORD_REPLACE_ARB, OpenGL.GL_TRUE);
            gl.Enable(OpenGL.GL_POINT_SMOOTH);
            gl.Hint(OpenGL.GL_POINT_SMOOTH_HINT, OpenGL.GL_NICEST);
            gl.Enable(OpenGL.GL_BLEND);
            gl.BlendEquation(OpenGL.GL_FUNC_ADD_EXT);
            gl.BlendFuncSeparate(OpenGL.GL_SRC_ALPHA, OpenGL.GL_ONE_MINUS_SRC_ALPHA, OpenGL.GL_ONE, OpenGL.GL_ONE);


            gl.BindTexture(OpenGL.GL_TEXTURE_2D, this.texture[0]);

            int[] viewport = new int[4];
            gl.GetInteger(OpenGL.GL_VIEWPORT, viewport);

            ShaderProgram shader = this.shaderProgram;

            shader.Bind(gl);
            shader.SetUniform1(gl, "tex", this.texture[0]);
            shader.SetUniformMatrix4(gl, "projectionMatrix", projectionMatrix.to_array());
            shader.SetUniformMatrix4(gl, "viewMatrix", viewMatrix.to_array());
            shader.SetUniformMatrix4(gl, "modelMatrix", modelMatrix.to_array());
            shader.SetUniform1(gl, "pointSize", this.textureWidth * 1.0f);
            shader.SetUniform3(gl, "textColor", this.textColor.x, this.textColor.y, this.textColor.z);
        }
        protected void BeforeRendering(OpenGL gl, RenderMode renderMode)
        {
            IScientificCamera camera = this.camera;

            if (camera != null)
            {
                if (camera.CameraType == CameraTypes.Perspecitive)
                {
                    IPerspectiveViewCamera perspective = camera;
                    this.projectionMatrix = perspective.GetProjectionMat4();
                    this.viewMatrix       = perspective.GetViewMat4();
                }
                else if (camera.CameraType == CameraTypes.Ortho)
                {
                    IOrthoViewCamera ortho = camera;
                    this.projectionMatrix = ortho.GetProjectionMat4();
                    this.viewMatrix       = ortho.GetViewMat4();
                }
                else
                {
                    throw new NotImplementedException();
                }
            }

            gl.Enable(OpenGL.GL_TEXTURE_2D);
            this.texture.Bind(gl);

            modelMatrix = mat4.identity();
            ShaderProgram shaderProgram = this.shaderProgram;

            //  Bind the shader, set the matrices.
            shaderProgram.Bind(gl);
            shaderProgram.SetUniformMatrix4(gl, "projectionMatrix", projectionMatrix.to_array());
            shaderProgram.SetUniformMatrix4(gl, "viewMatrix", viewMatrix.to_array());
            shaderProgram.SetUniformMatrix4(gl, "modelMatrix", modelMatrix.to_array());

            shaderProgram.SetUniform1(gl, "tex", this.texture.TextureName);
            shaderProgram.SetUniform1(gl, "brightness", this.Brightness);


            gl.Enable(OpenGL.GL_POLYGON_SMOOTH);
            gl.Hint(OpenGL.GL_POLYGON_SMOOTH_HINT, OpenGL.GL_NICEST);
        }
Example #16
0
        /// <summary>
        /// 蛇形管道(井)+文字显示
        /// </summary>
        /// <param name="srcWellPath"></param>
        /// <param name="pipeRadius"></param>
        /// <param name="pipeColor"></param>
        /// <param name="name"></param>
        /// <param name="position"></param>
        /// <param name="camera"></param>
        public Well(IScientificCamera camera, List <Vertex> srcWellPath, float pipeRadius, GLColor pipeColor, String name,
                    GLColor textColor = null, int fontSize = 32, int maxRowWidth = 256)
        {
            if (srcWellPath == null || srcWellPath.Count < 2)
            {
                throw new ArgumentException("well path error");
            }

            this.wellInitPath     = srcWellPath;
            this.wellInitRadius   = pipeRadius;
            this.wellPathInitMaxZ = wellInitPath[0].Z;
            this.wellPathInitMinZ = wellInitPath[this.wellInitPath.Count - 1].Z;

            this.wellPathMaxDisplayZ = this.wellPathInitMaxZ;
            this.wellName            = name;
            this.wellPathColor       = pipeColor;
            this.textColor           = textColor;
            this.fontSize            = fontSize;
            this.maxRowWidth         = maxRowWidth;
        }
        /// <summary>
        /// 根据摄像机的类型获取其投影矩阵
        /// </summary>
        /// <param name="camera"></param>
        /// <returns></returns>
        public static mat4 GetProjectionMat4(this IScientificCamera camera)
        {
            mat4 result;

            switch (camera.CameraType)
            {
            case CameraTypes.Perspecitive:
                result = ((IPerspectiveCamera)camera).GetProjectionMat4();
                break;

            case CameraTypes.Ortho:
                result = ((IOrthoCamera)camera).GetProjectionMat4();
                break;

            default:
                throw new NotImplementedException();
            }

            return(result);
        }
        /// <summary>
        /// Pushes the effect onto the specified parent element.
        /// </summary>
        /// <param name="gl">The OpenGL instance.</param>
        /// <param name="parentElement">The parent element.</param>
        public override void Push(OpenGL gl, SceneElement parentElement)
        {
            //  Push the stack.
            gl.PushMatrix();

            // Try to get the scene's camera.
            if (this.arcBall.Camera == null)
            {
                SceneContainer container = parentElement.TraverseToRootElement();
                if (container != null)
                {
                    Scene             scene  = container.ParentScene;
                    IScientificCamera camera = scene.CurrentCamera as IScientificCamera;
                    this.arcBall.Camera = camera;
                }
            }

            //  Perform the transformation.
            arcBall.TransformMatrix(gl);
        }
Example #19
0
 /// <summary>
 /// 对摄像机执行一次缩放操作
 /// </summary>
 /// <param name="camera"></param>
 /// <param name="delta"></param>
 public static void MouseWheel(this IScientificCamera camera, int delta)
 {
     //if (camera.CameraType == CameraTypes.Perspecitive)
     {
         var target2Position = camera.Position - camera.Target;
         if (target2Position.Magnitude() < 0.01)
         {
             target2Position.Normalize();
             target2Position.x *= 0.01f;
             target2Position.y *= 0.01f;
             target2Position.z *= 0.01f;
         }
         var scaledTarget2Position = target2Position * (1 - delta * 0.001f);
         camera.Position = camera.Target + scaledTarget2Position;
         double lengthDiff = scaledTarget2Position.Magnitude() - target2Position.Magnitude();
         // Increase ortho camera's Near/Far property in case the camera's position changes too much.
         IPerspectiveCamera perspectiveCamera = camera;
         perspectiveCamera.Far += lengthDiff;
         //perspectiveCamera.Near += lengthDiff;
         IOrthoCamera orthoCamera = camera;
         orthoCamera.Far  += lengthDiff;
         orthoCamera.Near += lengthDiff;
     }
     //else if (camera.CameraType == CameraTypes.Ortho)
     {
         IOrthoCamera orthoCamera = camera;
         double       distanceX   = orthoCamera.Right - orthoCamera.Left;
         double       distanceY   = orthoCamera.Top - orthoCamera.Bottom;
         double       centerX     = (orthoCamera.Left + orthoCamera.Right) / 2;
         double       centerY     = (orthoCamera.Bottom + orthoCamera.Top) / 2;
         orthoCamera.Left   = centerX - distanceX * (1 - delta * 0.001) / 2;
         orthoCamera.Right  = centerX + distanceX * (1 - delta * 0.001) / 2;
         orthoCamera.Bottom = centerY - distanceY * (1 - delta * 0.001) / 2;
         orthoCamera.Top    = centerX + distanceY * (1 - delta * 0.001) / 2;
     }
 }
Example #20
0
 public PointSetGridderWell3DHelper(PointGridderSource source, IScientificCamera camera)
 {
     this.gridderSource = source;
     this.camera        = camera;
 }
Example #21
0
 /// <summary>
 /// Render models with shader and VAO.
 /// <para>Use <see cref="IHasObjectSpace"/> and <paramref name="camera"/> to update projection and view matrices.</para>
 /// </summary>
 /// <param name="camera"></param>
 public ModernSceneControlSceneElement(IScientificCamera camera = null)
 {
     this.Camera = camera;
 }
Example #22
0
        private void PrepareCamera()
        {
            var camera = this.Camera;
            if (camera != null)
            {
                vec3 back = camera.Position - camera.Target;
                vec3 right = Camera.UpVector.VectorProduct(back);
                vec3 up = back.VectorProduct(right);
                back.Normalize();
                right.Normalize();
                up.Normalize();

                this.back = back;
                this.right = right;
                this.up = up;

                if (this.originalCamera == null)
                { this.originalCamera = new ScientificCamera(); }
                this.originalCamera.Position = camera.Position;
                this.originalCamera.UpVector = camera.UpVector;
            }
        }
 public Well3DTrajectoryHelper(GridderSource source, IScientificCamera camera, List <WellTrajectory> wells)
 {
     this.gridder            = source;
     this.camera             = camera;
     this.wellTrajectoryList = wells;
 }
 public HexahedronGrid(OpenGL gl, IScientificCamera camera)
     : base(gl, camera)
 {
 }
Example #25
0
 public PointGrid(OpenGL gl, IScientificCamera camera)
     : base(gl, camera)
 {
 }
Example #26
0
 /// <summary>
 /// Initializes a new instance of the <see cref="RenderEventArgs"/> class.
 /// </summary>
 /// <param name="graphics">The graphics.</param>
 public RenderEventArgs(RenderModes renderMode, IScientificCamera camera)
 {
     this.RenderMode = renderMode;
     this.Camera     = camera;
 }
Example #27
0
 /// <summary>
 /// Rotates a camera on a sphere, whose center is camera's Target.
 /// <para>Just like a satellite moves around a fixed star.</para>
 /// </summary>
 /// <param name="camera"></param>
 public SatelliteRotator(IScientificCamera camera = null)
 {
     this.Camera = camera;
 }
Example #28
0
 public HexahedronGrid(OpenGL gl, IScientificCamera camera)
     : base(gl, camera)
 {
 }
        void IRenderable.Render(OpenGL gl, RenderMode renderMode)
        {
            if (!this.RenderModel)
            {
                return;
            }

            if (!initialised)
            {
                this.Initialise(gl);
            }
            // Update matrices.
            IScientificCamera camera = this.Camera;

            if (camera != null)
            {
                if (camera.CameraType == CameraTypes.Perspecitive)
                {
                    IPerspectiveViewCamera perspective = camera;
                    this.projectionMatrix = perspective.GetProjectionMat4();
                    this.viewMatrix       = perspective.GetViewMat4();
                }
                else if (camera.CameraType == CameraTypes.Ortho)
                {
                    IOrthoViewCamera ortho = camera;
                    this.projectionMatrix = ortho.GetProjectionMat4();
                    this.viewMatrix       = ortho.GetViewMat4();
                }
                else
                {
                    throw new NotImplementedException();
                }
            }

            modelMatrix = glm.scale(mat4.identity(), new vec3(1, 1, this.ZAxisScale));

            //gl.PointSize(3);

            var shader = (renderMode == RenderMode.HitTest) ? pickingShaderProgram : shaderProgram;

            //  Bind the shader, set the matrices.
            shader.Bind(gl);
            shader.SetUniformMatrix4(gl, "projectionMatrix", projectionMatrix.to_array());
            shader.SetUniformMatrix4(gl, "viewMatrix", viewMatrix.to_array());
            shader.SetUniformMatrix4(gl, "modelMatrix", modelMatrix.to_array());
            if (renderMode == RenderMode.HitTest)
            {
                shader.SetUniform1(gl, "pickingBaseID", ((IColorCodedPicking)this).PickingBaseID);
            }

            //  Bind the out vertex array.
            vertexBufferArray.Bind(gl);

            //  Draw the square.
            ScientificModel model = this.Model;

            if (model.First != null && model.Count != null && model.PrimitiveCount > 0)
            {
                gl.MultiDrawArrays((uint)model.Mode, model.First, model.Count, model.PrimitiveCount);
            }
            else
            {
                gl.DrawArrays((uint)this.Model.Mode, 0, this.Model.VertexCount);
            }

            //  Unbind our vertex array and shader.
            vertexBufferArray.Unbind(gl);
            shader.Unbind(gl);
        }
 public DynamicUnstructureGrid(OpenGL gl, IScientificCamera camera)
     : base(gl, camera)
 {
 }
Example #31
0
 public HexahedronGridderWell3DHelper(HexahedronGridderSource hexahedronGridder, IScientificCamera camera)
 {
     this.gridder = hexahedronGridder;
     this.camera  = camera;
 }
        void ISupportInitialize.EndInit()
        {
            CreateRenderContext();

            this.camera = new ScientificCamera(CameraTypes.Perspecitive, this.Width, this.Height);

            this.rotator = new SatelliteRotator(this.camera);

            this.MouseDown += scientificVisual3DControl1_MouseDown;
            this.MouseMove += scientificVisual3DControl1_MouseMove;
            this.MouseUp += scientificVisual3DControl1_MouseUp;

            {
                IUILayoutParam param = new IUILayoutParam(AnchorStyles.Left | AnchorStyles.Bottom,
                    new Padding(10, 10, 10, 10), new Size(50, 50));
                uiAxis = new SimpleUIAxis(param);
                uiAxis.Initialize();
                this.ElementList.Add(uiAxis);
            }
            {
                IUILayoutParam param = new IUILayoutParam(AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Bottom,
                    new Padding(100, 30, 40, 30), new Size(30, 30));
                ColorPalette colorPalette = ColorPaletteFactory.CreateRainbow();
                uiColorIndicator = new SimpleUIColorIndicator(param, colorPalette, new Objects.GLColor(1, 1, 1, 1), -100, 100, 5);
                uiColorIndicator.Initialize();
                this.ElementList.Add(uiColorIndicator);
            }
        }
 public ScientificModelElement(ScientificModel model, IScientificCamera camera, bool renderModel = true)
 {
     this.Model       = model;
     this.Camera      = camera;
     this.RenderModel = renderModel;
 }
Example #34
0
 /// <summary>
 /// Rotates a camera on a sphere, whose center is camera's Target.
 /// <para>Just like a satellite moves around a fixed star.</para>
 /// </summary>
 /// <param name="camera"></param>
 public SatelliteRotation(IScientificCamera camera = null)
 {
     this.Camera = camera;
 }
Example #35
0
 /// <summary>
 /// Render models with shader and VAO.
 /// <para>Use <see cref="IHasObjectSpace"/> and <paramref name="camera"/> to update projection and view matrices.</para>
 /// </summary>
 /// <param name="positiveGrowth"></param>
 /// <param name="camera"></param>
 public ModernMySceneControlSceneElement(bool positiveGrowth = true, IScientificCamera camera = null)
 {
     this.positiveGrowth = positiveGrowth;
     this.Camera         = camera;
 }
Example #36
0
 public PointGrid(OpenGL gl, IScientificCamera camera)
     : base(gl, camera)
 {
 }
Example #37
0
 /// <summary>
 /// Initializes a new instance of the <see cref="RenderEventArgs"/> class.
 /// </summary>
 /// <param name="graphics">The graphics.</param>
 public RenderEventArgs(RenderModes renderMode, IScientificCamera camera)
 {
     this.RenderMode = renderMode;
     this.Camera = camera;
 }
 public DynamicUnstructureGrid(OpenGL gl, IScientificCamera camera)
     : base(gl, camera)
 {
 }