Exemplo n.º 1
0
        public async Task <IActionResult> PutEmission(long id, Emission Emission)
        {
            if (id != Emission.Id)
            {
                return(BadRequest());
            }

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

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!EmissionExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Exemplo n.º 2
0
    void updateEmissions()
    {
        int i = 0;

        while (i < emissions.Count)
        {
            Emission em = emissions [i];
            em.Update(pipes);
            if (em.shouldDestroy)
            {
                em.DestroyInternals();
                emissions.RemoveAt(i);
            }
            else
            {
                i++;
                Vector2 emissionGridLocation = em.getGridLocation();
                playerTowers.ForEach(aT => {
                    Vector2 aTLocation = Utilities.getGridLocation(aT.getLocation());
                    //					Debug.unityLogger.Log ("==AT:", aTLocation);
                    //					Debug.unityLogger.Log ("==ET:", emissionGridLocation);
                    if (emissionGridLocation.x == aTLocation.x && emissionGridLocation.y == aTLocation.y)
                    {
                        em.setWon();
                        addScoreForPlayer(aT);
                    }
                });
            }
        }
    }
        public void Save(SaveContext saveContext)
        {
            var utility = saveContext.Utility;

            CGFXDebug.SaveStart(this, saveContext);

            EmissionF.Save(utility);
            AmbientF.Save(utility);
            DiffuseF.Save(utility);
            Specular0F.Save(utility);
            Specular1F.Save(utility);
            Constant0F.Save(utility);
            Constant1F.Save(utility);
            Constant2F.Save(utility);
            Constant3F.Save(utility);
            Constant4F.Save(utility);
            Constant5F.Save(utility);

            Emission.Save(utility);
            Ambient.Save(utility);
            Diffuse.Save(utility);
            Specular0.Save(utility);
            Specular1.Save(utility);
            Constant0.Save(utility);
            Constant1.Save(utility);
            Constant2.Save(utility);
            Constant3.Save(utility);
            Constant4.Save(utility);
            Constant5.Save(utility);

            utility.Write(CommandCache);
        }
Exemplo n.º 4
0
 public EmissionDTO(Emission e)
 {
     Id      = e.Id;
     Start   = e.Start;
     Stop    = e.Stop;
     Channel = new ChannelDTO(e.ChannelEmitted);
 }
Exemplo n.º 5
0
        public async static Task <Consumable> LoadLCISet(string id)
        {
            var task = new Task <Consumable>(() =>
            {
                var m = new XmlSerializer(typeof(TEcoSpold));


                FileInfo file = new FileInfo(Path.Combine(DataDir, id + ".spold"));
                {
                    TEcoSpold ecoSpold = null;
                    try
                    {
                        using (var f = file.OpenRead())
                        {
                            ecoSpold = (TEcoSpold)m.Deserialize(f);
                            f.Close();
                            var activity      = ecoSpold.Items.FirstOrDefault();
                            var referenceFlow = activity.flowData.intermediateExchange.FirstOrDefault(t =>
                                                                                                      (t.Item is TIntermediateExchangeOutputGroup
                                    ? (TIntermediateExchangeOutputGroup)t.Item
                                    : TIntermediateExchangeOutputGroup.Item2)
                                                                                                      == TIntermediateExchangeOutputGroup.Item0);
                            if (referenceFlow == null)
                            {
                                return(null);
                            }
                            decimal convertvalue;
                            var consum = new Consumable()
                            {
                                Name       = referenceFlow.name.First().ToString(),
                                ecospoldId = activity.activityDescription.activity.id,
                                PerUnit    = GetUnit(referenceFlow.unitId, out convertvalue)
                            };

                            var lciset       = new LciSet();
                            lciset.Emissions = new List <Emission>();
                            foreach (var flow in activity.flowData.elementaryExchange)
                            {
                                var e = new Emission();

                                e.SIUnit       = GetUnit(flow.unitId, out convertvalue);
                                e.Value        = (decimal)flow.amount * convertvalue;
                                e.EmissionName = flow.name.ToString();

                                lciset.Emissions.Add(e);
                            }
                            consum.LciSet = lciset;
                            return(consum);
                        }
                    }
                    catch
                    {
                    }
                }
                return(null);
            });

            task.Start();
            return(await task);
        }
Exemplo n.º 6
0
        public ActionResult DeleteConfirmed(int id)
        {
            Emission emission = db.Emissions.Find(id);

            db.Emissions.Remove(emission);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Exemplo n.º 7
0
        public async Task <ActionResult <Emission> > PostEmission(Emission Emission)
        {
            _context.Emissions.Add(Emission);
            await _context.SaveChangesAsync();

            // return CreatedAtAction("GetEmission", new { id = Emission.Id }, Emission);
            return(CreatedAtAction(nameof(GetEmission), new { id = Emission.Id }, Emission));
        }
Exemplo n.º 8
0
 public bool Equals(IHiddenMarkovModel <TDistribution> other)
 {
     if (!(VectorExtentions.EqualsTo(Pi, other.Pi) && TransitionProbabilityMatrix.EqualsTo(other.TransitionProbabilityMatrix) && N == other.N && M == other.M && Likelihood == other.Likelihood))
     {
         return(false);
     }
     return(!Emission.Where((t, i) => !t.Equals(other.Emission[i])).Any());
 }
Exemplo n.º 9
0
            public override int GetHashCode()
            {
                int hashCode = Emission.GetHashCode();

                hashCode ^= Source.GetHashCode();
                hashCode ^= Func.GetHashCode();
                return(hashCode);
            }
Exemplo n.º 10
0
 public GenerationOutput(XmlOffshore _offShore, XmlOnshore onshore, XmlGas gas, XmlCoal coal, Emission emission, HeatRate heatRate)
 {
     this.OffShore = _offShore;
     this.Onshore  = onshore;
     this.Gas      = gas;
     this.Coal     = coal;
     this.Emission = emission;
     this.Heatrate = heatRate;
 }
Exemplo n.º 11
0
        public bool Apply(Emission em)
        {
            bool from_fits     = !From.HasValue || em.Start.TimeOfDay > From.Value;
            bool to_fits       = !To.HasValue || em.Stop.TimeOfDay < To.Value;
            bool date_fits     = !Date.HasValue || em.Start.Date == Date.Value.Date;
            bool channels_fits = !ChannelIds.Any() || ChannelIds.Contains(em.ChannelId);

            return(from_fits && to_fits && date_fits && channels_fits);
        }
Exemplo n.º 12
0
    public Emission Emit()
    {
        Emission returnedEmission = null;

        if (emissionDelay.trigger())
        {
            returnedEmission = new Emission(getLocation(), limit, getRandomDirection());
        }
        return(returnedEmission);
    }
Exemplo n.º 13
0
 public ActionResult Edit([Bind(Include = "report_id,facility_id,substance_id,jurisdiction_facility_id,facility_name,registered_business_name,primary_anzsic_class_code,primary_anzsic_class_name,substance_name,air_total_emission_kg,suburb,postcode,latitude,longitude")] Emission emission)
 {
     if (ModelState.IsValid)
     {
         db.Entry(emission).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(emission));
 }
Exemplo n.º 14
0
 void updateEmitters()
 {
     foreach (FluidEmitter emitter in emitters)
     {
         // Check if pipes are around the emitter. If so, add emission in that direction.
         Emission em = emitter.Emit();
         if (em != null)
         {
             emissions.Add(em);
         }
         emitter.Update();
     }
 }
Exemplo n.º 15
0
        // GET: Emissions/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Emission emission = db.Emissions.Find(id);

            if (emission == null)
            {
                return(HttpNotFound());
            }
            return(View(emission));
        }
Exemplo n.º 16
0
        public override void Save(asStream stream)
        {
            stream.PutString(Name, 32);

            Emission.CopyTo(stream);

            Ambient.CopyTo(stream);
            Diffuse.CopyTo(stream);

            Specular.CopyTo(stream);

            stream.Put(Shininess);
            stream.Put(Reserved);
        }
Exemplo n.º 17
0
    public void SendResource(Vector3 initPos, Vector3 toPos, Player player, ResourcesManager toMan, ResourcesEnum resourcesEnum)  //仅发送一个资源
    {
        GameObject obj    = Instantiate(resourceObj[resourcesEnum], initPos, Quaternion.identity);
        Emission   entity = obj.GetComponent <Emission>();

        entity.SetToWhere(toPos);
        entity.SetPlayer(player);
        entity.SetSpeed(0.1f);//
        entity.OnArrive += (object sender, System.EventArgs e) => {
            ResourceRequire _require = new ResourceRequire();
            _require.resource  = resourcesEnum;
            _require.updateVal = 1;
            toMan.UpdateResources(_require);
        };
    }
Exemplo n.º 18
0
    public void EmitBullet(Vector3 initPos, Land toLand, Player player)
    {
        Emission entity = Instantiate(bulletPrefab, initPos, Quaternion.identity);

        entity.SetToWhere(toLand.transform.position);
        entity.SetPlayer(player);
        entity.SetSpeed(0.1f);//
        entity.OnArrive += (object sender, System.EventArgs e) => {
            if (toLand == null || toLand.GetPlayer().Equals(player))
            {
                return;
            }
            toLand.Damage(10, player);
        };
    }
Exemplo n.º 19
0
 public virtual void Release()
 {
     if (Albedo != null)
     {
         Albedo.Release();
         Albedo = null;
     }
     if (Height != null)
     {
         Height.Release();
         Height = null;
     }
     if (Normal != null)
     {
         Normal.Release();
         Normal = null;
     }
     if (Metallic != null)
     {
         Metallic.Release();
         Metallic = null;
     }
     if (Roughness != null)
     {
         Roughness.Release();
         Roughness = null;
     }
     if (Occlusion != null)
     {
         Occlusion.Release();
         Occlusion = null;
     }
     if (Thickness != null)
     {
         Thickness.Release();
         Thickness = null;
     }
     if (Emission != null)
     {
         Emission.Release();
         Emission = null;
     }
 }
Exemplo n.º 20
0
    public static JsonData getEmissionData(Emission emission)
    {
        if (emission == null)
        {
            return(null);
        }

        var ret = new JsonData();

        ret["scale"]    = emission.scale;
        ret["nSamples"] = emission.sampleNum;
        ret["twoSided"] = emission.twoSided;
        var Le = new JsonData();

        Le["colorType"] = 1;
        Le["color"]     = fromColor(emission.color);
        ret["Le"]       = Le;

        return(ret);
    }
Exemplo n.º 21
0
        internal static IHitTarget GenerateEarthLampBvhScene()
        {
            var returnList = new List <IHitTarget>();

            var perlinTexture = new NoiseTexture(new Color(0.8, 0.8, 0.8), 4.0, NoiseTypes.MARBLE, 0.5, 10.0, 15);

            returnList.Add(new Sphere(new Vec3(0, -1000, 0), 1000, new Lambertian(perlinTexture)));

            var loader = new ImageReader();

            using (var stream = File.Open("earthMap.jpg", FileMode.Open))
            {
                var image = loader.Read(stream, StbImage.STBI_rgb);

                var material = new Emission(new ImageTexture(image.Data, image.Width, image.Height), 10);

                returnList.Add(new Sphere(new Vec3(0, 1, 0), 1.0, material));
            }

            return(new BvhNode(returnList, 0.0, 1.0));
        }
Exemplo n.º 22
0
        public void Read()
        {
            System.Globalization.CultureInfo ci = new System.Globalization.CultureInfo("en-US");
            System.Threading.Thread.CurrentThread.CurrentCulture = ci;

            string file_xml_generation = ConfigurationManager.AppSettings["GenerationReport"];
            string file_xml_reference  = ConfigurationManager.AppSettings["ReferenceData"];
            string file_xml_write      = ConfigurationManager.AppSettings["outputXml"];


            ParseXmlReferenceData xmlRef = new ParseXmlReferenceData(file_xml_reference);

            ParseXmlGenerationReport xmlGeneration = new ParseXmlGenerationReport();
            var xReport = xmlGeneration.Read(file_xml_generation);

            XmlOffshore         offShore     = new XmlOffshore(xReport);
            List <WindOffShore> offshoreList = offShore.Read();

            XmlOnshore         onshore     = new XmlOnshore(xReport);
            List <WindOnshore> onshoreList = onshore.Read();

            XmlGas gas = new XmlGas(xReport);
            Dictionary <int, List <Gas> > gasList = gas.Read();
            //gas.GasTotalGeneration();

            XmlCoal coal = new XmlCoal(xReport);
            Dictionary <int, List <Coal> > coalList = coal.Read();
            //coal.CoalTotalGeneration();

            Emission emission = new Emission(gasList, coalList);
            //emission.HighestEmissionByDate();

            HeatRate ht = new HeatRate(coalList);
            //ht.ActualHeatRates();

            GenerationOutput outputXml = new GenerationOutput(offShore, onshore, gas, coal, emission, ht);

            outputXml.XmlWrite(file_xml_write);
        }
Exemplo n.º 23
0
    public static JsonData getEmissionData(MeshFilter prim)
    {
        Emission emission = prim.gameObject.GetComponent <Emission>();

        if (emission == null)
        {
            return(null);
        }

        var ret = new JsonData();

        ret["scale"]    = emission.scale;
        ret["nSamples"] = emission.sampleNum;
        ret["twoSided"] = emission.twoSided;
        var Le = new JsonData();

        Le["colorType"] = 1;
        Le["color"]     = fromColor(emission.color);
        ret["Le"]       = Le;

        return(ret);
    }
Exemplo n.º 24
0
        public async Task <ObjectResult> PostNotification(string name, [FromBody] RatingJson body)
        {
            Emission remindMeOf = DbContext.Emissions.FirstOrDefault(em => em.Id == body.Id);

            if (remindMeOf != null)
            {
                Notification new_reminder = new Notification()
                {
                    Id          = updateService.GetNewId(DbContext.Notifications),
                    EmissionId  = body.Id,
                    RelEmission = remindMeOf,
                    UserLogin   = name
                };
                DbContext.Notifications.Add(new_reminder);
                DbContext.SaveChanges();
                return(StatusCode(200, new RatingJson()
                {
                    Id = new_reminder.EmissionId, RatingValue = 1
                }));
            }

            return(StatusCode(404, "Program nie istnieje"));
        }
Exemplo n.º 25
0
        public void ParseAll(XDocument doc)
        {
            if (!db.FeatureTypes.Any())
            {
                FillFeatureTypes();
            }

            IEnumerable <XElement> channels_in_xml = doc.Root.Elements("channel");

            InitGuideUpdate(channels_in_xml.First().Element("url").Value);
            ParseChannels(channels_in_xml);

            //programy
            LogService.Log($"parsing programmes");
            IEnumerable <XElement> programmes_in_xml = doc.Root.Elements("programme").ToList();

            LogService.Log($"{programmes_in_xml.Count()} found");
            if (programmes_in_xml.Count() > 0)
            {
                LogService.Log($"first at {programmes_in_xml.First().Attribute("start")}");
            }
            List <Programme> new_programmes = new List <Programme>();
            long             new_id         = GetNewId(db.Programmes);
            List <Emission>  new_emissions  = new List <Emission>();
            long             em_id          = GetNewId(db.Emissions);

            List <Description> new_descriptions = new List <Description>();
            long           desc_id      = GetNewId(db.Descriptions);
            List <Feature> new_features = new List <Feature>();
            long           feat_id      = GetNewId(db.Features);

            List <ProgrammesFeature> new_feature_examples = new List <ProgrammesFeature>();

            foreach (XElement programme in programmes_in_xml)
            {
                string new_title = programme.Elements("title").First().Value;
                if (new_title.Length > 180)
                {
                    new_title = new_title.Substring(0, 180);
                    int last_space = new_title.LastIndexOf(' ');
                    new_title  = new_title.Substring(0, last_space);
                    new_title += "...";
                }
                Programme new_prog = null;
                if (db.Programmes.Any())
                {
                    new_prog = db.Programmes.SingleOrDefault(prog => prog.Title.ToLower() == new_title.ToLower());
                }
                if (new_prog == null)
                {
                    new_prog = new_programmes.SingleOrDefault(prog => prog.Title.ToLower() == new_title.ToLower());
                }

                if (new_prog == null)
                {
                    new_prog = new Programme()
                    {
                        Id      = new_id,
                        Title   = new_title,
                        IconUrl = programme.Element("icon")?.Attribute("src").Value
                    };
                    new_programmes.Add(new_prog);
                    new_id++;
                }

                Emission new_em = null;
                if (programme.Attribute("start") == null || programme.Attribute("stop") == null)
                {
                    throw new DataException($"Missing emission hours ({new_prog.Title})");
                }

                DateTime em_start   = ParseDateTime(programme.Attribute("start").Value);
                DateTime em_stop    = ParseDateTime(programme.Attribute("stop").Value);
                Channel  em_channel = db.Channels.Where(ch => ch.Name == programme.Attribute("channel").Value).Single();

                if (db.Emissions.Any())
                {
                    new_em = db.Emissions.FirstOrDefault(e => e.Start == em_start && e.Stop == em_stop && e.ChannelId == em_channel.Id);
                }
                if (new_em == null)
                {
                    new_em = new_prog.Emissions.FirstOrDefault(e => e.Start == em_start && e.Stop == em_stop && e.ChannelId == em_channel.Id);
                }

                if (new_em == null)
                {
                    new_em = new Emission()
                    {
                        ChannelEmitted = em_channel,
                        ChannelId      = em_channel.Id,
                        Start          = em_start,
                        Stop           = em_stop,
                        RelProgramme   = new_prog,
                        ProgrammeId    = new_prog.Id
                    };

                    if (!new_prog.Emissions.Contains(new_em))
                    {
                        new_prog.Emissions.Add(new_em);
                        em_id++;
                    }
                }

                Description new_desc = db.Descriptions.Any() ? db.Descriptions.FirstOrDefault(desc => desc.ProgrammeId == new_prog.Id) : null;

                if (new_desc == null)
                {
                    new_desc = new Description()
                    {
                        Id           = desc_id,
                        ProgrammeId  = new_prog.Id,
                        RelProgramme = new_prog,
                        Content      = programme.Element("desc")?.Value ?? ""
                    };
                    if (new_prog.Descriptions.Where(description => description.Content == new_desc.Content).Count() == 0)
                    {
                        new_prog.Descriptions.Add(new_desc);
                        desc_id++;
                    }
                }

                string[]        feat_names = { "date", "category", "country" };
                List <XElement> features   = programme.Elements().Where(elem => feat_names.Contains(elem.Name.LocalName)).ToList();
                if (programme.Element("credits") != null)
                {
                    features.AddRange(programme.Element("credits").Elements());
                }
                if (features.Where(el => el.Name.LocalName == "date").Count() == 0)
                {
                    features.Add(new XElement("date", $"{DateTime.Now.Year}"));
                }

                foreach (XElement feat in features)
                {
                    string type = feat.Name.LocalName;

                    long type_id = db.FeatureTypes
                                   .FirstOrDefault(ft => ft.TypeName == type)
                                   .Id;

                    string  value    = feat.Value;
                    Feature new_feat = null;
                    if (db.Features != null && db.Features.Count() > 0)
                    {
                        new_feat = db.Features.SingleOrDefault(f => f.Type == type_id && f.Value.ToLower() == value.ToLower());
                    }
                    if (new_feat == null)
                    {
                        new_feat = new_features.SingleOrDefault(f => f.Type == type_id && f.Value.ToLower() == value.ToLower());
                    }
                    if (new_feat == null)
                    {
                        new_feat = new Feature()
                        {
                            Id      = feat_id,
                            RelType = db.FeatureTypes.Single(ft => ft.TypeName == type),
                            Type    = type_id,
                            Value   = value
                        };
                        new_features.Add(new_feat);
                        feat_id++;
                    }

                    ProgrammesFeature pf_value_found = null;

                    if (db.ProgrammesFeatures != null && db.ProgrammesFeatures.Any())
                    {
                        pf_value_found = db.ProgrammesFeatures.SingleOrDefault(fe => fe.FeatureId == new_feat.Id && fe.ProgrammeId == new_prog.Id);
                    }
                    if (new_prog.ProgrammesFeatures != null && new_prog.ProgrammesFeatures.Any())
                    {
                        pf_value_found = new_prog.ProgrammesFeatures.SingleOrDefault(fe => fe.FeatureId == new_feat.Id && fe.ProgrammeId == new_prog.Id);
                    }
                    if (pf_value_found == null)
                    {
                        new_prog.ProgrammesFeatures.Add(new ProgrammesFeature()
                        {
                            FeatureId   = new_feat.Id,
                            ProgrammeId = new_prog.Id,
                        });
                    }
                }
            }
            db.Features.AddRange(new_features);
            db.Programmes.AddRange(new_programmes);
            LogService.Log($"saving programmes");
            db.SaveChanges();
            LogService.Log($"programmes done");

            Cleanup();
            FinishGuideUpdate();
        }
Exemplo n.º 26
0
 public Emission Update()
 {
     FluctuateSignature();
     Emission signals = new Emission(location, emissionSignature);
     return signals;
 }
Exemplo n.º 27
0
 public override string Serialize() => Invariant($"{Refraction}}}{Albedo.Serialize()}}}{Emission.Serialize()}}}");
Exemplo n.º 28
0
 public override string Serialize() => Emission.Serialize();
Exemplo n.º 29
0
        public override void ImportFromUsd()
        {
            Material mat = Material;

            if (DiffuseMap)
            {
                mat.SetTexture("_MainTex", DiffuseMap);
            }
            else
            {
                mat.color = Diffuse.GetValueOrDefault(mat.color);
            }

            if (NormalMap)
            {
                mat.SetTexture("_BumpMap", NormalMap);
                mat.EnableKeyword("_NORMALMAP");
            }
            else
            {
                // TODO: Unity has no notion of a constant normal map.
            }

            if (DisplacementMap)
            {
                mat.SetTexture("_ParallaxMap", DisplacementMap);
                mat.EnableKeyword("_PARALLAXMAP");
            }
            else
            {
                // TODO: Unity has no notion of a parallax map.
            }

            if (OcclusionMap)
            {
                mat.SetTexture("_OcclusionMap", OcclusionMap);
            }
            else
            {
                // TODO: Unity has no notion of a constant occlusion value.
            }

            if (EmissionMap)
            {
                mat.SetTexture("_EmissionMap", EmissionMap);
                mat.EnableKeyword("_EMISSION");
            }
            else
            {
                var rgb = Emission.GetValueOrDefault(Color.black);
                mat.SetColor("_EmissionColor", rgb);
                if (rgb.r > 0 || rgb.g > 0 || rgb.b > 0)
                {
                    mat.EnableKeyword("_EMISSION");
                }
            }

            if (!IsMetallicWorkflow)
            {
                if (SpecularMap)
                {
                    mat.SetTexture("_SpecGlossMap", SpecularMap);
                    mat.EnableKeyword("_SPECGLOSSMAP");
                }
                else
                {
                    var rgb = Specular.GetValueOrDefault(Color.gray);
                    mat.SetColor("_SpecColor", rgb);
                }

                if (RoughnessMap)
                {
                    // Roughness for spec setup is tricky, since it may require merging two textures.
                    // For now, just detect that case and issue a warning (e.g. when roughness has a map,
                    // but isn't the albedo or spec map).
                    // Roughness also needs to be converted to glossiness.
                    if (RoughnessMap != SpecularMap && SpecularMap != null)
                    {
                        var specGlossTex = MaterialImporter.CombineRoughnessToGloss(SpecularMap, RoughnessMap);
                        mat.SetTexture("_SpecGlossMap", specGlossTex);
                        mat.EnableKeyword("_SPECGLOSSMAP");
                    }
                    else if (SpecularMap == null && RoughnessMap != DiffuseMap)
                    {
                        var mainGlossTex = MaterialImporter.CombineRoughnessToGloss(DiffuseMap, RoughnessMap);
                        mat.SetTexture("_SpecGlossMap", mainGlossTex);
                        mat.EnableKeyword("_SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A");
                    }
                    else
                    {
                        // TODO: create a new texture with constant spec value, combined with roughness texture.
                    }
                }
                else
                {
                    float smoothness = 1 - Roughness.GetValueOrDefault(.5f);
                    mat.SetFloat("_Glossiness", smoothness);
                    mat.SetFloat("_GlossMapScale", smoothness);
                }
            }
            else
            {
                if (MetallicMap)
                {
                    mat.SetTexture("_MetallicGlossMap", MetallicMap);
                    mat.EnableKeyword("_METALLICGLOSSMAP");
                }
                else
                {
                    mat.SetFloat("_Metallic", Metallic.GetValueOrDefault(0));
                }

                if (RoughnessMap)
                {
                    // In this case roughness get its own map, but still must be converted to glossiness.
                    mat.SetTexture("_SpecGlossMap", RoughnessMap);
                }
                else
                {
                    float smoothness = 1 - Roughness.GetValueOrDefault(.5f);
                    mat.SetFloat("_Glossiness", smoothness);
                    mat.SetFloat("_GlossMapScale", smoothness);
                }
            }
        }
Exemplo n.º 30
0
        public override void ImportFromUsd()
        {
            Material mat = Material;

            if (DiffuseMap)
            {
                Debug.Log("here");
                mat.SetTexture("_BaseColorMap", DiffuseMap);
                mat.SetColor("_BaseColor", Color.white);
            }
            else
            {
                mat.SetColor("_BaseColor", Diffuse.GetValueOrDefault(mat.color));
            }

            // TODO: What about opacity map?

            if (!IsSpecularWorkflow)
            {
                // Robustness: It would be ideal if this parameter were provided by HDRP, however that
                // would require this asset package having a dependency on the HDRP package itself,
                // which is (yet) not desirable.
                mat.SetFloat("_MaterialID", /*Standard Metallic*/ 1);
            }
            else
            {
                mat.SetFloat("_MaterialID", /*Spec Color*/ 4);
                mat.EnableKeyword("_MATERIAL_FEATURE_SPECULAR_COLOR");
                mat.EnableKeyword("_SPECULARCOLORMAP");
            }

            // R=Metallic, G=Occlusion, B=Displacement, A=Roughness(Smoothness)
            var MaskMap = BuildMaskMap(!IsSpecularWorkflow ? MetallicMap : null, OcclusionMap, DisplacementMap, RoughnessMap);

            if (MaskMap)
            {
                mat.SetTexture("_MaskMap", MaskMap);
                mat.EnableKeyword("_MASKMAP");
            }

            if (!IsSpecularWorkflow)
            {
                if (!MetallicMap)
                {
                    mat.SetFloat("_Metallic", Metallic.GetValueOrDefault());
                }
            }
            else
            {
                if (SpecularMap)
                {
                    mat.SetTexture("_SpecularColorMap", SpecularMap);
                }
                else
                {
                    mat.SetColor("_SpecularColor", Specular.GetValueOrDefault());
                }
            }

            if (!RoughnessMap)
            {
                var smoothness = 1 - Roughness.GetValueOrDefault();
                mat.SetFloat("_Smoothness", smoothness);
                // HDRP Lit does not seem to respect smoothness, so just clamp to the correct value.
                mat.SetFloat("_SmoothnessRemapMin", smoothness);
                mat.SetFloat("_SmoothnessRemapMax", smoothness);
            }

            if (!OcclusionMap)
            {
                mat.SetFloat("_AORemapMin", Occlusion.GetValueOrDefault());
                mat.SetFloat("_AORemapMax", Occlusion.GetValueOrDefault());
            }

            // Single displacement scalar value not supported.

            if (ClearcoatMap)
            {
                mat.SetTexture("_CoatMaskMap", ClearcoatMap);
                mat.EnableKeyword("_MATERIAL_FEATURE_CLEAR_COAT");
            }
            mat.SetFloat("_CoatMask", ClearcoatRoughness.GetValueOrDefault());

            if (NormalMap)
            {
                mat.SetTexture("_NormalMap", NormalMap);
                mat.EnableKeyword("_NORMALMAP");
            }

            if (EmissionMap)
            {
                mat.SetTexture("_EmissionMap", EmissionMap);
                mat.EnableKeyword("_EMISSIVE_COLOR_MAP");
            }
            else
            {
                mat.SetColor("_EmissionColor", Emission.GetValueOrDefault());
            }
        }
Exemplo n.º 31
0
        protected override void LayeredTexture(Texture2D texture)
        {
            int index, index2;

            index  = Array.FindIndex(Character.Options, o => o.Name == "Face");
            index2 = Array.FindIndex(Character.Options, o => o.Name == "Skin Color");
            if (Character.Class == 6)
            {
                Texture2D face = Character.TextureFromBLP(Character.Choices[index][Character.Customization[index]].Textures[Character.Customization[index2]].Texture2);
                DrawTexture(texture, face, 512, 0);
            }
            else
            {
                Texture2D face = Character.TextureFromBLP(Character.Choices[index][Character.Customization[index]].Textures[Character.Customization[index2]].Texture1);
                DrawTexture(texture, face, 512, 0);
            }
            index  = Array.FindIndex(Character.Options, o => o.Name == "Tattoo");
            index2 = Array.FindIndex(Character.Options, o => o.Name == "Tattoo Color");
            if (Character.Choices[index][Character.Customization[index]].Textures[0].Texture1 == -1 && Character.Choices[index2][Character.Customization[index2]].Textures[Character.Customization[index]].Texture1 >= 0)
            {
                Texture2D tattoo = Character.TextureFromBLP(Character.Choices[index2][Character.Customization[index2]].Textures[Character.Customization[index]].Texture1);
                DrawTexture(texture, tattoo, 0, 0);
                Texture2D temp = Resources.Load <Texture2D>("Materials/Emission");
                Emission = new Texture2D(temp.width, temp.height, TextureFormat.ARGB32, false);
                Emission.SetPixels32(temp.GetPixels32());
                tattoo = Character.TextureFromBLP(Character.Choices[index2][Character.Customization[index2]].Textures[Character.Customization[index]].Texture2);
                DrawTexture(Emission, tattoo, 0, 0);
            }
            else if (Character.Choices[index][Character.Customization[index]].Textures[0].Texture1 >= 0)
            {
                Texture2D tattoo = Character.TextureFromBLP(Character.Choices[index][Character.Customization[index]].Textures[0].Texture1);
                MultiplyTexture(texture, tattoo, 0, 0);
                Emission = null;
            }
            else
            {
                Emission = null;
            }
            index = Array.FindIndex(Character.Options, o => o.Name == "Scars");
            if (Character.Choices[index][Character.Customization[index]].Textures[0].Texture1 >= 0)
            {
                Texture2D scars = Character.TextureFromBLP(Character.Choices[index][Character.Customization[index]].Textures[0].Texture1);
                OverlayTexture(texture, scars, 512, 0);
            }
            index = Array.FindIndex(Character.Options, o => o.Name == "Skin Color");
            Texture2D underwear = null;

            if (!(Character.Items[3] != null && Character.Items[3].UpperLeg ! > 0) && Character.Items[10] == null)
            {
                underwear = Character.TextureFromBLP(Character.Choices[index][Character.Customization[index]].Textures[0].Texture3);
                DrawTexture(texture, underwear, 256, 192);
            }
            if (Emission != null)
            {
                if (underwear != null)
                {
                    Texture2D temp = new Texture2D(underwear.width, underwear.height, TextureFormat.ARGB32, false);
                    BlackTexture(underwear, temp);
                    temp.Apply();
                    DrawTexture(Emission, temp, 256, 192);
                }
                Character.BlackChest(Emission);
                Character.BlackShirt(Emission);
                Character.BlackTabard(Emission);
                Character.BlackWrist(Emission);
                Character.BlackHands(Emission);
                Character.BlackWaist(Emission);
                Character.BlackLegs(Emission);
                Character.BlackFeet(Emission);
                Emission.Apply();
            }
            index = Array.FindIndex(Character.Options, o => o.Name == "Eye Color");
            if (Character.Choices[index][Character.Customization[index]].Textures[0].Texture2 >= 0)
            {
                Texture2D eyeglow = Character.TextureFromBLP(Character.Choices[index][Character.Customization[index]].Textures[0].Texture2);
                DrawTexture(texture, eyeglow, 512, 0, 0.5f);
            }
            index  = Array.FindIndex(Character.Options, o => o.Name == "Hair Style");
            index2 = Array.FindIndex(Character.Options, o => o.Name == "Hair Color");
            if (Character.Choices[index][Character.Customization[index]].Textures[Character.Customization[index2]].Texture1 >= 0)
            {
                Texture2D scalp = Character.TextureFromBLP(Character.Choices[index][Character.Customization[index]].Textures[Character.Customization[index2]].Texture1);
                DrawTexture(texture, scalp, 512, 0);
            }
            Character.TextureShirt(texture);
            if (!(Character.Items[4] != null && Character.Items[4].Geoset1 != 0))
            {
                Character.TextureWrist(texture);
            }
            Character.TextureLegs(texture);
            Character.TextureFeet(texture);
            Character.TextureChest(texture);
            if (!(Character.Items[3] != null && Character.Items[3].Geoset1 != 0))
            {
                Character.TextureWrist(texture);
            }
            Character.TextureHands(texture);
            if (!(Character.Items[8] != null && Character.Items[8].Geoset1 != 0))
            {
                Character.TextureChest(texture);
            }
            Character.TextureTabard(texture);
            Character.TextureWaist(texture);
        }