public JumpByState (JumpBy action, Node target) : base (action, target) { Delta = action.Position; Height = action.Height; Jumps = action.Jumps; P = StartPosition = target.Position; }
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; }
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; } }
public JumpBy (float duration, Vector3 position, float height, uint jumps) : base (duration) { Position = position; Height = height; Jumps = jumps; }
public MoveTo (float duration, Vector3 position) : base (duration, position) { EndPosition = position; }
public Place (Vector3 pos) { Position = pos; }
public Place (int posX, int posY, int posZ = 0) { Position = new Vector3(posX, posY, posZ); }
public MoveBy (float duration, Vector3 position) : base (duration) { PositionDelta = position; }
public MoveByState (MoveBy action, Node target) : base (action, target) { PositionDelta = action.PositionDelta; PreviousPosition = StartPosition = target.Position; }
public JumpTo (float duration, Vector3 position, float height, uint jumps) : base (duration, position, height, jumps) { }
public JumpToState (JumpBy action, Node target) : base (action, target) { Delta = new Vector3 (Delta.X - StartPosition.X, Delta.Y - StartPosition.Y, Delta.Z - StartPosition.Z); }
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; }
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); } }