#ifndef _TPFOBJ_H
#define _TPFOBJ_H

#include "ang.h"
#include "vec.h"
#include "tex.h"

/* Contains code to manipulate a Doom/Wolfenstein 3D style n-sided object */

/* Object structure
   Use the functions below as opposed to manipulating it directly */
typedef struct {
	tpfVec pos; /* Location */
	tpfAng rot; /* Rotation */
	int numsides; /* Number of sides */
	tpfTex **sides; /* Textures for each side */
	int flags;
} tpfObj;

/* Object flags: */
/* Stop the engine from drawing behind the object (i.e. the texture is solid) */
#define TPFOBJ_STOPRAY 1

#ifdef __cplusplus
extern "C" {
#endif

/* Create a new object, without any textures */
extern tpfObj *TpfObj_New();

/* Delete an object */
extern void TpfObj_Delete(tpfObj *o);

/* Set the location of the object
   A location of {0,0,0} will centre it over location 0,0 with the object base
   at height 0 */
extern void TpfObj_SetPos(tpfObj *o,tpfVec v);

/* Return a read-only pointer to the object's position */
extern tpfVec *TpfObj_GetPos(tpfObj *o);

/* Set the angle the object is drawn at */
extern void TpfObj_SetAng(tpfObj *o,tpfAng a);

/* Return the angle the object is drawn at */
extern tpfAng TpfObj_GetAng(tpfObj *o);

/* Set the number of sides the object has
   s must be at least zero
   If s is zero then the object won't be drawn at all
   If s is above zero then each side will be equally spaced around the object */
extern void TpfObj_SetSides(tpfObj *o,int s);

/* Return the number of sides the object has */
extern int TpfObj_GetSides(tpfObj *o);

/* Set the texture of side s
   s must be between 0 inclusive and the number of sides exclusive
   t can be null
   The texture is referenced by pointer; i.e. the original tpfTex must be left
   in existence */
extern void TpfObj_SetSide(tpfObj *o,int s,tpfTex *t);

/* Return the texture of side s
   s must be between 0 inclusive and the number of sides exclusive */
extern tpfTex *TpfObj_GetSide(tpfObj *o,int s);

/* Set the flags of the object
   f must be constructed from the TPFOBJ_* bitflags defined above */
extern void TpfObj_SetFlags(tpfObj *o,int f);

/* Return the flags for the object */
extern int TpfObj_GetFlags(tpfObj *o);

#ifdef __cplusplus
}
#endif

#endif
