Source

gltut / framework / ObjectPole.h

#ifndef FRAMEWORK_OBJECT_POLE_H
#define FRAMEWORK_OBJECT_POLE_H

#include <glm/glm.hpp>
#include <glm/gtc/quaternion.hpp>


namespace Framework
{
	class MousePole;

	class ObjectPole
	{
	public:
		enum ActionButtons
		{
			AB_LEFT_MOUSE,
			AB_MIDDLE_MOUSE,
			AB_RIGHT_MOUSE,
		};

		ObjectPole(const glm::vec3 &initialPos,
			const MousePole *pView = NULL, ActionButtons eButton = AB_RIGHT_MOUSE);

		glm::mat4 CalcMatrix() const;

		enum Axis
		{
			AXIS_X,
			AXIS_Y,
			AXIS_Z,

			NUM_AXES,
		};

		enum RotateMode
		{
			RM_DUAL_AXIS,
			RM_BIAXIAL,
			RM_SPIN,
		};

		void RotateWorldDegrees(const glm::fquat &rot, bool bFromInitial = false);
		void RotateLocalDegrees(const glm::fquat &rot, bool bFromInitial = false);
		void RotateViewDegrees(const glm::fquat &rot, bool bFromInitial = false);

		void GLUTMouseMove(const glm::ivec2 &position);
		void GLUTMouseButton(int button, int btnState, const glm::ivec2 &position);
		void GLUTMouseWheel(int direction, const glm::ivec2 &position);

		bool IsDragging() const {return m_bIsDragging;}

	private:
		const MousePole *m_pView;
		glm::fquat m_orientation;
		glm::vec3 m_objectPos;

		int m_glutActionButton;

		RotateMode m_RotateMode;
		bool m_bIsDragging;

		glm::ivec2 m_prevPos;
		glm::ivec2 m_initialPos;
		glm::fquat m_initialOrient;
	};
}


#endif //FRAMEWORK_OBJECT_POLE_H
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.