public DATAField(BinaryFileReader r, int dataSize) { if (dataSize != 102 && dataSize != 86 && dataSize != 62 && dataSize != 42 && dataSize != 2) { WindVelocity = 1; } if (dataSize == 2) { Damage = r.ReadUInt16(); return; } WindVelocity = r.ReadSingle(); WindDirection = r.ReadSingle(); WaveAmplitude = r.ReadSingle(); WaveFrequency = r.ReadSingle(); SunPower = r.ReadSingle(); ReflectivityAmount = r.ReadSingle(); FresnelAmount = r.ReadSingle(); ScrollXSpeed = r.ReadSingle(); ScrollYSpeed = r.ReadSingle(); FogDistance_NearPlane = r.ReadSingle(); if (dataSize == 42) { Damage = r.ReadUInt16(); return; } FogDistance_FarPlane = r.ReadSingle(); ShallowColor = r.ReadT <ColorRef4>(dataSize); DeepColor = r.ReadT <ColorRef4>(dataSize); ReflectionColor = r.ReadT <ColorRef4>(dataSize); TextureBlend = r.ReadByte(); r.Skip(3); // Unused if (dataSize == 62) { Damage = r.ReadUInt16(); return; } RainSimulator_Force = r.ReadSingle(); RainSimulator_Velocity = r.ReadSingle(); RainSimulator_Falloff = r.ReadSingle(); RainSimulator_Dampner = r.ReadSingle(); RainSimulator_StartingSize = r.ReadSingle(); DisplacementSimulator_Force = r.ReadSingle(); if (dataSize == 86) { //DisplacementSimulator_Velocity = DisplacementSimulator_Falloff = DisplacementSimulator_Dampner = DisplacementSimulator_StartingSize = 0F; Damage = r.ReadUInt16(); return; } DisplacementSimulator_Velocity = r.ReadSingle(); DisplacementSimulator_Falloff = r.ReadSingle(); DisplacementSimulator_Dampner = r.ReadSingle(); DisplacementSimulator_StartingSize = r.ReadSingle(); Damage = r.ReadUInt16(); }
public DATAField(BinaryFileReader r, int dataSize) { Flags = r.ReadUInt32(); BaseCost = r.ReadSingle(); AssocItem = r.ReadInt32(); //wbUnion('Assoc. Item', wbMGEFFAssocItemDecider, [ // wbFormIDCk('Unused', [NULL]), // wbFormIDCk('Assoc. Weapon', [WEAP]), // wbFormIDCk('Assoc. Armor', [ARMO, NULL{?}]), // wbFormIDCk('Assoc. Creature', [CREA, LVLC, NPC_]), // wbInteger('Assoc. Actor Value', itS32, wbActorValueEnum) MagicSchool = r.ReadInt32(); ResistValue = r.ReadInt32(); CounterEffectCount = r.ReadUInt16(); r.Skip(2); // Unused Light = new FormId <LIGHRecord>(r.ReadUInt32()); ProjectileSpeed = r.ReadSingle(); EffectShader = new FormId <EFSHRecord>(r.ReadUInt32()); if (dataSize == 36) { return; } EnchantEffect = new FormId <EFSHRecord>(r.ReadUInt32()); CastingSound = new FormId <SOUNRecord>(r.ReadUInt32()); BoltSound = new FormId <SOUNRecord>(r.ReadUInt32()); HitSound = new FormId <SOUNRecord>(r.ReadUInt32()); AreaSound = new FormId <SOUNRecord>(r.ReadUInt32()); ConstantEffectEnchantmentFactor = r.ReadSingle(); ConstantEffectBarterFactor = r.ReadSingle(); }
public int Flags; // 0 = ?, 1 = Ignore Normal Weapon Resistance? public DATAField(BinaryFileReader r, int dataSize, GameFormat format) { if (format == GameFormat.TES3) { Weight = r.ReadSingle(); Value = r.ReadInt32(); Type = r.ReadUInt16(); Health = r.ReadInt16(); Speed = r.ReadSingle(); Reach = r.ReadSingle(); Damage = r.ReadInt16(); ChopMin = r.ReadByte(); ChopMax = r.ReadByte(); SlashMin = r.ReadByte(); SlashMax = r.ReadByte(); ThrustMin = r.ReadByte(); ThrustMax = r.ReadByte(); Flags = r.ReadInt32(); return; } Type = (ushort)r.ReadUInt32(); Speed = r.ReadSingle(); Reach = r.ReadSingle(); Flags = r.ReadInt32(); Value = r.ReadInt32(); Health = (short)r.ReadInt32(); Weight = r.ReadSingle(); Damage = r.ReadInt16(); ChopMin = ChopMax = SlashMin = SlashMax = ThrustMin = ThrustMax = 0; }
public DATAField(BinaryFileReader r, int dataSize) { Speed = r.ReadSingle(); Flags = r.ReadUInt32(); Value = r.ReadUInt32(); Weight = r.ReadSingle(); Damage = r.ReadUInt16(); }
ushort[] GetPalette(BinaryFileReader r) { var pal = new ushort[0x100]; for (var i = 0; i < 0x100; ++i) { pal[i] = (ushort)(r.ReadUInt16() | 0x8000); } return(pal); }
public byte StartTime; // Start time public DATAField(BinaryFileReader r, int dataSize, GameFormat format) { Volume = format == GameFormat.TES3 ? r.ReadByte() : (byte)0; MinRange = r.ReadByte(); MaxRange = r.ReadByte(); if (format == GameFormat.TES3) { return; } FrequencyAdjustment = r.ReadSByte(); r.ReadByte(); // Unused Flags = r.ReadUInt16(); r.ReadUInt16(); // Unused if (dataSize == 8) { return; } StaticAttenuation = r.ReadUInt16(); StopTime = r.ReadByte(); StartTime = r.ReadByte(); }
private void ReadObjectTemplates(BinaryFileReader reader) { uint defAmount = reader.ReadUInt32(); Console.WriteLine("ReadObjectTemplates totally:" + defAmount); // Read custom defs for (int idd = 0; idd < defAmount; ++idd) { string animationFile = reader.ReadString(); Console.WriteLine("Object Animation File:" + animationFile); int[] blockMask = new int[6]; int[] visitMask = new int[6]; foreach (int val in blockMask) { int r = reader.ReadUInt8(); //Console.WriteLine("BlockMask: " + r); } foreach (int val in visitMask) { int r = reader.ReadUInt8(); //Console.WriteLine("VisitMask: " + r); } reader.ReadUInt16(); int terrMask = reader.ReadUInt16(); uint objectId = reader.ReadUInt32(); uint objectSubId = reader.ReadUInt32(); int type = reader.ReadUInt8(); int printPriority = reader.ReadUInt8() * 100; reader.Skip(16); } }
public DATAField(BinaryFileReader r, int dataSize) { Density = r.ReadByte(); MinSlope = r.ReadByte(); MaxSlope = r.ReadByte(); r.ReadByte(); UnitFromWaterAmount = r.ReadUInt16(); r.Skip(2); UnitFromWaterType = r.ReadUInt32(); PositionRange = r.ReadSingle(); HeightRange = r.ReadSingle(); ColorRange = r.ReadSingle(); WavePeriod = r.ReadSingle(); Flags = r.ReadByte(); r.Skip(3); }
private bool LoadArtifactToSlot(BinaryFileReader reader, object hero, int slot) { //// const int artmask = map->version == EMapFormat::ROE ? 0xff : 0xffff; const int artmask = 0xffff; int aid; aid = reader.ReadUInt16(); bool isArt = (aid != artmask); if (isArt) { Console.WriteLine("loadArtifactToSlot: id={0}, slot={1}", aid, slot); return(true); } return(false); }
public ColorRef4 VertexShading; // RGB + Shading radius (0 - 200) % public RDOTField(BinaryFileReader r, int dataSize) { Object = new FormId <Record>(r.ReadUInt32()); ParentIdx = r.ReadUInt16(); r.Skip(2); // Unused Density = r.ReadSingle(); Clustering = r.ReadByte(); MinSlope = r.ReadByte(); MaxSlope = r.ReadByte(); Flags = r.ReadByte(); RadiusWrtParent = r.ReadUInt16(); Radius = r.ReadUInt16(); MinHeight = r.ReadSingle(); MaxHeight = r.ReadSingle(); Sink = r.ReadSingle(); SinkVariance = r.ReadSingle(); SizeVariance = r.ReadSingle(); AngleVariance = new Vector3Int(r.ReadUInt16(), r.ReadUInt16(), r.ReadUInt16()); r.Skip(2); // Unused VertexShading = r.ReadT <ColorRef4>(dataSize); }
private void ReadPredefinedHeroes(BinaryFileReader reader) { if (mapObject.Header.Version == EMapFormat.WOG || mapObject.Header.Version == EMapFormat.SOD) { for (int z = 0; z < GameConstants.HEROES_QUANTITY; z++) { Console.WriteLine(string.Format("===Reading Predefined Hero [{0}]", z)); int custom = reader.ReadUInt8(); if (custom == 0) { Console.WriteLine("is not custom."); continue; } // Create Hero bool hasExp = reader.ReadBool(); if (hasExp) { uint exp = reader.ReadUInt32(); Console.WriteLine("Has exp:" + exp); } bool hasSecondSkills = reader.ReadBool(); if (hasSecondSkills) { uint howMany = reader.ReadUInt32(); Console.WriteLine("Has Second Skills count=" + howMany); for (int yy = 0; yy < howMany; ++yy) { int first = reader.ReadUInt8(); int second = reader.ReadUInt8(); Console.WriteLine(string.Format("Skill First: {0} Second: {1}", first, second)); } } // Set Artifacts bool artSet = reader.ReadBool(); if (artSet) { Console.WriteLine("Artifact is set."); if (false) { // Already set the pack } for (int pom = 0; pom < 16; pom++) { LoadArtifactToSlot(reader, null, pom); } if (true) { LoadArtifactToSlot(reader, null, 0); //catapult } LoadArtifactToSlot(reader, null, 0); //SpellBook // Misc5 possibly LoadArtifactToSlot(reader, null, 0); //Misc // Backpack items int amount = reader.ReadUInt16(); Console.WriteLine("Backpack item amount:" + amount); for (int ss = 0; ss < amount; ++ss) { LoadArtifactToSlot(reader, null, 0); } } bool hasCustomBio = reader.ReadBool(); if (hasCustomBio) { string biography = reader.ReadString(); Console.WriteLine("biography: " + biography); } int sex = reader.ReadUInt8(); Console.WriteLine("sex: " + sex); // Spells bool hasCustomSpells = reader.ReadBool(); if (hasCustomSpells) { HashSet <int> spells = new HashSet <int>(); reader.ReadBitMask(spells, 9, GameConstants.SPELLS_QUANTITY, false); Console.WriteLine("Spells: " + JsonConvert.SerializeObject(spells)); } bool hasCustomPrimSkills = reader.ReadBool(); if (hasCustomPrimSkills) { Console.WriteLine("Has Custom Primary Skills."); for (int xx = 0; xx < GameConstants.PRIMARY_SKILLS; xx++) { int value = reader.ReadUInt8(); Console.WriteLine("Primary Skills: " + value); } } } } }
private void ReadVictoryLossConditions(BinaryFileReader reader) { //// mapObject.Header.TrigggeredEvents = new List<TrigggeredEvent>(); var vicCondition = (EVictoryConditionType)reader.ReadUInt8(); if (vicCondition == EVictoryConditionType.WINSTANDARD) { // create normal condition } else { bool allowNormalVictory = reader.ReadBool(); bool appliesToAI = reader.ReadBool(); if (allowNormalVictory) { int playersOnMap = 2; if (playersOnMap == 1) { //// logGlobal->warn("Map %s has only one player but allows normal victory?", mapHeader->name); allowNormalVictory = false; // makes sense? Not much. Works as H3? Yes! } } switch (vicCondition) { case EVictoryConditionType.ARTIFACT: { int objectType = reader.ReadUInt8(); break; } case EVictoryConditionType.GATHERTROOP: { int objectType = reader.ReadUInt8(); uint value = reader.ReadUInt32(); break; } case EVictoryConditionType.GATHERRESOURCE: { int objectType = reader.ReadUInt8(); uint value = reader.ReadUInt32(); break; } case EVictoryConditionType.BUILDCITY: { var pos = reader.ReadPosition(); int objectType = reader.ReadUInt8(); int objectType2 = reader.ReadUInt8(); break; } case EVictoryConditionType.BUILDGRAIL: { var pos = reader.ReadPosition(); break; } case EVictoryConditionType.BEATHERO: { var pos = reader.ReadPosition(); break; } case EVictoryConditionType.CAPTURECITY: { var pos = reader.ReadPosition(); break; } case EVictoryConditionType.BEATMONSTER: { var pos = reader.ReadPosition(); break; } case EVictoryConditionType.TAKEDWELLINGS: { break; } case EVictoryConditionType.TAKEMINES: { break; } case EVictoryConditionType.TRANSPORTITEM: { uint value = reader.ReadUInt32(); var pos = reader.ReadPosition(); break; } default: break; } } ELossConditionType loseCondition = (ELossConditionType)reader.ReadUInt8(); Console.WriteLine("Lose Condition:" + loseCondition); if (loseCondition != ELossConditionType.LOSSSTANDARD) { switch (loseCondition) { case ELossConditionType.LOSSCASTLE: { var pos = reader.ReadPosition(); break; } case ELossConditionType.LOSSHERO: { var pos = reader.ReadPosition(); break; } case ELossConditionType.TIMEEXPIRES: { int val = reader.ReadUInt16(); break; } default: break; } } }
public PKDTField(BinaryFileReader r, int dataSize) { Flags = r.ReadUInt16(); Type = r.ReadByte(); r.Skip(dataSize - 3); // Unused }
public unsafe AnimationFrame(int uniqueAnimationIndex, object graphics, ushort[] palette, BinaryFileReader r, SittingTransformation sitting) { _animationIndex = uniqueAnimationIndex; int xCenter = r.ReadInt16(); int yCenter = r.ReadInt16(); int width = r.ReadUInt16(); int height = r.ReadUInt16(); // Fix for animations with no pixels. if (width == 0 || height == 0) { Texture = null; return; } if (sitting == SittingTransformation.StandSouth) { xCenter += 8; width += 8; height += 4; } var data = new byte[width * height * 4]; // for sitting: // somewhere around the waist of a typical mobile animation, we take twelve rows of pixels, // discard every third, and shift every remaining row (total of eight) one pixel to the left // or right (depending on orientation), for a total skew of eight pixels. fixed(byte *pData = data) { ushort *dataRef = (ushort *)pData; var dataRead = 0; int header; while ((header = r.ReadInt32()) != 0x7FFF7FFF) { header ^= DoubleXor; var x = ((header >> 22) & 0x3FF) + xCenter - 0x200; var y = ((header >> 12) & 0x3FF) + yCenter + height - 0x200; if (sitting == SittingTransformation.StandSouth) { const int skew_start = -17; const int skew_end = skew_start - 16; var iy = y - height - yCenter; if (iy > skew_start) { // pixels below the skew x -= 8; y -= 4; } else if (iy > skew_end) { // pixels within the skew if ((iy - skew_end) % 4 == 0) { r.Position += header & 0xFFF; continue; } x -= (iy - skew_end) / 2; y -= (iy - skew_end) / 4; } } ushort *cur = dataRef + y * width + x; ushort *end = cur + (header & 0xFFF); var filecounter = 0; var filedata = r.ReadBytes(header & 0xFFF); while (cur < end) { *cur++ = palette[filedata[filecounter++]]; } dataRead += header & 0xFFF; } Metrics.ReportDataRead(dataRead); } Center = new Vector2Int(xCenter, yCenter); Texture = new Texture2DInfo(width, height, TextureFormat.BGRA32, false, data); _picking.Set(_animationIndex, width, height, data); }
/// <summary> /// Reads a binary STL file filtered by a provided filter. /// </summary> /// <param name="file">The mesh file.</param> /// <param name="filter">The provided filtered.</param> /// <returns>The DMTModel that obeys to the filter condition.</returns> public List <DMTModel> ReadFile(File file, IDMTModelFilter filter) { if (file.Exists == false) { throw new DMTFileException(DMTFileError.FileDoesNotExist); } var blocksIn = new List <DMTTriangleBlock>(); var blocksOut = new List <DMTTriangleBlock>(); var blockIn = new DMTTriangleBlock(); var blockOut = new DMTTriangleBlock(); var objReader = new BinaryFileReader(file); try { //Read first 80 characters (bytes) and ignore them objReader.ReadBytes(80); //Read the next 4 bytes to get an unsigned integer of number of triangles var intNoOfFacets = objReader.ReadUInteger(); //Now keep reading until the end of the file var mapPointVertexIndexBlockIn = new Dictionary <Point, int>(); var mapPointVertexIndexBlockOut = new Dictionary <Point, int>(); var point1Index = -1; var point2Index = -1; var point3Index = -1; for (uint intCounter = 0; intCounter <= intNoOfFacets - 1; intCounter++) { //Read 3 32bit floating point numbers - triangle normal // We do not keep the normals in memory, they take too much space objReader.ReadSingle(); objReader.ReadSingle(); objReader.ReadSingle(); //Read 3 32bit floating point numbers - vertex 1 X/Y/Z var objPoint1 = new Point(); objPoint1.X = objReader.ReadSingle(); objPoint1.Y = objReader.ReadSingle(); objPoint1.Z = objReader.ReadSingle(); //Read 3 32bit floating point numbers - vertex 2 X/Y/Z var objPoint2 = new Point(); objPoint2.X = objReader.ReadSingle(); objPoint2.Y = objReader.ReadSingle(); objPoint2.Z = objReader.ReadSingle(); //Read 3 32bit floating point numbers - vertex 3 X/Y/Z var objPoint3 = new Point(); objPoint3.X = objReader.ReadSingle(); objPoint3.Y = objReader.ReadSingle(); objPoint3.Z = objReader.ReadSingle(); if (filter.CanAddTriangle(objPoint1, objPoint2, objPoint3)) { AddTriangle(mapPointVertexIndexBlockIn, blockIn, objPoint1, objPoint2, objPoint3); } else { AddTriangle(mapPointVertexIndexBlockOut, blockOut, objPoint1, objPoint2, objPoint3); } //Read 16 bit number objReader.ReadUInt16(); } blockIn.DoVerticesHaveNormals = false; blockOut.DoVerticesHaveNormals = false; blocksIn.Add(blockIn); blocksOut.Add(blockOut); var modelWithinFilter = new DMTModel(); var modelOutsideFilter = new DMTModel(); modelWithinFilter.TriangleBlocks.AddRange(blocksIn); modelOutsideFilter.TriangleBlocks.AddRange(blocksOut); var result = new List <DMTModel>(); result.Add(modelWithinFilter); result.Add(modelOutsideFilter); return(result); } finally { objReader.Close(); } }
public FieldHeader(BinaryFileReader r, GameFormat format) { Type = r.ReadASCIIString(4); DataSize = (int)(format == GameFormat.TES3 ? r.ReadUInt32() : r.ReadUInt16()); }