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

#if !defined(AFX_HILLADJUST_H__68E70A2D_B863_11D1_98AD_0040051EDCE7__INCLUDED_)
#define AFX_HILLADJUST_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


#ifdef STRICT							// Already defined by stdafx,
#undef STRICT							// so we avoid warning linking msg
#endif
#ifdef _MBCS							// The same as above
#undef _MBCS
#endif

class HillAdjustPanel;

#include "AnimationSuite.h"



#ifndef __HILLADJUST__
#define __HILLADJUST__


#define TIME_TO_FRAME(time, frame) \
		if (GetTicksPerFrame() != 0 || time != 0) \
		{ \
			frame = (int)((float)time / (float)GetTicksPerFrame()); \
		} \
			else \
		{ \
			frame = 0; \
		} 

class HillAdjustPanel : public UtilityObj {

	protected:
		HINSTANCE		m_hInstance;
		IUtil*			m_iu;

		enum {
			UpAngleType,
			DownAngleType,
			LeftAngleType,
			RightAngleType
		};

	public:
		Interface*		m_ip;
		HWND			m_hPanel, m_hQuickFile;
		int m_angleEnum;
		int m_leaveOriginalCurves;
		int m_leaveOriginalTangents;
		int m_scaleInPlace;

		ISpinnerControl *m_angleSpinner;
		Stuff::Scalar m_angleSlope;

		ISpinnerControl *m_rootScalePosXControl;
		ISpinnerControl *m_rootScalePosYControl;
		ISpinnerControl *m_rootScalePosZControl;
		
		ISpinnerControl *m_rootScaleRotXControl;
		ISpinnerControl *m_rootScaleRotYControl;
		ISpinnerControl *m_rootScaleRotZControl;
		
		ISpinnerControl *m_rootMovePosXControl;
		ISpinnerControl *m_rootMovePosYControl;
		ISpinnerControl *m_rootMovePosZControl;

		ISpinnerControl *m_rootMoveRotXControl;
		ISpinnerControl *m_rootMoveRotYControl;
		ISpinnerControl *m_rootMoveRotZControl;


		ISpinnerControl *m_hipScaleControl;
		ISpinnerControl *m_hipMoveControl;
		ISpinnerControl *m_torsoScaleXControl;
		ISpinnerControl *m_torsoScaleYControl;
		ISpinnerControl *m_torsoScaleZControl;

		ISpinnerControl *m_leftFootScaleCloseControl;
		ISpinnerControl *m_rightFootScaleCloseControl;
		
		Stuff::Point3D m_rootPosScale;
		Stuff::Point3D m_rootRotScale;
		Stuff::Point3D m_rootPosMove;
		Stuff::Point3D m_rootRotMove;
		
		Stuff::Point3D m_hipScale;
		Stuff::Point3D m_hipMove;
		Stuff::Point3D m_torsoScale;

		Stuff::Point3D m_leftFootPosScale;
		Stuff::Point3D m_rightFootPosScale;

        // Constructor & Destructor
        HillAdjustPanel() :m_angleEnum(-1) {}
        virtual ~HillAdjustPanel() {}

		// Overides of the UtilityObj class
		void BeginEditParams(Interface* ip, IUtil* iu);
		void EndEditParams(Interface* ip, IUtil* iu);
		void DeleteThis()						{}
		void Init(HWND hWnd);
		void Destroy(HWND hWnd);

		//Specific Methods
		void AdjustToHill();

		void ConvertTM(Control *c);
		void Convert(Control *parent_c, Control *c, int location);
		void SampleController(Control *parent_c, Control *c, int location);

		void AdjustGeneral(void);

		void AdjustUpHill(void);
		void AdjustDownHill(void);
		void AdjustLeftHill(void);
		void AdjustRightHill(void);

		void ScaleNodePosition(INode *node, Stuff::Point3D scale);
		void ScaleNodeRotation(INode *node, Stuff::Point3D scale);
		void MoveNodePosition(INode *node, Stuff::Point3D scale);
		void MoveNodeRotation(INode *node, Stuff::Point3D scale);

		void ScaleNodeAll(Control *c, float scale);
		void MoveNodeAll(Control *c, float scale);


		INode* FindNode(INode* node, const char *name_of_joint);

		Stuff::Scalar GetKeyValue(Control *c, IKeyControl *ikeys, int key_number);
		int GetKeyTime(Control *c, IKeyControl *ikeys, int key_number);

		void MoveKey(Control *c, IKeyControl *ikeys, Stuff::Scalar amount, int key_number);
		void ScaleKey(Control *c, IKeyControl *ikeys, Stuff::Scalar amount, Stuff::Scalar median,int key_number);

		//void RotateTangents(Control *c, IKeyControl *ikeys, Stuff::Scalar intan_amount, Stuff::Scalar outttan_amount, int key_number);
		void RotateTangents(Control *c, IKeyControl *ikeys, Stuff::Scalar height, int key_number);
		void LoadValues(HWND);
		void SaveValues();
};


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

#endif

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

#endif // !defined(AFX_HILLADJUST_H__68E70A2D_B863_11D1_98AD_0040051EDCE7__INCLUDED_)
