public StaticCameraPath(Routines.Animation animation, TimeSpan duration, ImmutableTransform @from, ImmutableTransform to) { _animation = animation; _duration = duration; _from = @from; _to = to; }
/// <summary> /// Get an immutable transform representing the spatial state of a single cell from a canopy /// in factory state /// </summary> /// <param name="config"></param> /// <param name="centroid"></param> /// <param name="cellIndex"></param> /// <returns></returns> public static ImmutableTransform GetCellTransform(ParachuteConfig config, Vector3 centroid, int cellIndex) { float circumference = config.RadiusHorizontal * Mathf.PI * 2f; float widthRatio = config.Span / circumference; float phaseStep = widthRatio * Mathf.PI * 2f / config.NumCells; float phase = -widthRatio * Mathf.PI; phase += phaseStep * cellIndex; Vector3 p0 = new Vector3( Mathf.Sin(phase) * config.RadiusHorizontal, Mathf.Cos(phase) * config.RadiusVertical + config.HeightOffset - config.RadiusVertical); Vector3 p1 = new Vector3( Mathf.Sin(phase + phaseStep) * config.RadiusHorizontal, Mathf.Cos(phase + phaseStep) * config.RadiusVertical + config.HeightOffset - config.RadiusVertical); Vector3 pos = Vector3.Lerp(p0, p1, 0.5f); Quaternion rot = Quaternion.LookRotation(Vector3.forward, Vector3.Cross(Vector3.forward, p1 - p0)); Vector3 scale = new Vector3(Vector3.Distance(p0, p1), config.Thickness, config.Chord); // todo: areaMultiplier // Apply rigging angle Quaternion riggingRotation = Quaternion.AngleAxis(config.RiggingAngle, Vector3.right); Vector3 centroidPos = pos - centroid; var t = new ImmutableTransform( centroid + riggingRotation * centroidPos, rot * riggingRotation, scale); return(t); }
/// <summary> /// Projects a 2D coordinate on a 2D rectangle in 3D (world) space. /// Useful for positioning things in front of the camera. /// </summary> /// <param name="plane">The rectangle to project the coordinate on</param> /// <param name="planeCoordinates">Vector2(0,0) is bottom-left and Vector2(1,1) is top-right</param> /// <returns>A point on the rectangle in 3D world space</returns> public static ImmutableTransform ProjectPointOnPlane(ImmutableTransform plane, Vector2 planeCoordinates) { var relativePlaneCoordinates = planeCoordinates - new Vector2(0.5f, 0.5f); var planePosition = new Vector3(relativePlaneCoordinates.x * plane.Scale.x, relativePlaneCoordinates.y * plane.Scale.y, 0f); return(plane.TranslateLocally(planePosition)); }
private void Awake() { var inputMapping = PilotInput.Bindings.DefaultXbox360Mapping.Value; _pilotActionMap = PilotInput.ActionMap.Create( new ActionMapConfig <WingsuitAction> { ControllerId = new ControllerId.XInput((PlayerIndex)_controllerId), InputSettings = InputSettings.Default, InputMapping = inputMapping }, _gameClock); _pilotPool = new ObjectPool <GameObject>(() => _pilot); var container = new DependencyContainer(); container.AddDependency("eventSystem", _eventSystem); container.AddDependency("windManager", _windManager); container.AddDependency("actionMap", new Ref <PilotActionMap>(_pilotActionMap)); container.AddDependency("gameClock", _gameClock); container.AddDependency("fixedClock", _fixedClock); DependencyInjector.Default.Inject(_pilot, container); _originalTransform = _pilot.transform.MakeImmutable(); _pooledPilot = _pilotPool.Take(); }
private static SerializableTransform SerializeTransform(ImmutableTransform t) { return(new SerializableTransform { Position = SerializeVector3(t.Position), Rotation = SerializeVector3(t.Rotation.eulerAngles), Scale = SerializeVector3(t.Scale) }); }
public void Deserialize(NetBuffer reader) { Spawnpoint = new ImmutableTransform( position: reader.ReadVector3(), rotation: reader.ReadRotation()); InputPitch = reader.ReadSingle(); InputRoll = reader.ReadSingle(); }
private static Parachute CreateNewInstance(ParachuteConfig config, ImmutableTransform transform, string name) { GameObject root = new GameObject("Parachute"); root.transform.Set(transform); root.name = name; Parachute p = root.AddComponent <Parachute>(); p.Init(config); return(p); }
public static Parachute Create(ParachuteConfig config, ImmutableTransform transform, string name) { ParachuteMaths.ValidateConfig(config); Parachute p = CreateNewInstance(config, transform, name); // Todo: Differentiate between game use and editor use CreateCells(p); CreateInterCellJoints(p); CreateRiggingLines(p); CreateControlGroups(p); p.CalculateCanopyBounds(); AddSounds(p); return(p); }
public Parachute Create(ParachuteConfig config, ImmutableTransform spawnpoint, string name = "Parachute") { Profiler.BeginSample("CreateParachute"); config.AirfoilDefinition = _airfoilDefinition; Profiler.BeginSample("CreateSimObject"); var parachute = UnityParachuteFactory.Create(config, spawnpoint, name); Profiler.EndSample(); Profiler.BeginSample("CreateSkinnedMesh"); UnityParachuteMeshFactory.CreateSkinnedMesh(parachute, _parachuteMeshconfig, _parachuteMaterial); Profiler.EndSample(); parachute.Inject(_windManager, _fixedClock, _fixedScheduler); Profiler.EndSample(); return(parachute); }
void CreateEditorChute(ParachuteConfig config, ImmutableTransform transform) { if (_editorParachute != null) { _editorParachute.DetachPilot(); GameObject.Destroy(_editorParachute.Root.gameObject); } _editorParachute = _data.EditorSpawner.Create(config, transform, "EditorParachute"); _environment.Pilot.SetKinematic(); _environment.Pilot.OnDespawn(); _environment.Pilot.transform.position = transform.Position; _environment.Pilot.transform.rotation = transform.Rotation; _environment.Pilot.OnSpawn(); _environment.Pilot.SetKinematic(); _editorParachute.AttachToPilot(_environment.Pilot, Parachute.DefaultUnfoldOrientation, _data.GameSettingsProvider); UnityParachuteFactory.SetKinematic(_editorParachute); _data.EditorCamera.SetTarget(_editorParachute); _editorParachuteChanges.OnNext(_editorParachute); }
public static SpawnpointLocation ToLocation(ImmutableTransform transform) { return(new SpawnpointLocation(transform.Position, transform.Rotation.eulerAngles.y)); }
private static void LayoutCell(Cell cell, ImmutableTransform t) { cell.transform.localPosition = t.Position; cell.transform.localRotation = t.Rotation; }
public static HistoricalCourseEditorState AddProp(this HistoricalCourseEditorState state, ImmutableTransform transform) { var propId = PropId.CreateRandomId(); var newProp = new EditorProp { Id = propId, PropType = state.SelectedPropType, Transform = transform }; // Immediately select the newly created prop var selectedProp = Maybe.Just(propId); return(state.Update(selectedProp, state.Props.Add(newProp.Id, newProp), state.PropOrder.Add(propId))); }
public CameraProperties(float fieldOfView, float aspect, ImmutableTransform transform) { FieldOfView = fieldOfView; Aspect = aspect; Transform = transform; }
public RenderableProp(ImmutableTransform transform, System.Func <IPooledGameObject> create) { _transform = transform; _create = create; }
public EditorProp UpdateTransform(ImmutableTransform t) { return(new EditorProp { Id = Id, PropType = PropType, Transform = t }); }