Example #1
0
		public char[] color;			// BGRA -- "A" seems to be ignored by the official client


		public RoGndTileData(BinaryReader bin, GenericFileFormatVersion version)
			: base(bin, version) {
			VectorWidth = bin.ReadVector4();
			VectorHeight = bin.ReadVector4();
			TextureIndex = bin.ReadUInt16();
			Lightmap = bin.ReadUInt16();
			color = bin.ReadChars(4);
		}
Example #2
0
		public RoGndCubeData(BinaryReader bin, GenericFileFormatVersion version)
			: base(bin, version) {
			Height = bin.ReadVector4();
			TileUp = bin.ReadInt32();
			TileSide = bin.ReadInt32();
			TileAside = bin.ReadInt32();
		}
Example #3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="QuatKey"/> class.
        /// </summary>
        /// <param name="reader">The reader.</param>
        /// <param name="type">The type.</param>
        /// <exception cref="Exception">Invalid eKeyType</exception>
        public QuatKey(BinaryReader reader, eKeyType type)
		{
			this.Time = reader.ReadSingle();
			if (type < eKeyType.LINEAR_KEY || type > eKeyType.TBC_KEY)
			{
				throw new Exception("Invalid eKeyType");
			}
			this.Value = reader.ReadVector4();
			if (type == eKeyType.TBC_KEY)
			{
				this.TBC = reader.ReadVector3();
			}
		}
        /// <summary>
        /// Initializes a new instance of the <see cref="NiRotatingParticlesData"/> class.
        /// </summary>
        /// <param name="file">The file.</param>
        /// <param name="reader">The reader.</param>
        public NiRotatingParticlesData(NiFile file, BinaryReader reader) : base(file, reader)
		{
			if (base.Version <= eNifVersion.VER_4_2_2_0)
			{
				this.HasRotations2 = reader.ReadBoolean(Version);
				this.Rotations2 = new Vector4[this.NumVertices];
				int num = 0;
				while ((long)num < (long)((ulong)this.NumVertices))
				{
					this.Rotations2[num] = reader.ReadVector4();
					num++;
				}
			}
		}
 public ErrorReportCommentsBlock(BinaryReader binaryReader)
 {
     this.paddingtext = binaryReader.ReadBytes(8);
     this.position = binaryReader.ReadVector3();
     this.nodeIndices = new NodeIndices[4];
     for (int i = 0; i < 4; ++i)
     {
         this.nodeIndices[i] = new NodeIndices(binaryReader);
     }
     this.nodeWeights = new NodeWeights[4];
     for (int i = 0; i < 4; ++i)
     {
         this.nodeWeights[i] = new NodeWeights(binaryReader);
     }
     this.color = binaryReader.ReadVector4();
 }
 public ErrorReportQuadsBlock(BinaryReader binaryReader)
 {
     this.points = new Points[4];
     for (int i = 0; i < 4; ++i)
     {
         this.points[i] = new Points(binaryReader);
     }
     this.color = binaryReader.ReadVector4();
 }
 public ErrorReportTrianglesBlock(BinaryReader binaryReader)
 {
     this.points = new Points[3];
     for (int i = 0; i < 3; ++i)
     {
         this.points[i] = new Points(binaryReader);
     }
     this.color = binaryReader.ReadVector4();
 }
 public ErrorReportVectorsBlock(BinaryReader binaryReader)
 {
     this.position = binaryReader.ReadVector3();
     this.nodeIndices = new NodeIndices[4];
     for (int i = 0; i < 4; ++i)
     {
         this.nodeIndices[i] = new NodeIndices(binaryReader);
     }
     this.nodeWeights = new NodeWeights[4];
     for (int i = 0; i < 4; ++i)
     {
         this.nodeWeights[i] = new NodeWeights(binaryReader);
     }
     this.color = binaryReader.ReadVector4();
     this.normal = binaryReader.ReadVector3();
     this.screenLength = binaryReader.ReadSingle();
 }
 public ModelNodeBlock(BinaryReader binaryReader)
 {
     this.name = binaryReader.ReadStringID();
     this.parentNode = binaryReader.ReadShortBlockIndex1();
     this.firstChildNode = binaryReader.ReadShortBlockIndex1();
     this.nextSiblingNode = binaryReader.ReadShortBlockIndex1();
     this.padding = binaryReader.ReadBytes(2);
     this.defaultTranslation = binaryReader.ReadVector3();
     this.defaultRotation = binaryReader.ReadVector4();
     this.defaultInverseScale = binaryReader.ReadSingle();
     this.defaultInverseForward = binaryReader.ReadVector3();
     this.defaultInverseLeft = binaryReader.ReadVector3();
     this.defaultInverseUp = binaryReader.ReadVector3();
     this.defaultInversePosition = binaryReader.ReadVector3();
 }
 public StructureBspFogPlaneBlock(BinaryReader binaryReader)
 {
     this.scenarioPlanarFogIndex = binaryReader.ReadInt16();
     this.padding = binaryReader.ReadBytes(2);
     this.plane = binaryReader.ReadVector4();
     this.flags = (Flags)binaryReader.ReadInt16();
     this.priority = binaryReader.ReadInt16();
 }
Example #11
0
 public Axes(Stream stream)
 {
     BinaryReader reader = new BinaryReader(stream);
     m_PreQ = reader.ReadVector4();
     m_PostQ = reader.ReadVector4();
     m_Sgn = reader.ReadVector4();
     m_Limit = new Limit(stream);
     m_Length = reader.ReadSingle();
     m_Type = reader.ReadUInt32();
 }
Example #12
0
        /// <summary>
        /// Loads the file from the specified stream.
        /// </summary>
        /// <param name="stream">The stream to read from.</param>
        public override void Load(Stream stream)
        {
            BinaryReader reader = new BinaryReader(stream, Encoding.GetEncoding("EUC-KR"));

            string identifier = reader.ReadNullTerminatedString();

            int version;

            if (string.Compare(identifier, FILE_IDENTIFIER_7, false) == 0) {
                version = 7;
            } else if (string.Compare(identifier, FILE_IDENTIFIER_8, false) == 0) {
                version = 8;
            } else {
                throw new FileIdentifierMismatchException(FilePath, string.Format("{0} / {1}", FILE_IDENTIFIER_7, FILE_IDENTIFIER_8), identifier);
            }

            format = (VertexFormat)reader.ReadInt32();
            BoundingBox = new Bounds(reader.ReadVector3(), reader.ReadVector3());

            short boneCount = reader.ReadInt16();

            for (int i = 0; i < boneCount; i++) {
                BoneTable.Add(reader.ReadInt16());
            }

            short vertexCount = reader.ReadInt16();

            for (int i = 0; i < vertexCount; i++) {
                ModelVertex vertex = new ModelVertex();
                vertex.Position = reader.ReadVector3();

                Vertices.Add(vertex);
            }

            if (NormalsEnabled) {
                for (int i = 0; i < vertexCount; i++) {
                    ModelVertex vertex = Vertices[i];
                    vertex.Normal = reader.ReadVector3();
                }
            }

            if (ColoursEnabled) {
                for (int i = 0; i < vertexCount; i++) {
                    float a = reader.ReadSingle();
                    ModelVertex vertex = Vertices[i];
                    vertex.Colour = new Color(reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle(), a);
                }
            }

            if (BonesEnabled) {
                for (int i = 0; i < vertexCount; i++) {
                    ModelVertex vertex = Vertices[i];
                    vertex.BoneWeights = reader.ReadVector4();
                    vertex.BoneIndices = reader.ReadShortVector4();
                }
            }

            if (TangentsEnabled) {
                for (int i = 0; i < vertexCount; i++) {
                    ModelVertex vertex = Vertices[i];
                    vertex.Tangent = reader.ReadVector3();
                }
            }

            if (TextureCoordinates1Enabled) {
                for (int i = 0; i < vertexCount; i++) {
                    ModelVertex vertex = Vertices[i];
                    vertex.TextureCoordinates[0] = reader.ReadVector2();
                }
            }

            if (TextureCoordinates2Enabled) {
                for (int i = 0; i < vertexCount; i++) {
                    ModelVertex vertex = Vertices[i];
                    vertex.TextureCoordinates[1] = reader.ReadVector2();
                }
            }

            if (TextureCoordinates3Enabled) {
                for (int i = 0; i < vertexCount; i++) {
                    ModelVertex vertex = Vertices[i];
                    vertex.TextureCoordinates[2] = reader.ReadVector2();
                }
            }

            if (TextureCoordinates4Enabled) {
                for (int i = 0; i < vertexCount; i++) {
                    ModelVertex vertex = Vertices[i];
                    vertex.TextureCoordinates[3] = reader.ReadVector2();
                }
            }

            short indexCount = reader.ReadInt16();

            for (int i = 0; i < indexCount; i++) {
                Indices.Add(reader.ReadShortVector3());
            }

            short materialCount = reader.ReadInt16();

            for (int i = 0; i < materialCount; i++) {
                Materials.Add(reader.ReadInt16());
            }

            short stripCount = reader.ReadInt16();

            for (int i = 0; i < stripCount; i++) {
                Strips.Add(reader.ReadInt16());
            }

            if (version >= 8) {
                Pool = (PoolType)reader.ReadInt16();
            }
        }
 public PlanesBlock(BinaryReader binaryReader)
 {
     this.plane = binaryReader.ReadVector4();
 }
		public RoRsmMeshPositionFrame(BinaryReader bin, GenericFileFormatVersion version)
			: base(bin, version) {
			Frame = bin.ReadInt32();
			Position = bin.ReadVector4();
		}
 public TransparentPlanesBlock(BinaryReader binaryReader)
 {
     this.sectionIndex = binaryReader.ReadInt16();
     this.partIndex = binaryReader.ReadInt16();
     this.plane = binaryReader.ReadVector4();
 }
 public ErrorReportsBlock(BinaryReader binaryReader)
 {
     this.type = (Type)binaryReader.ReadInt16();
     this.flags = (Flags)binaryReader.ReadInt16();
     this.paddingtext = binaryReader.ReadBytes(8);
     this.sourceFilename = binaryReader.ReadString32();
     this.sourceLineNumber = binaryReader.ReadInt32();
     {
         var elementSize = Marshal.SizeOf(typeof(ErrorReportVerticesBlock));
         var blamPointer = binaryReader.ReadBlamPointer(elementSize);
         this.vertices = new ErrorReportVerticesBlock[blamPointer.Count];
         using (binaryReader.BaseStream.Pin())
         {
             for (int i = 0; i < blamPointer.Count; ++i)
             {
                 binaryReader.BaseStream.Position = blamPointer[i];
                 this.vertices[i] = new ErrorReportVerticesBlock(binaryReader);
             }
         }
     }
     {
         var elementSize = Marshal.SizeOf(typeof(ErrorReportVectorsBlock));
         var blamPointer = binaryReader.ReadBlamPointer(elementSize);
         this.vectors = new ErrorReportVectorsBlock[blamPointer.Count];
         using (binaryReader.BaseStream.Pin())
         {
             for (int i = 0; i < blamPointer.Count; ++i)
             {
                 binaryReader.BaseStream.Position = blamPointer[i];
                 this.vectors[i] = new ErrorReportVectorsBlock(binaryReader);
             }
         }
     }
     {
         var elementSize = Marshal.SizeOf(typeof(ErrorReportLinesBlock));
         var blamPointer = binaryReader.ReadBlamPointer(elementSize);
         this.lines = new ErrorReportLinesBlock[blamPointer.Count];
         using (binaryReader.BaseStream.Pin())
         {
             for (int i = 0; i < blamPointer.Count; ++i)
             {
                 binaryReader.BaseStream.Position = blamPointer[i];
                 this.lines[i] = new ErrorReportLinesBlock(binaryReader);
             }
         }
     }
     {
         var elementSize = Marshal.SizeOf(typeof(ErrorReportTrianglesBlock));
         var blamPointer = binaryReader.ReadBlamPointer(elementSize);
         this.triangles = new ErrorReportTrianglesBlock[blamPointer.Count];
         using (binaryReader.BaseStream.Pin())
         {
             for (int i = 0; i < blamPointer.Count; ++i)
             {
                 binaryReader.BaseStream.Position = blamPointer[i];
                 this.triangles[i] = new ErrorReportTrianglesBlock(binaryReader);
             }
         }
     }
     {
         var elementSize = Marshal.SizeOf(typeof(ErrorReportQuadsBlock));
         var blamPointer = binaryReader.ReadBlamPointer(elementSize);
         this.quads = new ErrorReportQuadsBlock[blamPointer.Count];
         using (binaryReader.BaseStream.Pin())
         {
             for (int i = 0; i < blamPointer.Count; ++i)
             {
                 binaryReader.BaseStream.Position = blamPointer[i];
                 this.quads[i] = new ErrorReportQuadsBlock(binaryReader);
             }
         }
     }
     {
         var elementSize = Marshal.SizeOf(typeof(ErrorReportCommentsBlock));
         var blamPointer = binaryReader.ReadBlamPointer(elementSize);
         this.comments = new ErrorReportCommentsBlock[blamPointer.Count];
         using (binaryReader.BaseStream.Pin())
         {
             for (int i = 0; i < blamPointer.Count; ++i)
             {
                 binaryReader.BaseStream.Position = blamPointer[i];
                 this.comments[i] = new ErrorReportCommentsBlock(binaryReader);
             }
         }
     }
     this.padding = binaryReader.ReadBytes(380);
     this.reportKey = binaryReader.ReadInt32();
     this.nodeIndex = binaryReader.ReadInt32();
     this.boundsX = binaryReader.ReadRange();
     this.boundsY = binaryReader.ReadRange();
     this.boundsZ = binaryReader.ReadRange();
     this.color = binaryReader.ReadVector4();
     this.padding0 = binaryReader.ReadBytes(84);
 }
 public StructureBspWeatherPolyhedronPlaneBlock(BinaryReader binaryReader)
 {
     this.plane = binaryReader.ReadVector4();
 }
 public ErrorReportsBlock(BinaryReader binaryReader)
 {
     this.type = (Type)binaryReader.ReadInt16();
     this.flags = (Flags)binaryReader.ReadInt16();
     this.paddingtext = binaryReader.ReadBytes(8);
     this.sourceFilename = binaryReader.ReadString32();
     this.sourceLineNumber = binaryReader.ReadInt32();
     this.vertices = ReadVertices(binaryReader);
     this.vectors = ReadVectors(binaryReader);
     this.lines = ReadLines(binaryReader);
     this.triangles = ReadTriangles(binaryReader);
     this.quads = ReadQuads(binaryReader);
     this.comments = ReadComments(binaryReader);
     this.padding = binaryReader.ReadBytes(380);
     this.reportKey = binaryReader.ReadInt32();
     this.nodeIndex = binaryReader.ReadInt32();
     this.boundsX = binaryReader.ReadRange();
     this.boundsY = binaryReader.ReadRange();
     this.boundsZ = binaryReader.ReadRange();
     this.color = binaryReader.ReadVector4();
     this.padding0 = binaryReader.ReadBytes(84);
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="NiParticlesData"/> class.
        /// </summary>
        /// <param name="file">The file.</param>
        /// <param name="reader">The reader.</param>
        public NiParticlesData(NiFile file, BinaryReader reader) : base(file, reader)
		{
			if (this.File.Header.Version <= eNifVersion.VER_4_0_0_2)
			{
				this.NumParticles = reader.ReadUInt16();
			}
			if (this.File.Header.Version <= eNifVersion.VER_10_0_1_0)
			{
				this.ParticleRadius = reader.ReadSingle();
			}
			if (this.File.Header.Version >= eNifVersion.VER_10_1_0_0)
			{
				this.HasRadii = reader.ReadBoolean(Version);
				if (this.HasRadii)
				{
					this.Radii = reader.ReadFloatArray((int)this.NumVertices);
				}
			}
			this.NumActive = reader.ReadUInt16();
			this.HasSizes = reader.ReadBoolean(Version);
			if (this.HasSizes)
			{
				this.Sizes = reader.ReadFloatArray((int)this.NumVertices);
			}
			if (this.File.Header.Version >= eNifVersion.VER_10_0_1_0)
			{
				this.HasRotations = reader.ReadBoolean(Version);
				if (this.HasRotations)
				{
					this.Rotations = new Vector4[this.NumVertices];
					int num = 0;
					while ((long)num < (long)((ulong)this.NumVertices))
					{
						this.Rotations[num] = reader.ReadVector4();
						num++;
					}
				}
			}
		}
Example #20
0
		Material[] ReadMaterials (BinaryReader reader, Dictionary<string, Texture> textures) {
			var matCount = reader.ReadInt32();
			var mats = new MeshMaterial[matCount];
			for (var i = 0; i < matCount; i++) {
				var name = reader.ReadString();
				var mat = new MeshMaterial(null, name);
				mat.IsTwoSided = reader.ReadBoolean();
				mat.IsWireframeEnabled = reader.ReadBoolean();
				var shadingMode = (ShadingMode)reader.ReadInt32();
				mat.BlendMode = (BlendMode)reader.ReadInt32();
				mat.Opacity = reader.ReadSingle();
				mat.Shininess = reader.ReadSingle();
				mat.ShininessStrength = reader.ReadSingle();
				mat.ColorAmbient = reader.ReadVector4();
				mat.ColorDiffuse = reader.ReadVector4();
				mat.ColorSpecular = reader.ReadVector4();
				mat.ColorEmissive = reader.ReadVector4();
				mat.ColorTransparent = reader.ReadVector4();
				var boneCount = reader.ReadInt32();
				var boneSlotCount = reader.ReadInt32();
				mat.DiffuseMap = this.ReadTextureStack(reader, textures);
				mat.NormalMap = this.ReadTextureStack(reader, textures);
				mat.SpecularMap = this.ReadTextureStack(reader, textures);
				mat.EmissiveMap = this.ReadTextureStack(reader, textures);

				var settings = new MeshShaderSettings {
					MaxLights = 4,
					BoneCount = boneCount,
					BoneSlotCount = boneSlotCount,
					ShadingMode = shadingMode,
					Diffuse = GetMeshTextureStack(mat.DiffuseMap),
					Normal = GetMeshTextureStack(mat.NormalMap),
					Specular = GetMeshTextureStack(mat.SpecularMap),
					Emissive = GetMeshTextureStack(mat.EmissiveMap)
				};
				mat.Shader = new MeshShader(settings);

				mats[i] = mat;
			}
			return mats;
		}
Example #21
0
 public Limit(Stream stream)
 {
     BinaryReader reader = new BinaryReader(stream);
     m_Min = reader.ReadVector4();
     m_Max = reader.ReadVector4();
 }
Example #22
0
        public static MapLights ReadLights(string path)
        {
            /*string assetPath = path.Replace(".ded", ".asset");*/
            GameObject subGO = Scene.BeginEditingPrefab(path, "Lights");

            try
            {
                MapLights lights = subGO.AddComponent<MapLights>();

                BinaryReader reader = new BinaryReader(new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read));

                reader.SkipInt16(); //Usually the area's code
                reader.SkipInt16(); //Usually 1, saw a 20
                short globalLightsCount = reader.ReadInt16();
                reader.SkipInt16(0);
                short globalLightsOffset = reader.ReadInt16();
                reader.SkipInt16(0);
                reader.SkipBytes(8, 0);

                short weirdLightsCount = reader.ReadInt16();
                reader.SkipInt16(0);
                short weirdLightsOffset = reader.ReadInt16();
                reader.SkipInt16(0);
                reader.SkipBytes(8, 0);
                
                short lightsCount = reader.ReadInt16();
                reader.SkipInt16(0);
                short lightsOffset = reader.ReadInt16();
                reader.SkipInt16(0);

                reader.SkipBytes(40, 0);
                short ambientOffset = reader.ReadInt16();
                reader.SkipBytes(24, 0);

                Matrix4x4 transMat = lights.GetComponentInParent<Scene>().GetSH3ToUnityMatrix();

                reader.BaseStream.Position = globalLightsOffset;
                for (int i = 0; i != globalLightsCount; i++)
                {
                    GlobalLight gl = new GlobalLight();
                    gl.rotation = reader.ReadQuaternion();
                    gl.Unknown1 = reader.ReadVector3();
                    reader.SkipInt16(0);
                    gl.Unknown2 = reader.ReadInt16();
                    lights.globalLights.Add(gl);
                }

                reader.BaseStream.Position = weirdLightsOffset;
                for (int i = 0; i != weirdLightsCount; i++)
                {
                    LocalLight ll = new LocalLight();
                    ll.color = reader.ReadColor();
                    ll.Unknown1 = reader.ReadSingle();
                    ll.Range = reader.ReadSingle();
                    reader.SkipBytes(8, 0);
                    ll.position = reader.ReadVector3YInverted();
                    reader.SkipInt16(0x0);
                    ll.Unknown2 = reader.ReadInt16();
                    lights.weirdLights.Add(ll);
                }

                reader.BaseStream.Position = lightsOffset;
                for (int i = 0; i != lightsCount; i++)
                {
                    LocalLight ll = new LocalLight();
                    ll.color = reader.ReadColor();
                    ll.Unknown1 = reader.ReadSingle();
                    ll.Range = reader.ReadSingle();
                    reader.SkipBytes(8, 0);
                    ll.position = reader.ReadVector3YInverted();
                    reader.SkipInt16(0x0);
                    ll.Unknown2 = reader.ReadInt16();
                    lights.localLights.Add(ll);

                    GameObject lightGO = new GameObject("Light " + i);
                    lightGO.transform.SetParent(subGO.transform);
                    lightGO.transform.localPosition = transMat.MultiplyPoint(ll.position);

                    Light light = lightGO.AddComponent<Light>();
                    light.type = LightType.Point;
                    light.range = ll.Range * Scene.GLOBAL_SCALE;
                    light.color = ll.color;
                    light.intensity = 8.0f;
                    light.bounceIntensity = 1.0f;
                }

                reader.BaseStream.Position = ambientOffset;
                lights.Unknown1 = reader.ReadVector4();
                lights.Unknown2 = reader.ReadVector4();
                lights.ambientColor = reader.ReadColor();
                lights.Unknown3 = reader.ReadVector4();

                reader.Close();

                Scene.FinishEditingPrefab(path, subGO);

                return lights;

            }
            catch (Exception e)
            {
                Debug.LogException(e);
            }

            return null;
        }
Example #23
0
 public void LoadFrom(Stream stream)
 {
     BinaryReader reader = new BinaryReader(stream);
     m_Name = reader.ReadNameA4();
     m_Rect = new Rectf(stream);
     m_Offset = reader.ReadVector2();
     m_Border = reader.ReadVector4();
     m_PixelsToUnits = reader.ReadSingle();
     m_Extrude = reader.ReadUInt32();
     m_RD = new SpriteRenderData(file, stream);
 }
Example #24
0
		private void init(string filename, Stream stream, string contentDirectory, Dictionary<string,Type> materialTypes, List<MaterialFieldBinder> value1BinderTypes, List<MaterialFieldBinder> value2BinderTypes, List<MaterialFieldBinder> value3BinderTypes, List<MaterialFieldBinder> value4BinderTypes, List<MaterialFieldBinder> textureBinderTypes, Dictionary<string,string> fileExtOverrides, int classicInstanceCount, Loader.LoadedCallbackMethod loadedCallback)
		{
			try
			{
				var reader = new BinaryReader(stream);

				// meta data
				if (reader.ReadInt32() != Streams.MakeFourCC('R', 'M', 'F', 'T')) Debug.ThrowError("Error", "Not a ReignModel file: " + filename);
				float version = reader.ReadSingle();
				if (version != 1.0f) Debug.ThrowError("Error", "Unsuported model version: " + version.ToString());
				bool compressed = reader.ReadBoolean();

				// frames
				FrameStart = reader.ReadSingle();
				FrameEnd = reader.ReadSingle();
				FrameCount = FrameEnd - FrameStart;
				FPS = reader.ReadSingle();

				// materials
				int materialCount = reader.ReadInt32();
				Materials = new MaterialI[materialCount];
				Textures = new List<ITexture2D>();
				for (int i = 0; i != materialCount; ++i)
				{
					string name = reader.ReadString();

					// create material
					bool pass = false;
					foreach (var materialType in (Dictionary<string,Type>)materialTypes)
					{
						if (materialType.Key == name)
						{
							Materials[i] = (MaterialI)Activator.CreateInstance(materialType.Value);
							Materials[i].Name = name;
							pass = true;
							break;
						}
					}
					if (!pass) Debug.ThrowError("Model", "Failed to find a valid material type for: " + name);
					var material = Materials[i];

					// values1
					var values1 = new Dictionary<string,float>();
					int valueCount = reader.ReadInt32();
					for (int i2 = 0; i2 != valueCount; ++i2) values1.Add(reader.ReadString(), reader.ReadSingle());
					bindTypes(material, values1, value1BinderTypes, contentDirectory, fileExtOverrides, handleFoundValueBinder);

					// values2
					var values2 = new Dictionary<string,Vector2>();
					valueCount = reader.ReadInt32();
					for (int i2 = 0; i2 != valueCount; ++i2) values2.Add(reader.ReadString(), reader.ReadVector2());
					bindTypes(material, values2, value2BinderTypes, contentDirectory, fileExtOverrides, handleFoundValueBinder);

					// values3
					var values3 = new Dictionary<string,Vector3>();
					valueCount = reader.ReadInt32();
					for (int i2 = 0; i2 != valueCount; ++i2) values3.Add(reader.ReadString(), reader.ReadVector3());
					bindTypes(material, values3, value3BinderTypes, contentDirectory, fileExtOverrides, handleFoundValueBinder);

					// values4
					var values4 = new Dictionary<string,Vector4>();
					valueCount = reader.ReadInt32();
					for (int i2 = 0; i2 != valueCount; ++i2) values4.Add(reader.ReadString(), reader.ReadVector4());
					bindTypes(material, values4, value4BinderTypes, contentDirectory, fileExtOverrides, handleFoundValueBinder);

					// textures
					var textures = new Dictionary<string,string>();
					int textureCount = reader.ReadInt32();
					for (int i2 = 0; i2 != textureCount; ++i2) textures.Add(reader.ReadString(), reader.ReadString());
					bindTypes(material, textures, textureBinderTypes, contentDirectory, fileExtOverrides, handleFoundTextureBinder);
				}

				// meshes
				int meshCount = reader.ReadInt32();
				Meshes = new Mesh[meshCount];
				for (int i = 0; i != meshCount; ++i)
				{
					Meshes[i] = new Mesh(reader, this, classicInstanceCount);
				}

				// actions
				int actionCount = reader.ReadInt32();
				Actions = new Action[actionCount];
				for (int i = 0; i != actionCount; ++i)
				{
					Actions[i] = new Action(reader);
				}

				// armatures
				int armatureCount = reader.ReadInt32();
				Armatures = new Armature[armatureCount];
				for (int i = 0; i != armatureCount; ++i)
				{
					Armatures[i] = new Armature(reader);
				}

				// objects
				int objectCount = reader.ReadInt32();
				Objects = new Object[objectCount];
				for (int i = 0; i != objectCount; ++i)
				{
					string type = reader.ReadString();
					if (type == "MESH") Objects[i] = new ObjectMesh(reader, this);
					else if (type == "ARMATURE") Objects[i] = new ObjectArmature(reader, this);
					else Debug.ThrowError("Mesh", "Unsuported Object type: " + type);
				}

				// link objects
				foreach (var o in Objects)
				{
					o.linkObjects(Objects);
				}
			}
			catch (Exception e)
			{
				FailedToLoad = true;
				Loader.AddLoadableException(e);
				Dispose();
				if (loadedCallback != null) loadedCallback(this, false);
				return;
			}

			if (Textures.Count == 0)
			{
				Loaded = true;
				if (loadedCallback != null) loadedCallback(this, true);
			}
			else
			{
				new LoadWaiter(Textures.ToArray(),
				delegate(object sender, bool succeeded)
				{
					if (succeeded)
					{
						Loaded = true;
						if (loadedCallback != null) loadedCallback(this, true);
					}
					else
					{
						FailedToLoad = true;
						Dispose();
						if (loadedCallback != null) loadedCallback(this, false);
					}
				});
			}
		}
Example #25
0
        public void LoadFrom(Stream stream)
        {
            BinaryReader reader = new BinaryReader(stream);
            texture = new PPtr<Texture2D>(stream, file);

            int numVertices = reader.ReadInt32();
            vertices = new SpriteVertex[numVertices];
            for (int i = 0; i < numVertices; i++)
            {
                vertices[i] = new SpriteVertex(stream);
            }

            int numIndices = reader.ReadInt32();
            indices = reader.ReadUInt16Array(numIndices);
            if ((numIndices & 1) > 0)
            {
                reader.ReadBytes(2);
            }

            textureRect = new Rectf(stream);
            textureRectOffset = reader.ReadVector2();
            settingsRaw = reader.ReadUInt32();
            uvTransform = reader.ReadVector4();
        }
Example #26
0
        public void LoadFrom(Stream stream)
        {
            BinaryReader reader = new BinaryReader(stream);
            m_GameObject = new PPtr<GameObject>(stream, file);
            m_Enabled = reader.ReadBoolean();
            m_CastShadows = reader.ReadBoolean();
            m_ReceiveShadows = reader.ReadBoolean();
            m_LightmapIndex = reader.ReadByte();
            m_LightmapTilingOffset = reader.ReadVector4();

            int numMaterials = reader.ReadInt32();
            m_Materials = new List<PPtr<Material>>(numMaterials);
            for (int i = 0; i < numMaterials; i++)
            {
                m_Materials.Add(new PPtr<Material>(stream, file));
            }

            int numSubsetIndices = reader.ReadInt32();
            m_SubsetIndices = reader.ReadUInt32Array(numSubsetIndices);

            m_StaticBatchRoot = new PPtr<Transform>(stream, file);
            m_UseLightProbes = reader.ReadBoolean();
            reader.ReadBytes(3);
            m_LightProbeAnchor = new PPtr<Transform>(stream, file);
            m_SortingLayerID = reader.ReadUInt32();
            m_SortingOrder = reader.ReadInt16();
            reader.ReadBytes(2);
        }
Example #27
0
            public static Camera TryMakeCamera(BinaryReader reader, Matrix4x4 transMat)
            {
                Vector2 zoneA = reader.ReadVector2();
                reader.SkipBytes(8);
                Vector2 zoneB = reader.ReadVector2();
                Vector2 zoneHeights = reader.ReadVector2();

                Vector2 constraintA = reader.ReadVector2();
                reader.SkipBytes(8);
                Vector2 constraintB = reader.ReadVector2();
                Vector2 constraintHeights = reader.ReadVector2();

                reader.SkipInt32(0);
                int type = reader.ReadInt32();
                reader.SkipInt32(0);
                int Unknown1 = reader.ReadInt32();

                Vector4 Unknown2 = reader.ReadVector4();
                Vector2 Unknown3 = reader.ReadVector2();
                reader.SkipInt32(0);
                int Unknown4 = reader.ReadInt32();
                Vector2 Unknown5 = reader.ReadVector2();
                Vector2 Unknown6 = reader.ReadVector2();

                if (type != 1)
                {
                    Camera cam = new Camera();

                    Vector3 activeMin = new Vector3(zoneA.x, -zoneHeights.x, zoneA.y);
                    Vector3 activeMax = new Vector3(zoneB.x, -zoneHeights.y, zoneB.y);
                    cam.activeArea = new Bounds();
                    cam.activeArea.SetMinMax(transMat.MultiplyPoint(activeMin), transMat.MultiplyPoint(activeMax));

                    Vector3 constraintMin = new Vector3(constraintA.x, -constraintHeights.x, constraintA.y);
                    Vector3 constraintMax = new Vector3(constraintB.x, -constraintHeights.y, constraintB.y);
                    cam.constraintsArea = new Bounds();
                    cam.constraintsArea.SetMinMax(transMat.MultiplyPoint(constraintMin), transMat.MultiplyPoint(constraintMax));

                    cam.type = type;
                    cam.Unknown1 = Unknown1;
                    cam.Unknown2 = Unknown2;
                    cam.Unknown3 = Unknown3;
                    cam.Unknown4 = Unknown4;
                    cam.Unknown5 = Unknown5;
                    cam.Unknown6 = Unknown6;

                    return cam;
                }
                return null;
            }