// We should interpolate the frames // Looks like there will be a file per frame, so need to load all in directory etc, then build anim data from there public void LoadFrames(string path) { string[] files = Directory.GetFiles(path); frames.Clear(); for (int i = 0; i < files.Length; i++) { string ext = Path.GetExtension(files[i]); if (ext == ".bin") { //string filename = Path.GetFileNameWithoutExtension(files[i]); MegaFlowParticleFrame frame = Load(files[i]); frames.Add(frame); } } }
static public MegaFlowParticleFrame Parse(BinaryReader br) { uint code = br.ReadUInt32(); if (code == 0xFABADA) { MegaFlowParticleFrame frame = new MegaFlowParticleFrame(); frame.fluidname = br.ReadBytes(250).ToString(); frame.version = br.ReadUInt16(); frame.scale = br.ReadSingle(); frame.ftype = br.ReadInt32(); frame.etime = br.ReadSingle(); frame.fnum = br.ReadInt32(); frame.fps = br.ReadInt32(); frame.numparticles = br.ReadInt32(); frame.radius = br.ReadSingle(); frame.pressure = ReadVector3(br); frame.speed = ReadVector3(br); frame.temperature = ReadVector3(br); if (frame.version >= 7.0f) { frame.emitpos = ReadVector3(br); frame.emitrot = ReadVector3(br); frame.emitscl = ReadVector3(br); } frame.particles = new MegaFlowParticleData[frame.numparticles]; frame.particles1 = new ParticleSystem.Particle[frame.numparticles]; for (int i = 0; i < frame.numparticles; i++) { ParticleSystem.Particle p = MegaFlowParticleData.LoadParticleData(br, frame.version); frame.particles1[i] = p; //MegaFlowParticleData p = MegaFlowParticleData.Parse(br, frame.version); //frame.particles[i] = p; } return(frame); } return(null); }
MegaFlowParticleFrame Load(string filename) { FileStream fs = new FileStream(filename, FileMode.Open, FileAccess.Read, System.IO.FileShare.Read); BinaryReader br = new BinaryReader(fs); if (br != null) { //ParticleFrame frame = new ParticleFrame(); MegaFlowParticleFrame frame = MegaFlowParticleFrame.Parse(br); //DebugSD(); br.Close(); return(frame); } return(null); }
static public MegaFlowParticleFrame Parse(BinaryReader br) { uint code = br.ReadUInt32(); if ( code == 0xFABADA ) { MegaFlowParticleFrame frame = new MegaFlowParticleFrame(); frame.fluidname = br.ReadBytes(250).ToString(); frame.version = br.ReadUInt16(); frame.scale = br.ReadSingle(); frame.ftype = br.ReadInt32(); frame.etime = br.ReadSingle(); frame.fnum = br.ReadInt32(); frame.fps = br.ReadInt32(); frame.numparticles = br.ReadInt32(); frame.radius = br.ReadSingle(); frame.pressure = ReadVector3(br); frame.speed = ReadVector3(br); frame.temperature = ReadVector3(br); if ( frame.version >= 7.0f ) { frame.emitpos = ReadVector3(br); frame.emitrot = ReadVector3(br); frame.emitscl = ReadVector3(br); } frame.particles = new MegaFlowParticleData[frame.numparticles]; frame.particles1 = new ParticleSystem.Particle[frame.numparticles]; for ( int i = 0; i < frame.numparticles; i++ ) { ParticleSystem.Particle p = MegaFlowParticleData.LoadParticleData(br, frame.version); frame.particles1[i] = p; //MegaFlowParticleData p = MegaFlowParticleData.Parse(br, frame.version); //frame.particles[i] = p; } return frame; } return null; }