Пример #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Color4Key"/> class.
        /// </summary>
        /// <param name="reader">The reader.</param>
        /// <param name="type">The type.</param>
        /// <exception cref="Exception">Invalid eKeyType!</exception>
        public Color4Key(BinaryReader reader, eKeyType type) : base(reader, type)
		{
			this.Time = reader.ReadSingle();
			if (type < eKeyType.LINEAR_KEY || type > eKeyType.TBC_KEY)
			{
				throw new Exception("Invalid eKeyType!");
			}
			this.Value = reader.ReadColor4();
			if (type == eKeyType.QUADRATIC_KEY)
			{
				this.Forward = reader.ReadColor4();
				this.Backward = reader.ReadColor4();
			}
		}
Пример #2
0
        public new void LoadFrom(Stream stream)
        {
            base.LoadFrom(stream);

            BinaryReader reader = new BinaryReader(stream);
            m_Sprite = new PPtr<Sprite>(stream, file);
            m_Color = reader.ReadColor4();
        }
Пример #3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="NiColorExtraData" /> class.
        /// </summary>
        /// <param name="file">The file.</param>
        /// <param name="reader">The reader.</param>
        public NiColorExtraData(NiFile file, BinaryReader reader) : base(file, reader)
		{
			this.Data = reader.ReadColor4();
		}
Пример #4
0
        static void ReadMOCV2(BinaryReader br, WMOGroup group, uint size)
        {
            // Vertex colors, 4 bytes per vertex (BGRA), for WMO groups using indoor lighting.
            group.VertexColors2 = new Color4[size / 4];

            for (int i = 0; i < group.VertexColors2.Length; i++)
            {
                group.VertexColors2[i] = br.ReadColor4();
            }
        }
Пример #5
0
        static void ReadMFOG(BinaryReader br, WMORoot wmo, uint size)
        {
            wmo.Fogs = new Fog[size/48];

            for (int i = 0; i < wmo.Fogs.Length; i++)
            {
                var fog = new Fog
                              {
                                  Flags = (FogFlags)br.ReadUInt32(),
                                  Position = br.ReadVector3(),
                                  Start = br.ReadSingle(),
                                  End = br.ReadSingle(),
                                  FogInfo_FOG = new FogInfo
                                                 {
                                                     End = br.ReadSingle(),
                                                     StartScalar = br.ReadSingle(),
                                                     Color = br.ReadColor4()
                                                 },
                                  FogInfo_UWFOG = new FogInfo
                                                 {
                                                     End = br.ReadSingle(),
                                                     StartScalar = br.ReadSingle(),
                                                     Color = br.ReadColor4()
                                                 }
                              };

                wmo.Fogs[i] = fog;
            }
        }
Пример #6
0
        static void ReadMODD(BinaryReader br, WMORoot wmo, uint size)
        {
            // Why oh why is wmo.Header.DoodadCount wrong sometimes
            // 40 is the size of DoodadDefinition
            wmo.DoodadDefinitions = new DoodadDefinition[size / 40];

            for (var i = 0; i < wmo.DoodadDefinitions.Length; i++)
            {
                var dd = new DoodadDefinition
                             {
                                 NameIndex = br.ReadInt32(),
                                 Position = br.ReadVector3(),
                                 Rotation = br.ReadQuaternion(),
                                 Scale = br.ReadSingle(),
                                 Color = br.ReadColor4()
                             };

                if (dd.NameIndex != -1)
                {
                    if(!wmo.DoodadFiles.TryGetValue(dd.NameIndex, out dd.FilePath))
                    {
                        dd.FilePath = "";
                        log.Error(String.Format("Doodad File Path for index: {0} missing from the Dictionary!", dd.NameIndex));
                    }
                }

                wmo.DoodadDefinitions[i] = dd;
            }
        }
Пример #7
0
        static void ReadMOLT(BinaryReader br, WMORoot wmo)
        {
            wmo.LightInfo = new LightInformation[wmo.Header.LightCount];

            for (int i = 0; i < wmo.LightInfo.Length; i++)
            {
                var light = new LightInformation
                                {
                                    Byte_1 = br.ReadByte(),
                                    Byte_2 = br.ReadByte(),
                                    Byte_3 = br.ReadByte(),
                                    Byte_4 = br.ReadByte(),
                                    Color = br.ReadColor4(),
                                    Position = br.ReadVector3(),
                                    Intensity = br.ReadSingle(),
                                    AttenStart = br.ReadSingle(),
                                    AttenEnd = br.ReadSingle(),
                                    Float_4 = br.ReadSingle(),
                                    Float_5 = br.ReadSingle(),
                                    Float_6 = br.ReadSingle(),
                                    Float_7 = br.ReadSingle()
                                };

                //FixVector3(ref light.position);

                wmo.LightInfo[i] = light;
            }
        }
Пример #8
0
        static void ReadMOMT(BinaryReader br, WMORoot wmo)
        {
            wmo.Materials = new Material[wmo.Header.TextureCount];

            for (int i = 0; i < wmo.Materials.Length; i++)
            {
                var mt = new Material
                             {
                                 Flags = (MaterialFlags)br.ReadUInt32(),
                                 Int_1 = br.ReadUInt32(),
                                 BlendMode = br.ReadInt32(),
                                 TextureNameStart = br.ReadInt32(),
                                 SidnColor = br.ReadColor4(),
                                 FrameSidnColor = br.ReadColor4(),
                                 TextureNameEnd = br.ReadInt32(),
                                 DiffColor = br.ReadColor4(),
                                 GroundType = br.ReadInt32(),
                                 Float_1 = br.ReadSingle(),
                                 Float_2 = br.ReadSingle(),
                                 Int_2 = br.ReadInt32(),
                                 Int_3 = br.ReadInt32(),
                                 Int_4 = br.ReadInt32()
                             };

                // these 2 are set in RAM in the client to the associated HTEXTUREs
                br.ReadUInt32();// 0x38
                br.ReadUInt32();// 0x3C

                wmo.Materials[i] = mt;

                //if (mt.Flags != 0)
                    //Console.WriteLine();
            }
        }
Пример #9
0
        /// <summary>
        /// Reads the header for the root file
        /// </summary>
        static void ReadMOHD(BinaryReader br, WMORoot wmo)
        {
            wmo.Header.TextureCount = br.ReadUInt32();
            wmo.Header.GroupCount = br.ReadUInt32();
            wmo.Header.PortalCount = br.ReadUInt32();
            wmo.Header.LightCount = br.ReadUInt32();
            wmo.Header.ModelCount = br.ReadUInt32();
            wmo.Header.DoodadCount = br.ReadUInt32();
            wmo.Header.DoodadSetCount = br.ReadUInt32();

            wmo.Header.AmbientColor = br.ReadColor4();
            wmo.Header.WMOId = br.ReadUInt32();

            wmo.Header.BoundingBox = new BoundingBox(br.ReadWMOVector3(), br.ReadWMOVector3());

            wmo.Header.Flags = (WMORootHeaderFlags)br.ReadUInt32();

            wmo.Groups = new WMOGroup[wmo.Header.GroupCount];
        }
Пример #10
0
        /// <summary>
        /// Initializes a new instance of the <see cref="NiGeometryData" /> class.
        /// </summary>
        /// <param name="file">The file.</param>
        /// <param name="reader">The reader.</param>
        public NiGeometryData(NiFile file, BinaryReader reader) : base(file, reader)
		{
			if (base.Version >= eNifVersion.VER_10_2_0_0)
			{
				this.Unkown1 = reader.ReadUInt32();
			}
			
			this.NumVertices = (uint)reader.ReadUInt16();
			if (base.Version >= eNifVersion.VER_10_1_0_0)
			{
				this.KeepFlags = reader.ReadByte();
				this.CompressFlags = reader.ReadByte();
			}
			
			this.HasVertices = reader.ReadBoolean(Version);
			if (this.HasVertices)
			{
				this.Vertices = new Vector3[this.NumVertices];
				int num = 0;
				while ((long)num < (long)((ulong)this.NumVertices))
				{
					this.Vertices[num] = reader.ReadVector3();
					num++;
				}
			}
			
			int numUvSets = 0;
			if (base.Version >= eNifVersion.VER_10_0_1_0)
			{
				numUvSets = (int)reader.ReadByte();
				this.TSpaceFlag = reader.ReadByte();
			}
			
			this.HasNormals = reader.ReadBoolean(Version);
			if (this.HasNormals)
			{
				this.Normals = new Vector3[this.NumVertices];
				int num3 = 0;
				while ((long)num3 < (long)((ulong)this.NumVertices))
				{
					this.Normals[num3] = reader.ReadVector3();
					num3++;
				}
			}
			if (base.Version >= eNifVersion.VER_10_1_0_0)
			{
				this.Binormals = new Vector3[this.NumVertices];
				this.Tangents = new Vector3[this.NumVertices];
				if (this.HasNormals && (this.TSpaceFlag & 240) != 0)
				{
					int num4 = 0;
					while ((long)num4 < (long)((ulong)this.NumVertices))
					{
						this.Binormals[num4] = reader.ReadVector3();
						num4++;
					}
					int num5 = 0;
					while ((long)num5 < (long)((ulong)this.NumVertices))
					{
						this.Tangents[num5] = reader.ReadVector3();
						num5++;
					}
				}
			}
			
			this.Center = reader.ReadVector3();
			this.Radius = reader.ReadSingle();
			
			this.HasVertexColors = reader.ReadBoolean(Version);
			if (this.HasVertexColors)
			{
				this.VertexColors = new Color4[this.NumVertices];
				int num6 = 0;
				while ((long)num6 < (long)((ulong)this.NumVertices))
				{
					this.VertexColors[num6] = reader.ReadColor4();
					num6++;
				}
			}
			if (base.Version <= eNifVersion.VER_4_2_2_0)
			{
				numUvSets = (int)reader.ReadByte();
				this.TSpaceFlag = reader.ReadByte();
			}
			if (base.Version <= eNifVersion.VER_4_0_0_2)
			{
				this.HasUV = reader.ReadBoolean(Version);
			}
			int num7;
			if (base.Version < eNifVersion.VER_20_2_0_7 || this.File.Header.UserVersion != 1u)
			{
				num7 = (numUvSets & 63);
			}
			else
			{
				num7 = (numUvSets & 1);
			}
			this.UVSets = new Vector2[num7][];
			for (int i = 0; i < num7; i++)
			{
				this.UVSets[i] = new Vector2[this.NumVertices];
				int num8 = 0;
				while ((long)num8 < (long)((ulong)this.NumVertices))
				{
					this.UVSets[i][num8] = reader.ReadVector2();
					num8++;
				}
			}
			if (base.Version >= eNifVersion.VER_10_0_1_0)
			{
				this.ConsistencyFlags = reader.ReadUInt16();
			}
			if (base.Version >= eNifVersion.VER_20_0_0_4)
			{
				this.AdditionalDataID = reader.ReadUInt32();
			}
		}
Пример #11
0
        static void ReadMODD(BinaryReader br, WMORoot wmo, uint size)
        {
            // Why oh why is wmo.Header.DoodadCount wrong sometimes
            // 40 is the size of DoodadDefinition
            wmo.DoodadDefinitions = new DoodadDefinition[size / 40];

            for (var i = 0; i < wmo.DoodadDefinitions.Length; i++)
            {
                var dd = new DoodadDefinition
                             {
                                 NameIndex = br.ReadInt32(),
                                 Position = br.ReadWMOVector3(),
                                 Rotation = br.ReadQuaternion(),
                                 Scale = br.ReadSingle(),
                                 Color = br.ReadColor4()
                             };

                if (dd.NameIndex != -1)
                {
                    dd.FilePath = wmo.DoodadFiles[dd.NameIndex];
                }

                wmo.DoodadDefinitions[i] = dd;
            }
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="NiParticleSystemController" /> class.
        /// </summary>
        /// <param name="file">The file.</param>
        /// <param name="reader">The reader.</param>
        public NiParticleSystemController(NiFile file, BinaryReader reader) : base(file, reader)
		{
			if (base.Version <= eNifVersion.VER_3_1)
			{
				this.OldSpeed = reader.ReadUInt32();
			}
			if (base.Version >= eNifVersion.VER_3_3_0_13)
			{
				this.Speed = reader.ReadSingle();
			}
			this.RandomSpeed = reader.ReadSingle();
			this.VerticalDirection = reader.ReadSingle();
			this.VerticalAngle = reader.ReadSingle();
			this.HorizontalDirection = reader.ReadSingle();
			this.HorizontalAngle = reader.ReadSingle();
			this.UnkownNormal = reader.ReadVector3();
			this.UnkownColor = reader.ReadColor4();
			this.Size = reader.ReadSingle();
			this.EmitStartTime = reader.ReadSingle();
			this.EmitStopTime = reader.ReadSingle();
			if (base.Version >= eNifVersion.VER_4_0_0_2)
			{
				this.UnkownByte = reader.ReadByte();
			}
			if (base.Version <= eNifVersion.VER_3_1)
			{
				this.OldEmitRate = reader.ReadUInt32();
			}
			if (base.Version >= eNifVersion.VER_3_3_0_13)
			{
				this.EmitRate = reader.ReadSingle();
			}
			this.Lifetime = reader.ReadSingle();
			this.LifetimeRandom = reader.ReadSingle();
			if (base.Version >= eNifVersion.VER_4_0_0_2)
			{
				this.EmitFlags = reader.ReadUInt16();
			}
			this.StartRandom = new Vector3(reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle());
			this.Emitter = new NiRef<NiObject>(reader);
			if (base.Version >= eNifVersion.VER_4_0_0_2)
			{
				reader.ReadUInt16();
				reader.ReadSingle();
				reader.ReadUInt32();
				reader.ReadUInt32();
				reader.ReadUInt16();
			}
			if (base.Version <= eNifVersion.VER_3_1)
			{
				this.ParticleVelocity = reader.ReadVector3();
				this.ParticleUnkownVector = reader.ReadVector3();
				this.ParticleLifeTime = reader.ReadSingle();
				this.ParticleLink = new NiRef<NiObject>(reader);
				this.ParticleTimestamp = reader.ReadUInt32();
				this.ParticleUnkownShort = reader.ReadUInt16();
				this.ParticleVertexId = reader.ReadUInt16();
			}
			if (base.Version >= eNifVersion.VER_4_0_0_2)
			{
				this.NumParticles = reader.ReadUInt16();
				this.NumValid = reader.ReadUInt16();
				this.Particles = new Particle[(int)this.NumParticles];
				for (int i = 0; i < (int)this.NumParticles; i++)
				{
					this.Particles[i] = new Particle(file, reader);
				}
				this.UnkownRef = new NiRef<NiObject>(reader);
			}
			this.ParticleExtra = new NiRef<NiParticleModifier>(reader);
			this.UnkownRef2 = new NiRef<NiObject>(reader);
			if (base.Version >= eNifVersion.VER_4_0_0_2)
			{
				this.Trailer = reader.ReadByte();
			}
			if (base.Version <= eNifVersion.VER_3_1)
			{
				this.ColorData = new NiRef<NiColorData>(reader);
				this.UnkownFloat1 = reader.ReadSingle();
				this.UnkownFloats2 = reader.ReadFloatArray((int)this.ParticleUnkownShort);
			}
		}
Пример #13
0
 public void LoadFrom(Stream stream)
 {
     BinaryReader reader = new BinaryReader(stream);
     m_GameObject = new PPtr<GameObject>(stream, file);
     m_Enabled = reader.ReadByte();
     stream.Position += 3;
     m_ClearFlags = reader.ReadUInt32();
     m_BackGroundColor = reader.ReadColor4();
     m_NormalizedViewPortRect = new Rectf(stream);
     near_clip_plane = reader.ReadSingle();
     far_clip_plane = reader.ReadSingle();
     field_of_view = reader.ReadSingle();
     orthographic = reader.ReadBoolean();
     stream.Position += 3;
     orthographic_size = reader.ReadSingle();
     m_Depth = reader.ReadSingle();
     m_CullingMask = new BitField(stream);
     m_RenderingPath = reader.ReadInt32();
     m_TargetTexture = new PPtr<Texture2D>(stream, file);
     m_TargetDisplay = reader.ReadUInt32();
     m_HDR = reader.ReadBoolean();
     m_OcclusionCulling = reader.ReadBoolean();
     stream.Position += 2;
     m_StereoConvergence = reader.ReadSingle();
     m_StereoSeparation = reader.ReadSingle();
 }
Пример #14
0
 public void LoadFrom(Stream stream)
 {
     BinaryReader reader = new BinaryReader(stream);
     m_GameObject = new PPtr<GameObject>(stream, file);
     m_Enabled = reader.ReadByte();
     reader.ReadBytes(3);
     m_Type = reader.ReadInt32();
     m_Color = reader.ReadColor4();
     m_Intensity = reader.ReadSingle();
     m_Range = reader.ReadSingle();
     m_SpotAngle = reader.ReadSingle();
     m_CookieSize = reader.ReadSingle();
     m_Shadows = new ShadowSettings(stream);
     m_Cookie = new PPtr<Texture2D>(stream, file);
     m_DrawHalo = reader.ReadBoolean();
     m_ActuallyLightmapped = reader.ReadBoolean();
     reader.ReadBytes(2);
     m_Flare = new PPtr<Flare>(stream, file);
     m_RenderMode = reader.ReadInt32();
     m_CullingMask = new BitField(stream);
     m_Lightmapping = reader.ReadInt32();
 }