#ifndef KUGEL_H
#define KUGEL_H

#include <vector>
#include <GL/glut.h>
#include <GL/gl.h>
#include <GL/glu.h>
#include "./utils/vector3.h"
#include "kugel_vertex.h"

#include "utils/CtgaLoader.h"


//#include "./utils/vector2.h"

class kugel
{
public:
	kugel(void);
	bool init (void);

	void move (Vector3 delta);
	void update (Vector3 dv);
	void update (float dx,float dz);
	void render ();
	void create_vertices();
	void create_springs(double stiffness);
	void update_gravity (double dg);
	void update_internal_forces();
	int discs, slices;
	double radius;
	double damp;
	double delta_t;

	double mid_stiffness;
	double sp_stiffness;

	void toggle_vertices (void);
	void toggle_springs (void);
	void toggle_triangle (void);

	Vector3 pos;
	Vector3 speed;
	Vector3 acceleration;
	Vector3 gravity;
	std::vector<kugel_vertex*> vertices;

	
	CTGALoader STexture;

	void reconstitute (void);
	void reset (void);
	void destroy (void);


	bool bforce_collision (Vector3 p, Vector3 &n);

	bool bforce_midpoint_collision (Vector3 p, Vector3 &n);


public:
	bool DRAW_VERTICES;
	bool DRAW_SPRINGS;
	bool DRAW_TRIANGLES;

	int vertices_touching_ground;
	bool is_changeing;
	bool build_up;
	int current_vertex;
	int render_delay;


	~kugel(void);
};

#endif // KUGEL_H

