private PreviewModel CreatePreviewModel(VertexPositionNormalTexture[] vertices, int[] indices, ShaderTextureBinding textureBinding = null) { AssetDatabase lfd = new LooseFileDatabase(Path.Combine(AppContext.BaseDirectory, "Assets")); VertexBuffer vb = _rc.ResourceFactory.CreateVertexBuffer(vertices.Length * VertexPositionNormalTexture.SizeInBytes, false); vb.SetVertexData( vertices, new VertexDescriptor(VertexPositionNormalTexture.SizeInBytes, VertexPositionNormalTexture.ElementCount, 0, IntPtr.Zero)); IndexBuffer ib = _rc.ResourceFactory.CreateIndexBuffer(indices.Length * sizeof(int), false); ib.SetIndices(indices, sizeof(int), 0); MaterialAsset shadowmapAsset = lfd.LoadAsset <MaterialAsset>("MaterialAsset/ShadowCaster_ShadowMap.json"); MaterialAsset surfaceMaterial = lfd.LoadAsset <MaterialAsset>("MaterialAsset/ModelPreview.json"); Material shadowmapMaterial = shadowmapAsset.Create(lfd, _rc, _sceneProviders); Material regularMaterial = surfaceMaterial.Create(lfd, _rc, _sceneProviders); return(new PreviewModel( vb, ib, indices.Length, regularMaterial, shadowmapMaterial, new DynamicDataProvider <Matrix4x4>(Matrix4x4.Identity), textureBinding)); }
private PreviewModel CreatePreviewModel(VertexPositionNormalTexture[] vertices, ushort[] indices) { AssetDatabase lfd = new LooseFileDatabase(Path.Combine(AppContext.BaseDirectory, "Assets")); VertexBuffer vb = _rc.ResourceFactory.CreateVertexBuffer(vertices.Length * VertexPositionNormalTexture.SizeInBytes, false); vb.SetVertexData( vertices, new VertexDescriptor( VertexPositionNormalTexture.SizeInBytes, VertexPositionNormalTexture.ElementCount, IntPtr.Zero)); IndexBuffer ib = _rc.ResourceFactory.CreateIndexBuffer(indices.Length * sizeof(ushort), false); ib.SetIndices(indices); Material shadowmapMaterial = ShadowCaster.CreateShadowPassMaterial(_rc.ResourceFactory); Material regularMaterial = ShadowCaster.CreateRegularPassMaterial(_rc.ResourceFactory); var deviceTexture = lfd.LoadAsset <ImageSharpMipmapChain>("Textures/CubeTexture.png").CreateDeviceTexture(_rc.ResourceFactory); var textureBinding = _rc.ResourceFactory.CreateShaderTextureBinding(deviceTexture); return(new PreviewModel( vb, ib, indices.Length, regularMaterial, shadowmapMaterial, _rc.ResourceFactory.CreateConstantBuffer(ShaderConstantType.Matrix4x4), new DynamicDataProvider <Matrix4x4>(Matrix4x4.Identity), _rc.ResourceFactory.CreateConstantBuffer(ShaderConstantType.Matrix4x4), SceneBuffers, textureBinding)); }
private void DrawRecursiveNode(DirectoryNode node, bool pushTreeNode) { if (!pushTreeNode || ImGui.TreeNode(node.FolderName)) { foreach (DirectoryNode child in node.Children) { DrawRecursiveNode(child, pushTreeNode: true); } foreach (AssetInfo asset in node.AssetInfos) { if (ImGui.Selectable(asset.Name) && _loadedAssetPath != asset.Path) { _selectedAsset = _assetDb.LoadAsset(asset.Path); _loadedAssetPath = asset.Path; _filenameBuffer.StringValue = asset.Name; } if (ImGui.IsLastItemHovered()) { ImGui.SetTooltip(asset.Path); } if (ImGui.BeginPopupContextItem(asset.Name + "_context")) { if (ImGui.Button("Clone")) { _assetDb.CloneAsset(asset.Path); } if (ImGui.Button("Delete")) { _assetDb.DeleteAsset(asset.Path); } ImGui.EndPopup(); } } if (pushTreeNode) { ImGui.TreePop(); } } }