// 3DDlg.h :  Header file
//

#if !defined(AFX_3DDLG_H__E10E1136_91DF_4C13_9E41_1CD70E3EA789__INCLUDED_)
#define AFX_3DDLG_H__E10E1136_91DF_4C13_9E41_1CD70E3EA789__INCLUDED_

#include "VAIBO.h"
#include "AIBO3D.h"

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#define		ACC_QUEUE_MAX		5		// The size of the acceleration sensor queue


/////////////////////////////////////////////////////////////////////////////
// C3DDlg  dialog

class C3DDlg : public CDialog
{
// Construction
public:
	void SetPosture( int posture );
	void UpdateSensorValue(unsigned long numOfData, SensorRec *sensorRecAry);
	CAIBO3D		*m_aibo3D;
	C3DDlg( int robotDesign, int posture, CWnd* pParent = NULL);   // standard constructor
	void	MoveAIBO( int nWalk, float fSpeed );


// Dialog Data
	//{{AFX_DATA(C3DDlg)
	enum { IDD = IDD_DLG_3D };
	CComboBox	m_modelCombo;
	//}}AFX_DATA


	//{{AFX_VIRTUAL(C3DDlg)
	protected:
	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
	//}}AFX_VIRTUAL

//  Implementation
protected:

	// Generated message map functions
	//{{AFX_MSG(C3DDlg)
	virtual void OnOK();
	afx_msg void OnDestroy();
	virtual BOOL OnInitDialog();
	afx_msg void OnBtnLoad();
	afx_msg void OnBtnHomePosition();
	afx_msg void OnRadioMove();
	afx_msg void OnRadioTurn();
	afx_msg void OnRadioZoom();
	afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
	afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
	afx_msg void OnMouseMove(UINT nFlags, CPoint point);
	afx_msg void OnBtnFloor();
	afx_msg void OnBtnBack();
	afx_msg void OnBtnFloor2();
	afx_msg void OnBtnBack2();
	//}}AFX_MSG
	DECLARE_MESSAGE_MAP()

	float m_d3DPosX;
	float m_d3DPosY;
	float m_d3DPosZ;
	float m_d3DPitch;
	float m_d3DYaw;

	float m_d3DHomePosX;
	float m_d3DHomePosY;
	float m_d3DHomePosZ;
	float m_d3DHomePitch;
	float m_d3DHomeYaw;

	CPoint m_ptMouse;
	BOOL m_b3DViewChange;
	DWORD m_3DMode;
	enum{
		VM3D_MOVE,
		VM3D_TURN,
		VM3D_ZOOM
	};

	int		m_robotDesign;					// RobotDesign information
	int		m_posture;						// Posture information
	int		m_sensorNum;					// The number of sensors
	DWORD	*m_sensor;						// Sensor value storage array
	int		*m_jointArray;					// Joint identifier array
	int		*m_sensorID;					// Sensor ID array
	int		m_sensorArrayNum;				// The number of sensor elements
	int		*m_sensorArray;					// Sensor array
	int		m_accQueue[3][ACC_QUEUE_MAX];	// Acceleration sensor value queue

	CButton& buttonLoad() { return *(CButton*) GetDlgItem( IDC_BTN_LOAD ); };

private:
	void SetJoints( float *angle,int num );
	int RadToDegree( int rad );
	void QueueIn( int ix,int value );		// Store data in the  acceleration sensor queue.
	int GetAverage( int ix );			// Get the average of the acceleration sensor queue.
	void CalcRotation( float x,float y,float z,float *pitch,float *roll );	// Get the body rotation angle.

private:
	int*	pModelIDIndex;
};

//{{AFX_INSERT_LOCATION}}

#endif // !defined(AFX_3DDLG_H__E10E1136_91DF_4C13_9E41_1CD70E3EA789__INCLUDED_)
