00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00036 class PG_API pgScr
00037 {
00038 friend class pgDraw;
00039 friend class pgDrawMgr;
00040
00041 public:
00042 pgDefineException(ExceptionInvalidArgument);
00043 pgDefineException(ExceptionInvalidCall);
00044
00045 static const u32 DEFAULT_FOCUS_DIST = 1000;
00046 static const u32 DEFAULT_NEAR_CLIP_DIST = 10;
00047 static const u32 DEFAULT_FAR_CLIP_DIST = 100000;
00048 static const u32 GUEST_SCREEN_NUM = 4;
00049
00050 pgScr* getPrevN() const;
00051 pgScr* getNextN() const;
00052
00053 void moveFirst();
00054 void moveLast();
00055 void moveBefore(pgID id);
00056 void moveAfter(pgID id);
00057
00058 pgDraw* getFirstDrawN();
00059 pgDraw* getLastDrawN();
00060
00061 pgID getID() const;
00062
00063 s16 getLeftInFramebuffer() const;
00064 s16 getTopInFramebuffer() const;
00065 s16 getWidthInFramebuffer() const;
00066 s16 getHeightInFramebuffer() const;
00067 void setAreaInFramebuffer(s16 left, s16 top, u16 width, u16 height);
00068
00069 r32 getViewWidth() const;
00070 r32 getViewHeight() const;
00071 void setViewSize(r32 width, r32 height);
00072
00073 bool isActive() const;
00074 void setActive(bool is_active);
00075
00076 bool isClearColor() const;
00077 bool isClearDepth() const;
00078 void setClearMode(bool is_clear_color, bool is_clear_depth);
00079
00080 pgCol getClearColor() const;
00081 void setClearColor(pgCol col);
00082
00083 bool isPerspective() const;
00084 void setPerspective(bool is_perspective);
00085
00086 r32 getFocusDist() const;
00087 void setFocusDist(r32 focus_dist);
00088
00089 r32 getNearClipDist() const;
00090 r32 getFarClipDist() const;
00091 void setClipDist(r32 near, r32 far);
00092
00093 pgMat& view();
00094
00095 bool hasScreenTexture() const;
00096 pgID getScreenTextureID() const;
00097 void attachScreenTexture(pgTex::TexFormat format);
00098 void detachScreenTexture();
00099 void updateScreenTexture(bool is_frame_skip_reset);
00100
00101 pgID getGuestScreenID(u8 index) const;
00102 void setGuestScreenID(u8 index, pgID scr_id);
00103
00104 r32 screenXToFramebufferX(r32 x_in_screen) const;
00105 r32 screenYToFramebufferY(r32 y_in_screen) const;
00106 r32 framebufferXToScreenX(r32 x_in_framebuffer) const;
00107 r32 framebufferYToScreenY(r32 y_in_framebuffer) const;
00108
00109 pgVec worldToScreen(const pgVec& pos_in_world);
00110 pgVec worldToFramebuffer(const pgVec& pos_in_world);
00111 pgVec screenToPlane(r32 x_in_screen, r32 y_in_screen, const pgMat& xy_plane) const;
00112 pgVec framebufferToPlane(r32 x_in_framebuffer, r32 y_in_framebuffer, const pgMat& xy_plane) const;
00113
00114 bool isInScreen(const pgVec& pos_in_world);
00115 bool canBoundClip(const pgMat& world, const pgVec& bound_max, const pgVec& bound_min);
00116
00117 pgVec calcVisibleVector(const pgVec& pos1, const pgVec& pos2);
00118
00119 private:
00120 enum ScrFlag
00121 {
00122 FLAG_ACTIVE,
00123 FLAG_CLEAR_COLOR,
00124 FLAG_CLEAR_DEPTH,
00125 FLAG_PERSPECTIVE,
00126 FLAG_COPY_SCREEN
00127 };
00128
00129 pgScr(pgID scr_id);
00130 ~pgScr();
00131 void operator=(const pgScr&);
00132
00133 void calcProjection();
00134 void setupProjection();
00135 pgVec worldToClip_noCalcProjection(const pgVec& pos_in_world) const;
00136 bool canBoundClip_noCalcProjection(const pgMat& world, const pgVec& bound_max, const pgVec& bound_min) const;
00137 void copyScreenTexture();
00138
00139 pgFlag<u8, ScrFlag> m_flag;
00140 pgID m_id;
00141 s16 m_left_in_framebuffer;
00142 s16 m_top_in_framebuffer;
00143 u16 m_width_in_framebuffer;
00144 u16 m_height_in_framebuffer;
00145 r32 m_view_width;
00146 r32 m_view_height;
00147 pgCol m_clear_col;
00148 r32 m_focus_dist;
00149 r32 m_near_clip_dist;
00150 r32 m_far_clip_dist;
00151 pgMat m_view;
00152 pgDraw m_root_draw;
00153 pgTex* m_scr_tex;
00154 pgID m_guest_id[GUEST_SCREEN_NUM];
00155 r32 m_view_to_clip[16];
00156 r32 m_world_to_view[16];
00157 r32 m_world_to_clip[16];
00158 };