示例#1
0
文件: JumpBy.cs 项目: Zamir7/urho
		public JumpByState (JumpBy action, Node target)
			: base (action, target)
		{ 
			Delta = action.Position;
			Height = action.Height;
			Jumps = action.Jumps;
			P = StartPosition = target.Position;
		}
示例#2
0
文件: MoveBy.cs 项目: Zamir7/urho
		public override void Update (float time)
		{
			if (Target == null)
				return;

			var currentPos = Target.Position;
			var diff = currentPos - PreviousPosition;
			StartPosition = StartPosition + diff;
			Vector3 newPos = StartPosition + PositionDelta * time;
			Target.Position = newPos;
			PreviousPosition = newPos;
		}
示例#3
0
文件: JumpBy.cs 项目: Zamir7/urho
		public override void Update (float time)
		{
			if (Target != null)
			{
				// Is % equal to fmodf()???
				float frac = (time * Jumps) % 1f;
				float y = Height * 4f * frac * (1f - frac);
				y += Delta.Y * time;
				float x = Delta.X * time;
				float z = Delta.Z * time;

				Vector3 currentPos = Target.Position;

				Vector3 diff = currentPos - P;
				StartPosition = diff + StartPosition;

				Vector3 newPos = StartPosition + new Vector3 (x, y, z);
				Target.Position = newPos;

				P = newPos;
			}
		}
示例#4
0
文件: JumpBy.cs 项目: Zamir7/urho
		public JumpBy (float duration, Vector3 position, float height, uint jumps) : base (duration)
		{
			Position = position;
			Height = height;
			Jumps = jumps;
		}
示例#5
0
文件: MoveTo.cs 项目: Zamir7/urho
		public MoveTo (float duration, Vector3 position) : base (duration, position)
		{
			EndPosition = position;
		}
示例#6
0
文件: Place.cs 项目: Zamir7/urho
		public Place (Vector3 pos)
		{
			Position = pos;
		}
示例#7
0
文件: Place.cs 项目: Zamir7/urho
		public Place (int posX, int posY, int posZ = 0)
		{
			Position = new Vector3(posX, posY, posZ);
		}
示例#8
0
文件: MoveBy.cs 项目: Zamir7/urho
		public MoveBy (float duration, Vector3 position) : base (duration)
		{
			PositionDelta = position;
		}
示例#9
0
文件: MoveBy.cs 项目: Zamir7/urho
		public MoveByState (MoveBy action, Node target)
			: base (action, target)
		{ 
			PositionDelta = action.PositionDelta;
			PreviousPosition = StartPosition = target.Position;
		}
示例#10
0
文件: JumpTo.cs 项目: Zamir7/urho
		public JumpTo (float duration, Vector3 position, float height, uint jumps) 
			: base (duration, position, height, jumps)
		{
		}
示例#11
0
文件: JumpTo.cs 项目: Zamir7/urho
		public JumpToState (JumpBy action, Node target)
			: base (action, target)
		{ 
			Delta = new Vector3 (Delta.X - StartPosition.X, Delta.Y - StartPosition.Y, Delta.Z - StartPosition.Z);
		}
示例#12
0
        private Node AddBox(Vector3 position, Vector3 rotationDeltas)
        {
            var boxNode = _scene.CreateChild();
            boxNode.Position = position;
            //boxNode.RunActions(new Repeat(new RotateBy(1, rotationDeltas.X, rotationDeltas.Y, rotationDeltas.Z), 1));
            boxNode.LookAt(Vector3.Zero, Vector3.UnitY, TransformSpace.Parent);

            var modelObject = boxNode.CreateComponent<StaticModel>();
            modelObject.Model = ResourceCache.GetModel("Models/Box.mdl");

            return boxNode;
        }
示例#13
0
        private async Task PlaceBoxes()
        {

            if (_currentMapping == null)
            {
                return;
            }


            foreach (var measurement in _currentMapping.Measurements)
            {

                // ToDo: place images on boxes


                // Compute position
                /*
                 * 1. All measurements start from the horizontal and go down as the tilt angle increases
                 *    a) __ __ __      b) __ __ __   c) __ __ __
                 *      |                 \             __ __ __
                 *      | 90°              \ 45°            0°
                 *      |                   \
                 *    
                 * 2. Polar to Cartesian.  (https://en.wikipedia.org/wiki/Spherical_coordinate_system)
                 *      θ   :angle in XoY plane
                 *      Phi :angle from Z axis towards XoY plane
                 *      r   : distance from the origin 
                 *      
                 *     x = r × sin(θ) × cos(phi)
                 *     y = r × sin(θ) × sin(phi)
                 *     z = r × cos(theta)
                 * 
                 * 3. Careful: 
                 *  Scene Coordinate System           Spherical Coordinate System
                 *     (y) (z)                          (y)
                 *      |  /                             |           
                 *      | /                              | 
                 *      |/__ __ __(x)                    |__ __ __(x)
                 *                                      /                         
                 *                                     / 
                 *                                   (z)
                 *  theta = panAngle
                 *  phi = tiltAngle + 90
                 *  r = distanceCm                                   
                 */

                // Scale distance a bit 
                measurement.DistanceCm *= 0.5;

                var x = (float)(measurement.DistanceCm *
                                Math.Cos(measurement.PanAngle * degreesToRadConstant) *
                                Math.Sin((measurement.TiltAngle + 90) * degreesToRadConstant));

                var y = (float)(measurement.DistanceCm *
                                Math.Sin(measurement.PanAngle * degreesToRadConstant) *
                                Math.Sin((measurement.TiltAngle + 90) * degreesToRadConstant));

                var z = (float)(measurement.DistanceCm *
                                Math.Cos((measurement.TiltAngle + 90) * degreesToRadConstant));

                var position = new Vector3(x, z, y);
                System.Diagnostics.Debug.WriteLine($"Positioning at X: {position.X} Y: {position.Y} Z: {position.Z}");

                // Compute rotation deltas to face to the point (0.0,0.0,0.0)
                var rotation = new Vector3(0, (float)-measurement.PanAngle, (float)-measurement.TiltAngle);

                // Add box to the scene
                var currentNode = AddBox(position, rotation);

                _boxNodes.Add(currentNode, measurement);
            }
        }