/* Public domain */ #ifndef _FREESG_SG_VIEW_H_ #define _FREESG_SG_VIEW_H_ #include struct sg_camera; /* Managed per-view texture. */ typedef struct sg_view_texture { void *_Nonnull node; /* Pointer to parent node */ struct sg_view *_Nonnull sv; /* Pointer to SG_View */ Uint name; /* GL texture handle */ int frame; /* Animation frame (optional) */ AG_TexCoord tc; /* Texture coordinates */ AG_TAILQ_ENTRY(sg_view_texture) textures; } SG_ViewTexture; /* Managed per-view display list. */ typedef struct sg_view_list { void *_Nonnull node; /* Pointer to parent node */ struct sg_view *_Nonnull sv; /* Pointer to SG_View */ Uint name; /* GL display list handle */ int frame; /* Animation frame (optional) */ AG_TAILQ_ENTRY(sg_view_list) lists; } SG_ViewList; typedef struct sg_view_cam_action { M_Real incr; /* Increment */ Uint32 vMin, vAccel, vMax; /* Repeat delays */ M_Vector3 v; /* Axis or direction */ } SG_ViewCamAction; typedef struct sg_view { struct ag_widget _inherit; Uint flags; #define SG_VIEW_HFILL 0x001 #define SG_VIEW_VFILL 0x002 #define SG_VIEW_EXPAND (SG_VIEW_HFILL|SG_VIEW_VFILL) #define SG_VIEW_NO_LIGHTING 0x004 /* Disable lighting */ #define SG_VIEW_NO_DEPTH_TEST 0x008 /* Disable Z-buffering */ #define SG_VIEW_UPDATE_PROJ 0x010 /* Update projection at next draw */ #define SG_VIEW_PANNING 0x020 /* Mouse panning in progress */ #define SG_VIEW_CAMERA_STATUS 0x040 /* Display camera status overlay */ #define SG_VIEW_EDIT 0x080 /* Allow edition commands */ #define SG_VIEW_EDIT_STATUS 0x080 /* Display edition status overlay */ #define SG_VIEW_MOVING 0x100 /* Moving object */ #define SG_VIEW_ROTATING 0x200 /* Rotating object */ SG *_Nullable sg; /* Scene graph */ SG *_Nullable sgTrans; /* For SG_ViewTransition() */ Uint transFlags; #define SG_VIEW_TRANSFADE 0x01 /* Fade-out/fade-in */ AG_Timer toTransFade; /* Timer for fade */ float transProgress; /* Transition state */ AG_Color transFadeColor; /* Color for fade */ Uint transDuration; /* Duration for transition (ms) */ struct sg_camera *_Nullable cam; /* Current camera */ struct sg_camera *_Nullable camTrans; /* Transitioning to camera */ struct { int lx, ly; /* Last mouse position (for rotation) */ M_Vector3 rsens; /* Rotation sensitivity vector */ M_Vector3 tsens; /* Translation sensitivity vector */ } mouse; AG_Widget *_Nonnull editArea; /* Edit container widget */ SG_Node *_Nonnull editNode; /* Node being edited */ SG_ViewCamAction rot[3]; /* Keyboard controlled yaw/pitch/roll */ SG_ViewCamAction move[3]; /* Keyboard controlled translate */ AG_Timer toRot, toMove; int lastKeyDown; char editStatus[128]; /* Edit status text */ AG_PopupMenu *_Nonnull pmView; /* Popup menu per view */ AG_PopupMenu *_Nonnull pmNode; /* Popup menu per node */ AG_Timer toRefresh; /* View refresh timer */ } SG_View; __BEGIN_DECLS extern AG_WidgetClass sgViewClass; extern M_Real sgEyeSeparation; SG_View *_Nonnull SG_ViewNew(void *_Nullable, SG *_Nullable, Uint); int SG_ViewTransition(SG_View *_Nonnull, SG *_Nonnull, SG_Camera *_Nullable, Uint); void SG_ViewSetFadeColor(SG_View *_Nonnull, const AG_Color *_Nonnull); void SG_ViewSetFadeDuration(SG_View *_Nonnull, Uint); void SG_ViewUnProject(SG_View *_Nonnull, int,int, M_Vector4 *_Nonnull, M_Vector4 *_Nonnull); void SG_ViewSetCamera(SG_View *_Nonnull, struct sg_camera *_Nullable); __END_DECLS #include #endif /* _FREESG_SG_VIEW_H_ */