/// <summary> /// Create a RouteNode. /// </summary> /// <param name="data">Parameters of the RouteNode to construct.</param> /// <param name="getEventInstance">Function to get an existing RouteEvent instance.</param> /// <param name="registerEventInstance">Function to register a RouteEvent instance.</param> /// <param name="createEvent">Function to create a RouteEvent.</param> /// <returns>Function to create a RouteNode.</returns> private static FoxLib.Tpp.RouteSet.RouteNode Create(RouteNode data, TryGetEventInstanceDelegate getEventInstance, RegisterEventInstanceDelegate registerEventInstance, CreateEventDelegate createEvent) { FoxLib.Tpp.RouteSet.RouteEvent edgeEvent; if (!getEventInstance(data.EdgeEvent, out edgeEvent)) { edgeEvent = createEvent(data.EdgeEvent); registerEventInstance(data.EdgeEvent, edgeEvent); } List <FoxLib.Tpp.RouteSet.RouteEvent> eventInstances = new List <FoxLib.Tpp.RouteSet.RouteEvent>(); foreach (var @event in data.Events) { FoxLib.Tpp.RouteSet.RouteEvent eventInstance; if (!getEventInstance(@event, out eventInstance)) { var newInstance = createEvent(@event); registerEventInstance(@event, newInstance); eventInstances.Add(newInstance); continue; } eventInstances.Add(eventInstance); } return(new FoxLib.Tpp.RouteSet.RouteNode( FoxUtils.UnityToFox(data.transform.position), edgeEvent, eventInstances.ToArray() )); }
/// <summary> /// Converts from a FoxLib MaterialPreset to a FoxKit MaterialPreset. /// </summary> /// <param name="foxLibMaterialPreset"></param> public MaterialPreset(FoxLib.MaterialParamBinary.MaterialPreset foxLibMaterialPreset) { this.F0 = foxLibMaterialPreset.F0; this.RoughnessThreshold = foxLibMaterialPreset.RoughnessThreshold; this.ReflectionDependDiffuse = foxLibMaterialPreset.ReflectionDependDiffuse; this.AnisotropicRoughness = foxLibMaterialPreset.AnisotropicRoughness; this.SpecularColor = FoxUtils.FoxColorRGBToUnityColor(foxLibMaterialPreset.SpecularColor); this.Translucency = foxLibMaterialPreset.Translucency; }
/// <summary> /// Create a RouteNode. /// </summary> /// <param name="data">Parameters of the RouteNode.</param> /// <param name="routeSet">RouteSet the RouteNode belongs to.</param> /// <param name="route">Route the RouteNode belongs to.</param> /// <param name="name">Name of the RouteNode.</param> /// <param name="createEvent">Function to create a RouteEvent.</param> /// <returns>The constructed RouteNode.</returns> private static RouteNode Create(FoxLib.Tpp.RouteSet.RouteNode data, RouteSet routeSet, Route route, string name, CreateEventDelegate createNodeEvent, CreateEventDelegate createEdgeEvent) { var gameObject = new GameObject(name); var nodeComponent = gameObject.AddComponent <RouteNode>(); gameObject.transform.position = FoxUtils.FoxToUnity(data.Position); gameObject.transform.SetParent(route.transform); // TODO: Remove? We don't share event instances anymore. routeSet.RegisterRouteEvent(data.EdgeEvent, gameObject, createEdgeEvent); nodeComponent.Events = (from @event in data.Events select routeSet.RegisterRouteNodeEvent(@event, gameObject.transform, createNodeEvent)) .ToList(); return(nodeComponent); }
private static object ConvertValueToFox(Core.PropertyInfoType type, Func <Entity, ulong> getEntityAddress, Func <EntityLink, Core.EntityLink> convertEntityLink, object value) { switch (type) { case Core.PropertyInfoType.Int8: return(value); case Core.PropertyInfoType.UInt8: return(value); case Core.PropertyInfoType.Int16: return(value); case Core.PropertyInfoType.UInt16: return(value); case Core.PropertyInfoType.Int32: return(value); case Core.PropertyInfoType.UInt32: return(value); case Core.PropertyInfoType.Int64: return(value); case Core.PropertyInfoType.UInt64: return(value); case Core.PropertyInfoType.Float: return(value); case Core.PropertyInfoType.Double: return(value); case Core.PropertyInfoType.Bool: return(value); case Core.PropertyInfoType.String: return(value); case Core.PropertyInfoType.Path: return(FoxUtils.UnityPathToFoxPath(AssetDatabase.GetAssetPath(value as UnityEngine.Object))); case Core.PropertyInfoType.EntityPtr: return(getEntityAddress(value as Entity)); case Core.PropertyInfoType.Vector3: return(FoxUtils.UnityToFox((UnityEngine.Vector3)value)); case Core.PropertyInfoType.Vector4: return(FoxUtils.UnityToFox((UnityEngine.Vector4)value)); case Core.PropertyInfoType.Quat: return(FoxUtils.UnityToFox((UnityEngine.Quaternion)value)); case Core.PropertyInfoType.Matrix3: return(FoxUtils.UnityToFox((Matrix3x3)value)); case Core.PropertyInfoType.Matrix4: return(FoxUtils.UnityToFox((Matrix4x4)value)); case Core.PropertyInfoType.Color: return(FoxUtils.UnityColorToFoxColorRGBA((Color)value)); case Core.PropertyInfoType.FilePtr: return(FoxUtils.UnityPathToFoxPath(AssetDatabase.GetAssetPath(value as UnityEngine.Object))); case Core.PropertyInfoType.EntityHandle: return(getEntityAddress(value as Entity)); case Core.PropertyInfoType.EntityLink: return(convertEntityLink(value as EntityLink)); case Core.PropertyInfoType.PropertyInfo: Assert.IsTrue(false, "Attempting to convert value of type PropertyInfo. This should never happen."); break; case Core.PropertyInfoType.WideVector3: Assert.IsTrue(false, "Attempting to convert value of type WideVector3. This should never happen."); break; default: throw new ArgumentOutOfRangeException(nameof(type), type, null); } return(null); }