public Surface(int w, int h, string pathToFile, System.Windows.Forms.ToolStripProgressBar bar = null, System.Windows.Forms.ToolStripLabel label = null, Form1 form = null, bool shaderOption = false) { this.shaderOption = shaderOption; this.form = form; toolStripBar = bar; toolStripLabel = label; WhatToDraw = 1; Status = colrscl = rotate = false; minX = minY = min = float.MaxValue; maxX = maxY = max = float.MinValue; scale = 1.0f; angleX = angleY = 0.0f; width = w; height = h; NumOfIndexes = NumOfVertices = Xwidth = Ywidth = 0; //svetlo - smer,ambient,specular,diffuse light = new DirectionalLight(new Vector3(0.0f, 0.0f, -1.0f), new Vector3(1.0f, 1.0f, 1.0f), new Vector3(1.0f, 1.0f, 1.0f), new Vector3(1.0f, 1.0f, 1.0f)); //material - ambient,specular,diffuse,koeficienty - ambient, specular, diffuse, shininess material = new Material(0.29f, 0.86f, 0.57f, 128); //BigBrother = new Kamera(new Vector3(0.0f, 0.0f, 3.5f), new Vector3(0.0f, 0.0f, 0.0f), new Vector3(0.0f, 1.0f, 0.0f)); coords = new List<Vector3>(); VBO = new int[4]; VAO = new int[1]; VertexShader = new Shaders.Shader(); FragmentShader = new Shaders.Shader(); spMain = new Shaders.ShaderProgram(); var bw = new System.ComponentModel.BackgroundWorker(); bw.DoWork += (sender, args) => { // do your lengthy stuff here -- this will happen in a separate thread LoadData(pathToFile); if (Status = SetWidth()) { vertices = new Vector3[NumOfVertices]; color = new Vector3[NumOfVertices]; normals = new Vector3[NumOfVertices]; Indices = new List<int>(); Indexes = new int[NumOfIndexes]; //SetIndices(); SetIndexes(); if (Ywidth > Xwidth) { rotate = true; MatrixStore_Rotations = Matrix4.CreateFromAxisAngle(new Vector3(0.0f, 0.0f, 1.0f), -90.0f * (float)Math.PI / 180.0f); } } else { //dorobit sem este resetovanie progressBaru/labelu System.Windows.Forms.MessageBox.Show("Súbor " + pathToFile + " nemá podporu!", "Vnimanie!", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Warning); label lab = new label(SetToolStripLabel); progres progres = new progres(SetProgressBar); form.statusStrip1.Invoke(lab, "Súbor nemá podporu..."); form.statusStrip1.Invoke(progres, 0); } }; bw.RunWorkerCompleted += (sender, args) => { if (args.Error != null) // if an exception occurred during DoWork, System.Windows.Forms.MessageBox.Show(args.Error.ToString()); // do your error handling here if (Status) { colorScale = new ColorScale(min, max, width, height); CalculateColor(); ScaleHeights(10.0f); CalculateNormals(); InitScene(false); FirstDraw(); form.SetBoolean_surface(true); } else form.SetMenuStrip_Enabled(true); }; bw.RunWorkerAsync(); // starts the background worker }
public void ChangeMaterialProperties(float amb, float spec, float diff, int shin) { material = new Material(amb, spec, diff, shin); material.SetMaterialUniforms(spMain); }