//===========================================================================//
// File:	D3DRMVideoRenderables.cpp                                        //
// Project: MUNGA           Brick: Win95 Video Renderer 	                 // 
// Contents: GOS95 Layer Video Renderer									 //
//---------------------------------------------------------------------------//
//   Date    Who  Modification                                               //
// --------  ---  ---------------------------------------------------------- //
// 03/13/97  JTR  Initial coding.                                            //
//---------------------------------------------------------------------------//
// Copyright (C) 1997, Virtual World Entertainment, Inc.                     //
// All Rights reserved worldwide                                             //
// This unpublished sourcecode is PROPRIETARY and CONFIDENTIAL               //
//===========================================================================//

#include "AdeptHeaders.hpp"
#include "VideoHeaders.hpp"
#include "Tool.hpp"

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
SlidingShapeComponent::ClassData*
	SlidingShapeComponent::CreateFactoryRequest(
		FactoryRequestParameters *parameters,
		Entity::ClassData *class_data
	)
{
	Check_Object(parameters);

	//
	//-------------------------------------------------------------------------
	// Allocate enough room for what we need to write out, then call our parent
	//-------------------------------------------------------------------------
	//
	MemoryStream *component_stream = parameters->m_stream;
	Check_Object(component_stream);
	component_stream->AllocateBytes(sizeof(SlidingShapeComponent));
	Check_Object(Resource::ParentFileDependencies);

	//
	//----------------------------
	// Let our parent do its thing
	//----------------------------
	//
	bool result = BaseClass::CreateFactoryRequest(parameters) != NULL;

	//
	//------------------------------------
	// Find the parent object for the mesh
	//------------------------------------
	//
	Page *page = parameters->m_page;
	Check_Object(page);
	NotationFile *file = page->GetNotationFile();
	Check_Object(file);

	//
	//-------------------------
	// Read the attribute field
	//-------------------------
	//
	const char* transform_name;
	page->GetEntry("Transform", &transform_name, true);
	const AttributeEntry *transform_entry;

	Check_Object(class_data);
	transform_entry = 
		class_data->attributeTable.GetAttributeEntry(transform_name);
	if (transform_entry == NULL)
	{
		STOP((
			"%s: {[%s]Transform=%s}: Unknown attribute!",
			file->GetFileName(),
			page->GetName(),
			transform_name
		));
		return false;
	}
	Check_Object(transform_entry);
	if (transform_entry->attributeType != AffineMatrix4DClassID)
	{
		PAUSE((
			"%s: {[%s]Transform=%s}: Attribute is not correct type!",
			file->GetFileName(),
			page->GetName(),
			transform_name
		));
		result = false;
	}
	else
		*component_stream << transform_entry->attributeID;

	Check_Object(DefaultData);
	return (result) ? DefaultData : NULL;
}

