//////////////////////////////////////////////////////////////////////////////
//
// Asura_Platform_Shape.cpp
//
// Copyright (c) 2006 Rebellion. All rights reserved.
//
//////////////////////////////////////////////////////////////////////////////

// I N C L U D E S ///////////////////////////////////////////////////////////

#include "Core/Asura.h"

// This file's header.
#include "Asura_Platform_Shape.h"

// Engine independent.
#include "Camera/Asura_Camera.h"
#include "Core/Asura_Material_System.h"
#include "Core/Asura_MaterialResponse_System.h"
#include "Rendering/Asura_Render.h"

// Engine platform-specific.
#include "Rendering/Asura_PS3_RenderingOptions.h"

// C L A S S   I M P L E M E N T A T I O N S /////////////////////////////////

//
// Asura_Shape_Instance
//

void Asura_Shape_Instance::Platform_SetAmbientARGB( const unsigned int uARGB )
{
    m_uAmbientARGB = uARGB;
    m_uFlags &= ~ASURA_SHAPE_INSTANCE_USES_DEFAULT_AMBIENT;
}

void Asura_Shape_Instance::Platform_SetAmbientRGB( const unsigned char ucR,
                                                   const unsigned char ucG,
                                                   const unsigned char ucB,
                                                   const unsigned char ucA )
{
    m_uAmbientARGB = (ucA << 24) | (ucR << 16) | (ucG << 8) | ucB;
    m_uFlags &= ~ASURA_SHAPE_INSTANCE_USES_DEFAULT_AMBIENT;
}

void Asura_Shape_Instance::Platform_SetDefaultAmbientRGB( void )
{
    m_uFlags |= ASURA_SHAPE_INSTANCE_USES_DEFAULT_AMBIENT;
} 

//
// Asura_Platform_Shape_RenderData
//

Asura_Platform_Shape_RenderData::Asura_Platform_Shape_RenderData( const char*& pcChunkBuffer )
{
#if _DEBUG
    // Keep a copy of the name around in debug builds.
    const char* const szName = pcChunkBuffer;
    m_szName = Asura_StringUtil::Duplicate( szName );
#endif
    pcChunkBuffer += Asura_Shape_RenderData::NAME_BUFFER_SIZE;
}


Asura_Platform_Shape_RenderData::~Asura_Platform_Shape_RenderData( void )
{
#if _DEBUG
    delete[] m_szName;
#endif
}


int Asura_Shape::Platform_GetMaterialIdx( void ) const
{
	return 0;
}


void Asura_Shape::Platform_Render( const Asura_Shape_Instance* pxShapeInst,
                                   u_int uAmbientARGB,
                                   u_int uCamVisFlags ) const
{
}


void Asura_Shape::Platform_RenderShadow( const Asura_Shape_Instance* pxShapeInst, const Asura_Shadow& xShadow, u_int uCamVisFlags ) const
{
	Asura_Assert( false, "Asura_Shape shadow not supported!!!!" );
}


bool Asura_Shape::Platform_IsOpaque( void ) const
{
    int iMaterialIndex  = Platform_GetMaterialIdx();

    // Return whether this material is opaque...
	const Asura_MaterialResponse* const pxMaterial = Asura_MaterialResponse_System::GetMaterialByHashID( iMaterialIndex );
	return !pxMaterial || pxMaterial->GetBlendMode() == Asura_MaterialResponse::BLEND_MODE_OPAQUE;
}
