Exemplo n.º 1
0
        public JsonResult AgregarColor(int IdColor, decimal Costo)
        {
            var resultado = "No se pudo agregar el color";

            if (TempData["ListaColores"] != null)
            {
                Listacolores = (List <ColorMaterial>)TempData["ListaColores"];
            }
            try
            {
                ColorMaterial colormaterial = new ColorMaterial();
                colormaterial.IdColorMat     = IdColor;
                colormaterial.Costo          = Costo;
                colormaterial.NombreMaterial = db.ColorMat.Find(IdColor).Nombre.Trim();
                if (Listacolores.Count() == 0)
                {
                    Listacolores.Add(colormaterial);
                }
                else
                {
                    foreach (ColorMaterial color in Listacolores)
                    {
                        if (color.IdColorMat == IdColor)
                        {
                            TempData["ListaColores"] = Listacolores;
                            resultado = "No se puede duplicar el color!";
                            return(Json(resultado,
                                        JsonRequestBehavior.AllowGet));
                        }
                    }
                    Listacolores.Add(colormaterial);
                }
            }
            catch {
                return(Json(resultado,
                            JsonRequestBehavior.AllowGet));
            }
            TempData["ListaColores"] = Listacolores;
            return(Json(Listacolores.ToList(),
                        JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 2
0
    private async Task <Remote.Material> InitializeColorMaterial(RemoteMaterial material)
    {
        var remoteMaterial = RemoteManagerUnity.CurrentSession?.Actions.CreateMaterial(MaterialType.Color);

        remoteMaterial.Name = material.name;

        ColorMaterial colorMaterial = remoteMaterial as ColorMaterial;

        colorMaterial.AlbedoColor           = material.AlbedoColor.toRemoteColor4();
        colorMaterial.AlphaClipThreshold    = material.AlphaClipThreshold;
        colorMaterial.ColorFlags            = material.ColorFlags.toRemote();
        colorMaterial.ColorTransparencyMode = material.ColorTransparencyMode;
        colorMaterial.FadeOut        = material.FadeOut;
        colorMaterial.TexCoordOffset = material.TexCoordOffset.toRemote();
        colorMaterial.TexCoordScale  = material.TexCoordScale.toRemote();
        colorMaterial.VertexMix      = material.VertexMix;

        if (!String.IsNullOrEmpty(material.AlbedoTextureUrl))
        {
            colorMaterial.AlbedoTexture = await LoadTextureFromCache(material.AlbedoTextureUrl);
        }

        return(remoteMaterial);
    }
Exemplo n.º 3
0
        private void InitScene()
        {
            Scene = new Scene();

            var stallTexture     = new Texture("Resources/Textures/house.png");
            var stallTextureSnow = new Texture("Resources/Textures/checker.jpg");

            Shader = new Shader("Shaders/shader.vert", "Shaders/newShader.frag");
            var stallMaterial = new MaterialModel(Shader, new[] { stallTexture })
            {
                Ambient   = new Vector3(0.3f, 0.5f, 0.31f),
                Diffuse   = new Vector3(0.3f, 0.5f, 0.31f),
                Specular  = new Vector3(0.5f, 0.5f, 0.5f),
                Shininess = 32f
            };
            var stallMaterialSnow = new MaterialModel(Shader, new[] { stallTextureSnow })
            {
                Ambient   = new Vector3(0.3f, 0.5f, 0.31f),
                Diffuse   = new Vector3(0.3f, 0.5f, 0.31f),
                Specular  = new Vector3(0.5f, 0.5f, 0.5f),
                Shininess = 32f,
            };

            LampShader = new Shader("Shaders/shader.vert", "Shaders/lamp.frag");
            var cubeMat  = new ColorMaterial(LampShader, new Vector3(0f, 0f, 1f));
            var cubeMat2 = new ColorMaterial(LampShader, new Vector3(1f, 1f, 0f));

            var pointLight2      = new Light(LampShader, LightType.PointLight, new Vector3(1f, 1f, 0f) * 1.0f, new Vector3(1, 1, 1), 0.032f, 0.09f, 1);
            var pointLight       = new Light(LampShader, LightType.PointLight, new Vector3(0f, 0f, 1f) * 1.0f, new Vector3(1, 1, 1), 0.032f, 0.09f, 1);
            var directionalLight = new Light(LampShader, LightType.DirectionalLight, new Vector3(0.15f, 0.15f, 0.15f), new Vector3(1, 1, 1), 0.032f, 0.09f, 1);

            Camera = new Camera(Width / (float)Height, true, 3.5f, 3);

            Mesh meshCube   = MeshCreator.CreateMesh("Resources/cubeN.obj");
            Mesh meshGround = MeshCreator.CreateMesh("Resources/ground.obj");
            Mesh meshHouse  = MeshCreator.CreateMesh("Resources/houseTest.obj");
            Mesh meshStall  = MeshCreator.CreateMesh("Resources/stallTest.obj");

            GameObject cameraGameObject = new GameObject(new Transform(new Vector3(0, 2, 6), new Vector3(0, -90, 0), Vector3.One));

            cameraGameObject.AddComponent(Camera);
            cameraGameObject.AddComponent(new CameraMovement());

            GameObject pointLightGameObject = new GameObject(new Transform(new Vector3(2, 4f, 2), Vector3.Zero, new Vector3(0.5f, 0.5f, 0.5f)));

            pointLightGameObject.AddComponent(new MeshRenderer(meshCube, cubeMat));
            pointLightGameObject.AddComponent(new HouseMovement());
            pointLightGameObject.AddComponent(pointLight);

            GameObject pointLight2GameObject = new GameObject(new Transform(new Vector3(2, 4f, -2), Vector3.Zero, new Vector3(0.5f, 0.5f, 0.5f)));

            pointLight2GameObject.AddComponent(new MeshRenderer(meshCube, cubeMat2));
            //pointLight2GameObject.AddComponent(new HouseMovement());
            pointLight2GameObject.AddComponent(pointLight2);

            GameObject directionalLightGameObject = new GameObject(new Transform(Vector3.Zero, new Vector3(-5, 180, 0), Vector3.One));

            //directionalLightGameObject.AddComponent(new MeshRenderer(meshCube, cubeMat));
            directionalLightGameObject.AddComponent(directionalLight);

            GameObject groundGameObject = new GameObject();

            groundGameObject.AddComponent(new MeshRenderer(meshGround, stallMaterial));

            GameObject houseGameObject = new GameObject(new Transform(new Vector3(6, 0, 0), Vector3.Zero, Vector3.One));

            houseGameObject.AddComponent(new MeshRenderer(meshHouse, stallMaterial));

            GameObject house2GameObject = new GameObject(new Transform(new Vector3(15, 0, 0), new Vector3(0, 90, 0), Vector3.One));

            house2GameObject.AddComponent(new MeshRenderer(meshHouse, stallMaterialSnow));
            house2GameObject.AddComponent(new ChangeTextureScript());

            GameObject stallGameObject = new GameObject();

            stallGameObject.AddComponent(new MeshRenderer(meshStall, stallMaterial));

            GameObject stall2GameObject = new GameObject(new Transform(new Vector3(-4, 0, 0), new Vector3(0, 45, 0), Vector3.One));

            stall2GameObject.AddComponent(new MeshRenderer(meshStall, stallMaterial));



            Scene.AddGameObject(pointLightGameObject);
            Scene.AddGameObject(pointLight2GameObject);
            Scene.AddGameObject(groundGameObject);
            Scene.AddGameObject(houseGameObject);
            Scene.AddGameObject(house2GameObject);
            Scene.AddGameObject(stallGameObject);
            Scene.AddGameObject(stall2GameObject);
            Scene.AddGameObject(cameraGameObject);
            //Scene.AddGameObject(directionalLightGameObject);

            Scene.StartComponents();
        }
Exemplo n.º 4
0
        public ActionResult Editar(int?id)
        {
            if (!LoginController.validaUsuario(Session))
            {
                return(RedirectToAction("Index", "Home"));
            }
            if (!LoginController.validaRol(Session))
            {
                return(RedirectToAction("Index", "Home"));
            }

            ViewBag.CatMaterial = new SelectList((from s in db.CategoriaMat
                                                  where s.Estado == 1
                                                  select new
            {
                s.IdCategoria,
                s.Nombre
            }
                                                  ), "IdCategoria", "Nombre");
            ViewBag.Proveedor = new SelectList((from s in db.Proveedor
                                                where s.Estado == 1
                                                select new
            {
                s.IdProveedor,
                s.Nombre
            }
                                                ), "IdProveedor", "Nombre");
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Material material = db.Material.Find(id);

            if (material == null)
            {
                return(HttpNotFound());
            }
            if (material.IdCatMat != 1)
            {
                foreach (var item in (List <ColorMaterial>)material.ColorMaterial.ToList())
                {
                    ColorMaterial color = new ColorMaterial();
                    color.IdMaterial     = item.IdMaterial;
                    color.IdColorMat     = item.IdColorMat;
                    color.Costo          = item.Costo;
                    color.NombreMaterial = item.ColorMat.Nombre.Trim();
                    Listacolores.Add(color);
                }
                TempData["ListaColores"] = Listacolores;
            }
            ViewBag.ColorMaterial = new SelectList((from s in db.ColorMat
                                                    where s.IdCatMaterial == material.IdCatMat && s.Estado == 1
                                                    select new
            {
                IdColor = s.IdColor,
                Nombre = s.Nombre
            }), "IdColor", "Nombre");
            ViewBag.SubCatMaterial = new SelectList((from s in db.SubCategoria
                                                     where s.IdCatMat == material.IdCatMat && s.Estado == 1
                                                     select new
            {
                IdSubCatMat = s.IdSubCatMat,
                Nombre = s.Nombre
            }), "IdSubCatMat", "Nombre");
            ViewBag.TipoMateriales = new SelectList((from s in db.TipoMaterial
                                                     where s.IdCatMat == material.IdCatMat && s.Estado == 1
                                                     select new {
                s.IdTipoMaterial,
                s.Nombre
            }
                                                     ), "IdTipoMaterial", "Nombre");
            return(PartialView(material));
        }