Sei sulla pagina 1di 4

/* Start Header ****************************************************************

*/
/*!
/file Path.h
/author Team42, Jiawei Gu
/e-mail jiawei.gu@digipen.edu
/date 10/24/2015
/Brief Copyright (C) 2015 DigiPen Institute of Technology. Reproduction or
disclosure of this file or its contents without the prior written consent of
DigiPen Institute of Technology is prohibited.
*/
/* End Header ******************************************************************
*/
#ifndef A_PATH_H
#define A_PATH_H
#include
#include
#include
#include
#include
#include
#include

<GL/glew.h>
<vector>
"../Math/CatmullRomSpline.h"
"../Math/Vector3.h"
"../Animation/Transform.h"
"../UI/EditorUnit.h"
"CurveTable.h"

namespace Anime
{
/// <summary>
/// The path.
/// </summary>
class Path
{
public:
/// <summary>
/// Initialize the path.
/// </summary>
Path();
/// <summary>
/// Add control point to the path.
/// </summary>
/// <param name="point">New control point.</param>
void AddControlPoint(const Vector3 & point);
///
///
///
///
///

<summary>
Update a control point.
</summary>
<param name="center">The control point index.</param>
<param name="point">New position of this control point.</par

am>
void UpdateControlPoint(unsigned int index, const Vector3 & poin
t);
/// <summary>
/// Calculate the interpolation points of the path.
/// </summary>
void CalculatePath();
/// <summary>
/// Draw the control points.

/// </summary>
void DrawControlPoints();
/// <summary>
/// Draw the path.
/// </summary>
void DrawPath();
/// <summary>
/// Draw the model position in the path.
/// </summary>
void Reset();
/// <summary>
/// Clear the control points, path and curve table.
/// </summary>
void Clear();
/// <summary>
/// Setup the editor for some parameters.
/// </summary>
/// <param name="editor">The editor unit.</param>
void SetupEditor(EditorUnit * editor);
/// <summary>
/// Update the model position in the path.
/// </summary>
/// <param name="dt">Delta time.</param>
/// <param name="speed">The current speed.</param>
/// <param name="maxSpeed">The maximum speed.</param>
/// <param name="accelaration">The accelaration.</param>
void Update(float dt, float * speed, float maxSpeed, float accel
aration);
/// <summary>
/// Get the translation and rotation transform.
/// </summary>
/// <returns>Returns the tranformation VQS.</returns>
Transform GetTransform();
/// <summary>
/// Get number of control points.
/// </summary>
/// <returns>Number of control points.</returns>
unsigned int GetControlPointsNum() const;
/// <summary>
/// Get closest control point index to the click. Excluding the
first control point (spawn position).
/// </summary>
/// <param name="click">The click position.</param>
/// <returns>The closest control point index.</returns>
unsigned int GetClosestPointIndex(const Vector3 & click) const;
/// <summary>
/// Get the curve length of the path.
/// </summary>
/// <returns>The path length.</returns>
float GetPathLength() const;

/// <summary>
/// Switch on or off drawing control points.
/// </summary>
void SwitchDrawControlPoints();
/// <summary>
/// Switch on or off drawing paths.
/// </summary>
void SwitchDrawPath();
private:
/// <summary>
/// The control points.
/// </summary>
std::vector<Vector3> controlPoints;
///
///
///
int

<summary>
The number of control points.
</summary>
controlPointsCount;

/// <summary>
/// The whole path of interpolated points.
/// </summary>
std::vector<Vector3> wholePath;
///
///
///
int

<summary>
The number of interpolated points.
</summary>
interPolatedPointsCount;

/// <summary>
/// The Catmull-Rom spline.
/// </summary>
CatmullRomSpline spline;
/// <summary>
/// Normalized accumulate curve length. 0 <= accS <= 1 .
/// </summary>
float accS;
/// <summary>
/// Current Position.
/// </summary>
Vector3 curPos;
/// <summary>
/// Next Position.
/// </summary>
Vector3 nextPos;
/// <summary>
/// Facing direction.
/// </summary>
Vector3 direction;
/// <summary>
/// The vertex array objects.
/// </summary>
GLuint VAO[2];

/// <summary>
/// The vertex buffer objects.
/// </summary>
GLuint VBO[2];
/// <summary>
/// Flag for drawing path.
/// </summary>
bool drawPath;
/// <summary>
/// Flag for drawing control points.
/// </summary>
bool drawControlPoints;
/// <summary>
/// Set up OpenGL VAO, VBO.
/// </summary>
void SetupOpenGL();
/// <summary>
/// The curve length table.
/// </summary>
CurveTable curveTable;
///
///
///
///

<summary>
Recursive process to make the curve length table.
</summary>
<param name="pointA">One of the 2 endpoints of the segment.<

/param>
/// <param name="pointB">One of the 2 endpoints of the segment.<
/param>
/// <param name="uA">The parameter in the spline of pointA.</par
am>
/// <param name="uB">The parameter in the spline of pointB.</par
am>
void MakeCurveTable(const Vector3 & pointA, const Vector3 & poin
tB, float uA, float uB);
};
}
#endif

Potrebbero piacerti anche