public Bin(string fileName, Vector3 position, Vector3 rotation, Vector3 scale) { // header binaryReader = new ABinaryReader(Yay0.Decompress(fileName), Endianness.Big, Encoding.GetEncoding(932)); unk1 = binaryReader.Read8(); name = binaryReader.ReadClampedString(11); offsets = binaryReader.Read32s(21); // data graphObjects = (HasGraph ? GetGraphObjects(0) : new GraphObject[0]); batches = (HasBatches ? CollectionUtility.Initialize(GetBatchCount(), index => GetBatch(index)) : new Batch[0]); shaders = (HasShaders ? CollectionUtility.Initialize(GetShaderCount(), index => GetShader(index)) : new Shader[0]); materials = (HasMaterials ? CollectionUtility.Initialize(GetMaterialCount(), index => GetMaterial(index)) : new Material[0]); textures = (HasTextures ? CollectionUtility.Initialize(GetTextureCount(), index => GetTexture(index)) : new Texture[0]); positions = (HasPositions ? CollectionUtility.Initialize(GetPositionCount(), index => GetPosition(index)) : new Vector3[0]); normals = (HasNormals ? CollectionUtility.Initialize(GetNormalCount(), index => GetNormal(index)) : new Vector3[0]); texCoord0s = (HasTexCoord0s ? CollectionUtility.Initialize(GetTexCoord0Count(), index => GetTexCoord0(index)) : new Vector2[0]); texCoord1s = (HasTexCoord1s ? CollectionUtility.Initialize(GetTexCoord1Count(), index => GetTexCoord1(index)) : new Vector2[0]); // Load textures. glTextures = textures.Select(texture => texture.ToGLTexture()).ToArray(); // Orient. Position = position; Rotation = rotation; Scale = scale; }
public Bin(string fileName, Vector3 position, Vector3 rotation, Vector3 scale) { // header binaryReader = new ABinaryReader(Yay0.Decompress(fileName), Endianness.Big, Encoding.GetEncoding(932)); unk1 = binaryReader.Read8(); name = binaryReader.ReadClampedString(11); offsets = binaryReader.Read32s(21); // data graphObjects = (HasGraph ? GetGraphObjects(0) : new GraphObject[0]); batches = (HasBatches ? CollectionUtility.Initialize(GetBatchCount(), index => GetBatch(index)) : new Batch[0]); shaders = (HasShaders ? CollectionUtility.Initialize(GetShaderCount(), index => GetShader(index)) : new Shader[0]); materials = (HasMaterials ? CollectionUtility.Initialize(GetMaterialCount(), index => GetMaterial(index)) : new Material[0]); textures = (HasTextures ? CollectionUtility.Initialize(GetTextureCount(), index => GetTexture(index)) : new Texture[0]); positions = (HasPositions ? CollectionUtility.Initialize(GetPositionCount(), index => GetPosition(index)) : new Vector3[0]); normals = (HasNormals ? CollectionUtility.Initialize(GetNormalCount(), index => GetNormal(index)) : new Vector3[0]); texCoord0s = (HasTexCoord0s ? CollectionUtility.Initialize(GetTexCoord0Count(), index => GetTexCoord0(index)) : new Vector2[0]); texCoord1s = (HasTexCoord1s ? CollectionUtility.Initialize(GetTexCoord1Count(), index => GetTexCoord1(index)) : new Vector2[0]); // Load textures. glTextures = textures.Select(texture => texture.ToGLTexture()).ToArray(); // Orient. Position = position; Rotation = rotation; Scale = scale; }
public GraphObject(ABinaryReader binaryReader) { Visible = true; ParentIndex = binaryReader.ReadS16(); ChildIndex = binaryReader.ReadS16(); NextIndex = binaryReader.ReadS16(); PrevIndex = binaryReader.ReadS16(); if (binaryReader.Read8() != 0) { #if AROOKAS_DEMOLISHER_CHECKPADDING throw new Exception(String.Format("GraphObject padding != 0 at 0x{0:X8}.", binaryReader.Stream.Position)); #endif } RenderFlags = (GraphObjectRenderFlags)binaryReader.Read8(); if (binaryReader.Read16() != 0) { #if AROOKAS_DEMOLISHER_CHECKPADDING throw new Exception(String.Format("GraphObject padding != 0 at 0x{0:X8}.", binaryReader.Stream.Position)); #endif } Scale = new Vector3(binaryReader.ReadSingle(), binaryReader.ReadSingle(), binaryReader.ReadSingle()); Rotation = new Vector3(binaryReader.ReadSingle(), binaryReader.ReadSingle(), binaryReader.ReadSingle()); Position = new Vector3(binaryReader.ReadSingle(), binaryReader.ReadSingle(), binaryReader.ReadSingle()); BoundingBox = new BoundingBox(binaryReader.ReadVector3D().ToVector3(), binaryReader.ReadVector3D().ToVector3()); unk3 = binaryReader.ReadSingle(); int partCount = binaryReader.ReadS16(); if (binaryReader.Read16() != 0) { #if AROOKAS_DEMOLISHER_CHECKPADDING throw new Exception(String.Format("GraphObject padding != 0 at 0x{0:X8}.", binaryReader.Stream.Position)); #endif } int partOffset = binaryReader.ReadS32(); if (binaryReader.Read32s(7).Any(zero => zero != 0)) { #if AROOKAS_DEMOLISHER_CHECKPADDING throw new Exception(String.Format("GraphObject padding != 0 at 0x{0:X8}.", binaryReader.Stream.Position)); #endif } binaryReader.Goto(partOffset); parts = CollectionHelper.Initialize <Part>(partCount, () => new Part(binaryReader)); binaryReader.Back(); }