/* 
 * 
 * Confidential Information of Telekinesys Research Limited (t/a Havok).  Not for disclosure or distribution without Havok's
 * prior written consent.This software contains code, techniques and know-how which is confidential and proprietary to Havok.
 * Level 2 and Level 3 source code contains trade secrets of Havok. Havok Software (C) Copyright 1999-2008 Telekinesys Research Limited t/a Havok. All Rights Reserved. Use of this software is subject to the terms of an end user license agreement.
 * 
 */

#ifndef HK_CHARACTER_UTILS_H
#define HK_CHARACTER_UTILS_H

class hkpCharacterRigidBody;
struct hkpCharacterInput;
class hkpCharacterContext;


class CharacterUtils
{
	public:

		// Calls check support
	static void HK_CALL setCharacterInput( const hkpCharacterRigidBody* characterRb, hkpCharacterInput& input, const hkVector4& gravity);

		// Character control from mouse and/or dpads and sticks
		// based on what is appropriate for platform
	static void HK_CALL getUserInputForCharacter( hkDemoEnvironment* env, float& deltaAngle, float& dirX, float& dirY );

		// Utility to create a default state machine
	static hkpCharacterContext* HK_CALL createDefaultCharacterContext();

		// Convenience function to display character state as text on screen
	static void HK_CALL displayCharacterState(hkpCharacterContext* context, hkDemoEnvironment* env );

};

struct CharacterControls 
{
	// These values are from -1 to 1, and m_forward is a unit vector for convenience we are using the default character controller state machine
	// TODO - update the default state machine (or do a new one) that is more usable for AI
	hkReal m_forwardBack;
	hkReal m_straffeLeftRight;
	hkVector4 m_forward;

	hkBool m_wantJump;
};

class SimpleCharacter : public hkReferencedObject
{
	public:

			// Create a default first person character
		SimpleCharacter( const hkVector4& position, const hkVector4& up );

		SimpleCharacter( hkpCharacterRigidBody* characterRb, hkpCharacterContext* context );

		~SimpleCharacter();
	
		void update( hkReal timestep, const CharacterControls& controls, bool showForwardDirection = true );

	public:

		hkpCharacterRigidBody* m_characterRb;
		hkpCharacterContext* m_characterRbContext;

		hkReal m_currentAngle;
		hkQuaternion m_currentOrient;

		hkVector4 m_gravity;
};

class UserControlledSimpleCharacter : public SimpleCharacter
{
	public:

			// Create a default first person character
		UserControlledSimpleCharacter( const hkVector4& position, const hkVector4& up );

		UserControlledSimpleCharacter( hkpCharacterRigidBody* characterRb, hkpCharacterContext* context );

		void setInputFromUserControls( hkDemoEnvironment* env, CharacterControls& controls );

		void updateCamera( hkpWorld* world, hkDemoEnvironment* env );
	
		void update( hkReal timestep, hkDemoEnvironment* env, hkpWorld* world );

	public:

		// Flags
		hkBool m_hasUserControl;
		hkBool m_makeOccludingObjectsTransparent;

	public:

		hkArray< hkUlong > m_transparentObjects;
};



#endif // HK_CHARACTER_UTILS_H

/*
* Havok SDK - NO SOURCE PC DOWNLOAD, BUILD(#20080529)
*
* Confidential Information of Havok.  (C) Copyright 1999-2008 
* Telekinesys Research Limited t/a Havok. All Rights Reserved. The Havok
* Logo, and the Havok buzzsaw logo are trademarks of Havok.  Title, ownership
* rights, and intellectual property rights in the Havok software remain in
* Havok and/or its suppliers.
*
* Use of this software for evaluation purposes is subject to and indicates 
* acceptance of the End User licence Agreement for this product. A copy of 
* the license is included with this software and is also available at
* www.havok.com/tryhavok
*
*/
