Ejemplo n.º 1
0
    public void LoadData()
    {
        Names = new NameArray();
        Object obj = Resources.Load("names");

        Names = JsonUtility.FromJson <NameArray>(obj.ToString());
    }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            string[]  name      = new string[] { "Gill", "Amber", "Roven", "Claire", "Erica", "Frederica", "Jo", "Lindsay", "Morris" };
            NameArray nameArray = new NameArray();

            nameArray.Name = name;

            Console.Write("\nName = ");
            for (int i = 0; i < name.Length; i++)
            {
                Console.Write(name[i] + "  ");
            }
            nameArray.LongestString();  //Print the longest name

            System.Collections.ArrayList nameWithC = nameArray.TestStringIncludeC();
            Console.Write("\nName(s) include c or C : ");
            foreach (string s in nameWithC)
            {
                Console.Write(s + "  ");
            }
            Console.WriteLine("\n\nThere are {0} names including c or C.", nameWithC.Count);
            Console.WriteLine("\n\n");
        }
Ejemplo n.º 3
0
        public static PrimitiveData DecodeMorphedPrimitivesUnweighted(Matrix4 bindMatrix, Morph morph)
        {
            if (!(morph.BaseMeshUrl.GetElement(morph.Root) is Geometry baseMesh))
            {
                WriteLine("Morph base mesh '" + morph.BaseMeshUrl.TargetID + "' does not point to a valid geometry entry.");
                return(null);
            }

            DecodePrimitives(baseMesh, bindMatrix, null,
                             out VertexShaderDesc baseInfo, out List <VertexPrimitive> baseLines, out List <VertexPolygon> baseFaces);

            var           targets = morph.TargetsElement;
            InputUnshared morphTargets = null, morphWeights = null;

            foreach (InputUnshared input in targets.InputElements)
            {
                switch (input.CommonSemanticType)
                {
                case ESemantic.MORPH_TARGET: morphTargets = input; break;

                case ESemantic.MORPH_WEIGHT: morphWeights = input; break;
                }
            }

            Source targetSource = morphTargets?.Source?.GetElement <Source>(morphTargets.Root);
            Source weightSource = morphWeights?.Source?.GetElement <Source>(morphWeights.Root);

            NameArray  nameArray   = targetSource?.GetArrayElement <NameArray>();
            FloatArray weightArray = weightSource?.GetArrayElement <FloatArray>();

            string[] geomIds = nameArray?.StringContent?.Values;
            float[]  weights = weightArray?.StringContent?.Values;

            if (geomIds == null || weights == null)
            {
                WriteLine("Morph set for '" + morph.BaseMeshUrl.TargetID + "' does not have valid target and weight inputs.");
                return(null);
            }
            int count = geomIds.Length;

            if (geomIds.Length != weights.Length)
            {
                WriteLine("Morph set for '" + morph.BaseMeshUrl.TargetID + "' does not have a target count that matches weight count.");
                count = Math.Min(geomIds.Length, weights.Length);
            }

            Geometry geom;

            List <VertexPrimitive>[] morphLines = new List <VertexPrimitive> [count];
            List <VertexPolygon>[]   morphFaces = new List <VertexPolygon> [count];

            for (int i = 0; i < count; ++i)
            {
                geom = targets.Root.GetIDEntry <Geometry>(geomIds[i]);
                DecodePrimitives(geom, bindMatrix, null,
                                 out VertexShaderDesc info, out List <VertexPrimitive> lines, out List <VertexPolygon> faces);
                morphLines[i] = lines;
                morphFaces[i] = faces;
            }

            //TODO: create data using weights and morphLines or morphFaces array

            return(CreateData(baseInfo, baseLines, baseFaces));
        }