예제 #1
0
        public override void OnUpdate(AppTime time)
        {
            Single x = time.Delta * Maths.ToRadians(10f);

            Quaternion rot = Quaternion.CreateFromYawPitchRoll(x, 0, 0);

            this.Parent.Transform.LocalRotation *= rot;
        }
예제 #2
0
        // UPDATE
        // Override update so that every frame we can alter our parent SceneObject's orientation.
        public override void OnUpdate(AppTime time)
        {
            // If the Subject has not been set then this behviour will just early
            // out without making any changes to the
            if (Subject == null)
                return;

            this.Parent.Transform.LookAt(Subject);
        }
예제 #3
0
        public override void OnUpdate(AppTime time)
        {
            BoundingBox b;

            //f**k
            //this.Parent.Transform.Position
            b.Min = this.Parent.Transform.Location.Translation - (this.Parent.Transform.Scale / 2f);
            b.Max = this.Parent.Transform.Location.Translation + (this.Parent.Transform.Scale / 2f);

            this.Parent.Owner.Engine.DebugRenderer.AddBoundingBox (RenderPass, b, Colour);
        }
예제 #4
0
        // UPDATE
        // Override update so that every frame we move the parent SceneObjects transform a little.
        public override void OnUpdate(AppTime time)
        {
            Vector3 offset = this.Parent.Transform.LocalPosition - CameraSubject.Position;

            Matrix44 rotation =
                Matrix44.CreateRotationY(Speed * time.Delta);

            Vector3 offsetIn = offset;

            Vector3.Transform(ref offsetIn, ref rotation, out offset);

            this.Parent.Transform.LocalPosition = offset + CameraSubject.Position;
        }
예제 #5
0
        public override void OnUpdate(AppTime time)
        {
            WorkOutInputs();

            float translationSpeed = mTranslationSpeedStandard
                + mInputs.mTranslationSpeed *
                (mTranslationSpeedMaximum - mTranslationSpeedStandard);

            Vector3 translation = mInputs.mTranslation * translationSpeed * time.Delta;

            Vector3 rotation =
                mInputs.mRotation *
                Maths.ToRadians(mRotationSpeed) *
                mInputs.mRotationSpeedScale * time.Delta;

            localPitch += rotation.X;
            localYaw += rotation.Y;
            localRoll += rotation.Z;

            Quaternion rotationFromInputs = Quaternion.CreateFromYawPitchRoll(localYaw, localPitch, localRoll);

            Quaternion currentOri = this.Parent.Transform.Rotation;

            this.Parent.Transform.Rotation = Quaternion.Multiply(currentOri, rotationFromInputs);

            float yTranslation = translation.Y;
            translation.Y = 0.0f;

            this.Parent.Transform.Position +=
                oldPosition +
                Vector3.Transform(translation, this.Parent.Transform.Rotation) +
                new Vector3(0.0f, yTranslation, 0.0f);

            //focusDistance = 3.0f;

            //update the old position for next time
            oldPosition = this.Parent.Transform.Position;
        }
예제 #6
0
        void UpdateTouchTrackers(AppTime time)
        {
            // delete all touch trackers that whose last touch was in the released state
            int num = touchTrackers.RemoveAll(x => (x.Phase == TouchPhase.JustReleased || x.Phase == TouchPhase.Invalid));

            if( num > 0 )
            {
                Console.WriteLine("Blimey.Input", string.Format("Removing {0} touches.", num));
            }

            // go through all active touches
            foreach (var touch in controller.TouchCollection)
            {
                // find the platformresponding tracker

                TouchTracker tracker = touchTrackers.Find(x => (x.TouchID == touch.ID));

                if (tracker == null)
                {
                    tracker = new TouchTracker(
                        this.platform,
                        this.platform.Host.ScreenSpecification,
                        this.platform.Host.PanelSpecification,
                        touch.ID );

                    touchTrackers.Add(tracker);
                }

                tracker.RegisterTouch(touch);
            }

            // assert if there are any trackers in the list that have not been updated this frame
            var problems = touchTrackers.FindAll(x => (x.LatestTouch.FrameNumber != time.FrameNumber));
            if (problems.Count != 0)
                throw new Exception ();
        }
예제 #7
0
        void UpdateGestureDetection(AppTime time)
        {
            // Each frame we look for press combinations that could potentially
            // be the start of a gesture.
            foreach (var touchTracker in touchTrackers)
            {
                if( touchTracker.Phase == TouchPhase.JustPressed )
                {
                    // this could be the start of a tap
                    var potentialTapGesture =
                        new PotentialTapGesture(
                            this,
                            new String[]{touchTracker.TouchID} );

                    var potentialDoubleTapGesture =
                        new PotentialDoubleTapGesture(
                            this,
                            new String[]{touchTracker.TouchID} );

                    var potentialFlickGesture =
                        new PotentialFlickGesture(
                            this,
                            new String[]{touchTracker.TouchID} );

                    potentialGestures.Add(potentialTapGesture);
                    potentialGestures.Add(potentialDoubleTapGesture);
                    potentialGestures.Add(potentialFlickGesture);

                }

                int enqueueCount = 0;

                foreach(var potentialGesture in potentialGestures)
                {
                    var gesture = potentialGesture.Update(time.Delta, touchTrackers);

                    if( gesture != null )
                    {
                        this.gestureQueue.Enqueue(gesture);
                        enqueueCount++;
                    }
                }

                int removeCount = potentialGestures.Count;
                potentialGestures.RemoveAll(x => x.Finished );
                removeCount -= potentialGestures.Count;

            }
        }
예제 #8
0
파일: Trait.cs 프로젝트: dreamsxin/engine-1
 public virtual void OnUpdate(AppTime time)
 {
 }
예제 #9
0
 internal void PostUpdate(AppTime appTime)
 {
     // make sure that everything gets removed.
     foreach (var pass in passState.Keys)
         if (passState[pass].nPrimsInBuffer > 0)
         _enqueue_batch (pass);
 }
예제 #10
0
파일: App.cs 프로젝트: gitter-badger/blimey
            public void Update(AppTime time)
            {
                if (stopwatch.Elapsed > sampleSpan)
                {
                    // Update FPS value and start next sampling period.
                    fps = (Single)sampleFrames / (Single)stopwatch.Elapsed.TotalSeconds;

                    stopwatch.Reset();
                    stopwatch.Start();
                    sampleFrames = 0;
                }
            }
예제 #11
0
        public override void OnUpdate(AppTime time)
        {
            Vector3 previousPosition = this.Parent.Transform.Position;

            Vector3 desiredPosition = Subject.Position + desiredPositionOffset;

            Vector3 stretch = previousPosition - desiredPosition;
            //Console.WriteLine(Parent.Name + ": ChaseSubject stretch=" + stretch + " - (" + previousPosition + " - " + desiredPosition + ")");

            if (this.dirty || ! SpringEnabled)
            {
                this.dirty = false;

                // Stop motion
                this.velocity = Vector3.Zero;

                // Force desired position
                this.Parent.Transform.Position = desiredPosition;
            }
            else
            {
                // Calculate spring force
                Vector3 force = -this.Stiffness * stretch - this.Damping * this.velocity;

                // Apply acceleration
                Vector3 acceleration = force / this.Mass;
                this.velocity += acceleration * time.Delta;

                // Apply velocity
                Vector3 deltaPosition = this.velocity * time.Delta;
                this.Parent.Transform.Position += deltaPosition;
            }
        }
예제 #12
0
        // Allows the game component to update itself.
        public override void OnUpdate(AppTime time)
        {
            var camUp = this.Parent.Transform.Up;

            var camLook = this.Parent.Transform.Forward;

            Vector3 pos = this.Parent.Transform.Position;
            Vector3 target = pos + (camLook * FarPlaneDistance);

            Matrix44.CreateLookAt(
                ref pos,
                ref target,
                ref camUp,
                out _view);

            Single width = (Single) this.Platform.Status.Width;
            Single height = (Single)this.Platform.Status.Height;

            if (Projection == CameraProjectionType.Orthographic)
            {
                if(TempWORKOUTANICERWAY)
                {
                    _projection =
                        Matrix44.CreateOrthographic(
                            width / SpriteTrait.SpriteConfiguration.Default.SpriteSpaceScale,
                            height / SpriteTrait.SpriteConfiguration.Default.SpriteSpaceScale,
                            1, -1);
                }
                else
                {
                    _projection =
                        Matrix44.CreateOrthographicOffCenter(
              -0.5f * ortho_width * ortho_zoom,  +0.5f * ortho_width * ortho_zoom,
              -0.5f * ortho_height * ortho_zoom, +0.5f * ortho_height * ortho_zoom,
              +0.5f * ortho_depth,  -0.5f * ortho_depth);
                }
            }
            else
            {
                _projection =
                    Matrix44.CreatePerspectiveFieldOfView (
                        FieldOfView,
                        width / height, // aspect ratio
                        NearPlaneDistance,
                        FarPlaneDistance);
            }
        }
예제 #13
0
        public Boolean Update(AppTime time)
        {
            // If the active state returns a game state other than itself then we need to shut
            // it down and start the returned state.  If a game state returns null then we need to
            // shut the platform down.

            //quitting the game
            if (nextScene == null)
            {
                activeScene.Uninitilise ();
                activeScene = null;
                return true;
            }

            if (nextScene != activeScene && activeScene != null)
            {
                activeScene.Uninitilise ();
                activeScene = null;
                GC.Collect ();
                return false;
            }

            if (nextScene != activeScene)
            {
                activeScene = nextScene;
                activeScene.Initialize (platform, engine);
            }

            nextScene = activeScene.RunUpdate (time);

            return false;
        }
예제 #14
0
 internal void PreUpdate(AppTime time)
 {
     this.DebugRenderer.Update(time);
     this.InputEventSystem.Update(time);
 }
예제 #15
0
 internal void PostUpdate(AppTime time)
 {
     this.PrimitiveRenderer.PostUpdate (time);
 }
예제 #16
0
파일: App.cs 프로젝트: gitter-badger/blimey
        /// <summary>
        /// Blimey's root update loop.
        /// </summary>
        public virtual Boolean Update(Platform platform, AppTime time)
        {
            FrameStats.SlowLog ();
            FrameStats.Reset ();

            using (new ProfilingTimer(t => FrameStats.Add ("UpdateTime", t)))
            {
                fps.Update(time);
                frameBuffer.Update(time);

                return this.sceneManager.Update(time);
            }
        }
예제 #17
0
파일: Scene.cs 프로젝트: dreamsxin/engine-1
 public abstract Scene Update(AppTime time);
예제 #18
0
파일: App.cs 프로젝트: gitter-badger/blimey
            public void Update(AppTime time)
            {
                colourChangeTimer += time.Delta;

                if (colourChangeTimer > colourChangeTime)
                {
                    colourChangeTimer = 0.0f;
                    randomColour = RandomGenerator.Default.GetRandomColour();
                }
            }
예제 #19
0
파일: Scene.cs 프로젝트: dreamsxin/engine-1
        internal Scene RunUpdate(AppTime time)
        {
            if (firstUpdate)
            {
                firstUpdate = false;
                isRunning = true;
            }

            this.engine.PreUpdate (time);

            foreach (Entity go in sceneGraph.GetAllObjects())
            {
                go.Update(time);
            }

            this.engine.PostUpdate (time);

            var ret =  this.Update(time);
            return ret;
        }
예제 #20
0
        public override void OnUpdate(AppTime time)
        {
            ApplyChanges(false);

            if (!String.IsNullOrWhiteSpace (this.DebugRender))
            {
                var yScale =
                    this.Parent.Transform.Scale.Z / 2;

                // this is f****d.  shouldn't have to normalise here
                var up = this.Parent.Transform.Location.Forward;
                Vector3.Normalise(ref up, out up);

                var xScale =
                    this.Parent.Transform.Scale.X / 2;

                // this is f****d.  shouldn't have to normalise here
                var right = this.Parent.Transform.Location.Right;
                Vector3.Normalise(ref right, out right);

                var a =   (up * yScale) - (right * xScale);
                var b =   (up * yScale) + (right * xScale);
                var c = - (up * yScale) + (right * xScale);
                var d = - (up * yScale) - (right * xScale);

                a = this.Parent.Transform.LocalPosition + a;
                b = this.Parent.Transform.LocalPosition + b;
                c = this.Parent.Transform.LocalPosition + c;
                d = this.Parent.Transform.LocalPosition + d;

                this.Engine.DebugRenderer.AddQuad(
                    this.DebugRender,
                    a,
                    b,
                    c,
                    d,
                    Rgba32.Red
                    );
            }
        }
예제 #21
0
 internal virtual void Update(AppTime time)
 {
     if( controller != null )
     {
         // before this the child should have updated this TouchCollection
         this.UpdateTouchTrackers(time);
         this.UpdateGestureDetection(time);
         this.InvokeGestureEvents(time);
     }
 }
예제 #22
0
        void InvokeGestureEvents(AppTime time)
        {
            foreach (var gesture in gestureQueue)
            {
                string line = string.Format("({1}) {0}", gesture.Type, gesture.ID);
                switch (gesture.Type)
                {
                    case GestureType.Tap:
                        line += string.Format(", finishing position {0}", gesture.GetFinishingPosition(TouchPositionSpace.NormalisedEngine));

                        if (this.Tap != null)
                        {
                            this.Tap(gesture);
                        }
                        break;

                    case GestureType.DoubleTap:
                        if (this.DoubleTap != null)
                        {
                            this.DoubleTap(gesture);
                        }
                        break;

                    case GestureType.Flick:
                        line += string.Format(", finishing position {0}", gesture.GetFinishingPosition(TouchPositionSpace.NormalisedEngine));
                        if (this.Flick != null)
                        {
                            this.Flick(gesture);
                        }
                        break;

                    default: throw new System.NotImplementedException();
                }

                Console.WriteLine("Blimey.Input", line);
            }

            gestureQueue.Clear();
        }
예제 #23
0
        internal void Update(AppTime time)
        {
            foreach (var pass in activeShapes.Keys)
            {
                // Go through our active shapes and retire any shapes that have expired to the
                // cache list.
                Boolean resort = false;
                for (int i = activeShapes[pass].Count - 1; i >= 0; i--)
                {
                    DebugShape s = activeShapes[pass] [i];

                    if (s.Lifetime < 0)
                    {
                        cachedShapes[pass].Add (s);
                        activeShapes[pass].RemoveAt (i);
                        resort = true;
                    }
                    else
                    {
                        s.Lifetime -= time.Delta;
                    }
                }

                // If we move any shapes around, we need to resort the cached list
                // to ensure that the smallest shapes are first in the list.
                if (resort)
                    this.cachedShapes[pass].Sort (CachedShapesSort);
            }
        }