Exemplo n.º 1
0
    static Mesh MergeSubsets(List <Subset> aSubsets, int aLightmapID)
    {
        Mesh               result       = new Mesh();
        Subset             resultSubset = new Subset();
        List <List <int> > indices      = new List <List <int> >();

        for (int i = 0; i < aSubsets.Count; ++i)
        {
            if (aSubsets[i].mLightmapID != aLightmapID)
            {
                continue;
            }

            int startID = resultSubset.Count;
            resultSubset.Add(aSubsets[i]);

            List <int> subIndices = new List <int>();
            for (int t = 0; t < aSubsets[i].mIndices.Count; t += 1)
            {
                subIndices.Add(startID + aSubsets[i].mIndices[t]);
            }
            indices.Add(subIndices);
        }
        // cap it off if we used that category of data at all!
        resultSubset.CheckArrays();

        result.vertices = resultSubset.mPoints.ToArray();
        result.normals  = resultSubset.mNormals.ToArray();
        result.uv       = resultSubset.mUVs.ToArray();
        result.tangents = resultSubset.mTangents.ToArray();
        result.colors   = resultSubset.mColors.ToArray();
#if UNITY_5
        result.uv2 = resultSubset.mLightUVs.ToArray();
#else
        result.uv1 = resultSubset.mLightUVs.ToArray();
#endif

        result.subMeshCount = aSubsets.Count;
        for (int i = 0; i < indices.Count; ++i)
        {
            result.SetIndices(indices[i].ToArray(), MeshTopology.Triangles, i);
        }
        result.RecalculateBounds();

        return(result);
    }
        private void ComputeDefinitions()
        {
            var result = new List <DefinitionInstruction>();

            foreach (var node in this.cfg.Nodes)
            {
                foreach (var instruction in node.Instructions)
                {
                    if (instruction is DefinitionInstruction)
                    {
                        var definition = instruction as DefinitionInstruction;

                        if (definition.HasResult)
                        {
                            result.Add(definition);
                        }
                    }
                }
            }

            this.definitions          = result.ToArray();
            this.variable_definitions = new Dictionary <IVariable, Subset <DefinitionInstruction> >();

            for (var i = 0; i < this.definitions.Length; ++i)
            {
                var definition = this.definitions[i];
                Subset <DefinitionInstruction> defs = null;

                if (variable_definitions.ContainsKey(definition.Result))
                {
                    defs = variable_definitions[definition.Result];
                }
                else
                {
                    defs = this.definitions.ToEmptySubset();
                    variable_definitions[definition.Result] = defs;
                }

                defs.Add(i);
            }
        }
        public OBO_Typedef(List <KeyValuePair <string, string> > data = null)
        {
            if (data != null)
            {
                foreach (var datum in data)
                {
                    switch (datum.Key.ToLower())
                    {
                    case "id":
                        Id = datum.Value;
                        break;

                    case "is_anonymous":
                        IsAnonymous = Convert.ToBoolean(datum.Value);
                        break;

                    case "name":
                        Name = datum.Value;
                        break;

                    case "namespace":
                        Namespace = datum.Value;
                        break;

                    case "alt_id":
                        AltId.Add(datum.Value);
                        break;

                    case "def":
                        Def = datum.Value;
                        break;

                    case "comment":
                        Comment = datum.Value;
                        break;

                    case "subset":
                        Subset.Add(datum.Value);
                        break;

                    case "synonym":
                        Synonym.Add(datum.Value);
                        break;

                    case "xref":
                        XRef.Add(datum.Value);
                        break;

                    case "domain":
                        Domain = datum.Value;
                        break;

                    case "range":
                        Range = datum.Value;
                        break;

                    case "is_anti_symmetric":
                        IsAntiSymmetric = Convert.ToBoolean(datum.Value);
                        break;

                    case "is_cyclic":
                        IsCyclic = Convert.ToBoolean(datum.Value);
                        break;

                    case "is_reflexive":
                        IsReflexive = Convert.ToBoolean(datum.Value);
                        break;

                    case "is_symmetric":
                        IsSymmetric = Convert.ToBoolean(datum.Value);
                        break;

                    case "is_transitive":
                        IsTransitive = Convert.ToBoolean(datum.Value);
                        break;

                    case "is_a":
                        IsA.Add(datum.Value);
                        break;

                    case "inverse_of":
                        InverseOf = datum.Value;
                        break;

                    case "transitive_over":
                        TransitiveOver.Add(datum.Value);
                        break;

                    case "relationship":
                        Relationship.Add(datum.Value);
                        break;

                    case "is_obsolete":
                        IsObsolete = Convert.ToBoolean(datum.Value);
                        break;

                    case "replaced_by":
                        ReplacedBy.Add(datum.Value);
                        break;

                    case "consider":
                        Consider.Add(datum.Value);
                        break;

                    case "created_by":
                        CreatedBy = datum.Value;
                        break;

                    case "creation_date":
                        CreationDate = datum.Value;
                        break;

                    default:
                        break;
                    }
                }
            }
        }
Exemplo n.º 4
0
        private void GetSubsets(EffectTechnique technique, int subsetCount)
        {
            string subset = EffectParseHelper.getAnnotationString(technique, "Subset");

            //Subsetの解析
            if (string.IsNullOrWhiteSpace(subset))
            {
                for (int i = 0; i <= subsetCount; i++) //指定しない場合は全てがレンダリング対象のサブセットとなる
                {
                    Subset.Add(i);
                }
            }
            else
            {
                string[] chunks = subset.Split(','); //,でサブセットアノテーションを分割
                foreach (string chunk in chunks)
                {
                    if (chunk.IndexOf('-') == -1) //-がない場合はそれが単体であると認識する
                    {
                        int value = 0;
                        if (int.TryParse(chunk, out value))
                        {
                            Subset.Add(value);
                        }
                        else
                        {
                            throw new InvalidMMEEffectShaderException(
                                      string.Format("テクニック「{0}」のサブセット解析中にエラーが発生しました。「{1}」中の「{2}」は認識されません。",
                                                    technique.Description.Name, subset, chunk));
                        }
                    }
                    else
                    {
                        string[] regions = chunk.Split('-'); //-がある場合は範囲指定と認識する。
                        if (regions.Length > 2)
                        {
                            throw new InvalidMMEEffectShaderException(
                                      string.Format("テクニック「{0}」のサブセット解析中にエラーが発生しました。「{1}」中の「{2}」には\"-\"が2つ以上存在します。",
                                                    technique.Description.Name, subset, chunk));
                        }
                        if (string.IsNullOrWhiteSpace(regions[1])) //この場合、X-の形だと認識される。
                        {
                            int value = 0;
                            if (int.TryParse(regions[0], out value))
                            {
                                for (int i = value; i <= subsetCount; i++)
                                {
                                    Subset.Add(i);
                                }
                            }
                            else
                            {
                                throw new InvalidMMEEffectShaderException(
                                          string.Format("テクニック「{0}」のサブセット解析中にエラーが発生しました。「{1}」中の「{2}」の「{3}」は認識されません。",
                                                        technique.Description.Name, subset, chunk, regions[0]));
                            }
                        }
                        else //この場合X-Yの形式だと認識される
                        {
                            int value1 = 0;
                            int value2 = 0;
                            if (int.TryParse(regions[0], out value1) && int.TryParse(regions[1], out value2))
                            {
                                for (int i = value1; i <= value2; i++)
                                {
                                    Subset.Add(i);
                                }
                            }
                            else
                            {
                                throw new InvalidMMEEffectShaderException(
                                          string.Format(
                                              "テクニック「{0}」のサブセット解析中にエラーが発生しました。「{1}」中の「{2}」の「{3}」もしくは「{4}」は認識されません。",
                                              technique.Description.Name, subset, chunk, regions[0], regions[1]));
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 5
0
            public OBO_Term(List <KeyValuePair <string, string> > data = null)
            {
                if (data != null)
                {
                    foreach (var datum in data)
                    {
                        switch (datum.Key.ToLower())
                        {
                        case "id":
                            Id = datum.Value;
                            break;

                        case "is_anonymous":
                            IsAnonymous = Convert.ToBoolean(datum.Value);
                            break;

                        case "name":
                            Name = datum.Value;
                            break;

                        case "namespace":
                            Namespace = datum.Value;
                            break;

                        case "alt_id":
                            AltId.Add(datum.Value);
                            break;

                        case "def":
                            Def = datum.Value;
                            break;

                        case "comment":
                            Comment = datum.Value;
                            break;

                        case "subset":
                            Subset.Add(datum.Value);
                            break;

                        case "synonym":
                            Synonym.Add(datum.Value);
                            break;

                        case "xref":
                            XRef.Add(datum.Value);
                            break;

                        case "is_a":
                            IsA.Add(datum.Value);
                            break;

                        case "intersection_of":
                            IntersectionOf.Add(datum.Value);
                            break;

                        case "union_of":
                            UnionOf.Add(datum.Value);
                            break;

                        case "disjoint_from":
                            DisjointFrom.Add(datum.Value);
                            break;

                        case "relationship":
                            Relationship.Add(datum.Value);
                            break;

                        case "is_obsolete":
                            IsObsolete = Convert.ToBoolean(datum.Value);
                            break;

                        case "replaced_by":
                            ReplacedBy.Add(datum.Value);
                            break;

                        case "consider":
                            Consider.Add(datum.Value);
                            break;

                        case "created_by":
                            CreatedBy = datum.Value;
                            break;

                        case "creation_date":
                            CreationDate = datum.Value;
                            break;

                        default:
                            break;
                        }
                    }
                }
            }