#include "c4d_memory.h"
#include "c4d_general.h"
#include "c4d_materialplugin.h"
#include "c4d_resource.h"
#ifdef __API_INTERN__
	#include "shdlist.h"
#else
	#include "ge_prepass.h"
#endif

Bool MaterialData::Draw(BaseMaterial *mat, BaseObject *op, BaseTag *tag, BaseDraw *bd, BaseDrawHelp *bh)
{
	return TRUE;
}

VOLUMEINFO MaterialData::GetRenderInfo(BaseMaterial *mat)
{	
	return VOLUMEINFO_0;
}

INITRENDERRESULT MaterialData::InitRender(BaseMaterial *mat, const InitRenderStruct &irs)
{
	return INITRENDERRESULT_OK;
}

void MaterialData::FreeRender(BaseMaterial *mat)
{
}

void MaterialData::InitCalculation(BaseMaterial *mat, VolumeData *vd, INITCALCULATION type)
{
}

void MaterialData::Displace(BaseMaterial *mat, VolumeData *vd)
{
}

void MaterialData::ChangeNormal(BaseMaterial *mat, VolumeData *vd)
{
}

void MaterialData::CalcSurface(BaseMaterial *mat, VolumeData *vd)
{
}

void MaterialData::CalcTransparency(BaseMaterial *mat, VolumeData *vd)
{
}

void MaterialData::CalcAlpha(BaseMaterial *mat, VolumeData *vd)
{
}

void MaterialData::CalcVolumetric(BaseMaterial *mat, VolumeData *vd)
{
}

Bool MaterialData::InitGLImage(BaseMaterial *mat, BaseDocument* doc, BaseThread* th, BaseBitmap *bmp, LONG doccolorspace, Bool linearworkflow)
{
	return TRUE;
}

GL_MESSAGE MaterialData::GlMessage(BaseMaterial *mat, LONG type, void *data)
{
	return GL_MESSAGE_ERROR;
}


static void FillMaterialPlugin(MATERIALPLUGIN *np, DataAllocator *npalloc, LONG info, LONG disklevel, void *emulation)
{
	FillNodePlugin(np,info,npalloc,NULL,disklevel,emulation);

	np->Draw								= &MaterialData::Draw;
	np->GetRenderInfo				= &MaterialData::GetRenderInfo;
	np->InitRender					= &MaterialData::InitRender;
	np->FreeRender					= &MaterialData::FreeRender;
	np->InitCalculation			= &MaterialData::InitCalculation;
	np->Displace						= &MaterialData::Displace;
	np->ChangeNormal				= &MaterialData::ChangeNormal;
	np->CalcSurface					= &MaterialData::CalcSurface;
	np->CalcTransparency		= &MaterialData::CalcTransparency;
	np->CalcAlpha						= &MaterialData::CalcAlpha;
	np->CalcVolumetric			= &MaterialData::CalcVolumetric;
	np->InitGLImage			    = &MaterialData::InitGLImage;
	np->GlMessage			      = &MaterialData::GlMessage;
}

Bool RegisterMaterialPlugin(LONG id, const String &str, LONG info, DataAllocator *npalloc, const String &description, LONG disklevel, void *emulation)
{
	if (description.Content() && !RegisterDescription(id,description)) return FALSE;

	MATERIALPLUGIN np;
	ClearMem(&np,sizeof(np));
	FillMaterialPlugin(&np,npalloc,info,disklevel,emulation);
	return GeRegisterPlugin(PLUGINTYPE_MATERIAL,id,str,&np,sizeof(np));
}
