public AudioSignalNode(NodeDescription description, IResourceHandle <GlobalEngine> engineHandle, NodeContext nodeContext) : base(nodeContext) { this.description = description; FSignalInstance = (AudioSignal)Activator.CreateInstance(description.Signal); FEngineHandle = engineHandle; foreach (var input in description.Inputs) { FInputsMap.Add(input.Name, new MyPin() { Name = input.Name, Type = input.Type, Value = input.DefaultValue }); } Inputs = FInputsMap.Values.ToArray(); foreach (var output in description.Outputs) { FOutputsMap.Add(output.Name, new MyPin() { Name = output.Name, Type = output.Type, Value = output.DefaultValue }); } Outputs = FOutputsMap.Values.ToArray(); }
public LoadResourceFromBytesTask(IResourceHandle handle, byte[] bytes, AccessLevel al, GameType type) { this.handle = handle; this.bytes = bytes; this.AccessLevel = al; Game = type; }
void EnsureDeviceOpen() { if (FOutDeviceHandle == null) { FOutDeviceHandle = FOutDeviceProvider.GetHandle(); } }
public LoadResourceFromFileTask(IResourceHandle handle, string file, AccessLevel al, GameType type) { this.handle = handle; this.file = file; this.AccessLevel = al; this.Game = type; }
public void OnResourceLoaded(IResourceHandle handle) { if (Resource != null && Resource.TryLock()) { CreateSubmeshes(); OnWorldMatrixChanged(); Renderer.AddBackgroundUploadTask((d, cl) => { if (Submeshes != null && Resource.TryLock()) { foreach (var sm in Submeshes) { sm.CreateDeviceObjects(d, cl, null); } if (AutoRegister) { RegisterWithScene(RenderScene); } Created = true; Resource.Unlock(); } }); Resource.Unlock(); } }
void CloseDevice() { if (FOutDeviceHandle != null) { FOutDeviceHandle.Dispose(); FOutDeviceHandle = null; } }
public void OnResourceLoaded(IResourceHandle handle) { if (_resource != null && _resource.TryLock()) { _resource.Unlock(); NotifyAvailable(); } }
public StrideRenderHandler(NodeContext nodeContext) { var gameProvider = nodeContext.Factory.CreateService <IResourceProvider <Game> >(nodeContext); gameHandle = gameProvider?.GetHandle() ?? throw new ArgumentNullException(nameof(nodeContext), "The game service wasn't found"); var renderContext = RenderContext.GetShared(gameHandle.Resource.Services); Initialize(renderContext); }
public void OnResourceUnloaded(IResourceHandle handle) { foreach (var submesh in _submeshes) { submesh.Invalidate(); } _submeshes.Clear(); NotifyUnavailable(); }
public void OnResourceUnloaded(IResourceHandle handle) { if (Resource != null) { Created = false; UnregisterWithScene(); Submeshes = null; } }
public override void OnCreate(PlayableGraph gragh, IResourceHandle resourceHandle) { m_resourceHandle = resourceHandle; AnimationClip clip = resourceHandle.GetResource <AnimationClip>(); m_clipPlayable = AnimationClipPlayable.Create(gragh, clip); Output = m_clipPlayable; }
/// <summary> /// Start the current pool manager instance. /// </summary> public void Start(IResourceHandle <T> resourceHandle) { if (resourceHandle == null) { throw new Exception("The resource handle was not supplied."); } this.ResourceHandle = resourceHandle; #region Create all resources instance by PoolSize field lock (this.AllAllocatedResources) { for (int _resIndex = 0; _resIndex < this.PoolSize; _resIndex++) { var _resource = new Resource <T>(); _resource.Current = this.CreateResourceInstance(); _resource.ResourceHandle = this.ResourceHandle; this.AllAllocatedResources.Add(_resource); } } #endregion #region Traversal all resources and recreate resources that were disconnected or had exception this.MonitorTimer = new Timer(new TimerCallback((state) => { lock (this.AllAllocatedResources) { this.AllAllocatedResources.ForEach(item => { item.InUse = false; if (!item.Available) { item.Current = this.CreateResourceInstance(); } }); } }), null, this.MonitorInterval, this.MonitorInterval); #endregion }
public VideoPlayer(NodeContext nodeContext) { renderDrawContextHandle = nodeContext.GetGameProvider() .Bind(g => RenderContext.GetShared(g.Services).GetThreadContext()) .GetHandle() ?? throw new ServiceNotFoundException(typeof(IResourceProvider <Game>)); colorSpaceConverter = new ColorSpaceConverter(renderDrawContextHandle.Resource); // Initialize MediaFoundation MediaManagerService.Initialize(); using var mediaEngineAttributes = new MediaEngineAttributes() { // _SRGB doesn't work :/ Getting invalid argument exception later in TransferVideoFrame AudioCategory = SharpDX.Multimedia.AudioStreamCategory.GameMedia, AudioEndpointRole = SharpDX.Multimedia.AudioEndpointRole.Multimedia, VideoOutputFormat = (int)SharpDX.DXGI.Format.B8G8R8A8_UNorm }; var graphicsDevice = renderDrawContextHandle.Resource.GraphicsDevice; var device = SharpDXInterop.GetNativeDevice(graphicsDevice) as Device; if (device != null) { // Add multi thread protection on device (MF is multi-threaded) using var deviceMultithread = device.QueryInterface <DeviceMultithread>(); deviceMultithread.SetMultithreadProtected(true); // Reset device using var manager = new DXGIDeviceManager(); manager.ResetDevice(device); mediaEngineAttributes.DxgiManager = manager; } using var classFactory = new MediaEngineClassFactory(); engine = new MediaEngine(classFactory, mediaEngineAttributes); engine.PlaybackEvent += Engine_PlaybackEvent; }
public void OnResourceUnloaded(IResourceHandle handle) { UpdateMaterial(); }
public void OnResourceUnloaded(IResourceHandle handle) { NotifyUnavailable(); }
public void ProcessBinder() { if (Binder == null) { string o; var path = ResourceManager.Locator.VirtualToRealPath(BinderVirtualPath, out o); Binder = InstantiateBinderReaderForFile(path, ResourceManager.Locator.Type); if (Binder == null) { return; } } for (int i = 0; i < Binder.Files.Count(); i++) { var f = Binder.Files[i]; if (BinderLoadMask != null && !BinderLoadMask.Contains(i)) { continue; } var binderpath = f.Name; var filevirtpath = ResourceManager.Locator.GetBinderVirtualPath(BinderVirtualPath, binderpath); if (AssetWhitelist != null && !AssetWhitelist.Contains(filevirtpath)) { continue; } IResourceHandle handle = null; /*if (ResourceMan.ResourceDatabase.ContainsKey(filevirtpath)) * { * handle = ResourceMan.ResourceDatabase[filevirtpath]; * }*/ if (filevirtpath.ToUpper().EndsWith(".TPF") || filevirtpath.ToUpper().EndsWith(".TPF.DCX")) { string virt = BinderVirtualPath; if (virt.StartsWith($@"map/tex")) { var regex = new Regex(@"\d{4}$"); if (regex.IsMatch(virt)) { virt = virt.Substring(0, virt.Length - 5); } else if (virt.EndsWith("tex")) { virt = virt.Substring(0, virt.Length - 4); } } PendingTPFs.Add(new Tuple <string, BinderFileHeader>(virt, f)); } else { if (ResourceMask.HasFlag(ResourceType.Flver) && (filevirtpath.ToUpper().EndsWith(".FLVER") || filevirtpath.ToUpper().EndsWith(".FLV") || filevirtpath.ToUpper().EndsWith(".FLV.DCX"))) { //handle = new ResourceHandle<FlverResource>(); handle = ResourceManager.GetResource <FlverResource>(filevirtpath); } else if (ResourceMask.HasFlag(ResourceType.CollisionHKX) && (filevirtpath.ToUpper().EndsWith(".HKX") || filevirtpath.ToUpper().EndsWith(".HKX.DCX"))) { handle = ResourceManager.GetResource <HavokCollisionResource>(filevirtpath); } else if (ResourceMask.HasFlag(ResourceType.Navmesh) && filevirtpath.ToUpper().EndsWith(".NVM")) { handle = ResourceManager.GetResource <NVMNavmeshResource>(filevirtpath); } else if (ResourceMask.HasFlag(ResourceType.NavmeshHKX) && (filevirtpath.ToUpper().EndsWith(".HKX") || filevirtpath.ToUpper().EndsWith(".HKX.DCX"))) { handle = ResourceManager.GetResource <HavokNavmeshResource>(filevirtpath); } if (handle != null) { PendingResources.Add(new Tuple <IResourceHandle, string, BinderFileHeader>(handle, filevirtpath, f)); } } } }
public VideoCapture(NodeContext nodeContext) { renderDrawContextHandle = GetRenderDrawContextHandle(nodeContext) ?? throw new ServiceNotFoundException(typeof(IResourceProvider <Game>)); colorSpaceConverter = new ColorSpaceConverter(renderDrawContextHandle.Resource); }
/// <summary> /// 创建状态 /// </summary> public abstract void OnCreate(PlayableGraph gragh, IResourceHandle resourceHandle);