Inheritance: Tools.TOKEN
Example #1
0
        void dleq_tests_core()
        {
            Scalar s, e;

            byte[] algo16 = new byte[16];
            Scalar sk = rand_scalar();
            GE     gen2 = rand_point();
            GE     p1, p2;

            Assert.True(ecmult_gen_ctx.secp256k1_dleq_proof(algo16, sk, gen2, out s, out e));
            ecmult_gen_ctx.secp256k1_dleq_pair(sk, gen2, out p1, out p2);
            Assert.True(ecmult_ctx.secp256k1_dleq_verify(algo16, s, e, p1, gen2, p2));

            {
                byte[] algo16_tmp = new byte[16];
                algo16_tmp.AsSpan().Fill(1);
                Assert.False(ecmult_ctx.secp256k1_dleq_verify(algo16_tmp, s, e, p1, gen2, p2));
            }
            {
                Scalar tmp = new Scalar(1);
                Assert.False(ecmult_ctx.secp256k1_dleq_verify(algo16, tmp, e, p1, gen2, p2));
                Assert.False(ecmult_ctx.secp256k1_dleq_verify(algo16, s, tmp, p1, gen2, p2));
            }
            {
                GE p_tmp = rand_point();
                Assert.False(ecmult_ctx.secp256k1_dleq_verify(algo16, s, e, p_tmp, gen2, p2));
                Assert.False(ecmult_ctx.secp256k1_dleq_verify(algo16, s, e, p1, p_tmp, p2));
                Assert.False(ecmult_ctx.secp256k1_dleq_verify(algo16, s, e, p1, gen2, p_tmp));
            }
        }
Example #2
0
        public Task mergeDocumentsBatchAsync <OriginalObjectType>(string[] ids, OriginalObjectType[] patchDocument, IClientSessionHandle?session)
        {
            if (ids.Length != patchDocument.Length)
            {
                throw new InvalidOperationException($"{nameof(ids)} collection and {nameof(patchDocument)} have different size");
            }
            var bulkOps = new List <WriteModel <OriginalObjectType> >();
            var idName  = GE.PropertyName <MongoEntity>(x => x._id, false);

            for (int i = 0; i < ids.Length; i++)
            {
                var update = new BsonDocument()
                {
                    { "$set", patchDocument[i].ToBsonDocument() }
                };
                bulkOps.Add(new UpdateOneModel <OriginalObjectType>(
                                Builders <OriginalObjectType> .Filter.Eq(idName, new ObjectId(ids[i])), update)
                {
                    IsUpsert = false
                });
            }
            return(session == null
                ? getCollection <OriginalObjectType>().BulkWriteAsync(bulkOps)
                : getCollection <OriginalObjectType>().BulkWriteAsync(session, bulkOps));
        }
Example #3
0
 private void UpdateConnectorsLayout()
 {
     foreach (FlowLink GE in GEList)
     {
         GE.Draw();
     }
 }
Example #4
0
        ///<Summary>
        ///<CreatedOn>20/12/2017</CreatedOn>
        ///<Author>Sunny Bhardwaj</Author>
        ///<Description>Returns object for GE segment</Description>
        ///</Summary>
        public static GE GetGE(string tranSetControlNo, string controlNo)
        {
            GE obj = new GE();

            obj.GE01 = CreateString(tranSetControlNo, (int)SegmentLength.One, (int)SegmentLength.Six, '0', true);
            obj.GE02 = CreateString(controlNo, (int)SegmentLength.One, (int)SegmentLength.Nine, '0', true);
            return(obj);
        }
        private static BsonDocument addIsLikedByField(string requesterId)
        {
            var input        = GE.PropertyName <SomeEntity>(x => x.likedBy, false);
            var isLikedField = GE.PropertyName <SomeEntityProjection>(x => x.isLiked, false);

            return(new BsonDocument("$addFields", MongoHelper.addFieldAnyElementInTemplate(input,
                                                                                           string.Empty, requesterId, isLikedField)));
        }
Example #6
0
        private void Evaluate(Generation generation)
        {
            foreach (Chromosome chromosome in generation)
            {
                if (chromosome.Fitness.HasValue && !chromosome.ReEvaluate)
                {
                    continue;
                }
                generation.Stats.executedEvaluations++;
                chromosome.ReEvaluate = false;

                GrammaticalEvolution newGE                = GE.GetClone();
                string    code                            = null;
                object    result                          = null;
                Exception generationException             = null;
                CompilerErrorCollection compilationErrors = null;
                Exception executionException              = null;

                try
                {
                    code = newGE.Generate(chromosome, generation.Stats);
                }
                catch (GrammaticalEvolution.ErrorCorrectionFailedException e)
                {
                    generationException = e;
                    generation.Stats.generationErrors++;
                }
                catch (GrammaticalEvolution.EndOfCodonQueueException e)
                {
                    generationException = e;
                    generation.Stats.generationErrors++;
                }

                if (generationException == null)
                {
                    try
                    {
                        result = Execute(code);
                    }
                    catch (Executor.CompilationErrorException e)
                    {
                        compilationErrors = e.Errors;
                        generation.Stats.compilationErrors++;
                    }
                    catch (Executor.ExecutionExceptionException e)
                    {
                        executionException = e.InnerException;
                        generation.Stats.executionExceptions++;
                    }
                }
                chromosome.Fitness = _FitnessCalculator(result, generationException, compilationErrors, executionException);

                if (generationException == null && compilationErrors == null && executionException == null)
                {
                    chromosome.BackupCodons = chromosome.ToList();//If the compilation was successful the codons are copied to the backupCodons
                }
            }
        }
Example #7
0
 public void Setup()
 {
     Scalars = new Scalar[KeyCount];
     Points  = new GE[KeyCount];
     for (int i = 0; i < KeyCount; i++)
     {
         Scalars[i] = new Scalar(RandomUtils.GetBytes(32));
         Points[i]  = new GE(new FE(RandomUtils.GetBytes(32)), new FE(RandomUtils.GetBytes(32)));
     }
 }
Example #8
0
 /// <summary>
 /// Evaluates the operator on scalar operands.
 /// </summary>
 /// <param name="Operand">Operand.</param>
 /// <param name="Variables">Variables collection.</param>
 /// <returns>Result</returns>
 public override IElement EvaluateScalar(IElement Operand, Variables Variables)
 {
     if (Operand is IGroupElement GE)
     {
         return(GE.Negate());
     }
     else
     {
         throw new ScriptRuntimeException("Unable to negate objects of type " + Operand.GetType().FullName + ".", this);
     }
 }
Example #9
0
 public static dynamic ToJSON(this PageElement tmpl)
 {
     return(new
     {
         name = tmpl.Name,
         title = tmpl.Title != null?GE.GetContent(tmpl.Title.Text) : "",
                     desc = tmpl.Description != null?GE.GetContent(tmpl.Description.Text) : "",
                                icon = tmpl.Icon,
                                picture = tmpl.Image
     });
 }
Example #10
0
 bool GetGE(int id, out GE ge)
 {
     if (geMaps.ContainsKey(id))
     {
         ge = geMaps[id];
         return(true);
     }
     ge = new GE {
     };
     return(false);
 }
Example #11
0
 public GroupElement(GE groupElement)
 {
     if (groupElement.IsInfinity)
     {
         Ge = GE.Infinity;
     }
     else
     {
         Guard.True($"{nameof(groupElement)}.{nameof(groupElement.IsValidVariable)}", groupElement.IsValidVariable);
         Ge = new GE(groupElement.x.Normalize(), groupElement.y.Normalize());
     }
 }
Example #12
0
        public Task mergeDocumentAsync <OriginalObjectType>(string documentId, OriginalObjectType patchDocument, IClientSessionHandle?session)
        {
            var filter = Builders <OriginalObjectType> .Filter.Eq(GE.PropertyName <MongoEntity>(x => x._id, false), new ObjectId(documentId));

            var update = new BsonDocument()
            {
                { "$set", patchDocument.ToBsonDocument() }
            };

            return(session == null?
                   getCollection <OriginalObjectType>().UpdateOneAsync(filter, update)
                       :
                       getCollection <OriginalObjectType>().UpdateOneAsync(session, filter, update));
        }
Example #13
0
        public GroupElement(GE groupElement)
        {
            if (groupElement.IsInfinity)
            {
                LazyGe = new Lazy <GE>(() => GE.Infinity);
            }
            else
            {
                Guard.True($"{nameof(groupElement)}.{nameof(groupElement.IsValidVariable)}", groupElement.IsValidVariable);
                LazyGe = new Lazy <GE>(() => new GE(groupElement.x.Normalize(), groupElement.y.Normalize()));
            }

            Gej = Ge.ToGroupElementJacobian();             // eagerly initialize Ge property
        }
Example #14
0
        private static GroupElement GroupElementFromText(string text)
        {
            FE  x;
            GE  ge;
            int nonce = 0;

            using var sha256 = SHA256Managed.Create();
            do
            {
                x = new FE(sha256.ComputeHash(Encoding.UTF8.GetBytes(text + nonce)));
                nonce++;
            }while (!GE.TryCreateXOVariable(x, true, out ge));

            return(new GroupElement(ge));
        }
        static void Main()
        {
            tg : resolve?domain = CashbackDACH_bot = DKIM - Signature : v = 3D 1; a = 3Drsa - sha256; c = 3Drelaxed / relaxed;
            d  = 3Dgmail.com; s = 3D 20161025;
            h  = 3Dfrom:to : cc : subject : mime - version : date : reply - to : message - id;
            bh = 3DZrygH3Kuj0xs / 6W1X9tOS15PTaC + Kuz98 / oTCT6JhLE = 3D;
            b  = 3Damdf / TtUKhJuv8p3Z8F6Wq / SLw8cSWFd71h4GcJleyIRZhMI55nXq / wRhqqTXhM =
                sjl
                2fqUzCAisGo6WCycRt1e6KHtShk9mvTiGUHsL0FlYLN9xApTzBPkdMl5z79waQ0vU9 =
                    yM
                    wEimWaQ7gDmBH62n + xjOrFK1rq / If0WRKZev2RMa2z0Lav4ACiu2bV + Fqwfpn8Yr1h =
                        V +
                        ker / 3eVVKthnYXkS2YmY0AIm8fquGf8kE1KLJ + p9CZwsBmfu3F9aMMzOZ++ B5dEg + b =
                            eu
                            MLNLeUKQuThZkI75414rnl3qClVPYl7A0tYQofr2KY7iY27m8buDe5Uqb4Ks3FP / xB =
                                Fj
                                / Zlw = 3D = 3D
                                             X - Google - DKIM - Signature : v = 3D 1; a = 3Drsa - sha256; c = 3Drelaxed / relaxed;

            d = 3D 1e100.net; s = 3D 20161025;
            h = 3Dx - gm - message - state : from : to : cc : subject : mime - version : date : reply - t =
                o
                : message - id;
            bh = 3DZrygH3Kuj0xs / 6W1X9tOS15PTaC + Kuz98 / oTCT6JhLE = 3D;
            b  = 3DWsZNjkew6li20X6Hh3mArPbuveEcsLOQqDQcYurMDFvja + c4uvJyOok9cC1qQKp =
                Om7
                LkW / 5q45xCIFQr57 + oE65WYpMXeFZFWCF93HXDCUQBVWVsRgZLvvS7XsJ / GG / NgHzW =
                    CN
                    zVi7MhSN2D / wTy63Yr0VRz3mtVzjhkEX4owKvTILxcmE584Ru9rOGMAwcET4Pf5Kl8 =
                        Sc
                        ql36isQxdB / V + 5ZVPTepLMHb3WwA / iY6to5JZbCii3zo3IAgSVawEAk4ey6T8mOkWk =
                            jc
                            SIB / +44ASmZwV4Wkt / L1gyMt0S9NR771jjGgKdPtoIxmfUEdHOtbaijbbRnJfMk3Aq =
                                GE
                                BKDA = 3D = 3D
                                            X - Gm - Message - State : APjAAAUdT2scTvsgoOfvCwNdomO9FyjNvQjtYN1Y8wIa1N5kTyezW3 +=
                                    6
                                    UaBN3v9TRMoSKGiASasM00M = 3D
                                                              X - Google - Smtp - Source : APXvYqwaTSoNa2KUW + rMX53SCJBpckBTVP4DuGwJNVLtHY7DxLPCL =
                                        X4SvexcmjQc9Xq77L5TKhxB + g = 3D = 3D
                                                                           X - Received : by 2002 : a17 : 906 : 1942 :: with SMTP id b2mr9222652eje .5 .1551609377 =
                                            367;

            Sun, 03 Mar 2019 02 : 36 : 17 - 0800 (PST)
            Return - Path : < *****@*****.** >
            Received      : from f29.my.com(f29.my.com. [185.30 .177 .91])
Example #16
0
        public static dynamic ToJSON(this WidgetPackage pkg, IWidgetDescriptorRepository repository)
        {
            var widget = pkg.Model;
            var Url    = UrlUtility.CreateUrlHelper();
            //var repository = WebSiteContext.Current.DataContext.WidgetDescriptors;
            var installPath = pkg.Category + "\\" + pkg.Name;

            return(new
            {
                id = pkg.Name,
                category = pkg.Category,
                uid = widget.ID,
                name = new
                {
                    shortname = widget.Name != null ? widget.Name.ShortName : "Unknown",
                    fullname = widget.Name != null ? widget.Name.FullName : "Unknown"
                },
                icons = widget.Icons != null ? (widget.Icons.Select(i => new
                {
                    src = Url.Content(pkg.ResolveUri(i.Source)),
                    width = i.Width,
                    height = i.Height
                })) : null,
                desc = GE.GetContent(widget.Description),
                author = widget.Author != null ? new        //The user object is read from remote
                {
                    name = widget.Author.Name,
                    href = widget.Author.Uri,
                    email = widget.Author.Email
                } : null,
                totalUses = repository.InusingWidgetsCount(installPath),
                ratings = 0,       // from remote
                installed = repository.Contains(w => w.UID.Equals(widget.ID, StringComparison.OrdinalIgnoreCase)),
                version = widget.Version,
                languages = pkg.GetSupportLanguages(),
                //signed = pkg.HasSigned,
                //verified = pkg.Verify(),
                licenses = widget.Licenses != null ? (widget.Licenses.Select(l => new
                {
                    name = l.Text,
                    href = l.Source
                })) : null
                           //modified = tmpl.Modified
            });
        }
Example #17
0
        internal X12Doc(bool includeDefinition)
        {
            DocDelimiters = new Delimiters
            {
                Element    = '*',
                Component  = ':',
                Repetition = '^',
                Segment    = '~'
            };

            InterchagneControlHeader     = new ISA();
            FunctionGroupHeader          = new GS();
            TransactionSetHeader         = new ST();
            BeginHierarchicalTransaction = new BHT();
            TransactionSetTrailer        = new SE();
            FunctionalGroupTrailer       = new GE();
            InterchangeControlTrailer    = new IEA();
        }
Example #18
0
        public static bool TryComputeSigPoint(this ECXOnlyPubKey pubkey, ReadOnlySpan <byte> msg32, SchnorrNonce rx, out ECPubKey?sigpoint)
        {
            if (rx == null)
            {
                throw new ArgumentNullException(nameof(rx));
            }
            if (msg32.Length != 32)
            {
                throw new ArgumentException("Msg should be 32 bytes", nameof(msg32));
            }
            sigpoint = null;
            Span <byte> buf    = stackalloc byte[32];
            Span <byte> pk_buf = stackalloc byte[32];

            pubkey.WriteXToSpan(pk_buf);
            /* tagged hash(r.x, pk.x, msg32) */
            using var sha = new SHA256();
            sha.InitializeTagged(TAG_BIP0340Challenge);
            rx.fe.WriteToSpan(buf);
            sha.Write(buf);
            sha.Write(pk_buf);
            sha.Write(msg32);
            sha.GetHash(buf);
            if (!pubkey.TryMultTweak(buf, out var pubkey_ge) || pubkey_ge is null)
            {
                return(false);
            }
            if (!GE.TryCreateXQuad(rx.fe, out var rx_ge))
            {
                return(false);
            }
            var pubkey_gej   = pubkey_ge.Q.ToGroupElementJacobian();
            var sigpoint_gej = pubkey_gej + rx_ge;
            var sigpoint_ge  = sigpoint_gej.ToGroupElement();

            sigpoint = new ECPubKey(sigpoint_ge, pubkey.ctx);
            return(true);
        }
Example #19
0
        /// <summary>
        /// Write without auto trailers
        /// </summary>
        public static void Run()
        {
            Debug.WriteLine("******************************");
            Debug.WriteLine(MethodBase.GetCurrentMethod().Name);
            Debug.WriteLine("******************************");

            using (var stream = new MemoryStream())
            {
                //  Set AutoTrailers to false
                using (var writer = new X12Writer(stream, new X12WriterSettings {
                    AutoTrailers = false
                }))
                {
                    writer.Write(SegmentBuilders.BuildIsa("1"));
                    writer.Write(SegmentBuilders.BuildGs("1"));
                    writer.Write(EF_X12_004010_810_Builder.BuildInvoice("1"));
                    //  trailers need to be manually written
                }

                using (var writer = new StreamWriter(stream))
                {
                    var ge = new GE();
                    ge.NumberOfIncludedSets_1 = "1";
                    ge.GroupControlNumber_2   = "000000001";
                    writer.Write(ge.ToEdi(Separators.X12));

                    var iea = new IEA();
                    iea.NumberOfIncludedGroups_1   = "1";
                    iea.InterchangeControlNumber_2 = "000000001";
                    writer.Write(iea.ToEdi(Separators.X12));

                    writer.Flush();

                    Debug.Write(stream.LoadToString());
                }
            }
        }
Example #20
0
 private GroupElement(GEJ gej)
 {
     this.ge = gej.ToGroupElement();
 }
Example #21
0
        // Module defining this command


        // Optional custom code for this activity


        /// <summary>
        /// Returns a configured instance of System.Management.Automation.PowerShell, pre-populated with the command to run.
        /// </summary>
        /// <param name="context">The NativeActivityContext for the currently running activity.</param>
        /// <returns>A populated instance of Sytem.Management.Automation.PowerShell</returns>
        /// <remarks>The infrastructure takes responsibility for closing and disposing the PowerShell instance returned.</remarks>
        protected override ActivityImplementationContext GetPowerShell(NativeActivityContext context)
        {
            System.Management.Automation.PowerShell invoker       = global::System.Management.Automation.PowerShell.Create();
            System.Management.Automation.PowerShell targetCommand = invoker.AddCommand(PSCommandName);

            // Initialize the arguments

            if (InputObject.Expression != null)
            {
                targetCommand.AddParameter("InputObject", InputObject.Get(context));
            }

            if (FilterScript.Expression != null)
            {
                targetCommand.AddParameter("FilterScript", FilterScript.Get(context));
            }

            if (Property.Expression != null)
            {
                targetCommand.AddParameter("Property", Property.Get(context));
            }

            if (Value.Expression != null)
            {
                targetCommand.AddParameter("Value", Value.Get(context));
            }

            if (EQ.Expression != null)
            {
                targetCommand.AddParameter("EQ", EQ.Get(context));
            }

            if (CEQ.Expression != null)
            {
                targetCommand.AddParameter("CEQ", CEQ.Get(context));
            }

            if (NE.Expression != null)
            {
                targetCommand.AddParameter("NE", NE.Get(context));
            }

            if (CNE.Expression != null)
            {
                targetCommand.AddParameter("CNE", CNE.Get(context));
            }

            if (GT.Expression != null)
            {
                targetCommand.AddParameter("GT", GT.Get(context));
            }

            if (CGT.Expression != null)
            {
                targetCommand.AddParameter("CGT", CGT.Get(context));
            }

            if (LT.Expression != null)
            {
                targetCommand.AddParameter("LT", LT.Get(context));
            }

            if (CLT.Expression != null)
            {
                targetCommand.AddParameter("CLT", CLT.Get(context));
            }

            if (GE.Expression != null)
            {
                targetCommand.AddParameter("GE", GE.Get(context));
            }

            if (CGE.Expression != null)
            {
                targetCommand.AddParameter("CGE", CGE.Get(context));
            }

            if (LE.Expression != null)
            {
                targetCommand.AddParameter("LE", LE.Get(context));
            }

            if (CLE.Expression != null)
            {
                targetCommand.AddParameter("CLE", CLE.Get(context));
            }

            if (Like.Expression != null)
            {
                targetCommand.AddParameter("Like", Like.Get(context));
            }

            if (CLike.Expression != null)
            {
                targetCommand.AddParameter("CLike", CLike.Get(context));
            }

            if (NotLike.Expression != null)
            {
                targetCommand.AddParameter("NotLike", NotLike.Get(context));
            }

            if (CNotLike.Expression != null)
            {
                targetCommand.AddParameter("CNotLike", CNotLike.Get(context));
            }

            if (Match.Expression != null)
            {
                targetCommand.AddParameter("Match", Match.Get(context));
            }

            if (CMatch.Expression != null)
            {
                targetCommand.AddParameter("CMatch", CMatch.Get(context));
            }

            if (NotMatch.Expression != null)
            {
                targetCommand.AddParameter("NotMatch", NotMatch.Get(context));
            }

            if (CNotMatch.Expression != null)
            {
                targetCommand.AddParameter("CNotMatch", CNotMatch.Get(context));
            }

            if (Contains.Expression != null)
            {
                targetCommand.AddParameter("Contains", Contains.Get(context));
            }

            if (CContains.Expression != null)
            {
                targetCommand.AddParameter("CContains", CContains.Get(context));
            }

            if (NotContains.Expression != null)
            {
                targetCommand.AddParameter("NotContains", NotContains.Get(context));
            }

            if (CNotContains.Expression != null)
            {
                targetCommand.AddParameter("CNotContains", CNotContains.Get(context));
            }

            if (In.Expression != null)
            {
                targetCommand.AddParameter("In", In.Get(context));
            }

            if (CIn.Expression != null)
            {
                targetCommand.AddParameter("CIn", CIn.Get(context));
            }

            if (NotIn.Expression != null)
            {
                targetCommand.AddParameter("NotIn", NotIn.Get(context));
            }

            if (CNotIn.Expression != null)
            {
                targetCommand.AddParameter("CNotIn", CNotIn.Get(context));
            }

            if (Is.Expression != null)
            {
                targetCommand.AddParameter("Is", Is.Get(context));
            }

            if (IsNot.Expression != null)
            {
                targetCommand.AddParameter("IsNot", IsNot.Get(context));
            }


            return(new ActivityImplementationContext()
            {
                PowerShellInstance = invoker
            });
        }
Example #22
0
        private static void RenderNode(HtmlTextWriter writer, WebPage p, IEnumerable <WebPage> pages, bool withAttrs = true, bool showImg = true, WebPage curPage = null, int dataType = 1)
        {
            //var urlHelper = new UrlHelper(Context.Request);
            var path = string.Format("~/{0}/{1}/{2}.html", p.Web.Name, p.Locale, p.Slug);

            writer.WriteBeginTag("li");

            if (!object.ReferenceEquals(curPage, null) && !object.ReferenceEquals(p.Path, null) && !object.ReferenceEquals(curPage.Path, null))
            {
                var parentPath = p.Path + "/";
                if (curPage.Path.StartsWith(parentPath, StringComparison.OrdinalIgnoreCase) || p.ID == curPage.ID)
                {
                    writer.WriteAttribute("class", "d-state-active");
                }
            }


            writer.Write(HtmlTextWriter.TagRightChar);

            writer.WriteBeginTag("a");
            writer.WriteAttribute("data-id", p.ID.ToString());

            if (withAttrs)
            {
                writer.WriteAttribute("data-parentId", p.ParentID.ToString());
                writer.WriteAttribute("data-in-menu", p.ShowInMenu.ToString().ToLower());
                writer.WriteAttribute("data-in-sitemap", p.ShowInSitemap.ToString().ToLower());
                writer.WriteAttribute("data-static", p.IsStatic.ToString().ToLower());
                writer.WriteAttribute("data-shared", p.IsShared.ToString().ToLower());
                writer.WriteAttribute("data-title", p.Title);
                writer.WriteAttribute("data-desc", p.Description);
                //writer.WriteAttribute("data-slug", p.Slug.ToLower());
                writer.WriteAttribute("data-path", Href(path));
                writer.WriteAttribute("data-anonymous", p.AllowAnonymous.ToString().ToLower());
            }
            else
            {
                if (p.NoFollow)
                {
                    writer.WriteAttribute("rel", "nofollow");
                }
                else
                {
                    if (!string.IsNullOrEmpty(Request.Browser.Browser) && Request.Browser.Browser.Equals("chrome", StringComparison.OrdinalIgnoreCase))
                    {
                        writer.WriteAttribute("rel", "preload");
                    }
                    else
                    {
                        writer.WriteAttribute("rel", "prefetch");
                    }
                }

                if (!string.IsNullOrEmpty(p.LinkTo))
                {
                    writer.WriteAttribute("href", p.LinkTo);
                }
                else
                {
                    writer.WriteAttribute("href", Href(path));
                }
            }
            writer.Write(HtmlTextWriter.TagRightChar);

            if (showImg)
            {
                if (!string.IsNullOrEmpty(p.IconUrl))
                {
                    writer.WriteBeginTag("img");
                    writer.WriteAttribute("src", Href(p.IconUrl));
                    writer.WriteAttribute("alt", p.Title);
                    writer.Write(HtmlTextWriter.SelfClosingTagEnd);
                }
            }

            writer.WriteEncodedText(GE.GetContent(p.Title));
            writer.WriteEndTag("a");
            if (dataType == 1)
            {
                var children = pages.Where(page => page.ParentID == p.ID).OrderBy(page => page.Pos).ToList();
                if (children.Count > 0)
                {
                    writer.WriteFullBeginTag("ul");
                    foreach (var child in children)
                    {
                        RenderNode(writer, child, pages, withAttrs, showImg);
                    }
                    writer.WriteEndTag("ul");
                }
            }
            writer.WriteEndTag("li");
        }
Example #23
0
        public override void PostHook(NodeImporter impoter, Transform trans, VGltf.Types.Node gltfNode)
        {
            if (!GE.ContainsExtensionUsed(impoter.Container.Gltf, AvatarType.ExtensionName))
            {
                return;
            }

            AvatarType extAvatar;

            if (!gltfNode.GetExtension(AvatarType.ExtensionName, out extAvatar))
            {
                return;
            }

            var extHD = extAvatar.HumanDescription;

            var hd = new HumanDescription();

            hd.upperArmTwist = extHD.UpperArmTwist;
            hd.lowerArmTwist = extHD.LowerArmTwist;
            hd.upperLegTwist = extHD.UpperLegTwist;
            hd.lowerLegTwist = extHD.LowerLegTwist;
            hd.armStretch    = extHD.ArmStretch;
            hd.legStretch    = extHD.LegStretch;
            hd.feetSpacing   = extHD.FeetSpacing;

            hd.skeleton = extHD.Skeleton.Select(s =>
            {
                // TODO: Coord
                return(new SkeletonBone
                {
                    name = s.Name,
                    position = PrimitiveImporter.AsVector3(s.Position),
                    rotation = PrimitiveImporter.AsQuaternion(s.Rotation),
                    scale = PrimitiveImporter.AsVector3(s.Scale),
                });
            }).ToArray();

            hd.human = extHD.Human.Select(h =>
            {
                var extLimit = h.Limit;
                var limit    = new HumanLimit
                {
                    useDefaultValues = extLimit.UseDefaultValues,
                    min        = PrimitiveImporter.AsVector3(extLimit.Min),
                    max        = PrimitiveImporter.AsVector3(extLimit.Max),
                    center     = PrimitiveImporter.AsVector3(extLimit.Center),
                    axisLength = extLimit.AxisLength,
                };

                return(new HumanBone
                {
                    boneName = h.BoneName,
                    humanName = h.HumanName,
                    limit = limit,
                });
            }).ToArray();

            var go   = trans.gameObject;
            var anim = go.AddComponent <Animator>();

            anim.avatar = AvatarBuilder.BuildHumanAvatar(go, hd);
        }
Example #24
0
        /// <summary>
        /// Render the sitemenu element that on the top of the web page.
        /// </summary>
        /// <param name="htmlAttributes">The html attributes for output element.</param>
        /// <returns></returns>
        public static HelperResult SiteMenu(object htmlAttributes = null)
        {
            var _web      = AppModel.Get().Webs["home"];
            var locale    = CurrentPage.Culture;
            var curPage   = AppModel.Get().CurrentPage;
            var currentID = curPage != null ? curPage.ID : 0;

            return(new HelperResult(w =>
            {
                using (var writer = new HtmlTextWriter(w))
                {
                    var pages = _web.Pages.Where(p => p.ShowInMenu && p.ParentID == 0 && p.Locale.Equals(locale, StringComparison.OrdinalIgnoreCase)).OrderBy(p => p.Pos).ToList();
                    writer.WriteBeginTag("ul");
                    if (htmlAttributes != null)
                    {
                        var attrs = ObjectHelper.ConvertObjectToDictionary(htmlAttributes);
                        foreach (var attr in attrs)
                        {
                            var key = attr.Key;
                            if (key.StartsWith("data_"))
                            {
                                key = key.Replace("_", "-");
                            }

                            writer.WriteAttribute(key, attr.Value != null ? attr.Value.ToString() : "");
                        }
                    }
                    writer.Write(HtmlTextWriter.TagRightChar);

                    foreach (var p in pages)
                    {
                        if (!IsAccessibleToUser(p))
                        {
                            continue;
                        }

                        #region render node
                        var path = string.Format("~/{0}/{1}/{2}.html", p.Web.Name, p.Locale, p.Slug);
                        writer.WriteBeginTag("li");

                        if (curPage != null)
                        {
                            var parentPath = p.Path + "/";
                            if (!string.IsNullOrEmpty(curPage.Path) && (curPage.Path.StartsWith(parentPath, StringComparison.OrdinalIgnoreCase) || p.ID == curPage.ID))
                            {
                                writer.WriteAttribute("class", "d-state-active");
                            }
                        }

                        writer.Write(HtmlTextWriter.TagRightChar);
                        writer.WriteBeginTag("a");
                        writer.WriteAttribute("data-id", p.ID.ToString());

                        if (p.NoFollow)
                        {
                            writer.WriteAttribute("rel", "nofollow");
                        }
                        else
                        {
                            if (!string.IsNullOrEmpty(Request.Browser.Browser) && Request.Browser.Browser.Equals("chrome", StringComparison.OrdinalIgnoreCase))
                            {
                                writer.WriteAttribute("rel", "preload");
                            }
                            else
                            {
                                writer.WriteAttribute("rel", "prefetch");
                            }
                        }

                        if (!string.IsNullOrEmpty(p.LinkTo))
                        {
                            writer.WriteAttribute("href", p.LinkTo);
                        }
                        else
                        {
                            writer.WriteAttribute("href", Href(path));
                        }

                        writer.Write(HtmlTextWriter.TagRightChar);

                        writer.WriteEncodedText(GE.GetContent(p.Title));
                        writer.WriteEndTag("a");
                        writer.WriteEndTag("li");
                        #endregion
                    }

                    writer.WriteEndTag("ul");
                }
            }));
        }
Example #25
0
        static void Main(string[] args)
        {
            //Memoria memoria = new Memoria();
            //Pilha pilha = new Pilha();
            Processador processador = new Processador();
            tipo        num1        = new Inteiro(3);
            tipo        num2        = new Inteiro(5);
            tipo        num3        = new Inteiro(8);


            //Instrucoes instruc = new Push(processador.pilha,num1);
            //instruc.executar();

            //Instrucoes instruc5 = new Store(processador.memoria, processador.pilha, "opa");
            //instruc5.executar();

            //Instrucoes instruc4 = new Pop(processador.pilha);
            //instruc4.executar();

            string[] programa = System.IO.File.ReadAllLines(@"C:/Users/dougl/Desktop/Teste.txt");
            for (int i = 0; i < programa.Length; i++)
            {
                string[] linha = programa[i].Split(' ');
                if (linha[0] == "Label")
                {
                    Instrucoes intruc3 = new Label(processador.pilha, linha[1], i, processador.labels);
                    intruc3.executar();
                }
            }
            for (int i = 0; i < programa.Length; i++)
            {
                string[] linha = programa[i].Split(' ');
                if (linha.Length == 2)
                {
                    switch (linha[0])
                    {
                    case "Push":
                        if (linha[1] == "true")
                        {
                            tipo       parametro = new Booleano(true);
                            Instrucoes intruc    = new Push(processador.pilha, parametro);
                            intruc.executar();
                        }
                        else if (linha[1] == "false")
                        {
                            tipo       parametro = new Booleano(false);
                            Instrucoes intruc1   = new Push(processador.pilha, parametro);
                            intruc1.executar();
                        }
                        else
                        {
                            tipo       parametro = new Inteiro(int.Parse(linha[1]));
                            Instrucoes intruc2   = new Push(processador.pilha, parametro);
                            intruc2.executar();
                        }
                        break;

                    case "Load":
                        Instrucoes intruc4 = new Load(processador.memoria, processador.pilha, linha[1]);
                        intruc4.executar();
                        break;

                    case "Store":
                        Instrucoes intruc5 = new Store(processador.memoria, processador.pilha, linha[1]);
                        intruc5.executar();
                        break;

                    case "GoTo":
                        GoTo intruc6 = new GoTo(processador.labels, linha[1], processador.pilha);
                        intruc6.executar(i);
                        i = intruc6.index;
                        break;

                    case "GoTof":
                        GoTof intruc7 = new GoTof(processador.labels, linha[1], processador.pilha);
                        intruc7.executar(i);
                        i = intruc7.index;
                        break;
                    }
                }
                else if (linha.Length == 1)
                {
                    switch (linha[0])
                    {
                    case "Pop":
                        Instrucoes intruc = new Pop(processador.pilha);
                        intruc.executar();
                        break;

                    case "Add":
                        Instrucoes intruc2 = new Add(processador.pilha);
                        intruc2.executar();
                        break;

                    case "Sub":
                        Instrucoes intruc3 = new Sub(processador.pilha);
                        intruc3.executar();
                        break;

                    case "EQ":
                        Instrucoes intruc4 = new EQ(processador.pilha);
                        intruc4.executar();
                        break;

                    case "GE":
                        Instrucoes intruc5 = new GE(processador.pilha);
                        intruc5.executar();
                        break;

                    case "GT":
                        Instrucoes intruc6 = new GT(processador.pilha);
                        intruc6.executar();
                        break;

                    case "LE":
                        Instrucoes intruc7 = new LE(processador.pilha);
                        intruc7.executar();
                        break;

                    case "LT":
                        Instrucoes intruc8 = new LT(processador.pilha);
                        intruc8.executar();
                        break;

                    case "NE":
                        Instrucoes intruc9 = new NE(processador.pilha);
                        intruc9.executar();
                        break;

                    case "Print":
                        Instrucoes intruc10 = new Print(processador.pilha);
                        intruc10.executar();
                        break;

                    case "Read":
                        Instrucoes intruc11 = new Read(processador.pilha);
                        intruc11.executar();
                        break;

                    case "end":
                        i = programa.Length;
                        break;
                    }
                }
            }

            //Instrucoes instruc3 = new Push(processador.pilha, num2);
            //instruc3.executar();

            //Instrucoes instruc6 = new Load(processador.memoria, processador.pilha, "opa");
            //instruc6.executar();

            //Instrucoes instruc7 = new Add(processador.pilha);
            //instruc7.executar();

            //Instrucoes instruc9 = new Push(processador.pilha, num3);
            //instruc9.executar();

            //Instrucoes instruc8 = new EQ(processador.pilha);
            //instruc8.executar();

            //Instrucoes instruc2 = new Print(processador.pilha);
            //instruc2.executar();

            Console.ReadKey();
        }
Example #26
0
        private void initOperators()
        {
            setName(NEG, "-");
            operators[NEG.operatorIndex()] = new[] {
                unary(NEG, TypeTag.INT, TypeTag.INT),
                unary(NEG, TypeTag.LONG, TypeTag.LONG),
                unary(NEG, TypeTag.FLOAT, TypeTag.DOUBLE),
                unary(NEG, TypeTag.DOUBLE, TypeTag.DOUBLE),
            };

            setName(NOT, "!");
            operators[NOT.operatorIndex()] = new[] {
                unary(NOT, TypeTag.BOOLEAN, TypeTag.BOOLEAN)
            };

            setName(COMPL, "~");
            operators[COMPL.operatorIndex()] = new[] {
                unary(COMPL, TypeTag.INT, TypeTag.INT),
                unary(COMPL, TypeTag.LONG, TypeTag.LONG)
            };

            setName(PRE_INC, "++");
            operators[PRE_INC.operatorIndex()] = new[] {
                unary(PRE_INC, TypeTag.INT, TypeTag.INT, LLVMAdd),
                unary(PRE_INC, TypeTag.LONG, TypeTag.LONG, LLVMAdd),
                unary(PRE_INC, TypeTag.FLOAT, TypeTag.FLOAT, LLVMFAdd),
                unary(PRE_INC, TypeTag.DOUBLE, TypeTag.DOUBLE, LLVMFAdd)
            };

            setName(PRE_DEC, "--");
            operators[PRE_DEC.operatorIndex()] = new[] {
                unary(PRE_DEC, TypeTag.INT, TypeTag.INT, LLVMSub),
                unary(PRE_DEC, TypeTag.LONG, TypeTag.LONG, LLVMSub),
                unary(PRE_DEC, TypeTag.FLOAT, TypeTag.FLOAT, LLVMFSub),
                unary(PRE_DEC, TypeTag.DOUBLE, TypeTag.DOUBLE, LLVMFSub)
            };

            setName(POST_INC, "++");
            operators[POST_INC.operatorIndex()] = new[] {
                unary(POST_INC, TypeTag.INT, TypeTag.INT, LLVMAdd),
                unary(POST_INC, TypeTag.LONG, TypeTag.LONG, LLVMAdd),
                unary(POST_INC, TypeTag.FLOAT, TypeTag.FLOAT, LLVMFAdd),
                unary(POST_INC, TypeTag.DOUBLE, TypeTag.DOUBLE, LLVMFAdd)
            };

            setName(POST_DEC, "--");
            operators[POST_DEC.operatorIndex()] = new[] {
                unary(POST_DEC, TypeTag.INT, TypeTag.INT, LLVMSub),
                unary(POST_DEC, TypeTag.LONG, TypeTag.LONG, LLVMSub),
                unary(POST_DEC, TypeTag.FLOAT, TypeTag.FLOAT, LLVMFSub),
                unary(POST_DEC, TypeTag.DOUBLE, TypeTag.DOUBLE, LLVMFSub)
            };

            setName(OR, "||");
            operators[OR.operatorIndex()] = new[] {
                binary(OR, TypeTag.BOOLEAN, TypeTag.BOOLEAN, TypeTag.BOOLEAN, LLVMOr),
            };

            setName(AND, "&&");
            operators[AND.operatorIndex()] = new[] {
                binary(AND, TypeTag.BOOLEAN, TypeTag.BOOLEAN, TypeTag.BOOLEAN, LLVMAnd),
            };

            // Order of combination listing for binary operators matters for correct resolution
            // More assignable types must be listed after less assignable ones,
            // which is the order listed in the TypeTag enum.

            setName(BITOR, "|");
            operators[BITOR.operatorIndex()] = new[] {
                binary(BITOR, TypeTag.BOOLEAN, TypeTag.BOOLEAN, TypeTag.BOOLEAN, LLVMOr),
                binary(BITOR, TypeTag.INT, TypeTag.INT, TypeTag.INT, LLVMOr),
                binary(BITOR, TypeTag.LONG, TypeTag.LONG, TypeTag.LONG, LLVMOr),
            };

            setName(BITXOR, "^");
            operators[BITXOR.operatorIndex()] = new[] {
                binary(BITXOR, TypeTag.BOOLEAN, TypeTag.BOOLEAN, TypeTag.BOOLEAN, LLVMXor),
                binary(BITXOR, TypeTag.INT, TypeTag.INT, TypeTag.INT, LLVMXor),
                binary(BITXOR, TypeTag.LONG, TypeTag.LONG, TypeTag.LONG, LLVMXor),
            };

            setName(BITAND, "&");
            operators[BITAND.operatorIndex()] = new[] {
                binary(BITAND, TypeTag.BOOLEAN, TypeTag.BOOLEAN, TypeTag.BOOLEAN, LLVMAnd),
                binary(BITAND, TypeTag.INT, TypeTag.INT, TypeTag.INT, LLVMAnd),
                binary(BITAND, TypeTag.LONG, TypeTag.LONG, TypeTag.LONG, LLVMAnd),
            };

            setName(EQ, "==");
            operators[EQ.operatorIndex()] = new[] {
                binary(EQ, TypeTag.BOOLEAN, TypeTag.BOOLEAN, TypeTag.BOOLEAN, LLVMICmp, LLVMIntEQ),
                binary(EQ, TypeTag.CHAR, TypeTag.CHAR, TypeTag.BOOLEAN, LLVMICmp, LLVMIntEQ),
                binary(EQ, TypeTag.INT, TypeTag.INT, TypeTag.BOOLEAN, LLVMICmp, LLVMIntEQ),
                binary(EQ, TypeTag.LONG, TypeTag.LONG, TypeTag.BOOLEAN, LLVMICmp, LLVMIntEQ),
                binary(EQ, TypeTag.FLOAT, TypeTag.FLOAT, TypeTag.BOOLEAN, LLVMFCmp, LLVMRealOEQ),
                binary(EQ, TypeTag.DOUBLE, TypeTag.DOUBLE, TypeTag.BOOLEAN, LLVMFCmp, LLVMRealOEQ),
            };

            setName(NEQ, "!=");
            operators[NEQ.operatorIndex()] = new[] {
                binary(NEQ, TypeTag.BOOLEAN, TypeTag.BOOLEAN, TypeTag.BOOLEAN, LLVMICmp, LLVMIntNE),
                binary(NEQ, TypeTag.CHAR, TypeTag.CHAR, TypeTag.BOOLEAN, LLVMICmp, LLVMIntNE),
                binary(NEQ, TypeTag.INT, TypeTag.INT, TypeTag.BOOLEAN, LLVMICmp, LLVMIntNE),
                binary(NEQ, TypeTag.LONG, TypeTag.LONG, TypeTag.BOOLEAN, LLVMICmp, LLVMIntNE),
                binary(NEQ, TypeTag.FLOAT, TypeTag.FLOAT, TypeTag.BOOLEAN, LLVMFCmp, LLVMRealONE),
                binary(NEQ, TypeTag.DOUBLE, TypeTag.DOUBLE, TypeTag.BOOLEAN, LLVMFCmp, LLVMRealONE),
            };

            setName(LT, "<");
            operators[LT.operatorIndex()] = new[] {
                binary(LT, TypeTag.CHAR, TypeTag.CHAR, TypeTag.BOOLEAN, LLVMICmp, LLVMIntULT),
                binary(LT, TypeTag.INT, TypeTag.INT, TypeTag.BOOLEAN, LLVMICmp, LLVMIntSLT),
                binary(LT, TypeTag.LONG, TypeTag.LONG, TypeTag.BOOLEAN, LLVMICmp, LLVMIntSLT),
                binary(LT, TypeTag.FLOAT, TypeTag.FLOAT, TypeTag.BOOLEAN, LLVMFCmp, LLVMRealOLT),
                binary(LT, TypeTag.DOUBLE, TypeTag.DOUBLE, TypeTag.BOOLEAN, LLVMFCmp, LLVMRealOLT),
            };

            setName(GT, ">");
            operators[GT.operatorIndex()] = new[] {
                binary(GT, TypeTag.CHAR, TypeTag.CHAR, TypeTag.BOOLEAN, LLVMICmp, LLVMIntUGT),
                binary(GT, TypeTag.INT, TypeTag.INT, TypeTag.BOOLEAN, LLVMICmp, LLVMIntSGT),
                binary(GT, TypeTag.LONG, TypeTag.LONG, TypeTag.BOOLEAN, LLVMICmp, LLVMIntSGT),
                binary(GT, TypeTag.FLOAT, TypeTag.FLOAT, TypeTag.BOOLEAN, LLVMFCmp, LLVMRealOGT),
                binary(GT, TypeTag.DOUBLE, TypeTag.DOUBLE, TypeTag.BOOLEAN, LLVMFCmp, LLVMRealOGT),
            };

            setName(LE, "<=");
            operators[LE.operatorIndex()] = new[] {
                binary(LE, TypeTag.CHAR, TypeTag.CHAR, TypeTag.BOOLEAN, LLVMICmp, LLVMIntULE),
                binary(LE, TypeTag.INT, TypeTag.INT, TypeTag.BOOLEAN, LLVMICmp, LLVMIntSLE),
                binary(LE, TypeTag.LONG, TypeTag.LONG, TypeTag.BOOLEAN, LLVMICmp, LLVMIntSLE),
                binary(LE, TypeTag.FLOAT, TypeTag.FLOAT, TypeTag.BOOLEAN, LLVMFCmp, LLVMRealOLE),
                binary(LE, TypeTag.DOUBLE, TypeTag.DOUBLE, TypeTag.BOOLEAN, LLVMFCmp, LLVMRealOLE),
            };

            setName(GE, ">=");
            operators[GE.operatorIndex()] = new[] {
                binary(GE, TypeTag.CHAR, TypeTag.CHAR, TypeTag.BOOLEAN, LLVMICmp, LLVMIntUGE),
                binary(GE, TypeTag.INT, TypeTag.INT, TypeTag.BOOLEAN, LLVMICmp, LLVMIntSGE),
                binary(GE, TypeTag.LONG, TypeTag.LONG, TypeTag.BOOLEAN, LLVMICmp, LLVMIntSGE),
                binary(GE, TypeTag.FLOAT, TypeTag.FLOAT, TypeTag.BOOLEAN, LLVMFCmp, LLVMRealOGE),
                binary(GE, TypeTag.DOUBLE, TypeTag.DOUBLE, TypeTag.BOOLEAN, LLVMFCmp, LLVMRealOGE),
            };

            setName(SHL, "<<");
            operators[SHL.operatorIndex()] = new[] {
                binary(SHL, TypeTag.INT, TypeTag.INT, TypeTag.INT, LLVMShl),
                binary(SHL, TypeTag.INT, TypeTag.LONG, TypeTag.INT, LLVMShl),
                binary(SHL, TypeTag.LONG, TypeTag.INT, TypeTag.LONG, LLVMShl),
                binary(SHL, TypeTag.LONG, TypeTag.LONG, TypeTag.LONG, LLVMShl),
            };

            setName(SHR, ">>");
            operators[SHR.operatorIndex()] = new[] {
                binary(SHR, TypeTag.INT, TypeTag.INT, TypeTag.INT, LLVMLShr),
                binary(SHR, TypeTag.INT, TypeTag.LONG, TypeTag.INT, LLVMLShr),
                binary(SHR, TypeTag.LONG, TypeTag.INT, TypeTag.LONG, LLVMLShr),
                binary(SHR, TypeTag.LONG, TypeTag.LONG, TypeTag.LONG, LLVMLShr),
            };

            setName(PLUS, "+");
            operators[PLUS.operatorIndex()] = new[] {
                binary(PLUS, TypeTag.INT, TypeTag.INT, TypeTag.INT, LLVMAdd),
                binary(PLUS, TypeTag.LONG, TypeTag.LONG, TypeTag.LONG, LLVMAdd),
                binary(PLUS, TypeTag.FLOAT, TypeTag.FLOAT, TypeTag.FLOAT, LLVMFAdd),
                binary(PLUS, TypeTag.DOUBLE, TypeTag.DOUBLE, TypeTag.DOUBLE, LLVMFAdd),
            };

            setName(MINUS, "-");
            operators[MINUS.operatorIndex()] = new[] {
                binary(MINUS, TypeTag.INT, TypeTag.INT, TypeTag.INT, LLVMSub),
                binary(MINUS, TypeTag.LONG, TypeTag.LONG, TypeTag.LONG, LLVMSub),
                binary(MINUS, TypeTag.FLOAT, TypeTag.FLOAT, TypeTag.FLOAT, LLVMFSub),
                binary(MINUS, TypeTag.DOUBLE, TypeTag.DOUBLE, TypeTag.DOUBLE, LLVMFSub),
            };

            setName(MUL, "*");
            operators[MUL.operatorIndex()] = new[] {
                binary(MUL, TypeTag.INT, TypeTag.INT, TypeTag.INT, LLVMMul),
                binary(MUL, TypeTag.LONG, TypeTag.LONG, TypeTag.LONG, LLVMMul),
                binary(MUL, TypeTag.FLOAT, TypeTag.FLOAT, TypeTag.FLOAT, LLVMFMul),
                binary(MUL, TypeTag.DOUBLE, TypeTag.DOUBLE, TypeTag.DOUBLE, LLVMFMul),
            };

            setName(DIV, "/");
            operators[DIV.operatorIndex()] = new[] {
                binary(DIV, TypeTag.INT, TypeTag.INT, TypeTag.INT, LLVMSDiv),
                binary(DIV, TypeTag.LONG, TypeTag.LONG, TypeTag.LONG, LLVMSDiv),
                binary(DIV, TypeTag.FLOAT, TypeTag.FLOAT, TypeTag.FLOAT, LLVMFDiv),
                binary(DIV, TypeTag.DOUBLE, TypeTag.DOUBLE, TypeTag.DOUBLE, LLVMFDiv),
            };

            setName(MOD, "%");
            operators[MOD.operatorIndex()] = new[] {
                binary(MOD, TypeTag.INT, TypeTag.INT, TypeTag.INT, LLVMSRem),
                binary(MOD, TypeTag.LONG, TypeTag.LONG, TypeTag.LONG, LLVMSRem),
                binary(MOD, TypeTag.FLOAT, TypeTag.FLOAT, TypeTag.FLOAT, LLVMFRem),
                binary(MOD, TypeTag.DOUBLE, TypeTag.DOUBLE, TypeTag.DOUBLE, LLVMFRem),
            };
        }
Example #27
0
        public override void PostHook(NodeExporter exporter, Transform trans, VGltf.Types.Node gltfNode)
        {
            var go = trans.gameObject;

            var anim = go.GetComponent <Animator>();

            if (anim == null)
            {
                return;
            }

            var extAvatar = new AvatarType();

            var hd    = anim.avatar.humanDescription;
            var extHD = new AvatarType.HumanDescriptionType();

            extHD.UpperArmTwist = hd.upperArmTwist;
            extHD.LowerArmTwist = hd.lowerArmTwist;
            extHD.UpperLegTwist = hd.upperLegTwist;
            extHD.LowerLegTwist = hd.lowerLegTwist;
            extHD.ArmStretch    = hd.armStretch;
            extHD.LegStretch    = hd.legStretch;
            extHD.FeetSpacing   = hd.feetSpacing;

            // Regenerate skeleton by referencing bones to support normalized bones.
            var allNodes = anim.GetComponentsInChildren <Transform>();

            extHD.Skeleton = allNodes.Where(n =>
            {
                return(!(
                           (n.GetComponent <MeshRenderer>() != null) ||
                           (n.GetComponent <SkinnedMeshRenderer>() != null)
                           ));
            }).Select(n =>
            {
                // TODO: Coord
                return(new AvatarType.HumanDescriptionType.SkeletonBone
                {
                    Name = n.name,
                    Position = PrimitiveExporter.AsArray(n.localPosition),
                    Rotation = PrimitiveExporter.AsArray(n.localRotation),
                    Scale = PrimitiveExporter.AsArray(n.localScale),
                });
            }).ToList();

            extHD.Human = hd.human.Select(h =>
            {
                // TODO: Coord
                var extLimit = new AvatarType.HumanDescriptionType.HumanLimit
                {
                    UseDefaultValues = h.limit.useDefaultValues,
                    Min        = PrimitiveExporter.AsArray(h.limit.min),
                    Max        = PrimitiveExporter.AsArray(h.limit.max),
                    Center     = PrimitiveExporter.AsArray(h.limit.center),
                    AxisLength = h.limit.axisLength,
                };

                return(new AvatarType.HumanDescriptionType.HumanBone
                {
                    BoneName = h.boneName,
                    HumanName = h.humanName,
                    Limit = extLimit,
                });
            }).ToList();

            extAvatar.HumanDescription = extHD;

            //
            gltfNode.AddExtension(AvatarType.ExtensionName, extAvatar);

            GE.AddExtensionUsed(exporter.Gltf, AvatarType.ExtensionName);
        }
Example #28
0
 public GroupElement(GE ge)
 {
     this.ge = ge;
 }