Ejemplo n.º 1
0
        public override bool OnInitialize()
        {
            //Read common header
            base.OnInitialize();

            //Set defaults
            _colors = new List <RGBAPixel>();

            //Read header values
            _flags = (SCN0FogFlags)Data->_flags;
            _type  = (FogType)(int)Data->_type;

            //Don't bother reading data if the entry is null
            if (_name == "<null>")
            {
                return(false);
            }

            //Read fog color
            ReadColors(
                (uint)_flags,
                (uint)SCN0FogFlags.FixedColor,
                ref _solidColor,
                ref _colors,
                FrameCount,
                Data->_color.Address,
                ref _constantColor,
                ref _numEntries);

            return(false);
        }
Ejemplo n.º 2
0
        protected override bool OnInitialize()
        {
            base.OnInitialize();

            starts = new List <SCN0Keyframe>();
            ends   = new List <SCN0Keyframe>();
            colors = new List <RGBAPixel>();

            flags   = (SCN0FogFlags)Data->_flags;
            density = Data->_density;
            if (Name != "<null>")
            {
                if (flags.HasFlag(SCN0FogFlags.FixedStart))
                {
                    starts.Add(new Vector3(Data->_start, 0, 0));
                }
                else
                {
                    SCN0KeyframeStruct *addr = Data->startKeyframes->Data;
                    for (int i = 0; i < Data->startKeyframes->_numFrames; i++)
                    {
                        starts.Add(*addr++);
                    }
                }
                if (flags.HasFlag(SCN0FogFlags.FixedEnd))
                {
                    ends.Add(new Vector3(Data->_end, 0, 0));
                }
                else
                {
                    SCN0KeyframeStruct *addr = Data->endKeyframes->Data;
                    for (int i = 0; i < Data->endKeyframes->_numFrames; i++)
                    {
                        ends.Add(*addr++);
                    }
                }
                if (flags.HasFlag(SCN0FogFlags.FixedColor))
                {
                    colors.Add(Data->_color);
                }
                else
                {
                    RGBAPixel *addr = Data->colorEntries;
                    for (int i = 0; i <= ((SCN0Node)Parent.Parent).FrameCount; i++)
                    {
                        colors.Add(*addr++);
                    }
                }
            }

            return(false);
        }
Ejemplo n.º 3
0
        public override bool OnInitialize()
        {
            base.OnInitialize();

            _colors = new List <ARGBPixel>();

            _startKeys = new KeyframeArray(FrameCount + 1);
            _endKeys   = new KeyframeArray(FrameCount + 1);

            flags = (SCN0FogFlags)Data->_flags;
            type  = Data->_type;
            if (Name != "<null>")
            {
                if (flags.HasFlag(SCN0FogFlags.FixedStart))
                {
                    _startKeys[0] = Data->_start;
                }
                else if (!_replaced)
                {
                    DecodeFrames(_startKeys, Data->startKeyframes);
                }

                if (flags.HasFlag(SCN0FogFlags.FixedEnd))
                {
                    _endKeys[0] = Data->_end;
                }
                else if (!_replaced)
                {
                    DecodeFrames(_endKeys, Data->endKeyframes);
                }

                if (flags.HasFlag(SCN0FogFlags.FixedColor))
                {
                    _constant   = true;
                    _numEntries = 0;
                    _solidColor = (ARGBPixel)Data->_color;
                }
                else
                {
                    _constant   = false;
                    _numEntries = FrameCount + 1;
                    RGBAPixel *addr = Data->colorEntries;
                    for (int i = 0; i <= FrameCount; i++)
                    {
                        _colors.Add((ARGBPixel)(*addr++));
                    }
                }
            }

            return(false);
        }
Ejemplo n.º 4
0
        public override void OnRebuild(VoidPtr address, int length, bool force)
        {
            base.OnRebuild(address, length, force);

            _matchAddr = null;

            if (_name == "<null>")
            {
                return;
            }

            SCN0Fog *header = (SCN0Fog *)address;

            int flags = 0;

            for (int i = 0; i < 2; i++)
            {
                _dataAddrs[0] += EncodeKeyframes(
                    KeyArrays[i],
                    _dataAddrs[0],
                    header->_start.Address + i * 4,
                    ref flags,
                    (int)SCN0FogFlags.FixedStart + i * 0x20);
            }

            _dataAddrs[1] += WriteColors(
                ref flags,
                (int)SCN0FogFlags.FixedColor,
                _solidColor,
                _colors,
                _constantColor,
                FrameCount,
                header->_color.Address,
                ref _matchAddr,
                _match == null ? null : _match._matchAddr,
                (RGBAPixel *)_dataAddrs[1]);

            _flags         = (SCN0FogFlags)flags;
            header->_flags = (byte)flags;
            header->_type  = (int)_type;
        }
Ejemplo n.º 5
0
        public override void OnRebuild(VoidPtr address, int length, bool force)
        {
            base.OnRebuild(address, length, force);

            _matchAddr = null;

            SCN0Fog *header = (SCN0Fog *)address;

            flags = SCN0FogFlags.None;
            if (_colors.Count > 1)
            {
                _matchAddr = lightAddr;
                if (_match == null)
                {
                    *((bint *)header->_color.Address) = (int)lightAddr - (int)header->_color.Address;
                    for (int i = 0; i <= ((SCN0Node)Parent.Parent).FrameCount; i++)
                    {
                        if (i < _colors.Count)
                        {
                            *lightAddr++ = (RGBAPixel)_colors[i];
                        }
                        else
                        {
                            *lightAddr++ = new RGBAPixel();
                        }
                    }
                }
                else
                {
                    *((bint *)header->_color.Address) = (int)_match._matchAddr - (int)header->_color.Address;
                }
            }
            else
            {
                flags         |= SCN0FogFlags.FixedColor;
                header->_color = (RGBAPixel)_solidColor;
            }
            if (_startKeys._keyCount > 1)
            {
                *((bint *)header->_start.Address) = (int)keyframeAddr - (int)header->_start.Address;
                EncodeFrames(_startKeys, ref keyframeAddr);
            }
            else
            {
                flags |= SCN0FogFlags.FixedStart;
                if (_startKeys._keyCount == 1)
                {
                    header->_start = _startKeys._keyRoot._next._value;
                }
                else
                {
                    header->_start = 0;
                }
            }
            if (_endKeys._keyCount > 1)
            {
                *((bint *)header->_end.Address) = (int)keyframeAddr - (int)header->_end.Address;
                EncodeFrames(_endKeys, ref keyframeAddr);
            }
            else
            {
                flags |= SCN0FogFlags.FixedEnd;
                if (_endKeys._keyCount == 1)
                {
                    header->_end = _endKeys._keyRoot._next._value;
                }
                else
                {
                    header->_end = 0;
                }
            }

            header->_flags = (byte)flags;
            header->_type  = type;
        }
Ejemplo n.º 6
0
        protected internal override void OnRebuild(VoidPtr address, int length, bool force)
        {
            base.OnRebuild(address, length, force);

            SCN0Fog *header = (SCN0Fog *)address;

            if (colors.Count > 1)
            {
                *((bint *)header->_color.Address) = (int)lightAddr - (int)header->_color.Address;
                for (int i = 0; i <= ((SCN0Node)Parent.Parent).FrameCount; i++)
                {
                    if (i < colors.Count)
                    {
                        *lightAddr++ = colors[i];
                    }
                    else
                    {
                        *lightAddr++ = new RGBAPixel();
                    }
                }
                flags &= ~SCN0FogFlags.FixedColor;
            }
            else
            {
                flags |= SCN0FogFlags.FixedColor;
                if (colors.Count == 1)
                {
                    header->_color = colors[0];
                }
                else
                {
                    header->_color = new RGBAPixel();
                }
            }
            if (starts.Count > 1)
            {
                *((bint *)header->_start.Address) = (int)keyframeAddr - (int)header->_start.Address;
                ((SCN0KeyframesHeader *)keyframeAddr)->_numFrames = (ushort)starts.Count;
                SCN0KeyframeStruct *addr = ((SCN0KeyframesHeader *)keyframeAddr)->Data;
                for (int i = 0; i < starts.Count; i++)
                {
                    *addr++ = starts[i];
                }
                keyframeAddr += 4 + starts.Count * 12;
                flags        &= ~SCN0FogFlags.FixedStart;
            }
            else
            {
                flags |= SCN0FogFlags.FixedStart;
                if (starts.Count == 1)
                {
                    header->_start = starts[0]._value;
                }
                else
                {
                    header->_start = 0;
                }
            }
            if (ends.Count > 1)
            {
                *((bint *)header->_end.Address) = (int)keyframeAddr - (int)header->_end.Address;
                ((SCN0KeyframesHeader *)keyframeAddr)->_numFrames = (ushort)ends.Count;
                SCN0KeyframeStruct *addr = ((SCN0KeyframesHeader *)keyframeAddr)->Data;
                for (int i = 0; i < ends.Count; i++)
                {
                    *addr++ = ends[i];
                }
                keyframeAddr += 4 + ends.Count * 12;
                flags        &= ~SCN0FogFlags.FixedEnd;
            }
            else
            {
                flags |= SCN0FogFlags.FixedEnd;
                if (ends.Count == 1)
                {
                    header->_end = ends[0]._value;
                }
                else
                {
                    header->_end = 0;
                }
            }

            header->_flags   = (byte)flags;
            header->_density = density;
        }
Ejemplo n.º 7
0
        public override void OnRebuild(VoidPtr address, int length, bool force)
        {
            base.OnRebuild(address, length, force);

            _matchAddr = null;

            SCN0Fog* header = (SCN0Fog*)address;

            flags = SCN0FogFlags.None;
            if (_colors.Count > 1)
            {
                _matchAddr = lightAddr;
                if (_match == null)
                {
                    *((bint*)header->_color.Address) = (int)lightAddr - (int)header->_color.Address;
                    for (int i = 0; i <= ((SCN0Node)Parent.Parent).FrameCount; i++)
                        if (i < _colors.Count)
                            *lightAddr++ = (RGBAPixel)_colors[i];
                        else
                            *lightAddr++ = new RGBAPixel();
                }
                else
                    *((bint*)header->_color.Address) = (int)_match._matchAddr - (int)header->_color.Address;
            }
            else
            {
                flags |= SCN0FogFlags.FixedColor;
                header->_color = (RGBAPixel)_solidColor;
            }
            if (_startKeys._keyCount > 1)
            {
                *((bint*)header->_start.Address) = (int)keyframeAddr - (int)header->_start.Address;
                EncodeFrames(_startKeys, ref keyframeAddr);
            }
            else
            {
                flags |= SCN0FogFlags.FixedStart;
                if (_startKeys._keyCount == 1)
                    header->_start = _startKeys._keyRoot._next._value;
                else
                    header->_start = 0;
            }
            if (_endKeys._keyCount > 1)
            {
                *((bint*)header->_end.Address) = (int)keyframeAddr - (int)header->_end.Address;
                EncodeFrames(_endKeys, ref keyframeAddr);
            }
            else
            {
                flags |= SCN0FogFlags.FixedEnd;
                if (_endKeys._keyCount == 1)
                    header->_end = _endKeys._keyRoot._next._value;
                else
                    header->_end = 0;
            }

            header->_flags = (byte)flags;
            header->_type = type;
        }
Ejemplo n.º 8
0
        public override bool OnInitialize()
        {
            base.OnInitialize();

            _colors = new List<ARGBPixel>();

            _startKeys = new KeyframeArray(FrameCount + 1);
            _endKeys = new KeyframeArray(FrameCount + 1);

            flags = (SCN0FogFlags)Data->_flags;
            type = Data->_type;
            if (Name != "<null>")
            {
                if (flags.HasFlag(SCN0FogFlags.FixedStart))
                    _startKeys[0] = Data->_start;
                else if (!_replaced)
                    DecodeFrames(_startKeys, Data->startKeyframes);

                if (flags.HasFlag(SCN0FogFlags.FixedEnd))
                    _endKeys[0] = Data->_end;
                else if (!_replaced)
                    DecodeFrames(_endKeys, Data->endKeyframes);

                if (flags.HasFlag(SCN0FogFlags.FixedColor))
                {
                    _constant = true;
                    _numEntries = 0;
                    _solidColor = (ARGBPixel)Data->_color;
                }
                else
                {
                    _constant = false;
                    _numEntries = FrameCount + 1;
                    RGBAPixel* addr = Data->colorEntries;
                    for (int i = 0; i <= FrameCount; i++)
                        _colors.Add((ARGBPixel)(*addr++));
                }
            }

            return false;
        }