Exemple #1
0
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
void
	MLR_I_C_DT_PMesh::Save(MemoryStream *stream)
{
	Check_Object(this);
	Check_Object(stream);

	MLR_I_DT_PMesh::Save(stream);

#if COLOR_AS_DWORD
	MemoryStreamIO_Write(stream, &colors);
#else
	Stuff::DynamicArrayOf<DWORD> smallColors;
	int i, len = colors.GetLength();

	const Stuff::RGBAColor *data = colors.GetData();

	smallColors.SetLength(len);

	for(i=0;i<len;i++)
	{
		smallColors[i] = GOSCopyColor(data+i);
	}

	MemoryStreamIO_Write(stream, &smallColors);
#endif
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
MLR_I_C_DeT_TMesh::MLR_I_C_DeT_TMesh(
	ClassData *class_data,
	MemoryStream *stream,
	int version
):
	MLR_I_DeT_TMesh(class_data, stream, version)
{
	Check_Pointer(this);
	Check_Pointer(stream);
	Verify(gos_GetCurrentHeap() == Heap);

	switch(version)
	{
		case 1:
		case 2:
		{
			STOP(("This class got created only after version 2 !"));
		}
		break;
		default:
		{
#if COLOR_AS_DWORD
			MemoryStreamIO_Read(stream, &colors);
#else
			Stuff::DynamicArrayOf<DWORD> smallColors;

			MemoryStreamIO_Read(stream, &smallColors);
		
			int i, len = smallColors.GetLength();

			colors.SetLength(len);

			DWORD theColor;

			for(i=0;i<len;i++)
			{
				theColor = smallColors[i];

				colors[i].blue = (theColor & 0xff) * One_Over_256;

				theColor = theColor>>8;

				colors[i].green = (theColor & 0xff) * One_Over_256;

				theColor = theColor>>8;

				colors[i].red = (theColor & 0xff) * One_Over_256;

				theColor = theColor>>8;

				colors[i].alpha = (theColor & 0xff) * One_Over_256;
			}
#endif
		}
		break;
	}

	actualColors = &colors;
}
Exemple #3
0
	inline
		GOSVertexPool::GOSVertexPool() 
	{ 
		Verify(gos_GetCurrentHeap() == Heap);
		lastUsed = 0;
		lastUsed2uv = 0;
		lastUsedIndex = 0;
		
		gos_PushCurrentHeap(StaticHeap);
		vertices.SetLength(Limits::Max_Number_Vertices_Per_Frame+4*Limits::Max_Number_ScreenQuads_Per_Frame+1);
		vertices2uv.SetLength(Limits::Max_Number_Vertices_Per_Frame+4*Limits::Max_Number_ScreenQuads_Per_Frame+1);
		indices.SetLength(Limits::Max_Number_Vertices_Per_Frame+16);

		verticesDB.SetLength(2*Limits::Max_Number_Vertices_Per_Mesh);
		vertices2uvDB.SetLength(2*Limits::Max_Number_Vertices_Per_Mesh);
		indicesDB.SetLength(2*Limits::Max_Number_Vertices_Per_Mesh);

		gos_PopCurrentHeap();

		vertexAlignment=32-( (int)vertices.GetData() & 31 );
		vertexAlignment2uv=32-( (int)vertices2uv.GetData() & 31 );
		indicesAlignment=32-( (int)indices.GetData() & 31 );
	}