예제 #1
0
        public bool loadFrom(BinStore s)
        {
            s.prepare();
            bool ok = s.prepare_nested(); // will update the file size left

            if (s.end_encountered())
            {
                return(ok);
            }
            string _name;

            while (s.nesting_name(out _name))
            {
                s.nest_in();
                if ("Trick" == _name)
                {
                    GeometryModifiers entry = new GeometryModifiers();
                    geometry_mods.Add(entry);
                    ok &= entry.loadFrom(s);
                }
                else if ("Texture" == _name)
                {
                    var entry = new TextureModifiers();
                    texture_mods.Add(entry);
                    ok &= entry.loadFrom(s);
                }
                else
                {
                    Debug.Assert(false, "unknown field referenced.");
                }

                s.nest_out();
            }
            Debug.LogFormat("Loaded {0} GeomMods and {1} TexMods", geometry_mods.Count, texture_mods.Count);
            Debug.Assert(ok);
            return(ok);
        }
예제 #2
0
        private void setupTrick(GeometryModifiers gmod)
        {
            if (rgbAreZero(gmod.node.TintColor0))
            {
                gmod.node.TintColor0 = new Color32(255, 255, 255, 255);
            }
            if (rgbAreZero(gmod.node.TintColor1))
            {
                gmod.node.TintColor1 = new Color32(255, 255, 255, 255);
            }
            gmod.AlphaRef /= 255.0f;
            if (gmod.ObjTexBias != 0.0f)
            {
                gmod.node._TrickFlags |= TrickFlags.TexBias;
            }
            if (gmod.AlphaRef != 0.0f)
            {
                gmod.node._TrickFlags |= TrickFlags.AlphaRef;
            }
            if (gmod.FogDist.x != 0.0f || gmod.FogDist.y != 0.0f)
            {
                gmod.node._TrickFlags |= TrickFlags.FogHasStartAndEnd;
            }
            if (gmod.ShadowDist != 0.0f)
            {
                gmod.node._TrickFlags |= TrickFlags.CastShadow;
            }
            if (gmod.NightGlow.x != 0.0f || gmod.NightGlow.y != 0.0f)
            {
                gmod.node._TrickFlags |= TrickFlags.NightGlow;
            }
            if (gmod.node.ScrollST0.x != 0.0f || gmod.node.ScrollST0.y != 0.0f)
            {
                gmod.node._TrickFlags |= TrickFlags.ScrollST0;
            }
            if (gmod.node.ScrollST1.x != 0.0f || gmod.node.ScrollST1.y != 0.0f)
            {
                gmod.node._TrickFlags |= TrickFlags.ScrollST1;
            }
            if (gmod.StAnim.Count != 0)
            {
                //        if(setStAnim(&a1->StAnim.front()))
                if (setStAnim(gmod.StAnim[0]))
                {
                    gmod.node._TrickFlags |= TrickFlags.STAnimate;
                }
            }

            if (((GroupFlags)gmod.GroupFlags & GroupFlags.VisTray) != 0)
            {
                gmod.ObjFlags |= 0x400;
            }
            if (gmod.name.Length == 0)
            {
                Debug.Log("No name in trick");
            }
            string lower_name = gmod.name.ToLower();

            if (g_tricks_string_hash_tab.ContainsKey(lower_name))
            {
                Debug.Log("duplicate model trick!");
                return;
            }
            g_tricks_string_hash_tab[lower_name] = gmod;
        }