コード例 #1
0
        protected override void WriteCore(ResourceWriter writer)
        {
            if (Version > 0x1104190)
            {
                writer.WriteInt32(( int )Flags);
            }

            writer.WriteInt32(( int )Type);
            writer.WriteVector4(AmbientColor);
            writer.WriteVector4(DiffuseColor);
            writer.WriteVector4(SpecularColor);

            switch (Type)
            {
            case LightType.Type1:
                writer.WriteSingle(Field20);
                writer.WriteSingle(Field04);
                writer.WriteSingle(Field08);
                break;

            case LightType.Point:
                writer.WriteSingle(Field10);
                writer.WriteSingle(Field04);
                writer.WriteSingle(Field08);

                if (Flags.HasFlag(LightFlags.Bit2))
                {
                    writer.WriteSingle(AttenuationStart);
                    writer.WriteSingle(AttenuationEnd);
                }
                else
                {
                    writer.WriteSingle(Field60);
                    writer.WriteSingle(Field64);
                    writer.WriteSingle(Field68);
                }
                break;

            case LightType.Spot:
                writer.WriteSingle(Field20);
                writer.WriteSingle(Field08);
                writer.WriteSingle(Field04);
                writer.WriteSingle(AngleInnerCone);
                writer.WriteSingle(AngleOuterCone);
                goto case LightType.Point;
            }
        }
コード例 #2
0
ファイル: Light.cs プロジェクト: EzioArchiveLand/GFD-Studio
        internal override void Write(ResourceWriter writer)
        {
            if (Version > 0x1104190)
            {
                writer.WriteInt32(( int )Flags);
            }

            writer.WriteInt32(( int )Type);
            writer.WriteVector4(Field30);
            writer.WriteVector4(Field40);
            writer.WriteVector4(Field50);

            switch (Type)
            {
            case LightType.Type1:
                writer.WriteSingle(Field20);
                writer.WriteSingle(Field04);
                writer.WriteSingle(Field08);
                break;

            case LightType.Sky:
                writer.WriteSingle(Field10);
                writer.WriteSingle(Field04);
                writer.WriteSingle(Field08);

                if (Flags.HasFlag(LightFlags.Flag2))
                {
                    writer.WriteSingle(Field6C);
                    writer.WriteSingle(Field70);
                }
                else
                {
                    writer.WriteSingle(Field60);
                    writer.WriteSingle(Field64);
                    writer.WriteSingle(Field68);
                }
                break;

            case LightType.Type3:
                writer.WriteSingle(Field20);
                writer.WriteSingle(Field08);
                writer.WriteSingle(Field04);
                writer.WriteSingle(Field74);
                writer.WriteSingle(Field78);
                goto case LightType.Sky;
            }
        }
コード例 #3
0
        protected override void WriteCore(ResourceWriter writer)
        {
            writer.WriteInt32(Count);

            foreach (var property in Values)
            {
                writer.WriteInt32(( int )property.ValueType);
                writer.WriteStringWithHash(Version, property.Name);

                switch (property.ValueType)
                {
                case UserPropertyValueType.Int:
                    writer.WriteInt32(4);
                    writer.WriteInt32(property.GetValue <int>());
                    break;

                case UserPropertyValueType.Float:
                    writer.WriteInt32(4);
                    writer.WriteSingle(property.GetValue <float>());
                    break;

                case UserPropertyValueType.Bool:
                    writer.WriteInt32(1);
                    writer.WriteBoolean(property.GetValue <bool>());
                    break;

                case UserPropertyValueType.String:
                {
                    var value = property.GetValue <string>();
                    writer.WriteInt32(value.Length + 1);
                    writer.WriteStringRaw(value);
                }
                break;

                case UserPropertyValueType.ByteVector3:
                    writer.WriteInt32(3);
                    writer.WriteByteVector3(property.GetValue <ByteVector3>());
                    break;

                case UserPropertyValueType.ByteVector4:
                    writer.WriteInt32(4);
                    writer.WriteByteVector4(property.GetValue <ByteVector4>());
                    break;

                case UserPropertyValueType.Vector3:
                    writer.WriteInt32(12);
                    writer.WriteVector3(property.GetValue <Vector3>());
                    break;

                case UserPropertyValueType.Vector4:
                    writer.WriteInt32(16);
                    writer.WriteVector4(property.GetValue <Vector4>());
                    break;

                case UserPropertyValueType.ByteArray:
                {
                    var value = property.GetValue <byte[]>();
                    writer.WriteInt32(value.Length);
                    writer.WriteBytes(value);
                }
                break;

                default:
                    throw new InvalidOperationException($"Unknown node property type: {property.ValueType}");
                }
            }
        }