Esempio n. 1
0
        public ActionResult Create([Bind(Include = "Id,Bezeichnung,Beschreibung,Preis,Größe")] Modell modell)
        {
            if (ModelState.IsValid)
            {
                db.Modells.Add(modell);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(modell));
        }
        public void CreateDemodaten()
        {
            var m1 = new Modell()
            {
                Name = "Model Eins"
            };
            var m2 = new Modell()
            {
                Name = "Model Zwei"
            };

            var d1 = new Drucker()
            {
                Hersteller = "Anet", Model = "A8", MaxX = 220, MaxY = 220, MaxZ = 240, Speed = 60, Schnittstelle = "USB"
            };
            var d2 = new Drucker()
            {
                Hersteller = "CTC", Model = "DIY i3", MaxX = 220, MaxY = 220, MaxZ = 240, Speed = 60, Schnittstelle = "USB"
            };
            var d3 = new Drucker()
            {
                Hersteller = "Prusa", Model = "MK3", MaxX = 250, MaxY = 210, MaxZ = 210, Speed = 200, Schnittstelle = "USB"
            };
            var d4 = new Drucker()
            {
                Hersteller = "LulzBot", Model = "TAZ 6", MaxX = 280, MaxY = 280, MaxZ = 250, Speed = 300, Schnittstelle = "USB"
            };

            var a1 = new Auftrag()
            {
                Start = DateTime.Now.AddDays(-5), Status = Auftragstatus.Fertig, Modell = m1, Drucker = d1
            };
            var a2 = new Auftrag()
            {
                Start = DateTime.Now.AddDays(-4), Status = Auftragstatus.Abgebrochen, Modell = m1, Drucker = d2
            };
            var a3 = new Auftrag()
            {
                Start = DateTime.Now.AddDays(-3), Status = Auftragstatus.Fertig, Modell = m2, Drucker = d3
            };
            var a4 = new Auftrag()
            {
                Start = DateTime.Now.AddDays(-1), Status = Auftragstatus.Aktiv, Modell = m2, Drucker = d4
            };


            Repository.Add(a1);
            Repository.Add(a2);
            Repository.Add(a3);
            Repository.Add(a4);
            Repository.Save();
        }
Esempio n. 3
0
        // GET: Modells/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Modell modell = db.Modells.Find(id);

            if (modell == null)
            {
                return(HttpNotFound());
            }
            return(View(modell));
        }
Esempio n. 4
0
        public async Task <IActionResult> PutAuto(int id, Auto auto)
        {
            if (id != auto.ModellId)
            {
                return(BadRequest());
            }

            var gyartoId = await _context.Gyartok.Where(gy => gy.GyartoNev.ToUpper() == auto.GyartoNev.ToUpper()).Select(gy => gy.Id).FirstOrDefaultAsync();

            if (gyartoId == 0)
            {
                var newGyarto = new Gyarto
                {
                    GyartoNev = auto.GyartoNev
                };
                _context.Gyartok.Add(newGyarto);
                await _context.SaveChangesAsync();

                gyartoId = newGyarto.Id;
            }

            var reszletek = new Reszletek
            {
                Id           = auto.ReszletekId,
                Ajtok        = auto.Ajtok,
                Teljesitmeny = auto.Teljesitmeny,
                Ulesek       = auto.Ulesek,
                Evjarat      = auto.Evjarat
            };

            _context.Entry(reszletek).State = EntityState.Modified;

            var modell = new Modell
            {
                Id          = auto.ModellId,
                ModellNev   = auto.ModellNev,
                GyartoId    = gyartoId,
                ReszletekId = reszletek.Id
            };

            _context.Entry(modell).State = EntityState.Modified;


            await _context.SaveChangesAsync();


            return(NoContent());
        }
Esempio n. 5
0
        void loaded(object o, EventArgs e)
        {
            input.lastPos = new Vector2(Mouse.GetCursorState().X, Mouse.GetCursorState().Y);
            //texture = LoadResources.ReadTexture(Directory.GetCurrentDirectory() + @"\Mods\Default\Textures\earth.jpg");
            //Change clear color
            GL.ClearColor(Color.Black);
            //Render polygons in a correct order
            GL.Enable(EnableCap.DepthTest);
            GL.Enable(EnableCap.TextureCoordArray);
            //Setup buffers

            //Vertex buffer

            VEB = GL.GenBuffer();
            GL.BindBuffer(BufferTarget.ArrayBuffer, VEB);
            GL.BufferData <Vector3>(BufferTarget.ArrayBuffer, (IntPtr)(Vector3.SizeInBytes * vertexBuffer.Length),
                                    vertexBuffer, BufferUsageHint.DynamicDraw);
            GL.BindBuffer(BufferTarget.ArrayBuffer, 0);

            //Uv buffer

            UVB = GL.GenBuffer();
            GL.BindBuffer(BufferTarget.ArrayBuffer, UVB);
            GL.BufferData <Vector2>(BufferTarget.ArrayBuffer, (IntPtr)(Vector2.SizeInBytes * uvBuffer.Length),
                                    uvBuffer, BufferUsageHint.DynamicDraw);
            GL.BindBuffer(BufferTarget.ArrayBuffer, 0);

            //Normal buffer

            NOB = GL.GenBuffer();
            GL.BindBuffer(BufferTarget.ArrayBuffer, UVB);
            GL.BufferData <Vector3>(BufferTarget.ArrayBuffer, (IntPtr)(Vector3.SizeInBytes * normalBuffer.Length),
                                    normalBuffer, BufferUsageHint.DynamicDraw);
            GL.BindBuffer(BufferTarget.ArrayBuffer, 0);

            level = LevelGenerator.GenerateTerrain3D(20, 20, 20, .05f, 0, .5f);
            //Console.WriteLine(renderer.level.Length);
            Modell combined = CombineModells.Combine(CombineModells.GameObjectToModellArray(Init.ChunksToGameObjects(Init.NearChunck(level.ToArray(), player_pos, 9999)).ToArray()));

            //Console.WriteLine(combined.vertices.Length);
            //Console.WriteLine(combined.uv.Length);
            //Console.WriteLine(combined.normal.Length);

            UpdateBuffers(combined.vertices, combined.uv, combined.normal, combined.textures, combined.colors);
        }
Esempio n. 6
0
        public static GameObject[] GenerateTerrainOld(int width = 100, int height = 100, float scale = 1, int seed = 0, float divide = 100)
        {
            List <GameObject> gameObjects = new List <GameObject>();

            for (int x = 0; x < width; x++)
            {
                for (int z = 0; z < height; z++)
                {
                    string     type         = "none";
                    float      y            = 0;
                    Modell     cube         = LoadResources.ReadModell(Directory.GetCurrentDirectory() + @"\Mods\Default\Modells\cube.obj");
                    GameObject currentBlock = new GameObject(x + "." + z + "." + type, new Vector3(x, y, z), Vector3.Zero, new Vector3(1, 1, 1), cube);
                    //Console.WriteLine(new Vector3(x, y, z));
                    gameObjects.Add(currentBlock);
                }
            }
            return(gameObjects.ToArray());
        }
        // Läuft auf dem Hintergrund-Thread
        private void FuehreArbeitAus(object sender, DoWorkEventArgs e)
        {
            Modell modell = new Modell(
                ((KennlinienmodellArgs)e.Argument).Startgeschwindigkeit,
                ((KennlinienmodellArgs)e.Argument).Endgeschwindigkeit,
                ((KennlinienmodellArgs)e.Argument).AnzahlPunkte,
                ((KennlinienmodellArgs)e.Argument).Genauigkeit,
                ((KennlinienmodellArgs)e.Argument).AlleKraefte
                );

            Thread.Sleep(5000);

            Console.WriteLine("vmin = " + ((KennlinienmodellArgs)e.Argument).Startgeschwindigkeit);
            Console.WriteLine("vmax = " + ((KennlinienmodellArgs)e.Argument).Endgeschwindigkeit);
            Console.WriteLine("anzahlSchritte = " + ((KennlinienmodellArgs)e.Argument).AnzahlPunkte);
            Console.WriteLine("genauigkeit = " + ((KennlinienmodellArgs)e.Argument).Genauigkeit);
            Console.WriteLine("alleKraefte = " + ((KennlinienmodellArgs)e.Argument).AlleKraefte);
        }
Esempio n. 8
0
        static void Main(string[] args)
        {
            Modell     mesh   = LoadResources.ReadModell(Directory.GetCurrentDirectory() + @"\Mods\Default\Modells\cube.obj");//LoadObj.LoadModellFromObj(Directory.GetCurrentDirectory()+@"\Mods\Default\Modells\cube.obj");
            GameWindow window = new GameWindow(640, 480);

            List <GameObject>[] localLevel = LevelGenerator.GenerateTerrain3D(20, 20, 20, .05f, 0, .5f);
            OpenGlRenderer      renderer   = new OpenGlRenderer(window);

            renderer.ImmediateRendering = false;
            renderer.Quad = false;
            GameObject obj = new GameObject("test", new Vector3(1, 3, 2), Vector3.Zero, Vector3.One, mesh);

            renderer.level = localLevel;
            //Console.WriteLine(renderer.level.Length);
            Modell combined = CombineModells.Combine(CombineModells.GameObjectToModellArray(ChunksToGameObjects(NearChunck(renderer.level.ToArray(), renderer.player_pos, 9999)).ToArray()));

            //Console.WriteLine(combined.vertices.Length);
            //Console.WriteLine(combined.uv.Length);
            //Console.WriteLine(combined.normal.Length);
            renderer.UpdateBuffers(combined.vertices, combined.uv, combined.normal, combined.textures, combined.colors);
            window.Run(1 / DisplayDevice.Default.RefreshRate);
        }
Esempio n. 9
0
        public async Task <ActionResult <Auto> > PostAuto(Auto auto)
        {
            var gyartoId = await _context.Gyartok.Where(gy => gy.GyartoNev.ToUpper() == auto.GyartoNev.ToUpper()).Select(gy => gy.Id).FirstOrDefaultAsync();

            if (gyartoId == 0)
            {
                var newGyarto = new Gyarto
                {
                    GyartoNev = auto.GyartoNev
                };
                _context.Gyartok.Add(newGyarto);
                await _context.SaveChangesAsync();

                gyartoId = newGyarto.Id;
            }

            var reszletek = new Reszletek
            {
                Ajtok        = auto.Ajtok,
                Teljesitmeny = auto.Teljesitmeny,
                Ulesek       = auto.Ulesek,
                Evjarat      = auto.Evjarat
            };

            _context.Reszletek.Add(reszletek);
            await _context.SaveChangesAsync();

            var modell = new Modell
            {
                ModellNev   = auto.ModellNev,
                GyartoId    = gyartoId,
                ReszletekId = reszletek.Id
            };

            _context.Modellek.Add(modell);
            await _context.SaveChangesAsync();

            return(Ok());
        }
Esempio n. 10
0
        public static List <GameObject>[] GenerateTerrain3D(int width = 100, int height = 100, int depth = 100, float scale = 1, int seed = 0, float treshold = 100)
        {
            List <List <GameObject> > gameObjects = new List <List <GameObject> >();

            for (int c_x = 0; c_x < width; c_x += 16)
            {
                for (int c_z = 0; c_z < depth; c_z += 16)
                {
                    for (int c_y = 0; c_y < height; c_y += 16)
                    {
                        List <GameObject> chunk = new List <GameObject>();
                        for (int x = c_x; x < c_x + 16; x++)
                        {
                            for (int y = c_y; y < c_y + 16; y++)
                            {
                                for (int z = c_z; z < c_z + 16; z++)
                                {
                                    float noise = Perlin3D(x * scale, y * scale, z * scale);
                                    //Console.WriteLine(noise);
                                    if (noise >= treshold)
                                    {
                                        Modell cube = LoadResources.ReadModell(Directory.GetCurrentDirectory() + @"\Mods\Default\Modells\cube.obj");
                                        //Console.WriteLine(noise);
                                        string     type         = "none";
                                        GameObject currentBlock = new GameObject(x + "." + y + "." + z + "." + type, new Vector3(x, y, z), Vector3.Zero, new Vector3(.5f, .5f, .5f), cube);
                                        //Console.WriteLine(new Vector3(x, y, z));
                                        chunk.Add(currentBlock);
                                    }
                                }
                            }
                        }
                        gameObjects.Add(chunk);
                    }
                }
            }
            return(gameObjects.ToArray());
        }
Esempio n. 11
0
        public static Modell ReadModell(string path)
        {
            if (!File.Exists(path))
            {
                throw new Exception("File was not exist");
            }
            string[]       lines         = File.ReadAllLines(path);
            List <Vector3> localVertices = new List <Vector3>();
            List <Vector2> uv            = new List <Vector2>();
            List <int>     uvIndex       = new List <int>();
            List <int>     faces         = new List <int>();
            List <Vector3> normal        = new List <Vector3>();
            List <int>     normalIndexes = new List <int>();

            foreach (string line in lines)
            {
                if (line.Length > 0)
                {
                    if (line[0] == 'v' && line[1] != 'n' && line[1] != 't')
                    {
                        int  end      = 0;
                        bool finished = false;
                        foreach (char chr in line)
                        {
                            if (chr == 'v' && !finished)
                            {
                                end++;
                            }
                            else if (chr == ' ' && !finished)
                            {
                                end++;
                            }
                            else
                            {
                                finished = true;
                            }
                        }
                        string[] data = line.Substring(end, line.Length - end).Split(' ');
                        localVertices.Add(new Vector3(float.Parse(data[0].Replace('.', ',')), float.Parse(data[1].Replace('.', ',')), float.Parse(data[2].Replace('.', ','))));
                    }
                    else if (line[0] == 'f')
                    {
                        string[] data = line.Substring(2, line.Length - 2).Split(' ');
                        foreach (string vert in data)
                        {
                            string[] v_index = vert.Split('/');
                            faces.Add(int.Parse(v_index[0]));
                            uvIndex.Add(int.Parse(v_index[1]));
                            normalIndexes.Add(int.Parse(v_index[2]));
                        }
                    }
                    else if (line[0] == 'v' && line[1] == 't')
                    {
                        int  end      = 0;
                        bool finished = false;
                        foreach (char chr in line)
                        {
                            if (chr == 'v' && !finished)
                            {
                                end++;
                            }
                            else if (chr == 't' && !finished)
                            {
                                end++;
                            }
                            else if (chr == ' ' && !finished)
                            {
                                end++;
                            }
                            else
                            {
                                finished = true;
                            }
                        }
                        string[] data = line.Substring(end, line.Length - end).Split(' ');
                        uv.Add(new Vector2(float.Parse(data[0].Replace('.', ',')), float.Parse(data[1].Replace('.', ','))));
                    }
                    else if (line[0] == 'v' && line[1] == 'n')
                    {
                        int  end      = 0;
                        bool finished = false;
                        foreach (char chr in line)
                        {
                            if (chr == 'v' && !finished)
                            {
                                end++;
                            }
                            else if (chr == ' ' && !finished)
                            {
                                end++;
                            }
                            else if (chr == 'n' && !finished)
                            {
                                end++;
                            }
                            else
                            {
                                finished = true;
                            }
                        }
                        string[] data = line.Substring(end, line.Length - end).Split(' ');
                        normal.Add(new Vector3(float.Parse(data[0].Replace('.', ',')), float.Parse(data[1].Replace('.', ',')), float.Parse(data[2].Replace('.', ','))));
                    }
                }
            }
            List <Vector3>   finalVertices = new List <Vector3>();
            List <Vector3>   finalNormals  = new List <Vector3>();
            List <Vector2>   finalUV       = new List <Vector2>();
            List <Texture2D> textures      = new List <Texture2D>();
            List <Color>     colors        = new List <Color>();
            Random           rnd           = new Random();
            Texture2D        texture       = LoadResources.ReadTexture(Directory.GetCurrentDirectory() + @"\Mods\Default\Textures\rock.jpg");

            foreach (int vert_index in faces)
            {
                finalVertices.Add(localVertices[vert_index - 1]);
                textures.Add(texture);
                colors.Add(Color.FromArgb(255, rnd.Next(0, 255), rnd.Next(0, 255), rnd.Next(0, 255)));
            }

            foreach (int uv_index in uvIndex)
            {
                finalUV.Add(EngineMath.RotateVector(uv[uv_index - 1], 180));
            }

            foreach (int normal_index in normalIndexes)
            {
                finalNormals.Add(normal[normal_index - 1]);
            }
            Modell modell = new Modell()
            {
                vertices = finalVertices.ToArray(), uv = finalUV.ToArray(), normal = finalNormals.ToArray(), location = path
            };

            return(modell);
        }
Esempio n. 12
0
        public async Task <IActionResult> Cars(string sortOrder, string currentFilter, string Modell, int?page, int Marke, int Location)
        {
            ViewBag.CurrentSort  = sortOrder;
            ViewBag.NameSortParm = String.IsNullOrEmpty(sortOrder) ? "name_desc" : "";

            List <Marke>          markesListResponse = _dbContext.Marke.ToList();
            List <SelectListItem> markesList         = new List <SelectListItem>();

            foreach (Marke item in markesListResponse)
            {
                markesList.Add(new SelectListItem(item.MarkeName, item.MarkeId.ToString()));
            }
            ViewBag.marks = markesList;


            if (Modell != null)
            {
                page = 1;
            }
            else
            {
                Modell = currentFilter;
            }

            ViewBag.currentFilter = currentFilter;
            ViewBag.sortOrder     = sortOrder;
            ViewBag.Modell        = currentFilter;


            var cars = from s in _dbContext.Cars where s.IsActive == true && s.Marke != null
                       select s;


            if (!string.IsNullOrEmpty(Modell))
            {
                cars = cars.Where(s => s.Modell.ToLower().Contains(Modell.ToLower()));
            }

            if (Marke != null && Marke > 0)
            {
                cars = cars.Where(s => s.Marke.MarkeId == Marke);
            }

            if (Location != null && Location > 0)
            {
                cars = cars.Where(s => s.Location.LocationId == Location);
            }


            if (sortOrder != null)
            {
                // Sort by is given...
                switch (sortOrder)
                {
                case "priceUp":
                    cars = cars
                           .OrderByDescending(s => s.Promote).ThenBy(s => s.Price);
                    break;

                case "priceDown":
                    cars = cars
                           .OrderByDescending(s => s.Promote).ThenByDescending(s => s.Price);
                    break;

                case "nameUp":
                    cars = cars
                           .OrderByDescending(s => s.Promote).ThenBy(s => s.Marke);
                    break;

                default:
                    cars = cars
                           .OrderByDescending(s => s.Promote).ThenByDescending(s => s.Marke);
                    break;
                }
            }
            else if (sortOrder == null)
            {
                cars = cars.OrderByDescending(s => s.Promote).ThenByDescending(s => s.PostedDate);
            }


            List <Location>       locationsListResponse = _dbContext.Location.ToList();
            List <SelectListItem> locationsList         = new List <SelectListItem>();

            foreach (Location item in locationsListResponse)
            {
                locationsList.Add(new SelectListItem(item.LocationName, item.LocationId.ToString()));
            }
            ViewBag.locations = locationsList;

            int pageSize = 3;

            return(View(await PaginatedList <Cars> .CreateAsync(cars.AsNoTracking(), page ?? 1, pageSize)));
        }
Esempio n. 13
0
        public static void Main(string[] arg)
        {
            Modell m = new Modell(20, 90, 180);

            m.Show();
        }