public void RemoveInputCanvas(int id) { InputElements element = this.inputs.Single(x => x.Id == id); GameObject.Destroy(element.Object); this.inputs = this.inputs.Where(x => x.Id != id).ToList(); }
private void AddBuffer(Buffer buf, string inputName, Format format, int stride = 0) { if (stride == 0) { stride = format.SizeOfInBytes(); } var elementCount = buf.Description.SizeInBytes / stride; if (buffers.Count == 0) { VertexCount = elementCount; } else { if (elementCount != VertexCount) { throw CargoEngineException.Create("elementCount of Buffer doesn't match Vertexcount"); } } InputElements.AddElement(inputName, format, buffers.Count); var bufferBinding = new VertexBufferBinding(buf, stride, 0); buffers.Add(bufferBinding); }
public InputElements CreateInputCanvas(object value, int id, WorldSpaceUI worldSpaceUI, bool isVariable, string name = "constant") { GameObject obj = GameObject.Instantiate(this.constantAndVariablePanelPrefab); Canvas can = obj.GetComponent <Canvas>(); can.worldCamera = this.camera; GameObject buttonGo = obj.transform.Find("Button").gameObject; Button button = buttonGo.GetComponent <Button>(); GameObject textGO = buttonGo.transform.Find("Text").gameObject; TMP_Text text = textGO.GetComponent <TMP_Text>(); if (isVariable) { text.text = name; } else { text.text = value.ToString(); } DirectInputNode nodeBe = buttonGo.AddComponent <DirectInputNode>(); RectTransform rt = obj.GetComponent <RectTransform>(); InputElements result = new InputElements(obj, text, nodeBe, rt, button, id); obj.transform.SetParent(this.localParent); ///element scaling! rt.localScale *= this.constantsScale; nodeBe.Setup(value, id, worldSpaceUI, result, isVariable, name); this.inputs.Add(result); return(result); }
public bool Equals(EffectSignatureLayout other) { if (ReferenceEquals(null, other)) { return(false); } if (ReferenceEquals(this, other)) { return(true); } // Check the number of elements if (InputElements.Length != other.InputElements.Length) { return(false); } // Check the signature pointer if (ShaderSignature != other.ShaderSignature) { return(false); } return(!InputElements.Where((t, i) => t != other.InputElements[i]).Any()); }
public async Task InputsDisplay(Vector3 pos, ParameterNode node) { int columnCount = 2; float buttonX = 1.5f; float buttonY = 1f; /// Scaling buttonX *= this.constantsScale; buttonY *= this.constantsScale; ///... int rows = (int)Mathf.Ceil((float)this.inputs.Count / columnCount); float wholeY = rows * buttonY; float wholeX = buttonX * columnCount; for (int y = 0; y < rows; y++) { for (int x = 0; x < columnCount; x++) { int index = y * columnCount + x; if (index >= this.inputs.Count) { break; } InputElements c = this.inputs[index]; c.Object.SetActive(false); float yy = y * buttonY - wholeY / 2 + buttonY / 2; float xx = x * buttonX - wholeX / 2 + buttonX / 2; c.RectTransform.localPosition = new Vector3(xx, yy, 0); c.Node.FixColorBeforeShow(node); } } this.localParent.LookAt(this.localParent.transform.position + this.camera.transform.forward); Vector3 offset = (this.camera.transform.position - pos).normalized; this.localParent.position = pos + offset; this.inputsShowing = true; /// Enabaling the constant canvases after some time so one does not get automatically clicked await Task.Delay(100); foreach (var item in this.inputs) { item.Object.SetActive(true); } //Debug.Log("Display"); }
public void InputsHide() { for (int i = 0; i < this.inputs.Count; i++) { InputElements c = this.inputs[i]; c.Object.SetActive(false); } this.inputsShowing = false; //Debug.Log("Hide"); }
public void AddElement(string inputName, Format format, int slot) { int index = 0; InputElements.ForEach(element => { if (element.SemanticName.Equals(inputName)) { index++; } }); var el = new InputElement(inputName, index, format, slot); InputElements.Add(el); HashCode ^= el.GetHashCode(); }
public void Clear() { buffers.ForEach(buf => { if (buf.Buffer != null) { buf.Buffer.Dispose(); } }); buffers.Clear(); if (indexBuffer != null) { indexBuffer.Dispose(); } VertexCount = 0; NumIndices = 0; InputElements.Clear(); }
public bool Initialize(Device dev, InputElements inputType, Direct3D11.Buffer vertBuffer, string pathVertex, string pathPixel) { device = dev; VertexBuffer = vertBuffer; switch (inputType) { case InputElements.VertexPosCol: InputElem = new[] { new InputElement("POSITION", 0, Format.R32G32B32_Float, 0, 0), new InputElement("COLOR", 0, Format.R32G32B32A32_Float, 16, 0) }; InputTypeSize = Utilities.SizeOf <VertexPositionColor>(); break; case InputElements.VertexPosColTex: InputElem = new[] { new InputElement("POSITION", 0, Format.R32G32B32_Float, 0, 0), new InputElement("COLOR", 0, Format.R32G32B32A32_Float, 16, 0), new InputElement("TEXCOORD", 0, Format.R32G32_Float, 32, 0) }; InputTypeSize = Utilities.SizeOf <VertexPositionColorTexture>(); break; case InputElements.VertexPosNormTex: InputElem = new[] { new InputElement("POSITION", 0, Format.R32G32B32_Float, 0, 0), new InputElement("NORMAL", 0, Format.R32G32B32A32_Float, 16, 0), new InputElement("TEXCOORD", 0, Format.R32G32_Float, 32, 0) }; InputTypeSize = Utilities.SizeOf <VertexPositionNormalTexture>(); break; case InputElements.VertexPosNormWorldPos: InputElem = new[] { new InputElement("POSITION", 0, Format.R32G32B32_Float, 0, 0), new InputElement("NORMAL", 0, Format.R32G32B32A32_Float, 16, 0), new InputElement("TEXCOORD", 0, Format.R32G32_Float, 32, 0), new InputElement("SV_POSITION", 0, Format.R32G32_Float, 48, 0) }; InputTypeSize = Utilities.SizeOf <VertexPositionNormalWorldPosTexture>(); break; case InputElements.TrgPosNormTex: InputElem = new[] { new InputElement("POSITION", 0, Format.R32G32B32_Float, 0, 0), new InputElement("NORMAL", 0, Format.R32G32B32A32_Float, 16, 0), new InputElement("TEXCOORD", 0, Format.R32G32_Float, 32, 0) }; InputTypeSize = Utilities.SizeOf <TriangleInput>(); break; case InputElements.TrgAdjPosNormTex: InputElem = new[] { new InputElement("POSITION", 0, Format.R32G32B32_Float, 0, 0), new InputElement("NORMAL", 0, Format.R32G32B32A32_Float, 16, 0), new InputElement("TEXCOORD", 0, Format.R32G32_Float, 32, 0) }; InputTypeSize = Utilities.SizeOf <TrianglePositionNormalTextureAdjInput>(); break; case InputElements.TrgStripPosNormTex: InputElem = new[] { new InputElement("POSITION", 0, Format.R32G32B32_Float, 0, 0), new InputElement("NORMAL", 0, Format.R32G32B32A32_Float, 16, 0), new InputElement("TEXCOORD", 0, Format.R32G32_Float, 32, 0) }; InputTypeSize = Utilities.SizeOf <TrianglePositionNormalTextureStripInput>(); break; case InputElements.ShadowMapInput: InputElem = new[] { new InputElement("POSITION", 0, Format.R32G32B32_Float, 0, 0), }; InputTypeSize = Utilities.SizeOf <Vector4>(); break; } InitializeShaders(pathVertex, pathPixel); return(true); }
public void Clear() { InputElements.Clear(); HashCode = 0; }
public ActionResult Sort([FromBody] InputElements values) { if (values == null) { return(BadRequest()); } if (!ModelState.IsValid) { return(BadRequest(ModelState)); } OutSorted data = new OutSorted(); int[] result = values.Items; if (!string.IsNullOrEmpty(values.Algorithm)) { switch (values.Algorithm.ToLower()) { case "mergesort": MergeSort <int> mSort = new MergeSort <int>(); mSort.MergesortTime(result, 0, result.Length - 1); data.Complexity = "n log(n)"; data.Time = mSort.MSlog; data.Items = result; return(Ok(JsonConvert.SerializeObject(data))); case "quicksort": QuickSort <int> qSort = new QuickSort <int>(); qSort.QuickSortTime(result, 0, result.Length - 1); data.Complexity = "Ω(n log(n)) O(n²)"; data.Time = qSort.QSLog; data.Items = result; return(Ok(JsonConvert.SerializeObject(data))); case "heapsort": HeapSort <int, int> hSort = new HeapSort <int, int>(); int index = 0; var collection = hSort.Heapsort(BuildNodeArray <int>(result)); foreach (Node <int, int> node in collection) { result[index] = node.Key; index++; } data.Complexity = "Ω(n log(n)) O(n log(n))"; data.Time = hSort.HSlog; data.Items = result; return(Ok(JsonConvert.SerializeObject(data))); case "all": List <OutSorted> resultlist = new List <OutSorted>(); int[] mergedata = result; MergeSort <int> mergeSort = new MergeSort <int>(); mergeSort.MergesortTime(mergedata, 0, mergedata.Length - 1); resultlist.Add(new OutSorted() { Complexity = "n log(n)", Time = mergeSort.MSlog, Items = mergedata, Algorithm = "mergesort" }); int[] quickdata = result; QuickSort <int> quickSort = new QuickSort <int>(); quickSort.QuickSortTime(quickdata, 0, quickdata.Length - 1); resultlist.Add(new OutSorted() { Complexity = "Ω(n log(n)) O(n²)", Time = quickSort.QSLog, Items = quickdata, Algorithm = "quicksort" }); HeapSort <int, int> heapSort = new HeapSort <int, int>(); int idx = 0; int[] heapdata = result; var nodes = heapSort.Heapsort(BuildNodeArray <int>(heapdata)); foreach (Node <int, int> node in nodes) { heapdata[idx] = node.Key; idx++; } resultlist.Add(new OutSorted() { Complexity = "Ω(n log(n)) O(n log(n))", Time = heapSort.HSlog, Items = heapdata, Algorithm = "heapsort" }); return(Ok(JsonConvert.SerializeObject(resultlist))); default: return(NotFound(values.Algorithm.ToLower())); } } return(Ok()); }
public void InitializeResources(string texturePath, Materials.AbstractMaterial material, string pathVertShader, string pathPixShader, InputElements input, string vertFilePath = "") { InitializeVertices(vertFilePath); // Update(); VertexBuffer = Direct3D11.Buffer.Create(Device, BindFlags.VertexBuffer, Vertices); MainShaderManager.Initialize(Device, input, VertexBuffer, pathVertShader, pathPixShader); ShadowShaderManager.Initialize(Device, VertexBuffer, true); Material = material; Texture = TextureLoader.CreateTexture2DFromBitmap(Device, TextureLoader.LoadBitmap(new ImagingFactory2(), texturePath)); TextureView = new ShaderResourceView(Device, Texture); ShadowTransformBuffer = new Direct3D11.Buffer(Device, Utilities.SizeOf <Matrix>(), ResourceUsage.Default, BindFlags.ConstantBuffer, CpuAccessFlags.None, ResourceOptionFlags.None, 0); ShadowWorldBuffer = new Direct3D11.Buffer(Device, Utilities.SizeOf <MatrixBufferStruct>(), ResourceUsage.Default, BindFlags.ConstantBuffer, CpuAccessFlags.None, ResourceOptionFlags.None, 0); }
public void InitializeResources(string[] cubetexturePath, string pathVertShader, string pathPixShader, InputElements input, string vertFilePath = "") { InitializeVertices(vertFilePath); // Update(); VertexBuffer = Direct3D11.Buffer.Create(Device, BindFlags.VertexBuffer, Vertices); MainShaderManager.Initialize(Device, input, VertexBuffer, pathVertShader, pathPixShader); ShadowShaderManager.Initialize(Device, VertexBuffer, true); Material = new Materials.Silver(); List <Texture2D> temttext = new List <Texture2D>(); foreach (string texturePath in cubetexturePath) { temttext.Add(TextureLoader.CreateTexture2DFromBitmap(Device, TextureLoader.LoadBitmap(new ImagingFactory2(), texturePath))); } Texture2D texture2D = new Texture2D(Device, new Texture2DDescription { ArraySize = 6, MipLevels = 1, Height = temttext[0].Description.Height, Width = temttext[0].Description.Width, CpuAccessFlags = CpuAccessFlags.None, Format = DXGI.Format.R8G8B8A8_UNorm, BindFlags = BindFlags.ShaderResource, OptionFlags = ResourceOptionFlags.TextureCube, SampleDescription = new DXGI.SampleDescription(1, 0), Usage = ResourceUsage.Default //!! }); TexturesCube = temttext.ToArray(); isTextureCube = true; for (int i = 0; i < 6; i++) { Device.ImmediateContext.CopySubresourceRegion(TexturesCube[i], 0, null, texture2D, i); TexturesCube[i].Dispose(); } TextureView = new ShaderResourceView(Device, texture2D); ShadowTransformBuffer = new Direct3D11.Buffer(Device, Utilities.SizeOf <Matrix>(), ResourceUsage.Default, BindFlags.ConstantBuffer, CpuAccessFlags.None, ResourceOptionFlags.None, 0); ShadowWorldBuffer = new Direct3D11.Buffer(Device, Utilities.SizeOf <MatrixBufferStruct>(), ResourceUsage.Default, BindFlags.ConstantBuffer, CpuAccessFlags.None, ResourceOptionFlags.None, 0); }