#ifndef PROJECT_VOLUMES_H
#define PROJECT_VOLUMES_H

#include "math_vector3D.h"

enum {VGEN_EMPTY, VGEN_PLASMA, VGEN_SPHERE};

#define default_width 128
#define default_height 128
#define default_depth 128

#define default_iso_depth 128

class Cvolume
{
public:
	Cvolume(int width = default_width, int height = default_height, int depth = default_depth);
	~Cvolume();

	int GetWidth();
	int GetHeight();
	int GetDepth();

	unsigned char* GetDataPointer();
	unsigned int* GetPalPointer();
	unsigned char GetSample(Cvector pos);
	unsigned char GetSampleFiltered(Cvector pos);

	unsigned char back_step_sample(Cvector pos, Cvector dir, int num);

	int GetIsoDepth();
	void SetIsoDepth(int iso_depth);

	void ClearBorders();

	void GenVolume(int way);
	void LoadVolume(char *filename);
	void RenderVolume(Cvector pos, Cvector dir, Cvector up, Cvector right);

protected:
	int width;
	int height;
	int depth;

	int iso_depth;

	unsigned char *data;
	unsigned int *pal;

	void ZeroMemory();

	void GenVolumePlasma();
	void GenVolumeSphere();

	void RenderVolumeOpenCL(Cvector pos, Cvector dir, Cvector up, Cvector right);

	void FadeByDistanceFromCenter(float radius);
};

#endif
