Exemplo n.º 1
0
 public override IFrameState CreateWindowState(FrameOverlayManager manager)
 {
     IFrameState w = new FrameState(manager);
     if (mUseDefaultBG)
         w.AddFeature(new ColourFeature(mDefaultBG));
     return w;
 }
Exemplo n.º 2
0
        private (int X, int Y) TranslateToRenderCoords(FrameState renderState, int screenX, int screenY)
        {
            var x = renderState.OffsetInWindowX + screenX;
            var y = renderState.OffsetInWindowY + screenY;

            return(x, y);
        }
Exemplo n.º 3
0
 private void APP_Update()
 {
     if (spriteRender.sprite != photo_2)
     {
         state = FrameState.DISAPPEARING;
     }
 }
        private void RenderDebugOverlay(FrameState renderState)
        {
            if (DebugSettings.HasFlag(DebugFlags.SpriteBoundingBoxes))
            {
                RenderSpriteBoundingBoxes(renderState);
            }

            if (DebugSettings.HasFlag(DebugFlags.HitMapBoundingBoxes))
            {
                RenderHitMapBoundingBoxes(renderState);
            }

            if (DebugSettings.HasFlag(DebugFlags.HitMapPolygons))
            {
                RenderHitMapPolygons(renderState);
            }

            if (DebugSettings.HasFlag(DebugFlags.SystemTimings))
            {
                RenderTimingsGraph(renderState);
            }

            if (DebugSettings.HasFlag(DebugFlags.FramesPerSecond))
            {
                RenderFramesPerSecond(renderState);
            }

            RenderDebugLayerNames();
        }
Exemplo n.º 5
0
        public const int TOTAL_COG_MEMORY = 0x200;  // 512 longs of memory

        /// @brief Default constructor.
        public Cog(PropellerCPU host, uint programAddress, uint param, uint frequency, PLLGroup pll)
        {
            Hub = host;

            Memory         = new uint[TOTAL_COG_MEMORY];
            ProgramAddress = programAddress;
            ParamAddress   = param;

            FreqA           = new FreqGenerator(host, pll, true);
            FreqB           = new FreqGenerator(host, pll, false);
            Video           = new VideoGenerator(host, this);
            PhaseLockedLoop = pll;

            // Attach the video generator to PLLs
            PhaseLockedLoop.SetupPLL(Video);

            PC = 0;
            BreakPointCogCursor = -1;    // Breakpoint disabled initially
            frameFlag           = FrameState.frameNone;
            frameBreak          = FrameState.frameMiss;

            // We are in boot time load
            Memory[(int)Assembly.RegisterAddress.PAR] = param;
            State      = CogRunState.WAIT_LOAD_PROGRAM;
            StateCount = 0;

            // Clear the special purpose registers
            for (int i = (int)Assembly.RegisterAddress.CNT; i <= 0x1FF; i++)
            {
                this[i] = 0;
            }

            SetClock(frequency);
        }
Exemplo n.º 6
0
        public unsafe void ResetBox(int index)
        {
            if (index == 2 || index == 4 || index == 5 || index == 8)
            {
                return;
            }

            NumericInputBox     box = _transBoxes[index];
            MDL0MaterialRefNode mr  = TargetTexRef;
            SRT0TextureNode     entry;

            if (TargetTexRef != null)
            {
                if ((SelectedAnimation != null) && (CurrentFrame > 0) && ((entry = SelectedAnimation.FindChild(mr.Parent.Name + "/Texture" + mr.Index, true) as SRT0TextureNode) != null))
                {
                    KeyframeEntry e = entry.Keyframes.GetKeyframe((KeyFrameMode)index + 0x10, CurrentFrame - 1);
                    if (e == null)
                    {
                        box.Value     = entry.Keyframes[KeyFrameMode.ScaleX + index, CurrentFrame - 1];
                        box.BackColor = Color.White;
                    }
                    else
                    {
                        box.Value     = e._value;
                        box.BackColor = Color.Yellow;
                    }
                }
                else
                {
                    FrameState state = mr._bindState;
                    box.Value     = ((float *)&state)[index];
                    box.BackColor = Color.White;
                }
            }
        }
Exemplo n.º 7
0
 /// <summary>
 ///   See <see cref="InputDevice.GetDeviceSnapshot" />
 /// </summary>
 public InputSnapshot GetDeviceSnapshot(PlayerIndex player, FrameState frameState)
 {
     var gamePadState = frameState == FrameState.Current
                            ? CurrentGamePadStates[player]
                            : PreviousGamePadStates[player];
     return new InputSnapshot(null, gamePadState, null, null);
 }
Exemplo n.º 8
0
 public Frame()
 {
     Rolls     = new int[] { 0, 0 };
     State     = FrameState.NotAttempted;
     rollIndex = -1;
     Bonus     = 0;
 }
Exemplo n.º 9
0
        public void Roll(int pins)
        {
            if (pins < 0)
            {
                pins = 0;  // For negative value of pins
            }
            Rolls[++rollIndex] = pins;

            if (Rolls[0] == 10)
            {
                State = FrameState.Strike;
            }
            else if (Rolls[0] + Rolls[1] == 10)
            {
                State = FrameState.Spare;
            }
            else if (rollIndex == 1)
            {
                State = FrameState.None;
            }

            if (Rolls[0] + Rolls[1] > 10 && Type != FrameType.LastFrame)
            {
                throw new InvalidOperationException();
            }
        }
Exemplo n.º 10
0
        internal void ApplyCHR0(CHR0Node node, int index, bool linear)
        {
            CHR0EntryNode e;

            _frameState = _bindState;

            if (node != null && index > 0 && (e = node.FindChild(Name, false) as CHR0EntryNode) != null) //Set to anim pose
                fixed(FrameState *v = &_frameState)
                {
                    float *f = (float *)v;

                    for (int i = 0; i < 9; i++)
                    {
                        if (e.Keyframes[(KeyFrameMode)(i + 0x10)] > 0)
                        {
                            f[i] = e.GetFrameValue((KeyFrameMode)(i + 0x10), index - 1, linear, node.Loop);
                        }
                    }

                    _frameState.CalcTransforms();
                }

            foreach (MDL0BoneNode b in Children)
            {
                b.ApplyCHR0(node, index, linear);
            }
        }
Exemplo n.º 11
0
        //Initialize should only be called from parent group during parse.
        //Bones need not be imported/exported anyways
        protected override bool OnInitialize()
        {
            MDL0Bone *header = Header;

            SetSizeInternal(header->_headerLen);

            //Assign true parent using parent header offset
            int offset = header->_parentOffset;

            //Offsets are always < 0, because parent entries are listed before children
            if (offset < 0)
            {
                //Get address of parent header
                MDL0Bone *pHeader = (MDL0Bone *)((byte *)header + offset);
                //Search bone list for matching header
                foreach (MDL0BoneNode bone in _parent._children)
                {
                    if (pHeader == bone.Header)
                    {
                        _parent = bone; break;
                    }                          //Assign parent and break
                }
            }

            //Conditional name assignment
            if ((_name == null) && (header->_stringOffset != 0))
            {
                _name = header->ResourceString;
            }

            //Assign fields
            _flags     = (BoneFlags)(uint)header->_flags;
            _nodeIndex = header->_nodeId;
            _boneIndex = header->_index;

            _permanentID = header->_index;

            _bindState = _frameState = new FrameState(header->_scale, header->_rotation, header->_translation);
            (_bindState._quaternion = new Quaternion()).FromEuler(header->_rotation);
            _bindMatrix        = _frameMatrix = header->_transform;
            _inverseBindMatrix = _inverseFrameMatrix = header->_transformInv;

            _bMin = header->_boxMin;
            _bMax = header->_boxMax;

            if (header->_part2Offset != 0)
            {
                Part2Data *    part2  = (Part2Data *)((byte *)header + header->_part2Offset);
                ResourceGroup *group  = part2->Group;
                ResourceEntry *pEntry = &group->_first + 1;
                int            count  = group->_numEntries;
                for (int i = 0; i < count; i++)
                {
                    _entries.Add(new String((sbyte *)group + (pEntry++)->_stringOffset));
                }
            }
            //We don't want to process children because not all have been parsed yet.
            //Child assigning will be handled by the parent group.
            return(false);
        }
Exemplo n.º 12
0
 void Start()
 {
     mFrameState  = FrameState.IDLE;
     mAnim = transform.parent.GetComponent<Animator> ();
     if(mAnim != null)
         mAnim.enabled = false;
 }
Exemplo n.º 13
0
 public static IPipelineFilterStep ForAcceleration(
     HardwareAccelerationMode accelMode,
     FrameState currentState,
     FrameSize scaledSize,
     FrameSize paddedSize) =>
 accelMode switch
 {
Exemplo n.º 14
0
        private unsafe void ResetBox(int index)
        {
            NumericInputBox box = _transBoxes[index];

            if (_transformObject is MDL0BoneNode)
            {
                MDL0BoneNode  bone = _transformObject as MDL0BoneNode;
                CHR0EntryNode entry;
                if ((_selectedAnim != null) && (_animFrame > 0) && ((entry = _selectedAnim.FindChild(bone.Name, false) as CHR0EntryNode) != null))
                {
                    KeyframeEntry e = entry.Keyframes.GetKeyframe((KeyFrameMode)index + 0x10, _animFrame - 1);
                    if (e == null)
                    {
                        box.Value     = entry.Keyframes[KeyFrameMode.ScaleX + index, _animFrame - 1];
                        box.BackColor = Color.White;
                    }
                    else
                    {
                        box.Value     = e._value;
                        box.BackColor = Color.Yellow;
                    }
                }
                else
                {
                    FrameState state = bone._bindState;
                    box.Value     = ((float *)&state)[index];
                    box.BackColor = Color.White;
                }
            }
            else
            {
                box.Value     = 0;
                box.BackColor = Color.White;
            }
        }
Exemplo n.º 15
0
        /// <summary>
        /// Render detected faces via OpenCV.
        /// </summary>
        /// <param name="state">Current frame state.</param>
        /// <param name="image">Web cam or video frame.</param>
        /// <returns>Returns new image frame.</returns>
        private static Mat RenderFaces(FrameState state, Mat image)
        {
            Mat result = image.Clone();

            Cv2.CvtColor(image, image, ColorConversionCodes.BGR2GRAY);

            // Render all detected faces
            foreach (var face in state.Faces)
            {
                var center = new Point
                {
                    X = face.Center.X,
                    Y = face.Center.Y
                };
                var axes = new Size
                {
                    Width  = (int)(face.Size.Width * 0.5) + 10,
                    Height = (int)(face.Size.Height * 0.5) + 10
                };

                Cv2.Ellipse(result, center, axes, 0, 0, 360, _faceColorBrush, 4);
            }

            return(result);
        }
Exemplo n.º 16
0
        public static void DrawScreenCircle(this FrameState frame, int x0, int y0, int radius, Color color)
        {
            void DrawPoint(int xn, int yn)
            {
                frame.DrawScreenPoint(xn, yn, color);
            }

            var x           = radius;
            var y           = 0;
            var radiusError = 1 - x;

            while (x >= y)
            {
                DrawPoint(x + x0, y + y0);
                DrawPoint(y + x0, x + y0);
                DrawPoint(-x + x0, y + y0);
                DrawPoint(-y + x0, x + y0);
                DrawPoint(-x + x0, -y + y0);
                DrawPoint(-y + x0, -x + y0);
                DrawPoint(x + x0, -y + y0);
                DrawPoint(y + x0, -x + y0);
                y++;
                if (radiusError < 0)
                {
                    radiusError += 2 * y + 1;
                }
                else
                {
                    x--;
                    radiusError += 2 * (y - x + 1);
                }
            }
        }
Exemplo n.º 17
0
        public bool HasChanged(FrameState previousState, FrameState newState)
        {
            var prevStateNumber = previousState?.Faces?.Count ?? 0;
            var newStateNumber  = newState?.Faces?.Count ?? 0;

            return(prevStateNumber != newStateNumber);
        }
Exemplo n.º 18
0
        public static void DrawScreenLineSmooth(this FrameState frame, int x0, int y0, int x1, int y1, Color color)
        {
            void DrawScreenPoint(bool swap, int vx, int vy, float intensity)
            {
                if (swap)
                {
                    Common.Swap(ref vx, ref vy);
                }
                frame.DrawScreenPoint(vx, vy, color.ChangeAlpha((byte)(intensity * color.A)));
            }

            var steep = NormalizeLine(ref x0, ref y0, ref x1, ref y1);

            DrawScreenPoint(steep, x0, y0, 1);
            DrawScreenPoint(steep, x1, y1, 1);
            var dx       = x1 - x0;
            var dy       = y1 - y0;
            var gradient = (float)dy / dx;
            var y        = y0 + gradient;

            for (var x = x0 + 1; x < x1; x++)
            {
                DrawScreenPoint(steep, x, (int)y, 1 - (y - (int)y));
                DrawScreenPoint(steep, x, (int)y + 1, y - (int)y);
                y += gradient;
            }
        }
Exemplo n.º 19
0
 public FrameEvalState(FrameState initialState)
 {
     State = new Stack <FrameState>();
     State.Push(initialState);
     Result   = StandardRuntime.Nil;
     Complete = false;
 }
Exemplo n.º 20
0
        public void VideoBreak_Click(object sender, EventArgs e)
        {
            if (sender == breakNone)
            {
                breakNone.Checked = true;
                breakMiss.Checked = false;
                breakAll.Checked  = false;
                breakVideo        = FrameState.frameMiss;
            }
            if (sender == breakMiss)
            {
                breakNone.Checked = false;
                breakMiss.Checked = true;
                breakAll.Checked  = false;
                breakVideo        = FrameState.frameMiss;
            }
            if (sender == breakAll)
            {
                breakNone.Checked = true;
                breakMiss.Checked = false;
                breakAll.Checked  = false;
                breakVideo        = FrameState.frameNone;
            }
            Cog cog = Chip.GetCog(HostID);

            cog.VideoBreak = breakVideo;
        }
        private void RenderHitMapPolygons(FrameState renderState)
        {
            var roomHeightSubPixels = renderState.BackgroundHeightSubPixels;

            var overlay = renderState.Overlay;

            for (var i = 0; i < overlay.NumHitMaps; i++)
            {
                var color = GetDebugColorForIndex(i);
                var polyCartesianSubPixels = overlay.HitMapPolygonsCartesianSubPixels[i];

                for (var j = 0; j < polyCartesianSubPixels.NumVertices; j++)
                {
                    var nextIx = j + 1;
                    if (nextIx == polyCartesianSubPixels.NumVertices)
                    {
                        nextIx = 0;
                    }

                    var v1Cartesian = polyCartesianSubPixels.GetVertex(j);
                    var v2Cartesian = polyCartesianSubPixels.GetVertex(nextIx);

                    var v1Screen = new Utilities.Point(v1Cartesian.X, roomHeightSubPixels - v1Cartesian.Y);
                    var v2Screen = new Utilities.Point(v2Cartesian.X, roomHeightSubPixels - v2Cartesian.Y);

                    var v1Pixels = new Utilities.Point(v1Screen.X / PositionComponent.SUBPIXELS_PER_PIXEL, v1Screen.Y / PositionComponent.SUBPIXELS_PER_PIXEL);
                    var v2Pixels = new Utilities.Point(v2Screen.X / PositionComponent.SUBPIXELS_PER_PIXEL, v2Screen.Y / PositionComponent.SUBPIXELS_PER_PIXEL);

                    var v1AfterCamera = new Utilities.Point(v1Pixels.X - overlay.CameraX, v1Pixels.Y - overlay.CameraY);
                    var v2AfterCamera = new Utilities.Point(v2Pixels.X - overlay.CameraX, v2Pixels.Y - overlay.CameraY);

                    DrawLine(v1AfterCamera, v2AfterCamera, color);
                }
            }
        }
Exemplo n.º 22
0
 void Start()
 {
     spriteRender       = GetComponent <SpriteRenderer>();
     spriteRender.color = new Color(1, 1, 1, 0);
     Server.eventManager.RegistHandler <Change_Photo_Event>(SetPhoto);
     state = FrameState.DISAPPEARED;
 }
Exemplo n.º 23
0
        private bool IsMouseButtonActive(MouseButton button, FrameState state)
        {
            MouseState  mouseState = state == FrameState.Current ? CurrentMouseState : LastMouseState;
            ButtonState buttonState;

            switch (button)
            {
            case MouseButton.Left:
                buttonState = mouseState.LeftButton;
                break;

            case MouseButton.Right:
                buttonState = mouseState.RightButton;
                break;

            case MouseButton.Middle:
                buttonState = mouseState.MiddleButton;
                break;

            default:
                buttonState = ButtonState.Released;
                break;
            }

            return(buttonState == ButtonState.Pressed);
        }
Exemplo n.º 24
0
        private bool IsTriggerActive(Trigger trigger, FrameState state)
        {
            GamePadState gamepadState = state == FrameState.Current ? CurrentGamePadState : LastGamePadState;
            float        triggerMag   = trigger == Trigger.Left ? gamepadState.Triggers.Left : gamepadState.Triggers.Right;

            return(triggerMag >= triggerThreshold);
        }
Exemplo n.º 25
0
        private bool IsThumbstickActive(Thumbstick thumbstick, FrameState state)
        {
            GamePadState gamepadState      = state == FrameState.Current ? CurrentGamePadState : LastGamePadState;
            Vector2      gamepadThumbstick = thumbstick == Thumbstick.Left ? gamepadState.ThumbSticks.Left : gamepadState.ThumbSticks.Right;

            return(gamepadThumbstick.Length() >= thumbstickThreshold);
        }
Exemplo n.º 26
0
        private void menuItem_Save_Click(object sender, EventArgs e)
        {
            try
            {
                if (sc.manage.rootNode.Nodes.Count == 0)
                {
                    return;
                }

                if (!IsFileOpened)
                {
                    OpenSaveDialogToSaveSettings();
                }
                else
                {
                    IsSetingsCanSave = false;

                    _fileName = Path.Combine(GetDefaultConsoleDirectory(), _fileName);
                    FrameState fs       = GetFrameState();
                    string     tempFile = sc.manage.SaveConsoleSettingsToXml(fs);

                    if (File.Exists(_fileName))
                    {
                        File.Delete(_fileName);
                    }
                    File.Move(tempFile, _fileName);
                }
            }
            catch (Exception ex)
            {
                Logger.LogException("LMCMainForm.menuItem_Save_Click ()", ex);
            }
        }
Exemplo n.º 27
0
        private void ReadConsoleFile(string sFileName)
        {
            FileInfo fileInfo = new FileInfo(sFileName);

            if (fileInfo != null && fileInfo.Extension.Trim().Equals(".lmc"))
            {
                FrameState fs = new FrameState();
                sc.manage.ReadPluginNodeInfoFromConsoleSettings(sFileName, fs);

                // reestablish frame state
                if (fs.bShowMaximized)
                {
                    this.WindowState = FormWindowState.Maximized;
                }
                this.pivotPanel.Visible    = this.splitter1.Visible = fs.bShowTreeControl;
                this.menuItem_Save.Enabled = fs.bReadOnly ? false : true;

                if (navTree.SelectedNode.Nodes.Count == 0)
                {
                    navTree.SelectedNode.Expand();
                    sc.ShowControl(navTree.SelectedNode as LACTreeNode);
                }
                else
                {
                    LACTreeNode node = navTree.SelectedNode.Nodes[0] as LACTreeNode;
                    sc.ShowControl(node);
                    node.Expand();
                    navTree.SelectedNode = node;
                }
                navTree.Select();
                IsFileOpened = true;
            }
        }
    private void updateFrameStack()
    {
        GameObject[] ghostTimeBodies = GameObject.FindGameObjectsWithTag("GhostTimeBody");

        List <SinglePoint> pointsList = new List <SinglePoint>();

        foreach (GameObject ghostbody in ghostTimeBodies)
        {
            if (ghostbody.activeSelf)
            {
                int instanceID = ghostbody.GetInstanceID();

                // Check if ghostBody already has a corresponding visible timebody
                if (!visibleTimeBodies.ContainsKey(instanceID))
                {
                    // Create visible time body from ghostbody
                    Transform newBody = createVisibleTimeBody(ghostbody).transform;

                    // Track new timebody in visibleTimeBodies
                    visibleTimeBodies[instanceID] = newBody;
                }

                // Record the position state of the ghostbody
                SinglePoint point = new SinglePoint(ghostbody.transform.position, ghostbody.transform.rotation, instanceID);
                pointsList.Add(point);
            }
        }

        if (pointsList.Count > 0)
        {
            FrameState frameState = new FrameState(pointsList);
            frameStateStack.Add(frameState);
        }
    }
        public void Update(FrameState state)
        {
            wait++;

            if (wait >= smoothing)
            {
                currentFrame += 1;
                wait = 0;
            }
            //if (currentFrame >= recordedMovement.Length - 1) currentFrame = 0;

            float m = wait / (float)smoothing;


            if ((value++) % 2 == 0)
            {
                currentHand = GetHand();
                //currentTransform = Matrix.Lerp(recordedMovement[currentFrame].transform, recordedMovement[currentFrame + 1].transform, m);
                currentTransform = currentHand.transform;
            }

            Matrix headTransform = Camera.instance.rotation;
            //hand.PhysicsEntity.WorldTransform = Matrix.CreateRotationY(-MathHelper.PiOver2) * currentTransform * headTransform * Matrix.CreateTranslation(Camera.instance.headPosition + headTransform.Forward * 0.2f);
            hand.PhysicsEntity.WorldTransform = currentTransform * Matrix.CreateRotationY(-MathHelper.PiOver2) * headTransform * Matrix.CreateTranslation(Camera.instance.headPosition + headTransform.Forward * 2 + headTransform.Down * 0.5f);
            HandleFingers(state);
            
        }
 public static IPipelineFilterStep ForAcceleration(
     HardwareAccelerationMode accelMode,
     FrameState currentState,
     WatermarkState watermarkState,
     FrameSize resolution) =>
 accelMode switch
 {
Exemplo n.º 31
0
        internal void ApplyCHR0(CHR0Node node, float index)
        {
            CHR0EntryNode e;

            _frameState = _bindState;

            if (node != null && index >= 1 && (e = node.FindChild(Name, false) as CHR0EntryNode) != null) //Set to anim pose
                fixed(FrameState *v = &_frameState)
                {
                    float *f = (float *)v;

                    for (int i = 0; i < 9; i++)
                    {
                        if (e.Keyframes[i]._keyCount > 0)
                        {
                            f[i] = e.GetFrameValue(i, index - 1);
                        }
                    }

                    _frameState.CalcTransforms();
                }

            foreach (MDL0BoneNode b in Children)
            {
                b.ApplyCHR0(node, index);
            }
        }
Exemplo n.º 32
0
        private unsafe void RenderCatchCollision(Vector3 cam)
        {
            ResourceNode[] bl = _model._linker.BoneCache;

            int boneindex = _parameters[1];
            int size      = HitboxSize;

            Root.GetBoneIndex(ref boneindex);

            if (boneindex == 0) // if a hitbox is on TopN, make it follow TransN
            {
                if (Root.Data != null)
                {
                    boneindex = Root.Data._misc._boneRefs[4].boneIndex;
                    Root.GetBoneIndex(ref boneindex);
                }
                else
                {
                    int transindex = 0;
                    foreach (MDL0BoneNode bn in bl)
                    {
                        if (bn.Name.Equals("TransN"))
                        {
                            break;
                        }
                        transindex++;
                    }
                    if (transindex != bl.Length)
                    {
                        boneindex = transindex;
                    }
                }
            }
            MDL0BoneNode b = bl[boneindex] as MDL0BoneNode;

            Matrix     r         = b.Matrix.GetRotationMatrix();
            FrameState state     = b.Matrix.Derive();
            Vector3    bonePos   = state._translate;
            Vector3    pos       = new Vector3(Util.UnScalar(_parameters[3]), Util.UnScalar(_parameters[4]), Util.UnScalar(_parameters[5])) / state._scale;
            Vector3    globalPos = r.Multiply(pos);

            Matrix  m         = Matrix.TransformMatrix(new Vector3(1), state._rotate, globalPos + bonePos);
            Vector3 resultPos = m.GetPoint();

            m = Matrix.TransformMatrix(new Vector3(Util.UnScalar(size)), new Vector3(), resultPos);
            GL.PushMatrix();
            GL.MultMatrix((float *)&m);
            int    res       = 16;
            double drawangle = 360.0 / res;

            Vector3 color = Util.GetTypeColor(Util.HitboxType.Throwing);

            GL.Color4((color._x / 255.0f), (color._y / 225.0f), (color._z / 255.0f), 0.375f);
            GLDisplayList spheres = TKContext.GetSphereList();

            spheres.Call();

            GL.PopMatrix();
        }
 public static IPipelineFilterStep ForAcceleration(
     HardwareAccelerationMode accelMode,
     FrameState currentState,
     FrameState desiredState,
     Option <WatermarkInputFile> watermarkInputFile,
     Option <SubtitleInputFile> subtitleInputFile) =>
 accelMode switch
 {
Exemplo n.º 34
0
    public override FrameState NextState(FrameState currentState)
    {
        FrameState nextState = base.NextState(currentState);

        return(currentState.PixelFormat.Match(
                   pixelFormat => nextState with {
            PixelFormat = new PixelFormatNv12(pixelFormat.Name)
        },
Exemplo n.º 35
0
	    //main application draw method
		protected override void Frame(FrameState state)
		{
		    

            Camera.instance.Update();
            HandController.instance.Update(state);

            currentScene.Frame(state);

            HandleCollisions(state);
		}
		/// <summary>
		/// Run all drawing code for the frame
		/// </summary>
		/// <param name="state"></param>
		protected internal abstract void Frame(FrameState state);
		protected override void Frame(FrameState state)
		{
			//rotate the camera around the scene (similar to tutorial 14)
			RotateCamera(state);

			//draw the scene
			drawToScreen.Draw(state);
		}
		public void Draw(FrameState state)
		{
			if (state.FrameIndex != frameIndex)
			{
				anyChildDrawn = childDrawn;
				childDrawn = false;
				frameIndex = state.FrameIndex;
			}

			if (system != null)
				system.Draw(state);
		}
Exemplo n.º 39
0
			internal Exception Leave(FrameState prev)
			{
				// on the current (.NET 2.0 SP2) x86 JIT an explicit for loop is faster than Array.Clear() up to about 100 elements
				for (int i = 0; i < localRefIndex; i++)
				{
					active[i] = null;
				}
				while (--localRefSlot != prev.localRefSlot)
				{
					if (localRefs[localRefSlot] != null)
					{
						if (localRefs[localRefSlot].Length == LOCAL_REF_MAX_BUCKET_SIZE)
						{
							// if the bucket is totally allocated, we're assuming a leaky method so we throw the bucket away
							localRefs[localRefSlot] = null;
						}
						else
						{
							Array.Clear(localRefs[localRefSlot], 0, localRefs[localRefSlot].Length);
						}
					}
				}
				active = localRefs[localRefSlot];
				this.localRefIndex = prev.localRefIndex;
				this.callerID = prev.callerID;
				Exception x = pendingException;
				pendingException = null;
				return x;
			}
Exemplo n.º 40
0
		/// <summary>
		/// Perform all drawing to this draw target. All modifiers will be applied, and all drawable items in draw list will be drawn to the draw target
		/// </summary>
		/// <param name="state"></param>
		public void Draw(FrameState state)
		{
			if (!enabled)
				return;

			DrawState drawState = state.DrawState;
			if (drawState.DrawTarget != null)
				throw new ArgumentException("Already rendering to another draw target: " + drawState.DrawTarget.ToString());

			if (GetEnabled())
			{
				drawState.DrawTarget = this;

				int repeats = GetRepeatCount();
				drawState.RenderState.Push(ref nullState);

				rendering = true;
				ushort stackHeight, stateHeight, cameraHeight,preCull,postCull;

#if DEBUG
				System.Threading.Interlocked.Increment(ref drawState.Application.currentFrame.DrawTargetsDrawCount);
#endif
				Begin(drawState);

				for (int repeat = 0; repeat < repeats; repeat++)
				{
					drawState.GetStackHeight(out stackHeight, out stateHeight, out cameraHeight, out preCull, out postCull);

					ICamera cam = camera;
					if (repeats > 1)
					{
						if (!BeginRepeat(drawState, repeat, ref cam))
							continue;
					}

#if DEBUG
					System.Threading.Interlocked.Increment(ref drawState.Application.currentFrame.DrawTargetsPassCount);

#if XBOX360
					state.Application.currentFrame.XboxPixelFillBias += this.Width * this.Height;
#endif
#endif

					if (bufferClear.Enabled)
						bufferClear.Draw(drawState);

					if (modifiers != null)
					{
						foreach (IBeginEndDraw mod in modifiers)
						{
							if (mod.Enabled)
							{
								activeModifiers.Add(mod);
								mod.Begin(drawState);
							}
						}
					}

					drawState.Camera.Push(cam);

					foreach (IDraw block in drawList)
					{
						if (block.CullTest(drawState))
							block.Draw(drawState);
					}

					drawState.Camera.Pop();

					//end in reverse order
					if (modifiers != null)
					{
						for (int i = activeModifiers.Count - 1; i >= 0; i--)
						{
							activeModifiers[i].End(drawState);
						}
						activeModifiers.Clear();
					}

					if (repeats > 1)
						EndRepeat(drawState, repeat);

					drawState.ValidateStackHeight(stackHeight, stateHeight, cameraHeight, preCull, postCull);
				}
					
				End(drawState);

				drawState.RenderState.Pop();

				drawState.DrawTarget = null;
				rendering = false;

				drawState.EndFrameCleanup();
			}
		}
Exemplo n.º 41
0
		protected override void Frame(FrameState state)
		{
			particlesTarget.Draw(state);
			
			quaterDownsample.Draw(state);
			blurFilter.Draw(state);
						
			drawToScreen.Draw(state);
		}
Exemplo n.º 42
0
        public override void Frame(FrameState state)
        {
            Vector3 pos = Camera.instance.headPosition;
            if(_level == 3) pos.Y = 0;
            if (_level == 2) pos.Y -= 20;
            foreach (var followingParticle in followingParticles)
            {

                followingParticle.DefaultParticleEmitPosition = pos;
            }

            base.Frame(state);
        }
        private void AddParticles(Gesture gesture, FrameState state)
	    {
	        if (gesture == Gesture.Curse)
	        {
                curseParticlesTriger.FireTrigger(hand.PhysicsEntity.Position);
	        }
	    }
	    private void HandleFingers(FrameState state)
	    {
            bonesController.BendFingers(currentHand.bend[0], currentHand.bend[1], currentHand.bend[2], currentHand.bend[3], currentHand.bend[4]);

	        Gesture newGesture = Gesturator.getGesture(new Fingers(currentHand.bend));

            if (lastGesture == Gesture.Neutral)
            {
                if (newGesture == Gesture.Curse)
                {
                    TestScene._instance.AddBullet(hand.PhysicsEntity.WorldTransform.Translation, Camera.instance.rotation.Forward, "curse");
                    AddParticles(newGesture, state);
                }
                
            }
            lastGesture = newGesture;
	    }
		//main application draw method
		protected override void Frame(FrameState state)
		{
			//draw to the screen.
			//This causes the sphere to be drawn (because it was added to the screen)
			drawToScreen.Draw(state);
		}
Exemplo n.º 46
0
        private static FrameState setFrameState(string agentFullname, int frame, string behaviorFilename, string nodeId)
        {
            if (frame < 0 || string.IsNullOrEmpty(agentFullname) || string.IsNullOrEmpty(behaviorFilename) || string.IsNullOrEmpty(nodeId))
                return null;

            if (!_frameStates.ContainsKey(agentFullname))
                _frameStates[agentFullname] = new List<FrameState>();

            FrameState frameState = null;
            List<FrameState> frameStates = _frameStates[agentFullname];
            int index = findFrame(frameStates, frame);

            if (index < 0)
            {
                frameState = new FrameState();
                frameState.Frame = frame;
                frameState.BehaviorFilename = behaviorFilename;

                int neareatIndex = findNearestFrame(frameStates, frame);
                if (neareatIndex >= 0)
                {
                    foreach (string id in frameStates[neareatIndex].HighlightNodeIds)
                    {
                        frameState.HighlightNodeIds.Add(id);
                    }
                }

                frameStates.Add(frameState);
            }
            else
            {
                frameState = frameStates[index];
                if (frameState.BehaviorFilename != behaviorFilename)
                {
                    frameState.BehaviorFilename = behaviorFilename;
                    frameState.HighlightNodeIds.Clear();
                }
            }

            return frameState;
        }
Exemplo n.º 47
0
		protected override void Frame(FrameState state)
		{
			//draw the screen / effect
			drawToScreen.Draw(state);
		}
		protected override void Frame(FrameState state)
		{
			//draw the shadow map texture first,
			drawShadowDepth.Draw(state);

			//apply the blur filter to the shadow texture
			shadowDepthBlurFilter.Draw(state);

			//set a global light collection (that all models will use)
			using (state.DrawFlags.Push(new MaterialLightCollectionFlag(ambientLight)))
			{
				//draw the scene to the screen
				drawToScreen.Draw(state);
			}
		}
		//main application draw method
		protected override void Frame(FrameState state)
		{
			//move the sphere from left to right
			sphere.position = new Vector3((float)Math.Sin(state.TotalTimeSeconds) * 6, 0, 0);
			//and make sure the bounding box matches it
			sphereBoundingBox.position = sphere.position;


			//draw to the screen.
			drawToScreen.Draw(state);
		}
		protected override void Frame(FrameState state)
		{
			//rotate the camera around the ground plane
			RotateCamera(state);

			//draw everything
			drawToScreen.Draw(state);
		}
		protected override void Frame(FrameState state)
		{
			drawToScreen.Draw(state);
		}
Exemplo n.º 52
0
		public StateObject(Socket workSocket, int bufferSize = 8192)
		{
			WorkSocket = workSocket;
			BufferSize = bufferSize;
			Buffer = new byte[BufferSize];
			Stream = new MemoryStream();
			State = FrameState.FindSoh;
		}
		/// <summary>
		/// Perform the texture downsample filter
		/// </summary>
		/// <param name="state"></param>
		public void Draw(FrameState state)
		{
			foreach (IFrameDraw draw in passes)
				draw.Draw(state);
		}
		/// <summary>
		/// Apply the filter
		/// </summary>
		/// <param name="state"></param>
		public void Draw(FrameState state)
		{
			switch (kernelSize)
			{
				case 16:
					Kernel16 shader16 = state.GetShader<Kernel16>();
					shader16.Texture = source.GetTexture();
					shader16.TextureSize = new Vector2(1.0f / this.source.Size.X, 1.0f / this.source.Size.Y);
					shader16.Kernel = (this.filter);
					element.Shader = shader16;
					break;
				case 15:
					Kernel15 shader15 = state.GetShader<Kernel15>();
					shader15.Texture = source.GetTexture();
					shader15.TextureSize = new Vector2(1.0f / this.source.Size.X, 1.0f / this.source.Size.Y);
					shader15.Kernel = (this.filter);
					element.Shader = shader15;
					break;
				case 8:
					Kernel8 shader8 = state.GetShader<Kernel8>();
					shader8.Texture = source.GetTexture();
					shader8.TextureSize = new Vector2(1.0f / this.source.Size.X, 1.0f / this.source.Size.Y);
					shader8.Kernel = (this.filter);
					element.Shader = shader8;
					break;
				case 7:
					Kernel7 shader7 = state.GetShader<Kernel7>();
					shader7.Texture = source.GetTexture();
					shader7.TextureSize = new Vector2(1.0f / this.source.Size.X, 1.0f / this.source.Size.Y);
					shader7.Kernel = (this.filter);
					element.Shader = shader7;
					break;
				case 4:
					Kernel4 shader4 = state.GetShader<Kernel4>();
					shader4.Texture = source.GetTexture();
					shader4.TextureSize = new Vector2(1.0f / this.source.Size.X, 1.0f / this.source.Size.Y);
					shader4.Kernel = (this.filter);
					element.Shader = shader4;
					break;
				case 3:
					Kernel3 shader3 = state.GetShader<Kernel3>();
					shader3.Texture = source.GetTexture();
					shader3.TextureSize = new Vector2(1.0f / this.source.Size.X, 1.0f / this.source.Size.Y);
					shader3.Kernel = (this.filter);
					element.Shader = shader3;
					break;
				case 2:
					Kernel2 shader2 = state.GetShader<Kernel2>();
					shader2.Texture = source.GetTexture();
					shader2.TextureSize = new Vector2(1.0f / this.source.Size.X, 1.0f / this.source.Size.Y);
					shader2.Kernel = (this.filter);
					element.Shader = shader2;
					break;
			}
			targetClone.Draw(state);
		}
Exemplo n.º 55
0
			internal FrameState Enter([email protected] newCallerID)
			{
				FrameState prev = new FrameState(callerID, localRefSlot, localRefIndex);
				this.callerID = newCallerID;
				localRefSlot++;
				if (localRefSlot >= localRefs.Length)
				{
					object[][] tmp = new object[localRefs.Length * 2][];
					Array.Copy(localRefs, 0, tmp, 0, localRefs.Length);
					localRefs = tmp;
				}
				localRefIndex = 0;
				active = localRefs[localRefSlot];
				if (active == null)
				{
					active = localRefs[localRefSlot] = new object[LOCAL_REF_INITIAL_BUCKET_SIZE];
				}
				return prev;
			}
		/// <summary>
		/// Apply the filter
		/// </summary>
		/// <param name="state"></param>
		public void Draw(FrameState state)
		{
			filterV.Draw(state);
			filterH.Draw(state);
		}
		//callback by the drawproc,
		//this will be called at the very start of a rendered frame (before the application)
		internal void Draw(FrameState state)
		{
			if (disposed)
				return;

			threadWaitCallback.WaitForCompletion();

			int step = this.timeStep - renderStepCount;
			float deltaTime = 1.0f / systemLogic.Frequency;

			if (step == 0)
			{
				//first time rendering, must warm the systems
				foreach (ParticleStore store in this.particleStore)
					store.ParticleProcessor.Warm(state.Application);
			}

			//an update may happen more than once per frame
			for (int i = 0; i < renderStepCount; i++)
			{
				//draw each particle type, one by one (in dependancy sorted order)
				foreach (ParticleStore store in particleStoreSortedDrawOrder[i])
					store.ParticleProcessor.BeginDrawPass(i, deltaTime, step);
				foreach (ParticleStore store in particleStoreSortedDrawOrder[i])
					store.ParticleProcessor.DrawProcess(state, step);

				step++;
			}

			renderStepCount = 0;
		}
		internal void OnDraw(FrameState frame,DrawState state)
		{
#if DEBUG
			previousFrame = currentFrame;
			currentFrame.Reset();
			currentFrame.Begin();
#endif

			ushort stackHeight, stateHeight, cameraHeight, preCull,postCull;
			state.GetStackHeight(out stackHeight, out stateHeight, out cameraHeight,out preCull,out postCull);

			if (approxFps.Count == 20)
			{
				LinkedListNode<double> first = approxFps.First;
				approxFps.Remove(first);
				first.Value = state.DeltaTimeFrequency;
				approxFps.AddLast(first);
			}
			else
				approxFps.AddLast(state.DeltaTimeFrequency);
			
			double total = 0;
			foreach (double d in approxFps)
				total += d;
			if (approxFps.Count > 0)
				total /= approxFps.Count;

			approximateFrameRate = (float)total;

			if (drawableComponents > 0)
				state.renderState.InternalDirtyRenderState(Xen.Graphics.StateFlag.All);

			state.PrepareForNewFrame();

			//the predraw list is a list of items that need to be drawn before the frame starts
			//eg, an object in Update may require something is drawn this frame.
			//call PreFrameDraw in either Update() or Draw() to add to this list
			while (true)
			{
				lock (preFrameDrawList)
				{
					if (preFrameDrawList.Count == 0)
						break;

					foreach (IFrameDraw item in preFrameDrawList)
						preFrameDrawListBuffer.Add(item);
					preFrameDrawList.Clear();
				}

				foreach (IFrameDraw item in preFrameDrawListBuffer)
				{
					item.Draw(frame);
				}

				preFrameDrawListBuffer.Clear();
			}

			Frame(frame);

			state.ValidateStackHeight(stackHeight, stateHeight, cameraHeight, preCull, postCull);

#if DEBUG
			currentFrame.End();
#endif

#if !XBOX360
			//if (winFormsDispose)
			//{
			//	xnaLogic.Exit();
			//
			//	xnaLogic.Dispose();
			//}
#endif
		}
Exemplo n.º 59
0
    // Unmarshal and process the tracking data
    private void UpdateTrackers(FrameState frameState)
    {
        // Unmarshal the trackable data
        // Take our array of unmanaged data from native and create an array of
        // TrackableResultData structures to work with (one per trackable, regardless
        // of whether or not that trackable is visible this frame).
        for (int i = 0; i < frameState.numTrackableResults; i++)
        {
            IntPtr trackablePtr = new IntPtr(frameState.trackableDataArray.ToInt32() + i *
                    Marshal.SizeOf(typeof(TrackableResultData)));
            TrackableResultData trackableResultData = (TrackableResultData)
                    Marshal.PtrToStructure(trackablePtr, typeof(TrackableResultData));
            mTrackableResultDataArray[i] = trackableResultData;
        }

        // Add newly found Trackables to the queue, remove lost ones
        // We keep track of the order in which Trackables become visible for the
        // AUTO World Center mode. This keeps the camera from jumping around in the
        // scene too much.
        foreach (TrackableResultData trackableData in mTrackableResultDataArray)
        {
            // We found a trackable (or set of Trackables) that match this id
            if ((trackableData.status == TrackableBehaviour.Status.DETECTED
                 || trackableData.status ==
                 TrackableBehaviour.Status.TRACKED))
            {
                if (!mTrackableFoundQueue.Contains(trackableData.id))
                {
                    // The trackable just became visible, add it to the queue
                    mTrackableFoundQueue.AddLast(trackableData.id);
                }
            }
            else
            {
                if (mTrackableFoundQueue.Contains(trackableData.id))
                {
                    // The trackable just disappeared, remove it from the queue
                    mTrackableFoundQueue.Remove(trackableData.id);
                }
            }
        }

        // now remove those from the TrackableFoundQueue that were not in this frame's results:
        List<int> trackableFoundQueueCopy = new List<int>(mTrackableFoundQueue);
        foreach (int id in trackableFoundQueueCopy)
        {
            // check if the trackable is in this frame's results:
            if (Array.Exists(mTrackableResultDataArray, tr => tr.id == id))
                break;

            // not in the results, remove it from the queue
            mTrackableFoundQueue.Remove(id);
        }

        StateManagerImpl stateManager = (StateManagerImpl)
            TrackerManager.Instance.GetStateManager();

        // The "scene origin" is only used in world center mode auto or user.
        int originTrackableID = -1;

        if (mWorldCenterMode == QCARBehaviour.WorldCenterMode.USER &&
            mWorldCenter != null)
        {
            originTrackableID = mWorldCenter.Trackable.ID;
        }
        else if (mWorldCenterMode == QCARBehaviour.WorldCenterMode.AUTO)
        {
            stateManager.RemoveDisabledTrackablesFromQueue(ref mTrackableFoundQueue);
            if (mTrackableFoundQueue.Count > 0)
            {
                originTrackableID = mTrackableFoundQueue.First.Value;
            }
        }

        // Update the Camera pose before Trackable poses are updated.
        stateManager.UpdateCameraPose(mARCamera, mTrackableResultDataArray, originTrackableID);

        // Update the Trackable poses.
        stateManager.UpdateTrackablePoses(mARCamera, mTrackableResultDataArray, originTrackableID);

        // Update Virtual Button states.
        stateManager.UpdateVirtualButtons(frameState.numVirtualButtonResults, frameState.vbDataArray);
    }
		//main application draw method
		protected override void Frame(FrameState state)
		{
			//used by Tutorial03 shader
			state.ShaderGlobals.SetShaderGlobal("colour", new Vector4(1, 0, 0, 1));

			//NEW CODE
			//Draw the off screen texture (make sure it's drawn at least once before it's used!)
			//In this example, the texture is drawn every frame
			drawToTexture.Draw(state);

			//draw to the screen.
			//(drawing to the screen should always occur last, and only happen once per frame)
			drawToScreen.Draw(state);
		}