public override System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer> ReadFields(System.IO.BinaryReader binaryReader) { System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer> pointerQueue = new System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer>(base.ReadFields(binaryReader)); this.Position = binaryReader.ReadVector3(); this.Orientation = binaryReader.ReadQuaternion(); return(pointerQueue); }
public reaParser(Stream stream) { try { using (BinaryReader reader = new BinaryReader(stream)) { byte[] type = reader.ReadBytes(4); Trace.Assert(remParser.TypeCheck(reaANICsection.ClassType, type)); int anicLength = reader.ReadInt32(); int unk1 = reader.ReadInt32(); float unk2 = reader.ReadSingle(); int count = reader.ReadInt32(); ANIC = new reaANICsection(count); ANIC.unk1 = unk1; ANIC.unk2 = unk2; for (int i = 0; i < count; i++) { reaAnimationTrack track = new reaAnimationTrack(); type = reader.ReadBytes(4); Trace.Assert(remParser.TypeCheck(reaAnimationTrack.ClassType, type)); int anioLength = reader.ReadInt32(); byte[] name = reader.ReadBytes(256); track.boneFrame = remParser.GetIdentifier(name, 0, 256); int numScalings = reader.ReadInt32(); track.scalings = new reaIndexVector[numScalings]; int numRotations = reader.ReadInt32(); track.rotations = new reaIndexQuaternion[numRotations]; int numTranslations = reader.ReadInt32(); track.translations = new reaIndexVector[numTranslations]; for (int j = 0; j < numScalings; j++) { reaIndexVector ivec = new reaIndexVector(); ivec.index = reader.ReadInt32(); ivec.value = reader.ReadVector3(); track.scalings[j] = ivec; } for (int j = 0; j < numRotations; j++) { reaIndexQuaternion iq = new reaIndexQuaternion(); iq.index = reader.ReadInt32(); iq.value = reader.ReadQuaternion(); track.rotations[j] = iq; } for (int j = 0; j < numTranslations; j++) { reaIndexVector ivec = new reaIndexVector(); ivec.index = reader.ReadInt32(); ivec.value = reader.ReadVector3(); track.translations[j] = ivec; } ANIC.AddChild(track); } } } catch (FileNotFoundException) { Report.ReportLog("file not found"); } }
public override System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer> ReadFields(System.IO.BinaryReader binaryReader) { System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer> pointerQueue = new System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer>(base.ReadFields(binaryReader)); this.NodeName = binaryReader.ReadStringID(); this.DefaultRotation = binaryReader.ReadQuaternion(); this.DefaultTranslation = binaryReader.ReadVector3(); this.DefaultScale = binaryReader.ReadSingle(); this.MinBounds = binaryReader.ReadVector3(); this.MaxBounds = binaryReader.ReadVector3(); return(pointerQueue); }
public override System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer> ReadFields(System.IO.BinaryReader binaryReader) { System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer> pointerQueue = new System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer>(base.ReadFields(binaryReader)); this.RegionIndex = binaryReader.ReadByte(); this.PermutationIndex = binaryReader.ReadByte(); this.NodeIndex = binaryReader.ReadByte(); this.fieldpad = binaryReader.ReadBytes(1); this.Translation = binaryReader.ReadVector3(); this.Rotation = binaryReader.ReadQuaternion(); this.Scale = binaryReader.ReadSingle(); return(pointerQueue); }
public override System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer> ReadFields(System.IO.BinaryReader binaryReader) { System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer> pointerQueue = new System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer>(base.ReadFields(binaryReader)); this.Name = binaryReader.ReadString32(); this.Rotation = binaryReader.ReadQuaternion(); this.Translation = binaryReader.ReadVector3(); this.PaletteIndex = binaryReader.ReadShortBlockIndex1(); this.fieldpad = binaryReader.ReadBytes(2); this.UniqueID = binaryReader.ReadInt32(); this.ExportedObjectType = binaryReader.ReadTagClass(); this.ScenarioObjectName = binaryReader.ReadString32(); return(pointerQueue); }
public override System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer> ReadFields(System.IO.BinaryReader binaryReader) { System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer> pointerQueue = new System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer>(base.ReadFields(binaryReader)); this.Name = binaryReader.ReadStringID(); this.ParentNode = binaryReader.ReadShortBlockIndex1(); this.FirstChildNode = binaryReader.ReadShortBlockIndex1(); this.NextSiblingNode = binaryReader.ReadShortBlockIndex1(); this.fieldpad = binaryReader.ReadBytes(2); this.DefaultTranslation = binaryReader.ReadVector3(); this.DefaultRotation = binaryReader.ReadQuaternion(); this.DefaultInverseScale = binaryReader.ReadSingle(); this.DefaultInverseForward = binaryReader.ReadVector3(); this.DefaultInverseLeft = binaryReader.ReadVector3(); this.DefaultInverseUp = binaryReader.ReadVector3(); this.DefaultInversePosition = binaryReader.ReadVector3(); return(pointerQueue); }
private void CreateDetail(BinaryReader reader) { int id = reader.ReadInt32(); int parentID = reader.ReadInt32(); string model = reader.ReadString(); var pos = reader.ReadVector3(); var rot = reader.ReadQuaternion(); Shape shape = null; bool hasShape = reader.ReadBoolean(); if (hasShape == true) { var shapeSize = reader.ReadVector3(); shape = DetailHelper.CreateShape(shapeSize); } var parent = this.world.GetDetail(parentID); DetailObject obj = new DetailObject(parent, id, shape); obj.Position = pos; obj.Rotation = rot; obj.Model = model.Length > 0 ? model : null; this.world.RegisterDetail(obj); }
/// <summary> /// Reads the block data from the underlying stream. /// </summary> /// <param name="reader">The reader.</param> public virtual void Read(BinaryReader reader) { Name = reader.ReadByteString(); WarpID = reader.ReadInt16(); EventID = reader.ReadInt16(); ObjectType = reader.ReadInt32(); ObjectID = reader.ReadInt32(); MapPosition = new IntVector2(reader.ReadInt32(), reader.ReadInt32()); Rotation = reader.ReadQuaternion(); Position = reader.ReadVector3(); Scale = reader.ReadVector3(); }
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; } }
void IDefinition.FromArray(byte[] buffer) { BinaryReader bin = new BinaryReader(new MemoryStream(buffer)); unknown0 = bin.ReadInt16(); unknown1 = bin.ReadInt16(); shader_index = bin.ReadUInt16(); strip_start = bin.ReadUInt16(); strip_length = bin.ReadUInt16(); unknown2 = bin.ReadInt32(); s_unknown3 = bin.ReadInt16(); unknown4 = bin.ReadUInt32(); unknown5 = bin.ReadUInt32(); unknown6 = bin.ReadUInt32(); unknown7 = bin.ReadUInt32(); unknown8 = bin.ReadQuaternion(); local_bounds = bin.ReadDefinition<BoundingBox>(); }
public StructureBspMarkerBlock(BinaryReader binaryReader) { this.name = binaryReader.ReadString32(); this.rotation = binaryReader.ReadQuaternion(); this.position = binaryReader.ReadVector3(); }
/// <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")); short modelFileCount = reader.ReadInt16(); for (int i = 0; i < modelFileCount; i++) { string modelFile = reader.ReadNullTerminatedString(); ModelFiles.Add(modelFile); } short textureFileCount = reader.ReadInt16(); for (int i = 0; i < textureFileCount; i++) { TextureFile texture = new TextureFile(); texture.FilePath = reader.ReadNullTerminatedString(); texture.UseSkinShader = reader.ReadInt16() != 0; texture.AlphaEnabled = reader.ReadInt16() != 0; texture.TwoSided = reader.ReadInt16() != 0; texture.AlphaTestEnabled = reader.ReadInt16() != 0; texture.AlphaReference = reader.ReadInt16(); texture.DepthTestEnabled = reader.ReadInt16() != 0; texture.DepthWriteEnabled = reader.ReadInt16() != 0; texture.BlendType = (BlendType)reader.ReadInt16(); texture.UseSpecularShader = reader.ReadInt16() != 0; texture.Alpha = reader.ReadSingle(); texture.GlowType = (GlowType)reader.ReadInt16(); texture.GlowColour = reader.ReadColour3(); TextureFiles.Add(texture); } short effectFileCount = reader.ReadInt16(); for (int i = 0; i < effectFileCount; i++) { string effectFile = reader.ReadNullTerminatedString(); EffectFiles.Add(effectFile); } short objectCount = reader.ReadInt16(); for (int i = 0; i < objectCount; i++) { ModelListObject @object = new ModelListObject(); int cylinderRadius = reader.ReadInt32(); @object.BoundingCylinder = new BoundingCylinder(new Vector2(reader.ReadInt32(), reader.ReadInt32()), cylinderRadius); int partCount = reader.ReadInt16(); if (partCount > 0) { for (int j = 0; j < partCount; j++) { ModelListPart part = new ModelListPart(); part.Model = reader.ReadInt16(); part.Texture = reader.ReadInt16(); byte propertyType = 0; while ((propertyType = reader.ReadByte()) != 0) { byte size = reader.ReadByte(); switch ((ModelListPropertyType)propertyType) { case ModelListPropertyType.Position: part.Position = reader.ReadVector3(); break; case ModelListPropertyType.Rotation: part.Rotation = reader.ReadQuaternion(true); break; case ModelListPropertyType.Scale: part.Scale = reader.ReadVector3(); break; case ModelListPropertyType.AxisRotation: part.AxisRotation = reader.ReadQuaternion(true); break; case ModelListPropertyType.Parent: part.Parent = reader.ReadInt16(); break; case ModelListPropertyType.Collision: part.Collision = (CollisionType)reader.ReadInt16(); break; case ModelListPropertyType.ConstantAnimation: part.AnimationFilePath = reader.ReadString(size); break; case ModelListPropertyType.VisibleRangeSet: part.VisibleRangeSet = reader.ReadInt16(); break; case ModelListPropertyType.UseLightmap: part.UseLightmap = reader.ReadInt16() != 0; break; case ModelListPropertyType.BoneIndex: part.BoneIndex = reader.ReadInt16(); break; case ModelListPropertyType.DummyIndex: part.DummyIndex = reader.ReadInt16(); break; default: if (propertyType >= (int)ModelListPropertyType.Animation && propertyType < (int)ModelListPropertyType.Animation + ModelListPart.ANIMATION_COUNT) { propertyType -= (int)ModelListPropertyType.Animation; if (propertyType < ModelListPart.MONSTER_ANIMATION_COUNT) { part.MonsterAnimations[propertyType] = reader.ReadString(size); } else { propertyType -= ModelListPart.MONSTER_ANIMATION_COUNT; part.AvatarAnimations[propertyType] = reader.ReadString(size); } } else { stream.Seek(size, SeekOrigin.Current); } break; } } @object.Parts.Add(part); } int effectCount = reader.ReadInt16(); for (int j = 0; j < effectCount; j++) { ModelListEffect effect = new ModelListEffect(); effect.EffectType = (EffectType)reader.ReadInt16(); effect.Effect = reader.ReadInt16(); byte propertyType = 0; while ((propertyType = reader.ReadByte()) != 0) { byte size = reader.ReadByte(); switch ((ModelListPropertyType)propertyType) { case ModelListPropertyType.Position: effect.Position = reader.ReadVector3(); break; case ModelListPropertyType.Rotation: effect.Rotation = reader.ReadQuaternion(true); break; case ModelListPropertyType.Scale: effect.Scale = reader.ReadVector3(); break; case ModelListPropertyType.Parent: effect.Parent = reader.ReadInt16(); break; default: stream.Seek(size, SeekOrigin.Current); break; } } @object.Effects.Add(effect); } @object.BoundingBox = new BoundingBox(reader.ReadVector3(), reader.ReadVector3()); } Objects.Add(@object); } }
public StructureBspEnvironmentObjectBlock(BinaryReader binaryReader) { this.name = binaryReader.ReadString32(); this.rotation = binaryReader.ReadQuaternion(); this.translation = binaryReader.ReadVector3(); this.paletteIndex = binaryReader.ReadShortBlockIndex1(); this.padding = binaryReader.ReadBytes(2); this.uniqueID = binaryReader.ReadInt32(); this.exportedObjectType = binaryReader.ReadTagClass(); this.scenarioObjectName = binaryReader.ReadString32(); }
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; }
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; } }
GameObject HeiDeserialize(Transform parent, ref BinaryReader reader) { var id = reader.ReadInt32(); var name = reader.ReadString(); var gobj = new GameObject(name); var trans = gobj.transform; ReferenceMap[id] = trans; trans.parent = parent; trans.localPosition = reader.ReadVector3(); trans.localRotation = reader.ReadQuaternion(); trans.localScale = reader.ReadVector3(); var childCount = reader.ReadInt32(); //recurse to children for (int i = 0; i < childCount; i++) { HeiDeserialize(trans, ref reader); } return gobj; }
static void ReadMODD(BinaryReader br, WMORoot wmo, uint size) { // Why oh why is wmo.Header.DoodadCount wrong sometimes uint count = size / 40; // 40 is the size of DoodadDefinition wmo.DoodadDefinitions = new DoodadDefinition[count]; for (int 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.ReadUInt32() }; if (dd.NameIndex != -1) { if (!wmo.DoodadFiles.TryGetValue(dd.NameIndex, out dd.FilePath)) { Console.WriteLine("Erroneous dd.NameIndex in WmoRoot: {0}", wmo.FilePath); } } wmo.DoodadDefinitions[i] = dd; } }
/// <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")); Name = reader.ReadIntString(); SoundEnabled = reader.ReadInt32() != 0; SoundFilePath = reader.ReadIntString(); LoopCount = reader.ReadInt32(); int particleCount = reader.ReadInt32(); for (int i = 0; i < particleCount; i++) { EffectParticle particle = new EffectParticle(); particle.Name = reader.ReadIntString(); particle.UniqueIdentifier = reader.ReadIntString(); particle.ParticleIndex = reader.ReadInt32(); particle.FilePath = reader.ReadIntString(); particle.AnimationEnabled = reader.ReadInt32() != 0; particle.AnimationName = reader.ReadIntString(); particle.AnimationLoopCount = reader.ReadInt32(); particle.AnimationIndex = reader.ReadInt32(); particle.Position = reader.ReadVector3(); particle.Rotation = reader.ReadQuaternion(); particle.Delay = reader.ReadInt32(); particle.LinkedToRoot = reader.ReadInt32() != 0; Particles.Add(particle); } int animationCount = reader.ReadInt32(); for (int i = 0; i < animationCount; i++) { EffectAnimation animation = new EffectAnimation(); animation.EffectName = reader.ReadIntString(); animation.MeshName = reader.ReadIntString(); animation.MeshIndex = reader.ReadInt32(); animation.MeshFilePath = reader.ReadIntString(); animation.AnimationFilePath = reader.ReadIntString(); animation.TextureFilePath = reader.ReadIntString(); animation.AlphaEnabled = reader.ReadInt32() != 0; animation.TwoSidedEnabled = reader.ReadInt32() != 0; animation.AlphaTestEnabled = reader.ReadInt32() != 0; animation.DepthTestEnabled = reader.ReadInt32() != 0; animation.DepthWriteEnabled = reader.ReadInt32() != 0; animation.SourceBlend = reader.ReadInt32(); animation.DestinationBlend = reader.ReadInt32(); animation.BlendOperation = reader.ReadInt32(); animation.AnimationEnabled = reader.ReadInt32() != 0; animation.AnimationName = reader.ReadIntString(); animation.AnimationLoopCount = reader.ReadInt32(); animation.AnimationIndex = reader.ReadInt32(); animation.Position = reader.ReadVector3(); animation.Rotation = reader.ReadQuaternion(); animation.Delay = reader.ReadInt32(); animation.LoopCount = reader.ReadInt32(); animation.LinkedToRoot = reader.ReadInt32() != 0; Animations.Add(animation); } }
private void UpdateDetail(BinaryReader reader) { int id = reader.ReadInt32(); var pos = reader.ReadVector3(); var rot = reader.ReadQuaternion(); DetailObject obj = this.world.GetDetail(id); if (obj == null) return; obj.Position = pos; obj.Rotation = rot; }
void IDefinition.FromArray(byte[] buffer) { BinaryReader bin = new BinaryReader(new MemoryStream(buffer)); Name = bin.ReadStringID(); Parent_NodeIndex = bin.ReadInt16(); FirstChild_NodeIndex = bin.ReadInt16(); NextSibling_NodeIndex = bin.ReadInt16(); bin.BaseStream.Seek(sizeof(short), SeekOrigin.Current); Position = bin.ReadVector3(); Rotation = bin.ReadQuaternion(); Scale = bin.ReadSingle(); Right = bin.ReadVector3(); Forward = bin.ReadVector3(); Up = bin.ReadVector3(); AbsolutePosition = bin.ReadVector3(); }
/// <summary> /// Reads a channel frame from the underlying stream. /// </summary> /// <param name="reader">The reader.</param> /// <param name="frame">The frame to read.</param> public override void ReadFrame(BinaryReader reader, int frame) { frames[frame] = reader.ReadQuaternion(); }
public void Load(Stream fs, bool leaveOpen) { // Reset whole world foreach (var block in blocks.ToArray()) { this[block.X, block.Y, block.Z] = null; } Action<bool> assert = (b) => { if (!b) throw new InvalidDataException(); }; using (var br = new BinaryReader(fs, Encoding.UTF8, leaveOpen)) { assert(br.ReadString() == "BLOCKWORLD"); int major = br.ReadByte(); int minor = br.ReadByte(); assert(major == 1); int typeCount = br.ReadInt32(); Type[] types = new Type[typeCount]; for (int i = 0; i < typeCount; i++) { string typeName = br.ReadString(); types[i] = Type.GetType(typeName); if (types[i] == null) throw new TypeLoadException("Could not find type " + typeName); } long blockCount = br.ReadInt64(); for (long i = 0; i < blockCount; i++) { int x = br.ReadInt32(); int y = br.ReadInt32(); int z = br.ReadInt32(); Type type = types[br.ReadInt32()]; var block = Activator.CreateInstance(type) as Block; block.Deserialize(br); this[x, y, z] = block; } // Details are stored here as well if(minor == 1) { int detailCount = br.ReadInt32(); for (int i = 0; i < detailCount; i++) { int id = br.ReadInt32(); string model = br.ReadString(); int parentID = br.ReadInt32(); var position = br.ReadVector3(); var rotation = br.ReadQuaternion(); Shape shape = null; bool hasShape = br.ReadBoolean(); if (hasShape) { var size = br.ReadVector3(); shape = new BoxShape(size.Jitter()); } DetailObject detail = new DetailObject(this.GetDetail(parentID), id, shape); if (string.IsNullOrWhiteSpace(model) == false) detail.Model = model; detail.Position = position; detail.Rotation = rotation; this.RegisterDetail(detail); int behaviourCount = br.ReadInt32(); for (int j = 0; j < behaviourCount; j++) { var typeName = br.ReadString(); var type = Type.GetType(typeName, true); int behaviourID = br.ReadInt32(); bool isEnabled = br.ReadBoolean(); var behaviour = (Behaviour)Activator.CreateInstance(type); detail.CreateBehaviour(behaviour, behaviourID, isEnabled); } } int signalCount = br.ReadInt32(); for (int j = 0; j < signalCount; j++) { var signalDetailID = br.ReadInt32(); var signalBehaviourID = br.ReadInt32(); var signalName = br.ReadString(); var signal = this.GetDetail(signalDetailID).Behaviours[signalBehaviourID].Signals[signalName]; var slotCount = br.ReadInt32(); for (int k = 0; k < slotCount; k++) { var slotDetailID = br.ReadInt32(); var slotBehaviourID = br.ReadInt32(); var slotName = br.ReadString(); var slot = this.GetDetail(slotDetailID).Behaviours[slotBehaviourID].Slots[slotName]; signal.Connect(slot); } } } } }
public RenderModelNodeBlock(BinaryReader binaryReader) { this.name = binaryReader.ReadStringID(); this.parentNode = binaryReader.ReadShortBlockIndex1(); this.firstChildNode = binaryReader.ReadShortBlockIndex1(); this.nextSiblingNode = binaryReader.ReadShortBlockIndex1(); this.importNodeIndex = binaryReader.ReadInt16(); this.defaultTranslation = binaryReader.ReadVector3(); this.defaultRotation = binaryReader.ReadQuaternion(); this.inverseForward = binaryReader.ReadVector3(); this.inverseLeft = binaryReader.ReadVector3(); this.inverseUp = binaryReader.ReadVector3(); this.inversePosition = binaryReader.ReadVector3(); this.inverseScale = binaryReader.ReadSingle(); this.distanceFromParent = binaryReader.ReadSingle(); }
public RenderModelMarkerBlock(BinaryReader binaryReader) { this.regionIndex = binaryReader.ReadByte(); this.permutationIndex = binaryReader.ReadByte(); this.nodeIndex = binaryReader.ReadByte(); this.padding = binaryReader.ReadByte(); this.translation = binaryReader.ReadVector3(); this.rotation = binaryReader.ReadQuaternion(); this.scale = binaryReader.ReadSingle(); }
/// <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.ReadString(7); int version; if (string.Compare(identifier, FILE_IDENTIFIER_2, false) == 0) { version = 2; } else if (string.Compare(identifier, FILE_IDENTIFIER_3, false) == 0) { version = 3; } else { throw new FileIdentifierMismatchException(FilePath, string.Format("{0} / {1}", FILE_IDENTIFIER_2, FILE_IDENTIFIER_3), identifier); } int boneCount = reader.ReadInt32(); if (boneCount >= MAXIMUM_BONE_COUNT) { throw new InvalidBoneCountException(); } for (int i = 0; i < boneCount; i++) { Bone bone = new Bone(); bone.Parent = reader.ReadInt32(); bone.Name = reader.ReadNullTerminatedString(); bone.Translation = reader.ReadVector3(); bone.Rotation = reader.ReadQuaternion(true); Bones.Add(bone); } int dummyCount = reader.ReadInt32(); if (boneCount >= MAXIMUM_BONE_COUNT) { throw new InvalidBoneCountException(); } for (int i = 0; i < dummyCount; i++) { Bone dummy = new Bone(); dummy.Name = reader.ReadNullTerminatedString(); dummy.Parent = reader.ReadInt32(); dummy.Translation = reader.ReadVector3(); if (version == 3) { dummy.Rotation = reader.ReadQuaternion(true); } DummyBones.Clear(); } }