Esempio n. 1
0
        //

        public override void Open(HSDReader Reader)
        {
            var modelGroupOffset = Reader.ReadUInt32();
            var modelGroupCount  = Reader.ReadInt32();
            var unk1GroupOffset  = Reader.ReadUInt32();
            var unk1GroupCount   = Reader.ReadInt32();
            var unk2GroupOffset  = Reader.ReadUInt32();
            var unk2GroupCount   = Reader.ReadInt32();
            var lightGroupOffset = Reader.ReadUInt32();
            var lightGroupCount  = Reader.ReadInt32();
            var unk4GroupOffset  = Reader.ReadUInt32();
            var unk4GroupCount   = Reader.ReadInt32();
            var unk5GroupOffset  = Reader.ReadUInt32();
            var unk5GroupCount   = Reader.ReadInt32();

            for (int i = 0; i < modelGroupCount; i++)
            {
                Reader.Seek(modelGroupOffset + (uint)(12 * i));
                SBM_GrMapModelGroup mg = new SBM_GrMapModelGroup();
                mg.Open(Reader);
                ModelGroups.Add(mg);
            }

            for (int i = 0; i < modelGroupCount; i++)
            {
                Reader.Seek(lightGroupOffset + (uint)(i * 8));
                SBM_GrMapLight mg = new SBM_GrMapLight();
                mg.Open(Reader);
                Lights.Add(mg);
            }
        }
Esempio n. 2
0
        private Stage(BinaryReader br)
        {
            var mainSection = MainGeometrySection.Read(br);

            ObjectsGroup[] objectsGroups =
            {
                ObjectsGroup.Read(mainSection.Group1Pointer, br),
                ObjectsGroup.Read(mainSection.Group2Pointer, br),
                ObjectsGroup.Read(mainSection.Group3Pointer, br),
                ObjectsGroup.Read(mainSection.Group4Pointer, br)
            };

            _modelGroups = new ModelGroups(
                ModelGroup.Read(objectsGroups[0].objectListPointer, br),
                ModelGroup.Read(objectsGroups[1].objectListPointer, br),
                ModelGroup.Read(objectsGroups[2].objectListPointer, br),
                ModelGroup.Read(objectsGroups[3].objectListPointer, br)
                );

            (Textures, UsingTexturePages, Width, Height) = ReadTexture(mainSection.TexturePointer, br);
            Scenario = Memory.Encounters.Scenario;

            if (Textures == null || Textures.All(x => x.Value == null))
            {
                return;
            }

            //TextureHandler t = Textures.First(x => x.Value != null).Value;
            //Width = t.Width;
            //Height = t.Height;

            //Seems most animations skip the first frame. Can override with skip:0
            //Count defaults to rows * cols. Can override this to be less than that.
            //public Animation(int width, int height, byte clut, byte texturePage, byte cols, byte rows, ModelGroups _mg, int Count = 0, int x = 0, int y =0, int skip =1)
            if (Scenario == 8)//need to update the source texture with the animation frames or add new vertices and uvs because first frame is 3x larger
            {
                _textureAnimations = new List <TextureAnimation>
                {
                    new TextureAnimation(Textures[1], 32, 96, 2, 6, 1, skip: 3, y: 128)
                }
            }
Esempio n. 3
0
            public Animation(int width, int height, byte texturePage, byte cols, byte rows, ModelGroups mg,
                             int count = 0, int x = 0, int y = 0, int skip = 1, bool topDown = false, bool reversible = false,
                             TimeSpan?totalFrameTime = null, TimeSpan?pauseAtStart = null)
            {
                _totalFrameTime = totalFrameTime ?? TimeSpan.FromMilliseconds(100);
                _pauseAtStart   = pauseAtStart ?? TimeSpan.Zero;
                _topDown        = topDown;
                _reversible     = reversible;
                _width          = width;
                _height         = height;
                _cols           = cols;
                _rows           = rows;
                _frames         = count > 0 && count <= _cols * _rows ? count : _cols * _rows;
                _skip           = skip;
                var rectangle            = new Rectangle(x, y, width, height);
                IEnumerable <Model> temp = (from modelGroup in mg
                                            from model in modelGroup
                                            select model).Where(i => i.Quads != null && i.Triangles != null && i.Vertices != null).ToArray();

                _qs = (from model in temp
                       from q in model.Quads
                       select q).Where(q => rectangle.Contains(q.Rectangle()) && q.TexturePage == texturePage).ToList();
                _ts = (from model in temp
                       from q in model.Triangles
                       select q).Where(q => rectangle.Contains(q.Rectangle()) && q.TexturePage == texturePage).ToList();
            }
Esempio n. 4
0
            public Animation(int width, int height, byte clut, byte texturePage, byte cols, byte rows, int texWidth, ModelGroups _mg, int count = 0, int x = 0, int y = 0)
            {
                Width       = width;
                Height      = height;
                Clut        = clut;
                TexturePage = texturePage;
                Cols        = cols;
                Rows        = rows;
                Frames      = count > 0 && count <= Cols * Rows ? count: Cols * Rows;
                //start = CalculateUV(Vector2.Zero, texturePage);
                Rectangle = new Rectangle(x, y, width, height);
                IEnumerable <Model> temp = (from modelgroups in _mg
                                            from model in modelgroups
                                            select model).Where(i => i.quads != null && i.triangles != null && i.vertices != null);

                qs = (from model in temp
                      from q in model.quads
                      select q).Where(q => Rectangle.Contains(q.Rectangle) && q.TexturePage == texturePage).ToList();
                ts = (from model in temp
                      from q in model.triangles
                      select q).Where(q => Rectangle.Contains(q.Rectangle) && q.TexturePage == texturePage).ToList();
            }