예제 #1
0
#pragma warning restore 0649


        public void Evaluate(int SpreadMax)
        {
            var system = OpenVRManager.System;

            if (system != null)
            {
                FOutStatus.SliceCount = SpreadMax;
                for (int i = 0; i < SpreadMax; i++)
                {
                    FOutStatus[i] = "Ok";

                    var controller = FControllerIn[i];
                    if (controller == null)
                    {
                        FOutStatus[i] = "No Controller";
                    }
                    else if (FInHapticEnabled[i])
                    {
                        // see: https://github.com/ValveSoftware/openvr/wiki/IVRSystem::TriggerHapticPulse

                        // see: https://steamcommunity.com/app/358720/discussions/0/517141624283630663/
                        // for now only axis with id 0 is working/implemented in OpenVR... and probably this will ner´ver change
                        var duration = (int)VMath.Map(FInHapticDuration[0], 0, 1, 1, 3999, TMapMode.Clamp);
                        system.TriggerHapticPulse(controller.index, 0, (char)duration);
                    }
                }
            }
            else
            {
                FOutStatus.SliceCount = 1;
                FOutStatus[0]         = "OpenVR is not initialized, at least one Poser (OpenVR) or Camera (OpenVR) must exist";
            }
        }
예제 #2
0
        //called when data for any output pin is requested
        public void Evaluate(int SpreadMax)
        {
            //for each frame empty the lists
            vertices.Clear();
            indices.Clear();
            distance.Clear();

            float radius = IRadius[0];

            //for every incoming vector...
            for (int i = 0; i < SpreadMax; i++)
            {
                //check every other incoming vector...
                for (int j = i + 1; j < SpreadMax; j++)
                {
                    float dist = (float)VMath.Dist(IInput[i], IInput[j]);
                    if (dist < radius)
                    {
                        vertices.Add(IInput[i]);
                        vertices.Add(IInput[j]);
                        indices.Add(i);
                        indices.Add(j);
                        distance.Add(dist / radius);
                    }
                }
            }

            OVertices.AssignFrom(vertices);
            OIndices.AssignFrom(indices);
            ODistance.AssignFrom(distance);
        }
예제 #3
0
        //update JOINT
        private void UpdateJoint(ref int channelIndex, int frameIndex, BVHJoint joint)
        {
            List <float> frame;
            Vector3D     translate, rotate;

            //get MOTION data of frameIndex
            frame = FFrames[frameIndex];

            //init transform
            translate = new Vector3D(0.0);
            rotate    = new Vector3D(0.0);

            //set transform channel count times
            for (int i = 0; i < joint.GetChannelCount(); i++)
            {
                //get one value from MOTION data
                float f = frame[channelIndex++];

                //get target channel
                BVHChannel ch = joint.Channels[i];

                //set value to channel
                if (ch == BVHChannel.X_POSITION)
                {
                    translate.x = f;
                }
                else if (ch == BVHChannel.Y_POSITION)
                {
                    translate.y = f;
                }
                else if (ch == BVHChannel.Z_POSITION)
                {
                    translate.z = f;// -f;   //Right Hand to Left Hand
                }
                else if (ch == BVHChannel.X_ROTATION)
                {
                    //Degrees into Radians
                    rotate.x = f * VMath.DegToRad;
                }
                else if (ch == BVHChannel.Y_ROTATION)
                {
                    //Degrees into Radians
                    rotate.y = f * VMath.DegToRad;
                }
                else if (ch == BVHChannel.Z_ROTATION)
                {
                    //Degrees into Radians
                    rotate.z = f * VMath.DegToRad;
                }
            }

            //update AnimationTransform
            joint.AnimationTransform = VMath.Transform(translate, new Vector3D(1.0), rotate);

            //recusive call all children
            for (int i = 0; i < joint.Children.Count; i++)
            {
                UpdateJoint(ref channelIndex, frameIndex, (BVHJoint)joint.Children[i]);
            }
        }
예제 #4
0
        protected override void CopyData(DX11DynamicTexture2D texture)
        {
            lock (m_lock)
            {
                for (int i = 0; i < this.colpoints.Length; i++)
                {
                    if (FRelativeLookup[0])
                    {
                        this.colorimage[i * 2]     = (float)VMath.Map(colpoints[i].X - i % 640, 0, 640, 0, 1, TMapMode.Float);
                        this.colorimage[i * 2 + 1] = (float)VMath.Map(colpoints[i].Y - VMath.Abs(i / 640), 0, 480, 0, 1, TMapMode.Float);
                    }
                    else
                    {
                        this.colorimage[i * 2]     = (float)VMath.Map(colpoints[i].X, 0, 640, 0, 1, TMapMode.Clamp);
                        this.colorimage[i * 2 + 1] = (float)VMath.Map(colpoints[i].Y, 0, 480, 0, 1, TMapMode.Clamp);
                    }
                }

                fixed(float *f = &this.colorimage[0])
                {
                    IntPtr ptr = new IntPtr(f);

                    texture.WriteData(ptr, this.width * this.height * 8);
                }
            }
        }
예제 #5
0
        //update mouse
        public override bool UpdateMouse(Vector2D Mouse,
                                         bool MouseLeftDownEdge,
                                         bool MouseLeftPressed)
        {
            bool upEdgeHit = base.UpdateMouse(Mouse, MouseLeftDownEdge, MouseLeftPressed);

            //update slider
            for (int i = 0; i < FControllers.Length; i++)
            {
                //get current slider
                RotarySlider s = FControllers[i];


                //set selected slice number and color
                if (FMouseHit && i == SelectedSlice)
                {
                    Vector2D invMouse     = (s.InvTransform * Mouse).xy;
                    Vector2D invLastMouse = (s.InvTransform * FLastMouse).xy;

                    s.Value = VMath.Clamp(s.Value + (invMouse.y - invLastMouse.y) * FSliderSpeed, 0, 1);
                }

                s.ColorSlider = ColSlider;
            }

            FLastMouse = Mouse;

            return(upEdgeHit);
        }
예제 #6
0
        public static Vector2D FromMousePoint(this Point point, Size clientArea)
        {
            var position = new Vector2D(point.X, point.Y);
            var ca       = new Vector2D(clientArea.Width - 1, clientArea.Height - 1);

            return(VMath.Map(position, Vector2D.Zero, ca, new Vector2D(-1, 1), new Vector2D(1, -1), TMapMode.Float));
        }
예제 #7
0
            public T Read(int stride = 1)
            {
                var upstreamSlice = VMath.Zmod(FUpstreamSlices[Position], FStream.Length);

                Position += stride;
                return(FStream.Buffer[upstreamSlice]);
            }
예제 #8
0
        void CalcTriangleCoefficients(float slope)
        {
            //triangle magnitudes
            var slopeClamp = (float)VMath.Clamp(slope, 0.01, 0.99);

            A      = 1 / slopeClamp;
            B      = -1 / (1 - slopeClamp);
            AoverB = A / B;
            BoverA = B / A;

            var t4 = 4 * T;
            var t2 = 2 * T;

            //coeffs max
            var rezDenomA = 1 / (t4 * (A - 1));

            a2 = -rezDenomA;

            a1 = (t2 * A - t4 + 2) * rezDenomA;

            var tmp = A * T - 1;

            a0 = -(tmp * tmp) * rezDenomA;

            //coeffs min
            var rezDenomB = 1 / (t4 * (B + 1));

            b2 = -rezDenomB;
            b1 = (t2 * B + t4 - 2) * rezDenomB;

            tmp = B * T + 1;
            b0  = -(tmp * tmp) * rezDenomB;
        }
예제 #9
0
 // Eyetracker to vvvv mapping
 private Vector2D MapValue_ETToVVVV(Vector2D v)
 {
     return(new Vector2D(
                VMath.Map(v.x, 0, 1, -1, 1, TMapMode.Float),
                VMath.Map(v.y, 0, 1, 1, -1, TMapMode.Float)
                ));
 }
예제 #10
0
#pragma warning restore
        #endregion fields & pins

        //called when data for any output pin is requested
        public void Evaluate(int SpreadMax)
        {
            var count = FOutput.SliceCount = FSpread.SliceCount;

            int incr = 0;

            for (int i = 0; i < count; i++)
            {
                var os  = FOutput[i];
                var ind = VMath.Zmod(FIndex[i], count);
                if (i != ind)
                {
                    os.AssignFrom(FSpread[i]);
                }
                else
                {
                    var osCount = os.SliceCount;
                    for (int s = 0; s < osCount; s++)
                    {
                        os[s] = FInput[incr + s];
                    }
                    incr += osCount;
                }
            }
        }
예제 #11
0
        protected virtual void SubscribeToDevices()
        {
            var devices = Device.GetDevices()
                          .Where(d => d.DeviceType == FDeviceType)
                          .OrderBy(d => d, new DeviceComparer())
                          .ToList();

            if (devices.Count > 0)
            {
                var spreadMax = GetMaxSpreadCount();
                DeviceOut.SliceCount            = spreadMax;
                DeviceNameOut.SliceCount        = spreadMax;
                DeviceDescriptionOut.SliceCount = spreadMax;
                for (int i = 0; i < spreadMax; i++)
                {
                    var index  = VMath.Zmod(IndexIn[i], spreadMax);
                    var device = devices[index % devices.Count];
                    DeviceOut[i]            = CreateDevice(device, i);
                    DeviceNameOut[i]        = device.DeviceName;
                    DeviceDescriptionOut[i] = device.GetDeviceDescription();
                }
            }
            else
            {
                DeviceOut.SliceCount            = 0;
                DeviceNameOut.SliceCount        = 0;
                DeviceDescriptionOut.SliceCount = 0;
            }
        }
예제 #12
0
        public void Apply(DX11Texture2D texture, int w, int h, int d, SlimDX.DXGI.Format format, int slice)
        {
            format = format == SlimDX.DXGI.Format.Unknown ? texture.Format : format;

            if (this.rtarr != null)
            {
                if (this.rtarr.ElemCnt != d || this.rtarr.Width != w || this.rtarr.Height != h ||
                    this.rtarr.Format != format)
                {
                    this.rtarr.Dispose(); this.rtarr = null;
                }
            }

            if (this.rtarr == null)
            {
                this.rtarr = new DX11RenderTextureArray(this.context, w, h, d, format, true, 1);
            }

            this.shader.SelectTechnique("Render");
            this.quad.Bind(this.layout);

            int idx = VMath.Zmod(slice, d);

            //Push specific slice as render target
            this.context.RenderTargetStack.Push(this.rtarr.SliceRTV[idx]);

            //Call simple shader (could use full screen triangle instead)
            this.shader.SetBySemantic("TEXTURE", texture.SRV);
            this.shader.ApplyPass(0);
            this.quad.Draw();
            this.context.RenderTargetStack.Pop();
        }
예제 #13
0
        public static Point DoMapPositionInNormalizedProjectionToPixels(this Vector2D normV, Size clientSize)
        {
            var clientArea = new Vector2D(clientSize.Width - 1, clientSize.Height - 1);
            var v          = VMath.Map(normV, new Vector2D(-1, 1), new Vector2D(1, -1), Vector2D.Zero, clientArea, TMapMode.Float);

            return(new Point((int)v.x, (int)v.y));
        }
예제 #14
0
 void SetResult(int bin, int id, double refvalue, double?overrideWeight = null)
 {
     FirstOut[bin][0]        = id;
     WeightOfNextOut[bin][0] = overrideWeight
                               ?? VMath.Map(refvalue, OrderedInput[bin][id], OrderedInput[bin][id + 1], 0.0, 1.0, TMapMode.Clamp);
     DistanceOut[bin][0] = Math.Abs(OrderedInput[bin][id + 1] - OrderedInput[bin][id]);
 }
예제 #15
0
 private void SetScroll(Vector2D scrollTo)
 {
     if (FScrollTo != scrollTo)
     {
         FScrollTo = scrollTo;
         using (var mainFrame = FBrowser.GetMainFrame())
         {
             var x = VMath.Map(scrollTo.x, 0, 1, 0, 1, TMapMode.Clamp);
             var y = VMath.Map(scrollTo.y, 0, 1, 0, 1, TMapMode.Clamp);
             mainFrame.ExecuteJavaScript(
                 string.Format(CultureInfo.InvariantCulture,
                               @"
                     var body = document.body,
                         html = document.documentElement;
                     var width = Math.max(body.scrollWidth, body.offsetWidth, html.clientWidth, html.scrollWidth, html.offsetWidth);
                     var height = Math.max(body.scrollHeight, body.offsetHeight, html.clientHeight, html.scrollHeight, html.offsetHeight);
                     window.scrollTo({0} *  width, {1} * height);
                     ",
                               x,
                               y
                               ),
                 string.Empty,
                 0);
         }
     }
 }
예제 #16
0
        //update mouse
        public override void UpdateTouches(TouchList touches)
        {
            base.UpdateTouches(touches);

            //update slider
            for (int i = 0; i < FControllers.Length; i++)
            {
                //get current slider
                Slider s = FControllers[i];

                if (s.Hit)
                {
                    Vector2D invMouse     = (s.InvTransform * new Vector2D(s.AssignedTouch.X, s.AssignedTouch.Y)).xy;
                    Vector2D invLastMouse = (s.InvTransform * new Vector2D(s.LastTouchPos.X, s.LastTouchPos.Y)).xy;
                    s.Value = VMath.Clamp(s.Value + (invMouse.y - invLastMouse.y) * FSliderSpeed, 0, 1);
                    if (!FIsLong)
                    {
                        s.SliderTransform = FSliderSize * VMath.Translate(0, s.Value - 0.5, 0) * s.Transform;
                    }
                    else
                    {
                        s.SliderTransform = VMath.Scale(1, s.Value, 1) * VMath.Translate(0, s.Value * 0.5 - 0.5, 1) * s.Transform;
                    }
                }
            }
        }
예제 #17
0
        public static Point ToMousePoint(this Vector2D normV)
        {
            var clientArea = new Vector2D(ClientArea.Width - 1, ClientArea.Height - 1);
            var v          = VMath.Map(normV, new Vector2D(-1, 1), new Vector2D(1, -1), Vector2D.Zero, clientArea, TMapMode.Float);

            return(new Point((int)v.x, (int)v.y));
        }
예제 #18
0
// called every frame. computation could be triggered selectively on change for performance gains
        public void Evaluate(int SpreadMax)
        {
            FView.SliceCount                   =
                FProjection.SliceCount         =
                    FViewProjection.SliceCount = SpreadMax;


            for (int i = 0; i < SpreadMax; i++)
            {
                var translate = FTranslate[i];
                var rotate    = FRotate[i];
                var fov       = FFov[i];
                var shift     = FShift[i];

                var near = FNear[i];
                var far  = FFar[i];

                var view = VMath.Inverse(VMath.Rotate(rotate * Math.PI * 2) * VMath.Translate(translate));

                double scaleX = 1.0 / Math.Tan(fov[0] * Math.PI);
                double scaleY = 1.0 / Math.Tan(fov[1] * Math.PI);
                double fn     = far / (far - near);

                var proj = new Matrix4x4(
                    scaleX, 0, 0, 0,
                    0, scaleY, 0, 0,
                    -2 * shift.x, -2 * shift.y, fn, 1,
                    0, 0, -near * fn, 0
                    );

                FView[i]           = view;
                FProjection[i]     = proj;
                FViewProjection[i] = view * proj;
            }
        }
예제 #19
0
        /// <summary>
        /// Create a new texture renderer.
        /// </summary>
        /// <param name="logger">The logger to log to.</param>
        /// <param name="frameRate">
        /// The maximum rate in frames per second (fps) that CefRenderHandler::OnPaint will
        /// be called for a windowless browser. The actual fps may be lower if the browser
        /// cannot generate frames at the requested rate. The minimum value is 1 and the
        /// maximum value is 60 (default 30).
        /// </param>
        public HTMLTextureRenderer(ILogger logger, int frameRate)
        {
            Logger    = logger;
            FrameRate = VMath.Clamp(frameRate, MIN_FRAME_RATE, MAX_FRAME_RATE);

            FLoaded = false;

            var settings = new CefBrowserSettings();

            settings.FileAccessFromFileUrls = CefState.Enabled;
            settings.Plugins     = CefState.Enabled;
            settings.RemoteFonts = CefState.Enabled;
            settings.UniversalAccessFromFileUrls = CefState.Enabled;
            settings.WebGL               = CefState.Enabled;
            settings.WebSecurity         = CefState.Disabled;
            settings.WindowlessFrameRate = frameRate;

            var windowInfo = CefWindowInfo.Create();

            windowInfo.SetAsWindowless(IntPtr.Zero, true);

            FWebClient = new WebClient(this);
            // See http://magpcss.org/ceforum/viewtopic.php?f=6&t=5901
            // We need to maintain different request contexts in order to have different zoom levels
            // See https://bitbucket.org/chromiumembedded/cef/issues/1314
            var rcSettings = new CefRequestContextSettings()
            {
                IgnoreCertificateErrors = true
            };

            FRequestContext = CefRequestContext.CreateContext(rcSettings, new WebClient.RequestContextHandler());
            CefBrowserHost.CreateBrowser(windowInfo, FWebClient, settings, FRequestContext);
            // Block until browser is created
            FBrowserAttachedEvent.WaitOne();
        }
예제 #20
0
        private void AllFrameReady(object sender, AllFramesReadyEventArgs e)
        {
            if (!FUpdate)
            {
                return;
            }

            DepthImageFrame df = e.OpenDepthImageFrame();

            if (df != null)
            {
                df.CopyPixelDataTo(this.depthimage);
                this.runtime.Runtime.MapDepthFrameToColorFrame(DepthImageFormat.Resolution640x480Fps30, this.depthimage, ColorImageFormat.RgbResolution640x480Fps30, this.cp);

                lock (m_lock)
                {
                    for (int i = 0; i < this.cp.Length; i++)
                    {
                        this.colorimage[i * 2]     = (float)VMath.Map(cp[i].X, 0, 640, 0, 1, TMapMode.Clamp);
                        this.colorimage[i * 2 + 1] = (float)VMath.Map(cp[i].Y, 0, 480, 0, 1, TMapMode.Clamp);
                    }
                }

                this.FInvalidate = true;
                this.FUpdate     = false;
                this.frameindex  = df.FrameNumber;

                df.Dispose();
            }
        }
예제 #21
0
        static Point ToMousePoint(Vector2D normV)
        {
            var clientArea = new Vector2D(FClientArea.Width - 1, FClientArea.Height - 1);
            var v          = VMath.Map(normV, new Vector2D(-1, 1), new Vector2D(1, -1), Vector2D.Zero, clientArea, TMapMode.Clamp);

            return(new Point((int)v.x, (int)v.y));
        }
예제 #22
0
        //called when data for any output pin is requested
        public virtual void Evaluate(int spreadMax)
        {
            var inputSpread  = FSpreadContainer.IOObject;
            var outputSpread = FOutputContainer.IOObject;
            var input        = FInputContainer.IOObject;

            var count = outputSpread.SliceCount = inputSpread.SliceCount;

            for (int c = 0; c < count; c++) //copy in to out first
            {
                outputSpread[c].AssignFrom(inputSpread[c]);
            }

            var incr = 0;

            for (int i = 0; i < FIndex.SliceCount; i++) //loop through all indices to set
            {
                var ind     = VMath.Zmod(FIndex[i], count);
                var osCount = outputSpread[ind].SliceCount = inputSpread[ind].SliceCount;
                for (int s = 0; s < osCount; s++)
                {
                    outputSpread[ind][s] = input[incr + s];
                }
                incr += osCount;
            }
        }
예제 #23
0
파일: Disperse.cs 프로젝트: vnmone/vvvv-sdk
        //here we go, thats the method called by vvvv each frame
        //all data handling should be in here
        public void Evaluate(int SpreadMax)
        {
            if (FInput.PinIsChanged ||
                FGamma.PinIsChanged ||
                FBinSize.PinIsChanged)
            {
                double    curIn, curGamma, tmpBin;
                int       curBin;
                ArrayList outList = new ArrayList();
                ArrayList curList;
                for (int i = 0; i < SpreadMax; i++)
                {
                    FInput.GetValue(i, out curIn);
                    FGamma.GetValue(i, out curGamma);
                    FBinSize.GetValue(i, out tmpBin);
                    curBin  = (int)Math.Round(tmpBin);
                    curList = new ArrayList(curBin);
                    for (int j = 0; j < curBin; j++)
                    {
                        double start = j / (double)curBin / curGamma;
                        double end   = (curBin - 1.0) / (double)curBin / curGamma;
                        end = start + 1.0 - end;
                        curList.Add(VMath.Map(curIn, start, end, 0.0, 1.0, TMapMode.Clamp));
                    }
                    outList.AddRange(curList);
                }

                FOut.SliceCount = outList.Count;
                for (int i = 0; i < outList.Count; i++)
                {
                    FOut.SetValue(i, (double)outList[i]);
                }
            }
        }
예제 #24
0
        public override bool DistanceToRay(Ray ray, HitResult result)
        {
            var pos = Transform.Translation;

            float a = VMath.Dot(ray.vec, pos - ray.pos);
            float e = (pos - ray.pos).LengthSquare();

            float f = Range * Range - e + a * a;

            if (f < 0)
            {
                return(false);
            }

            float distance = a - (float)Math.Sqrt(f);

            if (result.distance > distance && distance > 0.05)
            {
                result.normal   = VMath.Normalize((ray.pos + ray.vec * distance) - pos);
                result.material = Material;
                result.distance = distance;
                return(true);
            }
            else
            {
                return(false);
            }
        }
예제 #25
0
        public void Evaluate(int spreadMax)
        {
            var touchDevice = FInput[0] ?? TouchDevice.Empty;

            if (touchDevice != FTouchDevice)
            {
                Unsubscribe();
                FTouchDevice = touchDevice;
                Subscribe();
            }

            var notifications = FEnumerator.MoveNext()
                ? FEnumerator.Current
                : FEmptyList;

            FEventTypeOut.SliceCount  = notifications.Count;
            PositionOut.SliceCount    = notifications.Count;
            IdOut.SliceCount          = notifications.Count;
            ContactAreaOut.SliceCount = notifications.Count;

            for (int i = 0; i < notifications.Count; i++)
            {
                var n = notifications[i];
                FEventTypeOut[i] = n.Kind;
                var position   = new Vector2D(n.Position.X, n.Position.Y);
                var clientArea = new Vector2D(n.ClientArea.Width, n.ClientArea.Height);
                PositionOut[i]    = VMath.Map(position, Vector2D.Zero, clientArea, new Vector2D(-1, 1), new Vector2D(1, -1), TMapMode.Float);
                IdOut[i]          = n.Id;
                ContactAreaOut[i] = new Vector2D(n.ContactArea.Width, n.ContactArea.Height);
            }
        }
        public static Matrix4x4 ConvertToVVVV(Matrix4x4 OpenCVMatrix)
        {
            Matrix4x4 flipy = VMath.Scale(1.0, -1.0, 1.0);
            Matrix4x4 flipz = VMath.Scale(1.0, 1.0, -1.0);

            return(OpenCVMatrix * flipz);
        }
예제 #27
0
        public void Evaluate(int spreadMax)
        {
            var gestureDevice = FInput[0] ?? GestureDevice.Empty;

            if (gestureDevice != FGestureDevice)
            {
                Unsubscribe();
                FGestureDevice = gestureDevice;
                Subscribe();
            }

            var notifications = FEnumerator.MoveNext()
                ? FEnumerator.Current
                : FEmptyList;

            var gestures = notifications.Where(g => (g.Kind == FGestureFilterKind) ||
                                               ((g.Kind == GestureNotificationKind.GestureEnd) && (IdOut.Contains(g.Id))))
                           .ToList();

            UseGestures(gestures);

            PositionOut.SliceCount = gestures.Count;
            IdOut.SliceCount       = gestures.Count;
            DeviceIDOut.SliceCount = gestures.Count;
            for (int i = 0; i < gestures.Count; i++)
            {
                var position           = new Vector2D(gestures[i].Position.X, gestures[i].Position.Y);
                var clientArea         = new Vector2D(gestures[i].ClientArea.Width, gestures[i].ClientArea.Height);
                var normalizedPosition = VMath.Map(position, Vector2D.Zero, clientArea, new Vector2D(-1, 1), new Vector2D(1, -1), TMapMode.Float);
                PositionOut[i] = normalizedPosition;
                IdOut[i]       = gestures[i].Id;
                DeviceIDOut[i] = gestures[i].GestureDeviceID;
            }
        }
예제 #28
0
        //calculate edgepoints from state position and radius
        public static EdgePoints GetEdgePoints(Point A, Point B, int Radius, int Radius2, double winkel)
        {
            var PointA = new Vector3D(A.X, A.Y, 0);
            var PointB = new Vector3D(B.X, B.Y, 0);

            Vector3D TempA;
            Vector3D TempB;
            Vector3D TempC;

            var tempVector = new Vector3D(VMath.PolarVVVV(PointA - PointB));                           //get Polar Values

            if (tempVector.y > 0)                                                                      // depending which quadrant of rotation
            {
                TempA = VMath.CartesianVVVV(tempVector.x + winkel, tempVector.y, 0 - Radius) + PointA; //minus Radius from Length > into Cartesian
                TempB = VMath.CartesianVVVV(tempVector.x - winkel, tempVector.y, Radius2) + PointB;    //Radius is Length > into Cartesian
            }
            else
            {
                TempA = VMath.CartesianVVVV(tempVector.x - winkel, tempVector.y, 0 - Radius) + PointA; //minus Radius from Length > into Cartesian
                TempB = VMath.CartesianVVVV(tempVector.x + winkel, tempVector.y, Radius2) + PointB;    //Radius is Length > into Cartesian
            }

            TempC = VMath.CartesianVVVV(VMath.PolarVVVV(TempA - TempB).x, VMath.PolarVVVV(TempA - TempB).y, 0 - VMath.PolarVVVV(TempA - TempB).z / 2.75) + TempA; // calculate center

            var myEdgeCoords = new EdgePoints
            {
                A      = new Point(Convert.ToInt16(TempA.x), Convert.ToInt16(TempA.y)), // create Point from Vector
                B      = new Point(Convert.ToInt16(TempB.x), Convert.ToInt16(TempB.y)), // create Point from Vector
                Center = new Point(Convert.ToInt16(TempC.x), Convert.ToInt16(TempC.y))
            };                                                                          // edgepoint definition

            return(myEdgeCoords);
        }
예제 #29
0
        public static Node ContructLineWall(Room room, Vector2R start, Vector2R end, int thickness,
                                            Dictionary <dynamic, dynamic> props = null, bool addToWallGroup = true)
        {
            float dist       = Vector2R.Distance(start, end);
            int   halfheight = (int)(dist / 2);
            int   halfwidth  = thickness / 2;
            float angle      = VMath.VectorToAngle(start - end);

            Node    n = new Node(room, props, ShapeType.Polygon);
            Polygon p = (Polygon)n.body.shape;

            n.body.orient = angle;
            p.SetBox(halfwidth, halfheight, false);
            n.body.pos = (start + end) / 2;
            n.body.DrawPolygonCenter = false;


            n.body.SetStatic();
            if (addToWallGroup)
            {
                room.MasterGroup.childGroups["Wall Group"].IncludeEntity(n);
                n.OnSpawn();
            }
            return(n);
        }
예제 #30
0
파일: Spread.cs 프로젝트: maroten/vvvv-sdk
 public T this[int index]
 {
     get
     {
         var length = FStream.Length;
         if (length > 0)
         {
             return(FStream[VMath.Zmod(index, length)]);
         }
         else
         {
             throw new IndexOutOfRangeException("The index was outside of the bounds of the spread.");
         }
     }
     set
     {
         var length = FStream.Length;
         if (length > 0)
         {
             FStream[VMath.Zmod(index, length)] = value;
         }
         else
         {
             throw new IndexOutOfRangeException("The index was outside of the bounds of the spread.");
         }
     }
 }