//===========================================================================//
// File:	CvExport.h                                                 
// Project: MechWarrior 4
// Contents: Plugin to adjust height of max anmiations
//---------------------------------------------------------------------------//
//   Date    Who  Modification                                               //
// --------  ---  ---------------------------------------------------------- //
// 04/28/99  JSE  Initial coding, 
// 05/10/00  fwang
//---------------------------------------------------------------------------//
// Copyright (C) 1998, Fasa Interactive, Inc.
// All Rights reserved worldwide
// This unpublished sourcecode is PROPRIETARY and CONFIDENTIAL
//===========================================================================//

#if !defined(AFX_CVEXPORT_H__68E70A2D_B863_11D1_98AD_0040051EDCE7__INCLUDED_)
#define AFX_CVEXPORT_H__68E70A2D_B863_11D1_98AD_0040051EDCE7__INCLUDED_

#if _MSC_VER >= 1000
#pragma once
#endif // _MSC_VER >= 1000

#ifndef __AFXWIN_H__
	#error include 'stdafx.h' before including this file for PCH
#endif

// Forward class declaration
class CvExp;
class MaxCollisionVolume;

#include "AnimationSuite.h"
#include "GeoExport.h"

class CvExp : public SceneExport 
{
public:
	CvExp():m_exp("") {}
	~CvExp() {}
	
	// Some inline functions
	int ExtCount() { return 1; }
	const TCHAR * Ext(int n) {
		switch(n) {
		case 0:
			// This cause a static string buffer overwrite
			// return GetString(IDS_EXTENSION1);
			return _T("OBB");
		}
		return _T("");
	}

	const TCHAR * LongDesc() { return GetString(IDS_LONGDESC); }
	const TCHAR * ShortDesc(){ return _T("MW4 OBB"); }
	const TCHAR * AuthorName() { return _T("Jonthan Kyle"); }
	const TCHAR * CopyrightMessage() { return GetString(IDS_COPYRIGHT); }
	const TCHAR * OtherMessage1() {	return _T(""); }
	const TCHAR * OtherMessage2() {	return _T(""); }
	unsigned int Version() { return 100; }
	void ShowAbout(HWND hWnd)
	{
		CAbout dlg;
		dlg.DoModal();
	}	
	
	int		DoExport(const TCHAR *name,ExpInterface *ei,Interface *i, BOOL suppressPrompts=FALSE,DWORD options=0);
	int		DoExportWrap(const TCHAR *name,ExpInterface *ei,Interface *i, BOOL suppressPrompts=FALSE);	

private:
	Interface *m_ip;
	bool m_bRemapMaterial;
	bool m_bUseNewNames;
    bool SaveSolidOBB(const TCHAR *name, MaxCollisionVolume *pCv);
	bool SaveHierarchicalOBB(const TCHAR *name, MaxCollisionVolume *pCv);
	bool LoadPlugCfg(Interface *i);
	BaseGeoExporter m_exp;
};

/////////////////////////////////////////////////////////////////////////////

class MaxCollisionVolume : public Adept::CollisionVolume
{
protected:
	INode *m_pNode;
public:
	MaxCollisionVolume(INode *pNode, bool bRemapMaterial);
	const char* GetName();
	MaxCollisionVolume *FindJointNode(const char *name);
	MaxCollisionVolume *FindCVNode(const char *name);
	void MakeGoodEnough();

	friend MaxCollisionVolume *ConstructCVHeirarchy(INode *pnode, bool bRemapMaterial=false);
	friend MaxCollisionVolume *OptimizeCV(MaxCollisionVolume *);
	friend void CountMaterials(MaxCollisionVolume *, Stuff::Page *logPage, CMapStringToPtr &);
	friend void ConstructCVs(Interface* ip, 
			      MaxCollisionVolume **pSolidCv,
				  MaxCollisionVolume **pHierarchicalCv,
				  bool bSuppressPrompts=false,
				  bool bRemapMaterial=false);
	
};

//{{AFX_INSERT_LOCATION}}
// Microsoft Developer Studio will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_ANIMEXPORT_H__68E70A2D_B863_11D1_98AD_0040051EDCE7__INCLUDED_)
