Esempio n. 1
0
/*
*******************************************************************
* Function: 
*
* Description: 
*    
* Parameters: 
*
* Returns: 
*
*******************************************************************
*/
void xDistributedQuatF::unpack(xNStream *bstream,float sendersOneWayTime)
{
	if (this->getPropertyInfo()->mPredictionType == E_PTYPE_PREDICTED)
	{
		sendersOneWayTime *= 0.001f;
		
		QuatF p;
		xMath::stream::mathRead(*bstream,&p);
		QuatF v;	
		xMath::stream::mathRead(*bstream,&v);

		mLastValue = mCurrentValue;
		mCurrentValue = p;
		mDifference= v;


		QuatF predictedPos;// = p + v * sendersOneWayTime;
		setOwnersOneWayTime(sendersOneWayTime);
	}

	if (this->getPropertyInfo()->mPredictionType == E_PTYPE_RELIABLE)
	{
		QuatF p;
		xMath::stream::mathRead(*bstream,&p);
	
		mLastValue = p;
		mCurrentValue = p;
	}
	
}
Esempio n. 2
0
/*
*******************************************************************
* Function: 
*
* Description: 
*    
* Parameters: 
*
* Returns: 
*
*******************************************************************
*/
void xDistributedPoint3F::unpack(xNStream *bstream,float sendersOneWayTime)
{
	if (this->getPropertyInfo()->mPredictionType == E_PTYPE_PREDICTED)
	{
		sendersOneWayTime *= 0.001f;

		TNL::Point3f p;
		bstream->readPointCompressed(&p,1.0f);
		Point3F realPos(p.x,p.y,p.z);


		TNL::Point3f v;
		bstream->readPointCompressed(&v,1.0f);
		Point3F velocity(v.x,v.y,v.z);

		Point3F predictedPos  = realPos + velocity * sendersOneWayTime;
		
		
		setOwnersOneWayTime(sendersOneWayTime);

		mLastValue = mCurrentValue;
		mCurrentValue = predictedPos;
		mDifference= mCurrentValue - mLastValue;
	}

	if (this->getPropertyInfo()->mPredictionType == E_PTYPE_RELIABLE)
	{

		TNL::Point3f p;
		bstream->readPointCompressed(&p,1.0f);
		Point3F realPos(p.x,p.y,p.z);

		mLastValue = realPos;
		mLastServerValue = realPos;
		mCurrentValue = realPos;
	}
}