/* Public domain */ enum sg_billboard_mode { SG_BILLBOARD_RECT, /* Opaque rectangle */ SG_BILLBOARD_POLY /* Complex polygon */ }; typedef struct sg_billboard { struct sg_node _inherit; enum sg_billboard_mode mode; /* Billboarding method */ Uint flags; #define SG_BILLBOARD_PROJECT 0x01 /* Render facing the camera */ #define SG_BILLBOARD_NODUP 0x02 /* Surface is not a copy */ #define SG_BILLBOARD_NODUP_ANIM 0x04 /* Animation is not a copy */ #define SG_BILLBOARD_WIREFRAME 0x08 /* Overlay wireframe */ #define SG_BILLBOARD_HOLES 0x10 /* Enable hole detection */ #define SG_BILLBOARD_SAVESU 0x20 /* Store surface in save */ #define SG_BILLBOARD_SAVED (SG_BILLBOARD_PROJECT|SG_BILLBOARD_WIREFRAME|\ SG_BILLBOARD_HOLES|SG_BILLBOARD_SAVESU) char path[AG_FILENAME_MAX]; /* Path for loading images or animations */ AG_Color color; /* Background color */ AG_Surface *su; /* Source surface (Anim: Effective surface) */ AG_TexCoord *tc; /* Effective texcoords */ AG_Anim *an; /* Source animation */ AG_AnimState ast; /* Playback instance */ M_Real w, h; /* Dimensions */ void *to; /* GLU tesselator object */ SG_GLVertex3 **tessBufs; /* Tesselator buffers */ Uint nTessBufs; float tolContour, tolHoles; /* For simplification */ M_Polygon contour; /* Computed polygon contour */ M_Polygon *holes; /* Computed holes */ Uint nHoles; AG_TAILQ_HEAD_(sg_view_texture) vtex; /* Per-view textures */ AG_TAILQ_HEAD_(sg_view_list) vlist; /* Per-view display lists */ } SG_Billboard; #define SGBILLBOARD(n) ((SG_Billboard *)(n)) __BEGIN_DECLS extern SG_NodeClass sgBillboardClass; SG_Billboard *SG_BillboardNew(void *, const char *); SG_Billboard *SG_BillboardFromSurface(void *, const char *, AG_Surface *); SG_Billboard *SG_BillboardFromSurfaceNODUP(void *, const char *, AG_Surface *); SG_Billboard *SG_BillboardFromAnim(void *, const char *, AG_Anim *); SG_Billboard *SG_BillboardFromAnimNODUP(void *, const char *, AG_Anim *); void SG_BillboardFreeCached(void *); void SG_BillboardFreeSurfaces(void *); int SG_BillboardSetSurface(void *, AG_Surface *); int SG_BillboardSetSurfaceNODUP(void *, AG_Surface *); int SG_BillboardSetAnim(void *, AG_Anim *); int SG_BillboardSetAnimNODUP(void *, AG_Anim *); void SG_BillboardSetMode(void *, enum sg_billboard_mode); void SG_BillboardSetModeAuto(void *); void SG_BillboardSetProj(void *, int); void SG_BillboardAnimPlay(void *); void SG_BillboardAnimStop(void *); /* Set the tolerance for polygon simplification. */ static __inline__ void SG_BillboardSetTolContour(void *obj, float tol) { SG_Billboard *bb = obj; AG_ObjectLock(bb); bb->tolContour = tol; AG_ObjectUnlock(bb); } /* Change the billboard size. */ static __inline__ void SG_BillboardSetSize(void *obj, M_Real w, M_Real h) { SG_Billboard *bb = obj; AG_ObjectLock(bb); bb->w = w; bb->h = h; AG_ObjectUnlock(bb); } /* Set the billboard background color. */ static __inline__ void SG_BillboardSetColor(void *obj, AG_Color C) { SG_Billboard *bb = obj; AG_ObjectLock(bb); bb->color = C; AG_ObjectUnlock(bb); } __END_DECLS