//=========================================================== void CSegRemanenceShape::serial(NLMISC::IStream &f) throw(NLMISC::EStream) { // version 2 : added default tracks // version 1 : rollup ratio // version 0 : base version sint ver = f.serialVersion(2); f.serial(_NumSlices); f.serial(_SliceTime); f.serialCont(_Corners); f.serial(_Mat); f.serial(_BBox); f.serial(_TextureShifting); f.serialPtr(_AnimatedMat); if (f.isReading()) { _GeomTouched = true; _MatTouched = true; } if (ver >= 1) { f.serial(_RollUpRatio); } if (ver >= 2) { f.serial(_DefaultPos); f.serial(_DefaultRotQuat); f.serial(_DefaultScale); } }
static void serial(T *&obj, NLMISC::IStream &dest) throw(NLMISC::EStream) { dest.serialPtr(obj); /*if (dest.isReading()) { std::auto_ptr<T> newObj(new T); newObj->serialPtr(dest); delete obj; obj = newObj.release(); } else { obj->serial(dest); }*/ }
///================================================================================================================== void CPSRibbon::serial(NLMISC::IStream &f) throw(NLMISC::EStream) { NL_PS_FUNC(CPSRibbon_serial) // Version 3 : - added brace mode // - added orientation enum sint ver = f.serialVersion(3); if (ver == 1) { nlassert(f.isReading()); /// we had CPSParticle::serial(f), but this is not the base class anymore, so we emulate this... /// version 2 : auto-lod saved sint ver2 = f.serialVersion(2); // here is CPSLocatedBindable::serial(f) sint ver3 = f.serialVersion(4); f.serialPtr(_Owner); if (ver3 > 1) f.serialEnum(_LOD); if (ver3 > 2) f.serial(_Name); if (ver3 > 3) { if (f.isReading()) { uint32 id; f.serial(id); setExternID(id); } else { f.serial(_ExternID); } } if (ver2 >= 2) { bool bDisableAutoLOD; f.serial(bDisableAutoLOD); disableAutoLOD(bDisableAutoLOD); } uint32 tailNbSegs; bool colorFading; bool systemBasisEnabled; bool drEnabled; // dying ribbons, not supported in this version CPSColoredParticle::serialColorScheme(f); CPSSizedParticle::serialSizeScheme(f); // we dont use the 2d angle anymore...serial a dummy one { CDummy2DAngle _Dummy2DAngle; _Dummy2DAngle.serialAngle2DScheme(f); } f.serial(colorFading, systemBasisEnabled); serialMaterial(f); f.serial(drEnabled); f.serial(tailNbSegs); ITexture *tex = NULL; f.serialPolyPtr(tex); _Tex = tex; if (_Tex != NULL) { f.serial(_UFactor, _VFactor) ; } // shape serialization f.serialCont(_Shape); _NbSegs = tailNbSegs >> 1; if (_NbSegs < 1) _NbSegs = 2; setInterpolationMode(Linear); nlassert(_Owner); resize(_Owner->getMaxSize()); initDateVect(); resetFromOwner(); }