Beispiel #1
0
// ***************************************************************************
void	CMaterialBase::CAnimatedTexture::serial(NLMISC::IStream &f)
{
    ITexture	*text= NULL;
    if(f.isReading())
    {
        f.serialPolyPtr(text);
        Texture= text;
    }
    else
    {
        text= Texture;
        f.serialPolyPtr(text);
    }
}
//=======================================================
void CPSRibbonLookAt::serial(NLMISC::IStream &f) throw(NLMISC::EStream)
{
	NL_PS_FUNC(CPSRibbonLookAt_serial)
	/** Version 4 : added CPSRibbonBase has a base class instead of CPSParticle
	  *
	  */
	sint ver = f.serialVersion(4);
	if (ver > 3)
	{
		CPSRibbonBase::serial(f);
	}
	else
	{
		CPSParticle::serial(f);
	}
	CPSColoredParticle::serialColorScheme(f);
	CPSSizedParticle::serialSizeScheme(f);
	serialMaterial(f);
	uint32 dummy = 0; /* _NbDyingRibbons */
	if (ver <= 3)
	{
		f.serial(_SegDuration, _NbSegs, dummy /*_NbDyingRibbons*/);
	}
	ITexture *tex = NULL;

	if (ver > 2)
	{
		f.serial(_Parametric);
	}


	if (!f.isReading())
	{
		tex = _Tex;
		f.serialPolyPtr(tex);
	}
	else
	{
		f.serialPolyPtr(tex);
		setTexture(tex);
		_Tex = tex;
		if (_Tex)
		{
			_Tex->setWrapS(ITexture::Clamp);
			_Tex->setWrapT(ITexture::Clamp);
		}
		setTailNbSeg(_NbSegs); // force to build the vb
	}
}
Beispiel #3
0
// ***************************************************************************
void CShapeStream::serial(NLMISC::IStream &f) throw(NLMISC::EStream)
{
	// First, serial an header or checking if it is correct
	f.serialCheck (NELID("PAHS"));

	// Then, serial the shape
	f.serialPolyPtr (_Shape);

	// Ok, it's done
}
Beispiel #4
0
// ************************************************************************
void	CTextureBlend::serial(NLMISC::IStream &f) throw(NLMISC::EStream)
{
	f.serialVersion(0);
	ITexture::serial(f);
	for (uint k = 0; k < 2; ++k)
	{
		ITexture *tex = NULL;
		if (f.isReading())
		{
			f.serialPolyPtr(tex);
			_BlendTex[k] = tex;
			touch();
		}
		else
		{
			tex = _BlendTex[k];
			f.serialPolyPtr(tex);
		}
	}
	f.serial(_SharingEnabled, _BlendFactor);
}
Beispiel #5
0
//***************************************************************************************************************
void CFlareShape::serial(NLMISC::IStream &f) throw(NLMISC::EStream)
{
	// Version 4 : - added occlusion test mesh, size reduction, angle modification when object is occluded
	//             - added lookat mode for first flare
	sint ver = f.serialVersion(5);
	f.serial(_Color, _Persistence, _Spacing);
	f.serial(_Attenuable);
	if (_Attenuable)
	{
		f.serial(_AttenuationRange);
	}
	f.serial(_FirstFlareKeepSize);
	if (f.isReading() && ver <= 4)
	{
		_FirstFlareKeepSize = false;
	}
	for (uint k = 0; k < MaxFlareNum; ++k)
	{
		ITexture *tex = _Tex[k];
		f.serialPolyPtr(tex);
		if (f.isReading())
		{
			_Tex[k] = tex;
		}
		f.serial(_Size[k], _Pos[k]);
	}
	f.serial(_InfiniteDist);
	if (!_InfiniteDist)
	{
		f.serial(_MaxViewDist, _MaxViewDistRatio);
	}
	f.serial(_DazzleEnabled);
	if (_DazzleEnabled)
	{
		f.serial(_DazzleColor, _DazzleAttenuationRange);
	}
	f.serial(_InfiniteDist);
	if (ver >= 2)
	{
		f.serial( _DistMax );
	}
	if (ver >= 4)
	{
		f.serial(_OcclusionTestMeshName);
		f.serial(_ScaleWhenDisappear);
		f.serial(_SizeDisappear);
		f.serial(_AngleDisappear);
		f.serial(_OcclusionTestMeshInheritScaleRot);
		f.serial(_LookAtMode);
	}
}
	// ***************************************************************************
	void CInterfaceElement::serial(NLMISC::IStream &f)
	{
		f.serialPolyPtr(_Parent);
		f.serial(_Id);
		f.serial(_Active);
		f.serial(_InvalidCoords);
		f.serial(_XReal, _YReal, _WReal, _HReal);
		f.serial(_X, _Y, _W, _H);
		f.serialEnum(_PosRef);
		f.serialEnum(_ParentPosRef);
		_ParentPos.serialPolyPtr(f);
		f.serial(_SizeRef);
		f.serial(_SizeDivW, _SizeDivH);
		_ParentSize.serialPolyPtr(f);
		f.serial(_ModulateGlobalColor);
		f.serial(_RenderLayer);
		f.serial(_AvoidResizeParent);
		nlassert(_Links == NULL); // not supported
	}
///===================================================================================
void CPSRotated2DParticle::serialAngle2DScheme(NLMISC::IStream &f) throw(NLMISC::EStream)
{
	NL_PS_FUNC(CPSRotated2DParticle_serialAngle2DScheme)
	f.serialVersion(1);
	if (f.isReading())
	{
		if (_Angle2DScheme)
		{
			delete _Angle2DScheme;
			_Angle2DScheme = NULL;
		}
	}
	bool useAngle2DScheme = _Angle2DScheme != NULL;
	f.serial(useAngle2DScheme);
	if (useAngle2DScheme)
	{
		f.serialPolyPtr(_Angle2DScheme);
	}
	else
	{
		f.serial(_Angle2D);
	}
}
//=======================================
void CPSSizedParticle::serialSizeScheme(NLMISC::IStream &f) throw(NLMISC::EStream)
{
	NL_PS_FUNC(CPSSizedParticle_serialSizeScheme)
	f.serialVersion(1);
	if (f.isReading())
	{
		if (_SizeScheme)
		{
			delete _SizeScheme;
			_SizeScheme = NULL;
		}
	}
	bool useSizeScheme = _SizeScheme != NULL;
	f.serial(useSizeScheme);
	if (useSizeScheme)
	{
		f.serialPolyPtr(_SizeScheme);
	}
	else
	{
		f.serial(_ParticleSize);
	}
};
//=======================================
void CPSColoredParticle::serialColorScheme(NLMISC::IStream &f) throw(NLMISC::EStream)
{
	NL_PS_FUNC(CPSColoredParticle_IStream )
	f.serialVersion(1);
	if (f.isReading())
	{
		if (_ColorScheme)
		{
			delete _ColorScheme;
			_ColorScheme = NULL;
		}
	}
	bool useColorScheme = _ColorScheme != NULL;
	f.serial(useColorScheme);
	if (useColorScheme)
	{
		f.serialPolyPtr(_ColorScheme);
	}
	else
	{
		f.serial(_Color);
	}
}
Beispiel #10
0
///==================================================================================================================
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();
	}
Beispiel #11
0
//============================================
void CWaterShape::serial(NLMISC::IStream &f) throw(NLMISC::EStream)
{
	/* ***********************************************
	 *	WARNING: This Class/Method must be thread-safe (ctor/dtor/serial): no static access for instance
	 *	It can be loaded/called through CAsyncFileManager for instance
	 * ***********************************************/

	// version 4 : added scene water env map
	// version 3 : added '_Splashenabled' flag
	sint ver = f.serialVersion(4);
	// serial 'shape'
	f.serial(_Poly);
	// serial heightMap identifier
	f.serial(_WaterPoolID);
	//serial maps
	ITexture *map = NULL;
	if (f.isReading())
	{
		f.serialPolyPtr(map); _EnvMap[0] = map;
		f.serialPolyPtr(map); _EnvMap[1] = map;
		f.serialPolyPtr(map); _BumpMap[0] = map;
		f.serialPolyPtr(map); _BumpMap[1] = map;
		f.serialPolyPtr(map); _ColorMap = map;
		computeBBox();
	}
	else
	{
		map = _EnvMap[0]; f.serialPolyPtr(map);
		map = _EnvMap[1]; f.serialPolyPtr(map);
		map = _BumpMap[0]; f.serialPolyPtr(map);
		map = _BumpMap[1]; f.serialPolyPtr(map);
		map = _ColorMap; f.serialPolyPtr(map);
	}

	f.serial(_HeightMapScale[0], _HeightMapScale[1],
			 _HeightMapSpeed[0], _HeightMapSpeed[1]);

	f.serial(_ColorMapMatColumn0, _ColorMapMatColumn1, _ColorMapMatPos);

	// serial default tracks
	f.serial(_DefaultPos);
	f.serial(_DefaultScale);
	f.serial(_DefaultRotQuat);

	f.serial(_TransitionRatio);

	f.serial(_WaveHeightFactor);

	if (ver >= 1)
		f.serial (_ComputeLightmap);

	if (ver >= 2)
		f.serial (_DistMax);

	if (ver >= 3)
		f.serial(_SplashEnabled);

	if (ver >= 4)
	{
		f.serial(_UsesSceneWaterEnvMap[0], _UsesSceneWaterEnvMap[1]);
	}

	// tmp
	/*
	if (f.isReading())
	{
		_UsesSceneWaterEnvMap[0] = true;
		_UsesSceneWaterEnvMap[1] = true;
	}
	*/
}
Beispiel #12
0
	static void serial(T *&obj, NLMISC::IStream &dest)  throw(NLMISC::EStream)
	{
		dest.serialPolyPtr(obj);
	}