示例#1
0
        public void DrawArcRectangle(Vector3 startPosition, Vector3 endPosition, float startRadius, float endRadius = 0)
        {
            if (rectangle[0] != null)
            {
                return;
            }

            if (endRadius <= 0)
            {
                endRadius = startRadius;
            }

            var difference = startPosition - endPosition;
            var rotation = difference.Rotated(MathUtil.DegreesToRadians(90));
            rotation.Normalize();

            var start = rotation * startRadius;
            var end = rotation * endRadius;

            var correctedEnd = startPosition.Extend(
                endPosition,
                startPosition.Distance2D(endPosition) - endRadius * 0.45f);

            var rightStartPosition = startPosition + start;
            var leftStartPosition = startPosition - start;
            var rightEndPosition = correctedEnd + end;
            var leftEndPosition = correctedEnd - end;

            rectangle[0] = DrawLine(rightStartPosition, rightEndPosition);
            rectangle[1] = DrawLine(rightStartPosition, leftStartPosition);
            rectangle[2] = DrawLine(leftStartPosition, leftEndPosition);
            rectangle[3] = DrawArc(endPosition, startPosition, endRadius);
        }
示例#2
0
        public void Init(int m, int n, float dx, float dt, float speed, float damping) {
            RowCount = m;
            ColumnCount = n;
            VertexCount = m * n;
            TriangleCount = (m - 1) * (n - 1) * 2;

            _timeStep = dt;
            _spatialStep = dx;

            var d = damping * dt + 2.0f;
            var e = (speed * speed) * (dt * dt) / (dx * dx);
            _k1 = (damping * dt - 2.0f) / d;
            _k2 = (4.0f - 8.0f * e) / d;
            _k3 = (2.0f * e) / d;

            _currentSolution = new Vector3[m*n];
            _prevSolution = new Vector3[m*n];
            _normals = new Vector3[m*n];
            _tangentX = new Vector3[m*n];

            var w2 = (n - 1) * dx * 0.5f;
            var d2 = (m - 1) * dx * 0.5f;

            for (var i = 0; i < m; i++) {
                var z = d2 - i * dx;
                for (var j = 0; j < n; j++) {
                    var x = -w2 + j * dx;
                    _prevSolution[i*n+j] = new Vector3(x, 0, z);
                    _currentSolution[i*n+j] = new Vector3(x, 0, z);
                    _normals[i*n+j] = new Vector3(0,1,0);
                    _tangentX[i*n+j] = new Vector3(1.0f, 0, 0);
                }
            }
        }
示例#3
0
        public override Result Update(float dt)
        {
            if (_heightmap == null) {

            } else {
                _angle += dt*0.5f;
                var center = _heightmap.Center;
                var eye = new Vector3(center.X + MathF.Cos(_angle)*center.X*2.0f, _heightmap.MaxHeight*8.0f, -center.Y + MathF.Sin(_angle)*center.Y*2.0f);
                var lookAt = new Vector3(center.X, 0.0f, -center.Y);

                var world = Matrix.Identity;
                var view = Matrix.LookAtLH(eye, lookAt, new Vector3(0, 1, 0));
                var proj = Matrix.PerspectiveFovLH(MathF.Pi/4, 1.3333f, 1.0f, 1000.0f);

                Device.SetTransform(TransformState.World, world);
                Device.SetTransform(TransformState.View, view);
                Device.SetTransform(TransformState.Projection, proj);

                if (Input.IsKeyDown(Key.Space)) {
                    _image++;
                    if (_image > 2) _image = 0;
                    switch (_image) {
                        case 0:
                            _heightmap.LoadFromFile("images/abe.jpg");
                            break;
                        case 1:
                            _heightmap.LoadFromFile("images/smiley.bmp");
                            break;
                        case 2:
                            _heightmap.LoadFromFile("images/heightmap.jpg");
                            break;
                    }
                    _hmRenderer.Release();
                    _hmRenderer = new HeightMapRenderer(_heightmap, Device);
                    _hmRenderer.CreateParticles();
                    Thread.Sleep(300);
                }
            }
            if (Input.IsKeyDown(Key.Escape)) {
                Quit();
            }
            return ResultCode.Success;
        }
示例#4
0
 public ParticleSystem() {
     _firstRun = true;
     EmitDirW = new Vector3(0, 1, 0);
 }
示例#5
0
        private ParticleEffect DrawArc(Vector3 startPosition, Vector3 endPosition, float radius)
        {
            var arc = new ParticleEffect(@"materials\ensage_ui\particles\semicircle_v2.vpcf", startPosition);
            arc.SetControlPoint(1, endPosition);
            arc.SetControlPoint(2, new Vector3(radius * 1.12f, 0, 0));
            arc.SetControlPoint(3, ParticleColor);
            arc.SetControlPoint(4, new Vector3(255, 15, 0));

            return arc;
        }
示例#6
0
        private ParticleEffect DrawLine(Vector3 startPosition, Vector3 endPosition)
        {
            var line = new ParticleEffect(@"materials\ensage_ui\particles\line.vpcf", startPosition);
            line.SetControlPoint(2, endPosition);
            line.SetControlPoint(3, new Vector3(255, 15, 0));
            line.SetControlPoint(4, ParticleColor);

            return line;
        }
示例#7
0
        public void UpdateRectaglePosition(
            Vector3 startPosition,
            Vector3 endPosition,
            float startWidth,
            float endWidth = 0)
        {
            if (rectangle[0] == null)
            {
                return;
            }

            if (endWidth <= 0)
            {
                endWidth = startWidth;
            }

            endPosition = startPosition.Extend(endPosition, startPosition.Distance2D(endPosition) + endWidth / 2);

            var difference = startPosition - endPosition;
            var rotation = difference.Rotated(MathUtil.DegreesToRadians(90));
            rotation.Normalize();

            var start = rotation * startWidth;
            var end = rotation * endWidth;

            var rightStartPosition = startPosition + start;
            var leftStartPosition = startPosition - start;
            var rightEndPosition = endPosition + end;
            var leftEndPosition = endPosition - end;

            rectangle[0].SetControlPoint(1, rightStartPosition);
            rectangle[0].SetControlPoint(2, rightEndPosition);

            rectangle[1].SetControlPoint(1, rightStartPosition);
            rectangle[1].SetControlPoint(2, leftStartPosition);

            rectangle[2].SetControlPoint(1, leftStartPosition);
            rectangle[2].SetControlPoint(2, leftEndPosition);

            rectangle[3].SetControlPoint(1, leftEndPosition);
            rectangle[3].SetControlPoint(2, rightEndPosition);
        }
示例#8
0
 public AbilityDrawer()
 {
     TextColor = Color.White;
     TextSize = new Vector2(20);
     ParticleColor = new Vector3(255, 100, 50);
 }
示例#9
0
 public void DrawTime(float time, Vector3 position)
 {
     Drawing.DrawText(
         time.ToString("0.00"),
         "Arial",
         Drawing.WorldToScreen(position),
         TextSize,
         TextColor,
         FontFlags.None);
 }
示例#10
0
 public void UpdateCirclePosition(Vector3 position)
 {
     circle?.SetControlPoint(0, position);
 }
示例#11
0
        public void DrawRectangle(Vector3 startPosition, Vector3 endPosition, float startWidth, float endWidth = 0)
        {
            if (rectangle[0] != null)
            {
                return;
            }

            if (endWidth <= 0)
            {
                endWidth = startWidth;
            }

            var difference = startPosition - endPosition;
            var rotation = difference.Rotated(MathUtil.DegreesToRadians(90));
            rotation.Normalize();

            var start = rotation * startWidth;
            var end = rotation * endWidth;

            var rightStartPosition = startPosition + start;
            var leftStartPosition = startPosition - start;
            var rightEndPosition = endPosition + end;
            var leftEndPosition = endPosition - end;

            rectangle[0] = DrawLine(rightStartPosition, rightEndPosition);
            rectangle[1] = DrawLine(rightStartPosition, leftStartPosition);
            rectangle[2] = DrawLine(leftStartPosition, leftEndPosition);
            rectangle[3] = DrawLine(leftEndPosition, rightEndPosition);
        }
示例#12
0
        public void DrawCircle(Vector3 position, float radius)
        {
            if (!Variables.Menu.Debug.DrawAbilities || circle != null)
            {
                return;
            }

            circle = new ParticleEffect(@"materials\ensage_ui\particles\drag_selected_ring_mod.vpcf", position);
            circle.SetControlPoint(1, ParticleColor);
            circle.SetControlPoint(2, new Vector3(radius * -1, 255, 0));
        }
示例#13
0
        private void BuildRandomVectorTexture() {
            var texDesc = new Texture2DDescription {
                Width = 256,
                Height = 256,
                MipLevels = 1,
                ArraySize = 1,
                Format = Format.R8G8B8A8_UNorm,
                SampleDescription = new SampleDescription(1, 0),
                Usage = ResourceUsage.Dynamic,
                BindFlags = BindFlags.ShaderResource,
                CpuAccessFlags = CpuAccessFlags.Write,
                OptionFlags = ResourceOptionFlags.None
            };
            var color = new List<Color4>();
            for (var i = 0; i < 256; i++) {
                for (var j = 0; j < 256; j++) {
                    var v = new Vector3(MathF.Rand(0, 1), MathF.Rand(0, 1), MathF.Rand(0, 1));
                    color.Add(new Color4(0, v.X, v.Y, v.Z));
                }
            }
            var tex = new Texture2D(_device, texDesc);

            var box = _dc.MapSubresource(tex, 0, MapMode.WriteDiscard, MapFlags.None);
            foreach (var color4 in color) {
                box.Data.Write((byte)(color4.Red * 255));
                box.Data.Write((byte)(color4.Green * 255));
                box.Data.Write((byte)(color4.Blue * 255));
                box.Data.Write((byte)(0));
            }
            _dc.UnmapSubresource(tex, 0);

            tex.DebugName = "random ssao texture";

            _randomVectorSRV = new ShaderResourceView(_device, tex);

            Util.ReleaseCom(ref tex);
        }
示例#14
0
 public OrthoCamera() {
     Target = new Vector3();
     Up = new Vector3(0, 0, 1);
     Look = new Vector3(0, -1, 0);      
 }
示例#15
0
 public override void LookAt(Vector3 pos, Vector3 target, Vector3 up) { }