//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
MLRTexturePool::MLRTexturePool(GOSImagePool *image_pool, int insDep):
	RegisteredClass(DefaultData)
{
	Check_Object(image_pool);
	Verify(gos_GetCurrentHeap() == Heap);

	instanceDepth = insDep;
	instanceMax = 1<<insDep;

	handleDepth = MLRState::TextureNumberBits - insDep;
	handleMax = 1<<handleDepth;

	freeHandle = new int [handleMax];
	Register_Pointer(freeHandle);
	lastHandle = 0;
	firstFreeHandle = 0;
	lastFreeHandle = 0;

	storedTextures = 0;

	imagePool = image_pool;

	for(int i=0;i<MLRState::TextureMask+1;i++)
	{
		textureArray[i] = NULL;
	}

	unLoadedImages = false;
}
Example #2
0
//------------------------------------------------------------------------------
//
gosFX::Effect__Specification::Effect__Specification(
	Stuff::RegisteredClass::ClassID class_id,
	Stuff::MemoryStream *stream,
	int gfx_version
):
	m_events(NULL)
{
	Check_Pointer(this);
	Check_Object(stream);
	Verify(gos_GetCurrentHeap() == Heap);

	if (gfx_version < 9)
	{
		STOP(("This version of gosFX is no longer supported"));
		return;
	}

	//
	//--------------
	// Read the name
	//--------------
	//
	m_class = class_id;
	*stream >> m_name;

	//
	//--------------------------------------------------------------------
	// Read the events.  If we are using an array, no events will be saved
	//--------------------------------------------------------------------
	//
	unsigned event_count;
	*stream >> event_count;
	while (event_count-- > 0)
	{
		Event *event = Event::Make(stream, gfx_version);
		Register_Object(event);
		m_events.Add(event);
	}

	//
	//--------------------------------------------------------
	// Load the curves, variances, and MLRState if appropriate
	//--------------------------------------------------------
	//
	m_lifeSpan.Load(stream, gfx_version);
	m_minimumChildSeed.Load(stream, gfx_version);
	m_maximumChildSeed.Load(stream, gfx_version);
	m_state.Load(stream, MidLevelRenderer::ReadMLRVersion(stream));
	if (gfx_version < 14)
	{
		m_state.SetRenderPermissionMask(
			m_state.GetRenderPermissionMask() | MidLevelRenderer::MLRState::TextureMask
		);
	}
	if (
		m_state.GetAlphaMode() != MidLevelRenderer::MLRState::OneZeroMode
		&& m_state.GetPriority() < MidLevelRenderer::MLRState::AlphaPriority
	)
		m_state.SetPriority(MidLevelRenderer::MLRState::AlphaPriority);
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
MLR_I_L_TMesh::MLR_I_L_TMesh(
	ClassData *class_data,
	MemoryStream *stream,
	int version
):
	MLR_I_C_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:
		{
			MemoryStreamIO_Read(stream, &normals);
		}
		break;
	}

	litColors.SetLength(colors.GetLength());
}
//------------------------------------------------------------------------------
//
gosFX::ShapeCloud__Specification::ShapeCloud__Specification(
	Stuff::MemoryStream *stream,
	int gfx_version
):
	SpinningCloud__Specification(gosFX::ShapeCloudClassID, stream, gfx_version)
{
	Check_Pointer(this);
	Verify(m_class == ShapeCloudClassID);
	Verify(gos_GetCurrentHeap() == Heap);
	m_particleClassSize = sizeof(gosFX::ShapeCloud::Particle);
	m_totalParticleSize = sizeof(gosFX::ShapeCloud::Particle);

	//
	//---------------
	// Load the shape
	//---------------
	//
	m_shape =
		MidLevelRenderer::MLRShape::Make(
			stream,
			MidLevelRenderer::ReadMLRVersion(stream)
		);
	Register_Object(m_shape);
	*stream >> m_radius;

	//
	//---------------------------------
	// Make sure everything is in order
	//---------------------------------
	//
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
MLRLookUpLight::MLRLookUpLight(
	Stuff::MemoryStream *stream,
	int version
) :
	MLRInfiniteLight(DefaultData, stream, version)
{
	Check_Object(stream);
	Verify(gos_GetCurrentHeap() == Heap);

	*stream >> mapOrigin;
	*stream >> mapZoneCountX >> mapZoneCountZ;
	*stream >> zoneSizeX >> zoneSizeZ;
	*stream >> mapName;

	one_Over_zoneSizeX = 1.0f/zoneSizeX;
	one_Over_zoneSizeZ = 1.0f/zoneSizeZ;

	maps = new unsigned char * [mapZoneCountX * mapZoneCountZ];
	Check_Pointer(maps);

	for(int i=0;i<mapZoneCountX*mapZoneCountZ;i++)
	{
		maps[i] = new unsigned char [256*256];
		Check_Pointer(maps[i]);

		stream->ReadBytes(maps[i], 256*256);
	}

}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
void
	MLR_I_C_DeT_TMesh::Copy(
		MLR_I_C_TMesh *tMesh,
		MLRState detailState,
		Stuff::Scalar xOff,
		Stuff::Scalar yOff,
		Stuff::Scalar xFac,
		Stuff::Scalar yFac
	)
{
	Check_Object(this);
	Check_Object(tMesh);
	Verify(gos_GetCurrentHeap() == Heap);

	int len;
#if COLOR_AS_DWORD
	DWORD *_colors;
#else
	RGBAColor *_colors;
#endif

	MLR_I_DeT_TMesh::Copy(tMesh, detailState, xOff, yOff, xFac, yFac);

	tMesh->GetColorData(&_colors, &len);
	SetColorData(_colors, len);
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
MLRAmbientLight::MLRAmbientLight(Stuff::Page *page) :
	MLRLight(DefaultData, page)
{
	Check_Object(page);
	Verify(gos_GetCurrentHeap() == Heap);
	lightMask = MLRState::FaceLightingMode|MLRState::VertexLightingMode;
}
Example #8
0
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
MLRPointLight::MLRPointLight(
	Stuff::MemoryStream *stream,
	int version
) :
	MLRInfiniteLightWithFalloff(DefaultData, stream, version)
{
	Check_Object(stream);
	Verify(gos_GetCurrentHeap() == Heap);
	lightMap = NULL;
	if (version > 7)
	{
		MString name;
		*stream >> name;
		if (name.GetLength() > 0)
		{
			Check_Object(MLRTexturePool::Instance);
			MLRTexture *texture = (*MLRTexturePool::Instance)(name, 0);
			if (!texture)
				texture = MLRTexturePool::Instance->Add(name, 0);
			Check_Object(texture);
			lightMap = new MLRLightMap(texture);
			Check_Object(lightMap);
			lightMask |= MLRState::LightMapLightingMode;
		}
	}
Example #9
0
//------------------------------------------------------------------------------
//
gosFX::ParticleCloud::ParticleCloud(
	ClassData *class_data,
	Specification *spec,
	unsigned flags
):
	Effect(class_data, spec, flags)
{
	Check_Pointer(this);
	Check_Object(spec);
	Verify(gos_GetCurrentHeap() == Heap);

	//
	//------------------------------------------------
	// Set up the data pointers into the channel block
	//------------------------------------------------
	//
	m_data.SetLength(spec->m_maxParticleCount*spec->m_totalParticleSize);

	//
	//-------------------------------
	// Set up an empty particle cloud
	//-------------------------------
	//
	m_activeParticleCount = 0;
	m_birthAccumulator = 0.0f;
}
Example #10
0
//------------------------------------------------------------------------------
//
void
	gosFX::Effect__Specification::AdoptEvent(Event *event)
{
	Check_Object(this);
	Check_Object(event);
	Verify(event->m_time >= 0.0f && event->m_time <= 1.0f);
	Verify(gos_GetCurrentHeap() == Heap);

	//
	//-----------------------------------------------------------
	// The event must be inserted into the chain in order of time
	//-----------------------------------------------------------
	//
	Stuff::ChainIteratorOf<Event*> events(&m_events);
	Event *insert = NULL;
	while ((insert = events.GetCurrent()) != NULL)
	{
		Check_Object(insert);
		if (insert->m_time > event->m_time)
		{
			events.Insert(event);
			return;
		}
		events.Next();
	}
	m_events.Add(event);
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
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;
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
MLR_I_C_DeT_TMesh::MLR_I_C_DeT_TMesh(ClassData *class_data):
	MLR_I_DeT_TMesh(class_data), colors(0)
{
	Check_Pointer(this);
	Verify(gos_GetCurrentHeap() == Heap);

	actualColors = &colors;
}
//------------------------------------------------------------------------------
//
gosFX::ShapeCloud::ShapeCloud(
	Specification *spec,
	unsigned flags
):
	SpinningCloud(DefaultData, spec, flags)
{
	Verify(gos_GetCurrentHeap() == Heap);
}
Example #14
0
//------------------------------------------------------------------------------
//
gosFX::Card__Specification::Card__Specification():
    Singleton__Specification(gosFX::CardClassID)
{
    Check_Pointer(this);
    Verify(gos_GetCurrentHeap() == Heap);
    m_animated = false;
    m_width = 1;
}
Example #15
0
//------------------------------------------------------------------------------
//
gosFX::ParticleCloud__Specification::ParticleCloud__Specification(
	Stuff::RegisteredClass::ClassID class_id
):
	Effect__Specification(class_id)
{
	Verify(gos_GetCurrentHeap() == Heap);
	m_maxParticleCount = 0;
	Check_Pointer(this);
}
Example #16
0
//------------------------------------------------------------------------------
//
gosFX::Shape::Shape(
	Specification *spec,
	unsigned flags
):
	Singleton(DefaultData, spec, flags)
{
	Verify(gos_GetCurrentHeap() == Heap);
	m_radius = spec->m_radius;
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
MLRTexturePool::MLRTexturePool(MemoryStream *stream):
	RegisteredClass(DefaultData)
{
	Verify(gos_GetCurrentHeap() == Heap);

	unLoadedImages = false;

	STOP(("Not implemented"));
}
Example #18
0
//------------------------------------------------------------------------------
//
gosFX::Effect__Specification::Effect__Specification(
	Stuff::RegisteredClass::ClassID class_id
):
	m_events(NULL)
{
	Check_Pointer(this);
	Verify(gos_GetCurrentHeap() == Heap);
	m_class = class_id;
}
Example #19
0
//------------------------------------------------------------------------------
//
gosFX::Card__Specification::Card__Specification(
    Stuff::MemoryStream *stream,
    int gfx_version
):
    Singleton__Specification(gosFX::CardClassID, stream, gfx_version)
{
    Check_Pointer(this);
    Verify(m_class == CardClassID);
    Verify(gos_GetCurrentHeap() == Heap);

    m_halfHeight.Load(stream, gfx_version);
    m_aspectRatio.Load(stream, gfx_version);

    //
    //-------------------------------------------------------------------
    // If we are reading an old version of the card cloud, ignore all the
    // animation on the UV channels
    //-------------------------------------------------------------------
    //
    if (gfx_version < 10)
    {
        m_index.m_ageCurve.SetCurve(0.0f);
        m_index.m_seedCurve.SetCurve(1.0f);
        m_index.m_seeded = false;

        SeededCurveOf<ComplexCurve, LinearCurve,Curve::e_ComplexLinearType> temp;
        temp.Load(stream, gfx_version);
        Stuff::Scalar v = temp.ComputeValue(0.0f, 0.0f);
        m_UOffset.SetCurve(v);

        temp.Load(stream, gfx_version);
        v = temp.ComputeValue(0.0f, 0.0f);
        m_VOffset.SetCurve(v);

        m_USize.Load(stream, gfx_version);
        m_VSize.Load(stream, gfx_version);

        m_animated = false;
    }

    //
    //------------------------------
    // Otherwise, read in the curves
    //------------------------------
    //
    else
    {
        m_index.Load(stream, gfx_version);
        m_UOffset.Load(stream, gfx_version);
        m_VOffset.Load(stream, gfx_version);
        m_USize.Load(stream, gfx_version);
        m_VSize.Load(stream, gfx_version);
        *stream >> m_animated;
    }
    SetWidth();
}
Example #20
0
//------------------------------------------------------------------------------
//
gosFX::Shape__Specification::Shape__Specification(
	MidLevelRenderer::MLRShape *shape
):
	Singleton__Specification(gosFX::ShapeClassID)
{
	Check_Pointer(this);
	Verify(gos_GetCurrentHeap() == Heap);
	m_shape = NULL;
	SetShape(shape);
}
Example #21
0
//------------------------------------------------------------------------------
//
gosFX::Event::Event(const Event& event):
	Plug(DefaultData)
{
	Check_Pointer(this);
	Verify(gos_GetCurrentHeap() == Heap);

	m_time = event.m_time;
	m_flags = event.m_flags;
	m_effectID = event.m_effectID;
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
MLRAmbientLight::MLRAmbientLight(
	Stuff::MemoryStream *stream,
	int version
) :
	MLRLight(DefaultData, stream, version)
{
	Check_Object(stream);
	Verify(gos_GetCurrentHeap() == Heap);
	lightMask = MLRState::FaceLightingMode|MLRState::VertexLightingMode;
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
MLRIndexedTriangleCloud::MLRIndexedTriangleCloud(int nr) :
	MLRTriangleCloud(nr)
{
	Verify(gos_GetCurrentHeap() == Heap);
	usedNrOfPoints = NULL;

	Check_Pointer(this);
	
	drawMode = SortData::TriIndexedList;
}
//------------------------------------------------------------------------------
//
gosFX::ShapeCloud__Specification::ShapeCloud__Specification(
	MidLevelRenderer::MLRShape *shape
):
	SpinningCloud__Specification(gosFX::ShapeCloudClassID)
{
	Check_Pointer(this);
	Verify(gos_GetCurrentHeap() == Heap);
	m_totalParticleSize = m_particleClassSize = sizeof(gosFX::ShapeCloud::Particle);
	m_shape = NULL;
	SetShape(shape);
}
Example #25
0
//------------------------------------------------------------------------------
//
gosFX::Event::Event(
	Stuff::MemoryStream *stream,
	int gfx_version
):
	Plug(DefaultData)
{
	Check_Pointer(this);
	Check_Object(stream);
	Verify(gos_GetCurrentHeap() == Heap);

	*stream >> m_time >> m_flags >> m_effectID >> m_localToParent;
}
Example #26
0
		virtual void
			SetSubprimitiveLengths(
				unsigned char *length_array,
				int subprimitive_count
				)
				{
					Check_Object(this);
					Verify(gos_GetCurrentHeap() == Heap);
					numOfTriangles = subprimitive_count;
					testList.SetLength(numOfTriangles);
					facePlanes.SetLength(numOfTriangles);
				}
Example #27
0
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
void
	MLRSorter::InitializeClass()
{
	Verify(!DefaultData);
	Verify(gos_GetCurrentHeap() == StaticHeap);
	DefaultData =
		new ClassData(
			MLRSorterClassID,
			"MidLevelRenderer::MLRSorter",
			RegisteredClass::DefaultData
		);
	Register_Object(DefaultData);
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
void
	MLRAmbientLight::InitializeClass()
{
	Verify(!DefaultData);
	Verify(gos_GetCurrentHeap() == StaticHeap);
	DefaultData =
		new ClassData(
			MLRAmbientLightClassID,
			"MidLevelRenderer::MLRAmbientLight",
			MLRLight::DefaultData
		);
	Register_Object(DefaultData);
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
void
	MLRLookUpLight::InitializeClass()
{
	Verify(!DefaultData);
	Verify(gos_GetCurrentHeap() == StaticHeap);
	DefaultData =
		new ClassData(
			MLRLookUpLightClassID,
			"MidLevelRenderer::MLRLookUpLight",
			MLRInfiniteLight::DefaultData
		);
	Check_Object(DefaultData);
}
Example #30
0
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
MLRNGonCloud::MLRNGonCloud(int vertices, int nr) :
	MLREffect(nr, DefaultData)
{
	Verify(gos_GetCurrentHeap() == Heap);
	usedNrOfNGons = NULL;

	numOfVertices = vertices;

	Check_Pointer(this);
	
	Verify(vertices*nr >= 0 && vertices*nr<=Limits::Max_Number_Vertices_Per_Mesh);
	specialClipColors.SetLength(vertices);
	drawMode = SortData::TriList;
}