コード例 #1
0
        private void ControllerDraw(Controller3D mc, ulong unused)
        {
            ((GLMatrixCalcUniformBlock)items.UB("MCUB")).Set(gl3dcontroller.MatrixCalc);        // set the matrix unform block to the controller 3d matrix calc.

            IGLRenderableItem       i = rObjects["DYNGRIDRENDER"];
            DynamicGridVertexShader s = items.PLShader("PLGRIDVertShader") as DynamicGridVertexShader;

            if (Math.Abs(lasteyedistance - gl3dcontroller.MatrixCalc.EyeDistance) > 10)     // a little histerisis
            {
                i.InstanceCount = s.ComputeGridSize(gl3dcontroller.MatrixCalc.EyeDistance, out lastgridwidth);
                lasteyedistance = gl3dcontroller.MatrixCalc.EyeDistance;
            }

            s.SetUniforms(gl3dcontroller.MatrixCalc.LookAt, lastgridwidth, i.InstanceCount);

            DynamicGridCoordVertexShader bs = items.PLShader("PLGRIDBitmapVertShader") as DynamicGridCoordVertexShader;

            bs.ComputeUniforms(lastgridwidth, gl3dcontroller.MatrixCalc, gl3dcontroller.PosCamera.CameraDirection, Color.Yellow, Color.Transparent);

            solmarker.Position = gl3dcontroller.MatrixCalc.LookAt;
            solmarker.Scale    = gl3dcontroller.MatrixCalc.EyeDistance / 20;

            rObjects.Render(glwfc.RenderState, gl3dcontroller.MatrixCalc);

            this.Text = "Looking at " + gl3dcontroller.MatrixCalc.LookAt + " eye@ " + gl3dcontroller.MatrixCalc.EyePosition + " dir " + gl3dcontroller.PosCamera.CameraDirection + " Dist " + gl3dcontroller.MatrixCalc.EyeDistance + " Zoom " + gl3dcontroller.PosCamera.ZoomFactor;
        }
コード例 #2
0
        private void ControllerDraw(Controller3D mc, ulong unused)
        {
            //System.Diagnostics.Debug.WriteLine("Draw");

            GLMatrixCalcUniformBlock mcub = (GLMatrixCalcUniformBlock)items.UB("MCUB");

            mcub.SetFull(gl3dcontroller.MatrixCalc);

            rObjects.Render(glwfc.RenderState, gl3dcontroller.MatrixCalc);

            var azel = gl3dcontroller.PosCamera.EyePosition.AzEl(gl3dcontroller.PosCamera.LookAt, true);

            this.Text = "Looking at " + gl3dcontroller.MatrixCalc.LookAt + " from " + gl3dcontroller.MatrixCalc.EyePosition + " cdir " + gl3dcontroller.PosCamera.CameraDirection + " azel " + azel + " zoom " + gl3dcontroller.PosCamera.ZoomFactor + " dist " + gl3dcontroller.MatrixCalc.EyeDistance + " FOV " + gl3dcontroller.MatrixCalc.FovDeg;

            //GL.MemoryBarrier(MemoryBarrierFlags.AllBarrierBits);
            //Vector4[] databack = dataoutbuffer.ReadVector4(0, 4);
            //for (int i = 0; i < databack.Length; i += 1)
            //{
            //   // databack[i] = databack[i] / databack[i].W;
            //   // databack[i].X = databack[i].X * gl3dcontroller.glControl.Width / 2 + gl3dcontroller.glControl.Width/2;
            //   // databack[i].Y = gl3dcontroller.glControl.Height - databack[i].Y * gl3dcontroller.glControl.Height;
            //    System.Diagnostics.Debug.WriteLine("{0}={1}", i, databack[i].ToStringVec(true));
            //}
            //GLStatics.Check();
        }
コード例 #3
0
        private void ControllerDraw(Controller3D mc, ulong unused)
        {
            GLMatrixCalcUniformBlock mcub = (GLMatrixCalcUniformBlock)items.UB("MCUB");

            mcub.Set(gl3dcontroller.MatrixCalc);

            vecoutbuffer.ZeroBuffer();
            rObjects.Render(glwfc.RenderState, gl3dcontroller.MatrixCalc);

            int count = vecoutbuffer.ReadInt(0);

            if (count > 0)
            {
                float[] values = vecoutbuffer.ReadFloats(4, Math.Min(2000, count), true);
                System.Diagnostics.Debug.WriteLine("Count " + count + " min " + values.Min() + " max " + values.Max());
                for (int i = 0; i < count; i = i + 4)
                {
                    Vector3 pos = new Vector3(values[i], values[i + 1], values[i + 2]);
                    System.Diagnostics.Debug.Write("    " + i / 4 + " = " + pos + " : " + values[i + 3]);

                    Vector3 up    = new Vector3(0, 1, 0);
                    float   value = Vector3.Dot(up, pos);
                    value = 0.0f + value;
                    System.Diagnostics.Debug.WriteLine("        -> dotp" + value);
                }
            }

            this.Text = "Looking at " + gl3dcontroller.MatrixCalc.LookAt + " dir " + gl3dcontroller.PosCamera.CameraDirection + " Dist " + gl3dcontroller.MatrixCalc.EyeDistance;
        }
コード例 #4
0
        private void ControllerDraw(Controller3D mc, ulong unused)
        {
            items.Get <GLMatrixCalcUniformBlock>("MCUB").Set(gl3dcontroller.MatrixCalc);        // set the matrix unform block to the controller 3d matrix calc.

            if (noisebox != null)
            {
                noisebox.InstanceCount = volumetricblock.Set(gl3dcontroller.MatrixCalc, boundingbox, 10.0f);        // set up the volumentric uniform
            }
            dataoutbuffer.ZeroBuffer();
            atomicbuffer.ZeroBuffer();

            rObjects.Render(glwfc.RenderState, gl3dcontroller.MatrixCalc);

            GL.MemoryBarrier(MemoryBarrierFlags.AllBarrierBits);

            Vector4[] databack = dataoutbuffer.ReadVector4s(0, 10);

            //System.Diagnostics.Debug.WriteLine("avg {0} txtavg {1}", databack[0].ToStringVec(), databack[1].ToStringVec());

            for (int i = 0; i < databack.Length; i += 1)
            {
                //       System.Diagnostics.Debug.WriteLine("db " + databack[i].ToStringVec());
            }

            this.Text = "Looking at " + gl3dcontroller.MatrixCalc.LookAt + " eye@ " + gl3dcontroller.MatrixCalc.EyePosition + " dir " + gl3dcontroller.PosCamera.CameraDirection + " Dist " + gl3dcontroller.MatrixCalc.EyeDistance + " Zoom " + gl3dcontroller.PosCamera.ZoomFactor;
        }
コード例 #5
0
        private void ControllerDraw(Controller3D mc, ulong unused)
        {
            GLMatrixCalcUniformBlock mcub = (GLMatrixCalcUniformBlock)items.UB("MCUB");

            mcub.Set(gl3dcontroller.MatrixCalc);
            rObjects.Render(glwfc.RenderState, gl3dcontroller.MatrixCalc);
        }
コード例 #6
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);
            Closed += ShaderTest_Closed;

            gl3dcontroller = new Controller3D();
            gl3dcontroller.PaintObjects = ControllerDraw;
            gl3dcontroller.MatrixCalc.PerspectiveNearZDistance = 0.1f;
            gl3dcontroller.ZoomDistance = 20F;
            gl3dcontroller.Start(glwfc, new Vector3(0, 0, 0), new Vector3(110f, 0, 0f), 1F);

            gl3dcontroller.KeyboardTravelSpeed = (ms, eyedist) =>
            {
                return((float)ms / 50.0f);
            };

            //items.Add("lensflarewhite", new GLTexture2D(Properties.Resources.lensflare_white64));
            items.Add(new GLTexture2D(Properties.Resources.StarFlare2, SizedInternalFormat.Rgba8), "lensflare");

            items.Add(new GLColorShaderWorld(), "COS");

            #region coloured lines

            {
                GLRenderState rl = GLRenderState.Lines(1);
                rObjects.Add(items.Shader("COS"),    // horizontal
                             GLRenderableItem.CreateVector4Color4(items, PrimitiveType.Lines, rl,
                                                                  GLShapeObjectFactory.CreateLines(new Vector3(-100, 0, -100), new Vector3(-100, 0, 100), new Vector3(10, 0, 0), 21),
                                                                  new Color4[] { Color.Red, Color.Red, Color.Green, Color.Green })
                             );


                rObjects.Add(items.Shader("COS"),    // vertical
                             GLRenderableItem.CreateVector4Color4(items, PrimitiveType.Lines, rl,
                                                                  GLShapeObjectFactory.CreateLines(new Vector3(-100, 0, -100), new Vector3(100, 0, -100), new Vector3(0, 0, 10), 21),
                                                                  new Color4[] { Color.Red, Color.Red, Color.Green, Color.Green })
                             );
            }

            var p = GLPointsFactory.RandomStars4(100, -100, 100, 100, -100, 100, -100);
            //p = new Vector4[10];
            //for( int i = 0; i < 10; i++)
            //{
            //    p[i] = new Vector4(i, 6.8f, 0,1);
            //}

            items.Add(new GLPointSprite(), "PS1");

            GLRenderState rp = GLRenderState.PointSprites();     // by program

            GLRenderDataTexture rt = new GLRenderDataTexture(items.Tex("lensflare"), 4);

            rObjects.Add(items.Shader("PS1"),
                         GLRenderableItem.CreateVector4Color4(items, PrimitiveType.Points, rp,
                                                              p, new Color4[] { Color.Red, Color.Yellow, Color.Green }, rt));

            #endregion

            items.Add(new GLMatrixCalcUniformBlock(), "MCUB");      // create a matrix uniform block
        }
        private void ControllerDraw(Controller3D mc, ulong time)
        {
            // System.Diagnostics.Debug.WriteLine("Draw eye " + gl3dcontroller.MatrixCalc.EyePosition + " to " + gl3dcontroller.Pos.Current);

            float zeroone10s = ((float)(time % 10000)) / 10000.0f;
            float zeroone5s  = ((float)(time % 5000)) / 5000.0f;
            float zerotwo5s  = ((float)(time % 5000)) / 2500.0f;
            float degrees    = zeroone10s * 360;

            // matrixbuffer.Write(Matrix4.CreateTranslation(new Vector3(zeroone * 20, 50, 0)),0,true);

            if (items.Contains("ShaderPos"))
            {
                ((GLMultipleTexturedBlended)items.Shader("ShaderPos")).CommonTransform.YRotDegrees = degrees;
                ((GLMultipleTexturedBlended)items.Shader("ShaderPos")).Blend = zerotwo5s;
            }

            if (items.Contains("ShaderMat"))
            {
                ((GLMultipleTexturedBlended)items.Shader("ShaderMat")).CommonTransform.ZRotDegrees = degrees;
                ((GLMultipleTexturedBlended)items.Shader("ShaderMat")).Blend = zerotwo5s;
            }

            GLMatrixCalcUniformBlock mcub = (GLMatrixCalcUniformBlock)items.UB("MCUB");

            mcub.Set(gl3dcontroller.MatrixCalc);

            rObjects.Render(glwfc.RenderState, gl3dcontroller.MatrixCalc);

            this.Text = "Looking at " + gl3dcontroller.MatrixCalc.LookAt + " dir " + gl3dcontroller.PosCamera.CameraDirection + " Dist " + gl3dcontroller.MatrixCalc.EyeDistance;
        }
コード例 #8
0
        private void ControllerDraw(Controller3D mc, ulong unused)
        {
            System.Diagnostics.Debug.WriteLine("Draw");

            GLMatrixCalcUniformBlock mcub = (GLMatrixCalcUniformBlock)items.UB("MCUB");

            mcub.SetFull(gl3dcontroller.MatrixCalc);

            rObjects.Render(glwfc.RenderState, gl3dcontroller.MatrixCalc, false);

            GLStatics.Check();

            //GLStatics.Flush();

            var t1 = ts1.GetCounter();
            var t2 = ts2.GetCounter();

            System.Diagnostics.Debug.WriteLine($"Time Taken {t2 - t1} ns");

            var t = sync.ClientWait(ClientWaitSyncFlags.SyncFlushCommandsBit, 100000000);

            System.Diagnostics.Debug.WriteLine($"Sync {t}");

            sync.Dispose();

            var azel = gl3dcontroller.PosCamera.EyePosition.AzEl(gl3dcontroller.PosCamera.LookAt, true);

            this.Text = "Looking at " + gl3dcontroller.MatrixCalc.LookAt + " from " + gl3dcontroller.MatrixCalc.EyePosition + " cdir " + gl3dcontroller.PosCamera.CameraDirection + " azel " + azel + " zoom " + gl3dcontroller.PosCamera.ZoomFactor + " dist " + gl3dcontroller.MatrixCalc.EyeDistance + " FOV " + gl3dcontroller.MatrixCalc.FovDeg;
        }
コード例 #9
0
        private void ControllerDraw(Controller3D mc, ulong unused)
        {
            // System.Diagnostics.Debug.WriteLine("Draw eye " + gl3dcontroller.MatrixCalc.EyePosition + " to " + gl3dcontroller.Pos.Current);

            GLMatrixCalcUniformBlock mcub = (GLMatrixCalcUniformBlock)items.UB("MCUB");

            mcub.Set(gl3dcontroller.MatrixCalc);

            countbuffer.ZeroBuffer();

            rObjects.Render(glwfc.RenderState, gl3dcontroller.MatrixCalc);

            GLMemoryBarrier.Vertex();

            int count = countbuffer.ReadInt(0);

            Vector4[] d = rejectedbuffer.ReadVector4s(0, count);
            for (int i = 0; i < count; i++)
            {
                System.Diagnostics.Debug.WriteLine(i + " = " + d[i]);
            }

            redraw.DrawCount = count;                                               // render passed back ones using red from vecoutbuffer
            rObjects2.Render(glwfc.RenderState, gl3dcontroller.MatrixCalc);
        }
コード例 #10
0
        private void ControllerDraw(Controller3D mc, ulong unused)
        {
            System.Diagnostics.Debug.WriteLine("Draw");

            GLMatrixCalcUniformBlock mcub = (GLMatrixCalcUniformBlock)items.UB("MCUB");

            mcub.SetFull(gl3dcontroller.MatrixCalc);

            rObjects.Render(glwfc.RenderState, gl3dcontroller.MatrixCalc, true);

            GLStatics.Check();

            GLStatics.Flush();

            var t1 = ts1.GetCounter();
            var t2 = ts2.GetCounter();

            System.Diagnostics.Debug.WriteLine($"Time Taken {t2-t1} ns");

            GLMemoryBarrier.All();
            Vector3[] values3 = varyingbuffer.ReadVector3sPacked(0, 8);     // varyings seem to ignore the vec3->vec4 packed thingy..

            System.Diagnostics.Debug.Assert(values3[1] == new Vector3(shape[1].X, shape[1].Y, shape[1].Z));
            System.Diagnostics.Debug.Assert(values3[3] == new Vector3(shape[3].X, shape[3].Y, shape[3].Z));

            var azel = gl3dcontroller.PosCamera.EyePosition.AzEl(gl3dcontroller.PosCamera.LookAt, true);

            this.Text = "Looking at " + gl3dcontroller.MatrixCalc.LookAt + " from " + gl3dcontroller.MatrixCalc.EyePosition + " cdir " + gl3dcontroller.PosCamera.CameraDirection + " azel " + azel + " zoom " + gl3dcontroller.PosCamera.ZoomFactor + " dist " + gl3dcontroller.MatrixCalc.EyeDistance + " FOV " + gl3dcontroller.MatrixCalc.FovDeg;
        }
コード例 #11
0
        private void ControllerDraw(Controller3D mc, ulong time)
        {
            // System.Diagnostics.Debug.WriteLine("Draw eye " + gl3dcontroller.MatrixCalc.EyePosition + " to " + gl3dcontroller.Pos.Current);

            float zeroone10000s = ((float)(time % 10000000)) / 10000000.0f;
            float zeroone5000s  = ((float)(time % 5000000)) / 5000000.0f;
            float zeroone1000s  = ((float)(time % 1000000)) / 1000000.0f;
            float zeroone500s   = ((float)(time % 500000)) / 500000.0f;
            float zeroone100s   = ((float)(time % 100000)) / 100000.0f;
            float zeroone10s    = ((float)(time % 10000)) / 10000.0f;
            float zeroone5s     = ((float)(time % 5000)) / 5000.0f;
            float zerotwo5s     = ((float)(time % 5000)) / 2500.0f;
            float timediv10s    = (float)time / 10000.0f;
            float timediv100s   = (float)time / 100000.0f;


            if (items.Contains("STAR"))
            {
                int vid = items.Shader("STAR").GetShader(OpenTK.Graphics.OpenGL4.ShaderType.FragmentShader).Id;
                ((GLRenderDataTranslationRotation)(rObjects["sun"].RenderData)).RotationDegrees = new Vector3(0, -zeroone100s * 360, 0);
                var stellarsurfaceshader = (GLPLStarSurfaceFragmentShader)items.Shader("STAR").GetShader(OpenTK.Graphics.OpenGL4.ShaderType.FragmentShader);
                stellarsurfaceshader.TimeDeltaSpots   = zeroone500s;
                stellarsurfaceshader.TimeDeltaSurface = timediv100s;
            }

            if (items.Contains("STAR-M2"))
            {
                var vid = items.Shader("STAR-M2").GetShader(OpenTK.Graphics.OpenGL4.ShaderType.VertexShader);
                ((GLPLVertexShaderModelCoordWorldAutoscale)vid).ModelTranslation = Matrix4.CreateRotationY((float)(-zeroone10s * Math.PI * 2));
                var stellarsurfaceshader = (GLPLStarSurfaceFragmentShader)items.Shader("STAR-M2").GetShader(OpenTK.Graphics.OpenGL4.ShaderType.FragmentShader);
                stellarsurfaceshader.TimeDeltaSpots   = zeroone500s;
                stellarsurfaceshader.TimeDeltaSurface = timediv100s;
            }

            if (items.Contains("STAR-M3"))
            {
                var vid = items.Shader("STAR-M3").GetShader(OpenTK.Graphics.OpenGL4.ShaderType.VertexShader);
                ((GLPLVertexShaderModelCoordWorldAutoscale)vid).ModelTranslation = Matrix4.CreateRotationY((float)(-zeroone10s * Math.PI * 2));
                var stellarsurfaceshader = (GLPLStarSurfaceFragmentShader)items.Shader("STAR-M3").GetShader(OpenTK.Graphics.OpenGL4.ShaderType.FragmentShader);
                stellarsurfaceshader.TimeDeltaSpots   = zeroone500s;
                stellarsurfaceshader.TimeDeltaSurface = timediv100s;
            }

            if (items.Contains("CORONA"))
            {
                ((GLShaderStarCorona)items.Shader("CORONA")).TimeDelta = (float)time / 100000f;
            }

            GLMatrixCalcUniformBlock mcub = (GLMatrixCalcUniformBlock)items.UB("MCUB");

            mcub.Set(gl3dcontroller.MatrixCalc);

            rObjects.Render(glwfc.RenderState, gl3dcontroller.MatrixCalc);
            GL.MemoryBarrier(MemoryBarrierFlags.AllBarrierBits);


            this.Text = //"Freq " + frequency.ToString("#.#########") + " unRadius " + unRadius + " scutoff" + scutoff + " BD " + blackdeepness + " CE " + concentrationequator
                        "    Looking at " + gl3dcontroller.MatrixCalc.LookAt + " dir " + gl3dcontroller.PosCamera.CameraDirection + " Dist " + gl3dcontroller.MatrixCalc.EyeDistance;
        }
コード例 #12
0
        private void Controller3dDraw(Controller3D mc, ulong unused)
        {
            ((GLMatrixCalcUniformBlock)items.UB("MCUB")).SetFull(gl3dcontroller.MatrixCalc);        // set the matrix unform block to the controller 3d matrix calc.

            rObjects.Render(glwfc.RenderState, gl3dcontroller.MatrixCalc);

            this.Text = "Looking at " + gl3dcontroller.MatrixCalc.LookAt + " eye@ " + gl3dcontroller.MatrixCalc.EyePosition + " dir " + gl3dcontroller.PosCamera.CameraDirection + " Dist " + gl3dcontroller.MatrixCalc.EyeDistance + " Zoom " + gl3dcontroller.PosCamera.ZoomFactor;
        }
コード例 #13
0
        private void ControllerDraw(Controller3D mc, long time)
        {
            ((GLMatrixCalcUniformBlock)items.UB("MCUB")).Set(gl3dcontroller.MatrixCalc);        // set the matrix unform block to the controller 3d matrix calc.

            rObjects.Render(gl3dcontroller.MatrixCalc);

            this.Text = "Looking at " + gl3dcontroller.MatrixCalc.TargetPosition + " dir " + gl3dcontroller.Pos.CameraDirection + " eye@ " + gl3dcontroller.MatrixCalc.EyePosition + " Dist " + gl3dcontroller.MatrixCalc.EyeDistance;
        }
コード例 #14
0
ファイル: EnemyAI.cs プロジェクト: kirinja/Irrbloss
    // Use this for initialization
    void Start()
    {
        _agent             = GetComponent <NavMeshAgent>();
        _agent.destination = Targets[_currentTarget].position;

        _player = GameObject.FindGameObjectWithTag("Player").GetComponent <Controller3D>();
        _speed  = _agent.speed;
    }
コード例 #15
0
        private void ControllerDraw(Controller3D mc, ulong unused)
        {
            GLMatrixCalcUniformBlock mcub = (GLMatrixCalcUniformBlock)items.UB("MCUB");

            mcub.Set(gl3dcontroller.MatrixCalc);

            rObjects.Render(glwfc.RenderState, gl3dcontroller.MatrixCalc);
            GL.MemoryBarrier(MemoryBarrierFlags.VertexAttribArrayBarrierBit);
        }
コード例 #16
0
        private void ControllerDraw(Controller3D mc, ulong unused)
        {
            GLMatrixCalcUniformBlock mcub = (GLMatrixCalcUniformBlock)items.UB("MCUB");

            mcub.Set(gl3dcontroller.MatrixCalc);

            rObjects.Render(glwfc.RenderState, gl3dcontroller.MatrixCalc);

            this.Text = "Looking at " + gl3dcontroller.MatrixCalc.LookAt + " dir " + gl3dcontroller.PosCamera.CameraDirection + " Dist " + gl3dcontroller.MatrixCalc.EyeDistance;
        }
コード例 #17
0
    void Start()
    {
        controller = GetComponent <Controller3D>();
        cast       = GetComponent <Cast>();

        gravity      = -(2 * jumpHeight) / Mathf.Pow(timeToJumpApex, 2);
        jumpVelocity = Mathf.Abs(gravity) * timeToJumpApex;

        startScale = playerSprite.transform.localScale.x;
    }
コード例 #18
0
    // Use this for initialization
    void Start()
    {
        controller = GetComponent <Controller3D>();
        anim       = GetComponent <Animator>();

        gravity         = -(2 * maxJumpHeight) / Mathf.Pow(timeToJumpApex, 2);
        maxJumpVelocity = Mathf.Abs(gravity) * timeToJumpApex;
        minJumpVelocity = Mathf.Sqrt(2 * Mathf.Abs(gravity) * minJumpHeight);
        distToGround    = GetComponent <CapsuleCollider>().bounds.extents.z;

        state = State.idle;
    }
コード例 #19
0
        private void ControllerDraw(Controller3D mc, ulong time)
        {
            float degrees   = ((float)time / 5000.0f * 360.0f) % 360f;
            float degreesd2 = ((float)time / 10000.0f * 360.0f) % 360f;

            GLMatrixCalcUniformBlock mcub = (GLMatrixCalcUniformBlock)items.UB("MCUB");

            mcub.Set(gl3dcontroller.MatrixCalc);

            System.Diagnostics.Debug.WriteLine("Draw eye " + gl3dcontroller.MatrixCalc.EyePosition + " to " + gl3dcontroller.PosCamera.LookAt);
            rObjects.Render(glwfc.RenderState, gl3dcontroller.MatrixCalc);
        }
コード例 #20
0
        private void ControllerDraw(Controller3D mc, ulong unused)
        {
            ((GLMatrixCalcUniformBlock)items.UB("MCUB")).Set(gl3dcontroller.MatrixCalc);        // set the matrix unform block to the controller 3d matrix calc.

            pointblock.StartWrite(0, pointblock.Length);
            float minzv = float.MaxValue, maxzv = float.MinValue;

            for (int i = 0; i < 8; i++)
            {
                Vector4 p = Vector4.Transform(boundingbox[i], mc.MatrixCalc.ModelMatrix);
                if (p.Z < minzv)
                {
                    minzv = p.Z;
                }
                if (p.Z > maxzv)
                {
                    maxzv = p.Z;
                }
                pointblock.Write(p);
            }

            pointblock.Write(minzv);
            pointblock.Write(maxzv);
            pointblock.Write(Vector4.Transform(new Vector4(mc.MatrixCalc.EyePosition, 0), mc.MatrixCalc.ModelMatrix));
            float slicedist  = (maxzv - minzv) / (float)slices;
            float slicestart = (maxzv - minzv) / ((float)slices * 2);

            pointblock.Write(slicestart); //slicestart
            pointblock.Write(slicedist);  //slicedist

            //     System.Diagnostics.Debug.WriteLine("slice start {0} dist {1}", slicestart, slicedist);
            // for (int ic = 0; ic < slices; ic++)
            //    System.Diagnostics.Debug.WriteLine("slice {0} {1} {2}", minzv, maxzv, minzv + slicestart + slicedist * ic);
            pointblock.StopReadWrite();

            dataoutbuffer.ZeroBuffer();
            atomicbuffer.ZeroBuffer();

            rObjects.Render(glwfc.RenderState, gl3dcontroller.MatrixCalc);

            GL.MemoryBarrier(MemoryBarrierFlags.AllBarrierBits);

            Vector4[] databack = dataoutbuffer.ReadVector4s(0, 5);

            //  System.Diagnostics.Debug.WriteLine("avg {0} txtavg {1}", databack[0].ToStringVec(), databack[1].ToStringVec());

            for (int i = 0; i < databack.Length; i += 1)
            {
                //       System.Diagnostics.Debug.WriteLine("db "+databack[i].ToStringVec());
            }

            this.Text = "Looking at " + gl3dcontroller.MatrixCalc.LookAt + " dir " + gl3dcontroller.PosCamera.CameraDirection + " eye@ " + gl3dcontroller.MatrixCalc.EyePosition + " Dist " + gl3dcontroller.MatrixCalc.EyeDistance;
        }
コード例 #21
0
        private void ControllerDraw(Controller3D mc, ulong unused)
        {
            ((GLMatrixCalcUniformBlock)items.UB("MCUB")).Set(gl3dcontroller.MatrixCalc);        // set the matrix unform block to the controller 3d matrix calc.

            if (galaxy != null)
            {
                galaxy.InstanceCount = volumetricblock.Set(gl3dcontroller.MatrixCalc, boundingbox, 50.0f);        // set up the volumentric uniform
            }
            rObjects.Render(glwfc.RenderState, gl3dcontroller.MatrixCalc);


            this.Text = "Looking at " + gl3dcontroller.MatrixCalc.LookAt + " eye@ " + gl3dcontroller.MatrixCalc.EyePosition + " dir " + gl3dcontroller.PosCamera.CameraDirection + " Dist " + gl3dcontroller.MatrixCalc.EyeDistance + " Zoom " + gl3dcontroller.PosCamera.ZoomFactor;
        }
コード例 #22
0
        private void ControllerDraw(Controller3D mc, ulong unused)
        {
            //System.Diagnostics.Debug.WriteLine("Draw");

            GLMatrixCalcUniformBlock mcub = (GLMatrixCalcUniformBlock)items.UB("MCUB");

            mcub.SetFull(gl3dcontroller.MatrixCalc);

            rObjects.Render(glwfc.RenderState, gl3dcontroller.MatrixCalc);

            var azel = gl3dcontroller.PosCamera.EyePosition.AzEl(gl3dcontroller.PosCamera.LookAt, true);

            this.Text = "Main Window Looking at " + gl3dcontroller.MatrixCalc.LookAt + " from " + gl3dcontroller.MatrixCalc.EyePosition + " cdir " + gl3dcontroller.PosCamera.CameraDirection + " azel " + azel + " zoom " + gl3dcontroller.PosCamera.ZoomFactor + " dist " + gl3dcontroller.MatrixCalc.EyeDistance + " FOV " + gl3dcontroller.MatrixCalc.FovDeg;
        }
コード例 #23
0
        // Demonstrate buffer feedback AND geo shader add vertex/dump vertex

        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            gl3dcontroller = new Controller3D();
            gl3dcontroller.PaintObjects = ControllerDraw;
            gl3dcontroller.ZoomDistance = 20F;
            gl3dcontroller.MatrixCalc.PerspectiveNearZDistance = 0.1f;
            gl3dcontroller.Start(glwfc, new Vector3(0, 0, 0), new Vector3(170f, 0, 0f), 1F);

            gl3dcontroller.KeyboardTravelSpeed = (ms, eyedist) =>
            {
                return((float)ms / 20.0f);
            };

            // 16 vertexes, passed thru geo shader above

            GLStorageBlock storagebuffer = new GLStorageBlock(5);           // new storage block on binding index 5 to provide vertexes

            Vector4[] vertexes = new Vector4[16];
            for (int v = 0; v < vertexes.Length; v++)
            {
                vertexes[v] = new Vector4(v % 4, 0, v / 4, 1);
            }
            storagebuffer.AllocateFill(vertexes);

            items.Add(new ShaderT3(), "Shader");            // geo shader
            GLRenderState ri = GLRenderState.Points();

            rObjects.Add(items.Shader("Shader"), "T1", new GLRenderableItem(PrimitiveType.Points, ri, vertexes.Length, null, null, 1));

            // list of rejected by geoshader above

            rejectedbuffer = new GLStorageBlock(1);                                                                     // new storage block on binding index 1 for vector out
            rejectedbuffer.AllocateBytes(sizeof(float) * 4 * 128, OpenTK.Graphics.OpenGL4.BufferUsageHint.DynamicCopy); // set size of vec buffer
            countbuffer = new GLStorageBlock(2);                                                                        // new storage block on binding index 2 for count out
            countbuffer.AllocateBytes(sizeof(int), OpenTK.Graphics.OpenGL4.BufferUsageHint.DynamicRead);                // set size to a int.

            // redrawer of rejected items

            items.Add(new GLShaderPipeline(new GLPLVertexShaderWorldCoord(), new GLPLFragmentShaderFixedColor(new Color4(0.9f, 0.0f, 0.0f, 1.0f))), "ResultShader");
            GLRenderState rs = GLRenderState.Points(30);

            redraw = GLRenderableItem.CreateVector4(items, PrimitiveType.Points, rs, rejectedbuffer, 0);
            rObjects2.Add(items.Shader("ResultShader"), redraw);

            items.Add(new GLMatrixCalcUniformBlock(), "MCUB");      // def binding of 0

            Closed += ShaderTest_Closed;
        }
コード例 #24
0
    public GroundState3D(Controller3D controller, Velocity3D velocity)
    {
        if (controller == null)
        {
            throw new ArgumentNullException("Controller");
        }
        if (velocity == null)
        {
            throw new ArgumentNullException("Velocity");
        }

        this.controller = controller;
        this.velocity   = velocity;
    }
コード例 #25
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);
            Closed += ShaderTest_Closed;

            gl3dcontroller = new Controller3D();
            gl3dcontroller.PaintObjects = ControllerDraw;
            gl3dcontroller.MatrixCalc.PerspectiveNearZDistance = 0.1f;
            gl3dcontroller.ZoomDistance = 20F;
            gl3dcontroller.Start(glwfc, new Vector3(0, 0, 0), new Vector3(110f, 0, 0f), 1F);

            gl3dcontroller.KeyboardTravelSpeed = (ms, eyedist) =>
            {
                return((float)ms / 100.0f);
            };


            items.Add(new GLColorShaderWorld(), "COSW");
            GLRenderState rl1 = GLRenderState.Lines(1);

            {
                rObjects.Add(items.Shader("COSW"), "L1",   // horizontal
                             GLRenderableItem.CreateVector4Color4(items, PrimitiveType.Lines, rl1,
                                                                  GLShapeObjectFactory.CreateLines(new Vector3(-100, 0, -100), new Vector3(-100, 0, 100), new Vector3(10, 0, 0), 21),
                                                                  new Color4[] { Color.Gray })
                             );


                rObjects.Add(items.Shader("COSW"),    // vertical
                             GLRenderableItem.CreateVector4Color4(items, PrimitiveType.Lines, rl1,
                                                                  GLShapeObjectFactory.CreateLines(new Vector3(-100, 0, -100), new Vector3(100, 0, -100), new Vector3(0, 0, 10), 21),
                                                                  new Color4[] { Color.Gray })
                             );
            }

            items.Add(new GLTexture2D(Properties.Resources.galheightmap7, SizedInternalFormat.Rgba8), "gal");

            items.Add(new GLGalShader(), "TEX-NC");

            GLRenderState rg = GLRenderState.Quads(cullface: false);

            rObjects.Add(items.Shader("TEX-NC"),
                         GLRenderableItem.CreateVector4Vector2(items, PrimitiveType.Quads, rg,
                                                               GLShapeObjectFactory.CreateQuad(200.0f, 200.0f, new Vector3(0, 0, 0)), GLShapeObjectFactory.TexQuadCW,
                                                               new GLRenderDataTranslationRotationTexture(items.Tex("gal"), new Vector3(0, 0, 0))
                                                               ));

            items.Add(new GLMatrixCalcUniformBlock(), "MCUB");      // create a matrix uniform block
        }
コード例 #26
0
ファイル: AirState3D.cs プロジェクト: Rostad/ProjectE
    public AirState3D(Controller3D controller, Velocity3D velocity)
    {
        if (controller == null)
        {
            throw new ArgumentNullException("Controller");
        }
        if (velocity == null)
        {
            throw new ArgumentNullException("Velocity");
        }

        this.controller = controller;
        this.velocity   = velocity;
        jumpCount       = 0;
        jumpGracePeriod = 0.2f;
        timeEntered     = Time.time;
    }
コード例 #27
0
ファイル: DodgeState3D.cs プロジェクト: Rostad/IkSO
    public DodgeState3D(Controller3D controller, Velocity3D velocity)
    {
        if (controller == null)
        {
            throw new ArgumentNullException("Controller");
        }
        if (velocity == null)
        {
            throw new ArgumentNullException("Velocity");
        }

        this.controller = controller;
        this.velocity   = velocity;
        direction       = new Vector3(Input.GetAxisRaw("Horizontal"), 0.0f, Input.GetAxisRaw("Vertical"));
        direction.Normalize();
        timer    = 0.0f;
        duration = controller.DodgeDuration;
    }
コード例 #28
0
ファイル: DodgeState3D.cs プロジェクト: Rostad/ProjectE
    public DodgeState3D(Controller3D controller, Velocity3D velocity)
    {
        if (controller == null)
        {
            throw new ArgumentNullException("Controller");
        }
        if (velocity == null)
        {
            throw new ArgumentNullException("Velocity");
        }

        this.controller = controller;
        this.velocity   = velocity;
        direction       = new Vector3(PlayerInputs.instance.MovementInput.x, 0.0f, PlayerInputs.instance.MovementInput.y);
        direction.Normalize();
        timer    = 0.0f;
        duration = controller.DodgeDuration;
    }
コード例 #29
0
        private void ControllerDraw(Controller3D c3d, ulong unused)
        {
            ((GLMatrixCalcUniformBlock)items.UB("MCUB")).Set(gl3dcontroller.MatrixCalc);        // set the matrix unform block to the controller 3d matrix calc.

            IGLRenderableItem       i = rObjects["DYNGRIDRENDER"];
            DynamicGridVertexShader s = items.PLShader("PLGRIDVertShader") as DynamicGridVertexShader;

            if (Math.Abs(lasteyedistance - gl3dcontroller.MatrixCalc.EyeDistance) > 10)     // a little histerisis
            {
                i.InstanceCount = s.ComputeGridSize(gl3dcontroller.MatrixCalc.EyeDistance, out lastgridwidth);
                lasteyedistance = gl3dcontroller.MatrixCalc.EyeDistance;
            }

            s.SetUniforms(gl3dcontroller.MatrixCalc.LookAt, lastgridwidth, i.InstanceCount);

            float dist = c3d.MatrixCalc.EyeDistance;
            float d1   = dist - lastgridwidth;
            float suc  = d1 / (9.0f * lastgridwidth);
            float cf   = 1.0f - suc.Clamp(0f, 1f);
            float a    = 0.7f * cf;

            float coordfade = lastgridwidth == 10000 ? (0.7f - (c3d.MatrixCalc.EyeDistance / 20000).Clamp(0.0f, 0.7f)) : 0.7f;
            Color coordscol = Color.FromArgb(coordfade < 0.05 ? 0 : 150, Color.Cyan);

            System.Diagnostics.Debug.WriteLine("Dist {0} grid {1} suc {2} cf {3} a {4} coord {5} {6}", dist, lastgridwidth, suc, cf, a, coordfade, coordscol);

            DynamicGridCoordVertexShader bs = items.PLShader("PLGRIDBitmapVertShader") as DynamicGridCoordVertexShader;

            bs.ComputeUniforms(lastgridwidth, gl3dcontroller.MatrixCalc, gl3dcontroller.PosCamera.CameraDirection, coordscol, Color.Transparent);

            if (galaxy != null)
            {
                galaxy.InstanceCount = volumetricblock.Set(gl3dcontroller.MatrixCalc, boundingbox, 50.0f);        // set up the volumentric uniform

                IGLProgramShader p = items.Shader("Galaxy");
                var fsgalaxy       = p.GetShader(OpenTK.Graphics.OpenGL4.ShaderType.FragmentShader) as GalaxyFragmentPipeline;
                fsgalaxy.SetFader(c3d.MatrixCalc.EyeDistance);
            }

            rObjects.Render(glwfc.RenderState, gl3dcontroller.MatrixCalc);


            this.Text = "Looking at " + gl3dcontroller.MatrixCalc.LookAt + " eye@ " + gl3dcontroller.MatrixCalc.EyePosition + " dir " + gl3dcontroller.PosCamera.CameraDirection + " Dist " + gl3dcontroller.MatrixCalc.EyeDistance + " Zoom " + gl3dcontroller.PosCamera.ZoomFactor;
        }
コード例 #30
0
        private void ControllerDraw(Controller3D mc, ulong unused)
        {
            ((GLMatrixCalcUniformBlock)items.UB("MCUB")).Set(gl3dcontroller.MatrixCalc);        // set the matrix unform block to the controller 3d matrix calc.

            dataoutbuffer.ZeroBuffer();
            atomicbuffer.ZeroBuffer();

            rObjects.Render(glwfc.RenderState, gl3dcontroller.MatrixCalc);

            GL.MemoryBarrier(MemoryBarrierFlags.AllBarrierBits);

            Vector4[] databack = dataoutbuffer.ReadVector4s(0, 2);
            for (int i = 0; i < databack.Length; i++)
            {
                System.Diagnostics.Debug.WriteLine(i + " = " + databack[i].ToString());
            }

            this.Text = "Looking at " + gl3dcontroller.MatrixCalc.LookAt + " dir " + gl3dcontroller.PosCamera.CameraDirection + " eye@ " + gl3dcontroller.MatrixCalc.EyePosition + " Dist " + gl3dcontroller.MatrixCalc.EyeDistance;
        }