#pragma once
#include <d3dx9.h>
#include "Direct3D.h"
#include "3DObject.h"
#include "Camera.h"
#include "Laser.h"

class CFighter : public C3DObject 
{
private:

	CDirect3D *d3d;

	float SpeedZ;
	float SpeedX;
	float SpeedY;
	
	float RotationZ;
	float RotationX;
	
	float PositionX;
	float PositionY;
	float PositionZ;
	
	//Last ComputeModel Event
	DWORD   LastTick;

	//Craft Projector
	D3DLIGHT9 light;
	D3DMATERIAL9 mtrl;

	//Fighter Mesh
    LPD3DXMESH          m_pMeshSysMem;      
    UINT                m_dwNumSegs;        
    D3DXMATERIAL*       m_pMaterials;       
    LPDIRECT3DTEXTURE9* m_ppTextures;       
    DWORD               m_dwNumMaterials;   
    LPD3DXBUFFER        m_pbufMaterials;    
    LPD3DXBUFFER        m_pbufAdjacency;    

	//Laser
	bool LaserShow;
	D3DXVECTOR3 LaserPosition;
	float LaserSpeed;

public:
	CLaser *Laser;

	CFighter(CDirect3D *d3d);
    virtual void Render();
	virtual ~CFighter(void);
//Modelling Flight
public:
    void IncreaseSpeed();
	void DecreaseSpeed();
	void IncreaseRotation();
	void DecreaseRotation();
	void IncreaseHeight();
	void DecreaseHeight();

	void ComputeModel();
	void ComputeLight();

	void Rotate(float ax, float ay, float az);
	void Scale(float sx, float sy, float sz);
    void Translate(float x, float y, float z);
	double ObjectSpeed() override;

	virtual IDirect3DVertexBuffer9 * getVertexBuffer() override;
    virtual DWORD getVertexCount() override;
	virtual DWORD getBytesPerVertex() override;

	double GetZPosition();

	void BeginShot();
	void EndShot();
};
