示例#1
0
void			CIDEEntry_2DFX_Ladder::unserialize(void)
{
	CDataReader *pDataReader = CDataReader::getInstance();
	
	CIDEEntry_2DFX::unserialize();
	
	m_vecLadderStartPosition = pDataReader->readVector3D();
	m_vecLadderEndPosition = pDataReader->readVector3D();
	m_vecClimbDirectionPosition = pDataReader->readVector3D();
	m_uiFlags = pDataReader->readTokenUint32();
}
示例#2
0
void			CIDEEntry_PATH_Node::unserialize(void)
{
	CDataReader *pDataReader = CDataReader::getInstance();

	if (getLatestPathGroup() == nullptr)
	{
		// path node found before path group
		throw EXCEPTION_INVALID_DATA_ORDER;
	}

	switch (pDataReader->getLineTokens().size())
	{
	case 9:
		CIDEEntry_PATH::unserialize();

		setFormatType(0);
		setFormatGames(GAME_FLAG_GTA_III | GAME_FLAG_GTA_VC);

		m_uiNodeType = pDataReader->readTokenUint32();
		m_uiNextNode = pDataReader->readTokenUint32();
		m_uiIsCrossRoad = pDataReader->readTokenUint32();
		m_vecPosition = pDataReader->readVector3D() / 16.0f;
		m_fUnknown1 = pDataReader->readTokenFloat32();
		m_uiLeftLaneCount = pDataReader->readTokenUint32();
		m_uiRightLaneCount = pDataReader->readTokenUint32();
		break;
	}

	getLatestPathGroup()->addEntry(this);
}
示例#3
0
void			CIDEEntry_ANIM::unserialize(void)
{
	CDataReader *pDataReader = CDataReader::getInstance();

	switch (pDataReader->getLineTokens().size())
	{
	case 6:
		// GTA SA
		setFormatType(0);
		setFormatGames(GAME_FLAG_GTA_SA);
		m_uiObjectId = pDataReader->readTokenUint32();
		m_strModelName = pDataReader->readTokenString();
		m_strTXDName = pDataReader->readTokenString();
		m_strAnimationName = pDataReader->readTokenString();
		m_fDrawDistance = pDataReader->readTokenFloat32();
		m_uiFlags = pDataReader->readTokenUint32();
		break;
	case 16:
		// GTA IV
		setFormatType(1);
		setFormatGames(GAME_FLAG_GTA_IV);
		m_strModelName = pDataReader->readTokenString();
		m_strTXDName = pDataReader->readTokenString();
		m_strAnimationName = pDataReader->readTokenString();
		m_fDrawDistance = pDataReader->readTokenFloat32();
		m_uiFlags = pDataReader->readTokenUint32();
		m_uiUnknown1 = pDataReader->readTokenUint32();
		m_vecBoundingBoxLowerLeftCorner = pDataReader->readVector3D();
		m_vecBoundingBoxUpperRightCorner = pDataReader->readVector3D();
		m_vecBoundingSphereCenterPosition = pDataReader->readVector3D();
		m_fBoundingSphereRadius = pDataReader->readTokenFloat32();
		m_strLODModel = pDataReader->readTokenString();
		break;
	default:
		throw EXCEPTION_UNKNOWN_FORMAT_TYPE;
	}
}
示例#4
0
void			CIDEEntry_TOBJ::unserialize(void)
{
	CDataReader *pDataReader = CDataReader::getInstance();

	switch (pDataReader->getLineTokens().size())
	{
	case 4: // Type 0: GTA III, VC, SA
		setFormatType(0);
		setFormatGames(GAME_FLAG_GTA_III | GAME_FLAG_GTA_VC | GAME_FLAG_GTA_SA);
		m_uiObjectId = pDataReader->readTokenUint32();
		m_strModelName = pDataReader->readTokenString();
		m_strTXDName = pDataReader->readTokenString();
		m_uiUnknown2 = pDataReader->readTokenUint32();
		break;
	case 8: // Type 1: GTA III, VC, SA
		setFormatType(1);
		setFormatGames(GAME_FLAG_GTA_III | GAME_FLAG_GTA_VC | GAME_FLAG_GTA_SA);
		m_uiObjectId = pDataReader->readTokenUint32();
		m_strModelName = pDataReader->readTokenString();
		m_strTXDName = pDataReader->readTokenString();
		m_uiClumpCount = pDataReader->readTokenUint32();
		m_vecDrawDistances = {
			pDataReader->readTokenFloat32()
		};
		m_uiFlags = pDataReader->readTokenUint32();
		m_uiTimeOn = pDataReader->readTokenUint32();
		m_uiTimeOff = pDataReader->readTokenUint32();
		break;
	case 9: // Type 2: GTA III, VC, SA
		setFormatType(2);
		setFormatGames(GAME_FLAG_GTA_III | GAME_FLAG_GTA_VC | GAME_FLAG_GTA_SA);
		m_uiObjectId = pDataReader->readTokenUint32();
		m_strModelName = pDataReader->readTokenString();
		m_strTXDName = pDataReader->readTokenString();
		m_uiClumpCount = pDataReader->readTokenUint32();
		m_vecDrawDistances = {
			pDataReader->readTokenFloat32(),
			pDataReader->readTokenFloat32()
		};
		m_uiFlags = pDataReader->readTokenUint32();
		m_uiTimeOn = pDataReader->readTokenUint32();
		m_uiTimeOff = pDataReader->readTokenUint32();
		break;
	case 10: // Type 3: GTA III, VC, SA
		setFormatType(3);
		setFormatGames(GAME_FLAG_GTA_III | GAME_FLAG_GTA_VC | GAME_FLAG_GTA_SA);
		m_uiObjectId = pDataReader->readTokenUint32();
		m_strModelName = pDataReader->readTokenString();
		m_strTXDName = pDataReader->readTokenString();
		m_uiClumpCount = pDataReader->readTokenUint32();
		m_vecDrawDistances = {
			pDataReader->readTokenFloat32(),
			pDataReader->readTokenFloat32(),
			pDataReader->readTokenFloat32()
		};
		m_uiFlags = pDataReader->readTokenUint32();
		m_uiTimeOn = pDataReader->readTokenUint32();
		m_uiTimeOff = pDataReader->readTokenUint32();
		break;
	case 7: // Type 4: GTA SA
		setFormatType(4);
		setFormatGames(GAME_FLAG_GTA_SA);
		m_uiObjectId = pDataReader->readTokenUint32();
		m_strModelName = pDataReader->readTokenString();
		m_strTXDName = pDataReader->readTokenString();
		m_vecDrawDistances = {
			pDataReader->readTokenFloat32()
		};
		m_uiFlags = pDataReader->readTokenUint32();
		m_uiTimeOn = pDataReader->readTokenUint32();
		m_uiTimeOff = pDataReader->readTokenUint32();
		break;
	case 17:
		// TOBJ - type 5: GTA IV [type 1 for GTA IV]
		setFormatType(5);
		setFormatGames(GAME_FLAG_GTA_IV);
		m_strModelName = pDataReader->readTokenString();
		m_strTXDName = pDataReader->readTokenString();
		m_vecDrawDistances.push_back(pDataReader->readTokenFloat32());
		m_uiFlags = pDataReader->readTokenUint32();
		m_uiUnknown2 = pDataReader->readTokenUint32();
		m_vecBoundingBoxLowerLeftCorner = pDataReader->readVector3D();
		m_vecBoundingBoxUpperRightCorner = pDataReader->readVector3D();
		m_vecBoundingSphereCenterPosition = pDataReader->readVector3D();
		m_fBoundingSphereRadius = pDataReader->readTokenFloat32();
		m_strLODModel = pDataReader->readTokenString();
		m_uiNightFlags = pDataReader->readTokenUint32();
		break;
	default:
	{
		uint32 uiLineTokenCount = pDataReader->getLineTokenCount();
		uint32 uiTokenIndex = 4; // starting at 1, so it can be compared directly with line token count

		setFormatType(6);
		setTokenCount(uiLineTokenCount);

		// first 4 tokens
		m_uiObjectId = pDataReader->readTokenUint32();
		m_strModelName = pDataReader->readTokenString();
		m_strTXDName = pDataReader->readTokenString();
		m_uiClumpCount = pDataReader->readTokenUint32();

		// draw distances
		if (uiLineTokenCount < (uiTokenIndex + m_uiClumpCount))
		{
			throw EXCEPTION_UNKNOWN_FORMAT_TYPE;
		}
		m_vecDrawDistances.resize(m_uiClumpCount);
		for (uint32 i = 0; i < m_uiClumpCount; i++)
		{
			m_vecDrawDistances[i] = pDataReader->readTokenFloat32();;
		}
		uiTokenIndex += m_uiClumpCount;

		// flags
		if (uiLineTokenCount < (uiTokenIndex + 1))
		{
			throw EXCEPTION_UNKNOWN_FORMAT_TYPE;
		}
		m_uiFlags = pDataReader->readTokenUint32();
		uiTokenIndex++;

		if (uiLineTokenCount >= (uiTokenIndex + 1))
		{
			// time on - optional
			m_uiTimeOn = pDataReader->readTokenUint32();
			uiTokenIndex++;

			if (uiLineTokenCount >= (uiTokenIndex + 1))
			{
				// time off - optional
				m_uiTimeOff = pDataReader->readTokenUint32();
				uiTokenIndex++;
			}
		}
		break;
	}
	}
}
示例#5
0
void							CRWSection_Geometry::unserialize(void)
{
	CDataReader *pDataReader = CDataReader::getInstance();

	m_usFlags = pDataReader->readUint16();
	m_ucUVCoordinateCount = pDataReader->readUint8();
	if (m_usFlags & 4)
	{
		m_ucUVCoordinateCount = 1;
	}
	m_ucGeometryNativeFlags = pDataReader->readUint8();
	m_uiTriangleCount = pDataReader->readUint32();
	m_uiVertexCount = pDataReader->readUint32();
	m_uiFrameCount = pDataReader->readUint32();

	if (m_uiSectionRWVersion < 0x1003FFFF)
	{
		m_uiAmbientColour = pDataReader->readUint32();
		m_uiDiffuseColour = pDataReader->readUint32();
		m_uiSpecularColour = pDataReader->readUint32();
	}
	else
	{
		m_uiAmbientColour = 1;
		m_uiDiffuseColour = 1;
		m_uiSpecularColour = 1;
	}

	if (!m_ucGeometryNativeFlags)
	{
		if (m_usFlags & 8)
		{
			m_vecVertexColours = pDataReader->readVector4ui8ArrayAsStdVector(m_uiVertexCount);
		}

		if (m_usFlags & 4)
		{
			m_vecTextureCoordinates = pDataReader->readVector2DArrayAsStdVector(m_uiVertexCount);
		}

		if (m_usFlags & 128)
		{
			for (uint32 i = 0, j = m_ucUVCoordinateCount; i < j; i++)
			{
				m_vecTextureCoordinates = pDataReader->readVector2DArrayAsStdVector(m_uiVertexCount);
			}
		}

		m_vecVertexIndices = pDataReader->readVector4ui16ArrayAsStdVector(m_uiTriangleCount);
	}

	m_boundingInfo.setCenter(pDataReader->readVector3D());
	m_boundingInfo.setCenterRadius(pDataReader->readFloat32());
	m_boundingInfo.setHasPosition(pDataReader->readUint32() != 0);
	m_boundingInfo.setHasNormals(pDataReader->readUint32() != 0);

	if (!m_ucGeometryNativeFlags)
	{
		if ((m_usFlags & 2) || m_boundingInfo.doesHavePosition() /* || true */)
		{
			m_vecTextureCoordinates = pDataReader->readVector2DArrayAsStdVector(m_uiVertexCount); // todo - store multiple texture coordinates so data loss doesn't occur
		}

		if ((m_usFlags & 16) || m_boundingInfo.doesHaveNormals())
		{
			m_vecVertexNormals = pDataReader->readVector3DArrayAsStdVector(m_uiVertexCount);
		}
	}
}