123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274 |
- #define CAMERA_CPP
- #include "RSPiX.h"
- #include "camera.h"
- CCamera::CCamera()
- {
-
- m_pScene = 0;
- m_pimFilm = 0;
- m_pHood = 0;
-
- m_bClip = true;
- }
- CCamera::~CCamera()
- {
- }
- void CCamera::SetScene(
- CScene* pScene)
- {
-
- m_pScene = pScene;
- }
- void CCamera::SetHood(
- CHood* pHood)
- {
-
- m_pHood = pHood;
- }
- void CCamera::SetView(
- short sSceneViewX,
- short sSceneViewY,
- short sViewW,
- short sViewH)
- {
-
- m_sSceneViewX = sSceneViewX;
- m_sSceneViewY = sSceneViewY;
- m_sViewW = sViewW;
- m_sViewH = sViewH;
-
- Update();
- }
- void CCamera::SetViewPos(
- short sSceneViewX,
- short sSceneViewY)
- {
-
- m_sSceneViewX = sSceneViewX;
- m_sSceneViewY = sSceneViewY;
-
- Update();
- }
- void CCamera::SetViewSize(
- short sViewW,
- short sViewH)
- {
-
- m_sViewW = sViewW;
- m_sViewH = sViewH;
-
- Update();
- }
- void CCamera::SetFilm(
- RImage* pimFilm,
- short sFilmViewX,
- short sFilmViewY)
- {
-
- m_pimFilm = pimFilm;
- m_sFilmViewX = sFilmViewX;
- m_sFilmViewY = sFilmViewY;
-
- Update();
- }
- void CCamera::SnapWithLensCoverOn(void)
- {
- ASSERT(m_pimFilm != NULL);
-
- rspRect(RSP_BLACK_INDEX, m_pimFilm, m_sFilmViewX, m_sFilmViewY, m_sViewW, m_sViewH);
- }
- void CCamera::Snap(void)
- {
- ASSERT(m_pScene != NULL);
- ASSERT(m_pimFilm != NULL);
-
- m_pScene->Render(m_sSceneViewX, m_sSceneViewY, m_sViewW, m_sViewH, m_pimFilm, m_sFilmViewX, m_sFilmViewY, m_pHood);
- }
- void CCamera::Snap(
- short sViewW,
- short sViewH,
- CScene* pScene,
- CHood* phood,
- short sSceneViewX,
- short sSceneViewY,
- RImage* pimFilm,
- short sFilmViewX,
- short sFilmViewY)
- {
-
- pScene->Render(sSceneViewX, sSceneViewY, sViewW, sViewH, pimFilm, sFilmViewX, sFilmViewY, phood);
- }
- void CCamera::Update(void)
- {
-
- if (m_bClip == true)
- {
-
- if (m_sSceneViewX < 0)
- m_sSceneViewX = 0;
-
- if (m_sSceneViewY < 0)
- m_sSceneViewY = 0;
-
- if (m_pHood != 0)
- {
- short sClipX = (m_sSceneViewX + m_sViewW) - m_pHood->GetWidth();
- if (sClipX > 0)
- m_sSceneViewX -= sClipX;
-
- short sClipY = (m_sSceneViewY + m_sViewH) - m_pHood->GetHeight();
- if (sClipY > 0)
- m_sSceneViewY -= sClipY;
- }
- }
-
- m_sScene2FilmX = m_sSceneViewX - m_sFilmViewX;
- m_sScene2FilmY = m_sSceneViewY - m_sFilmViewY;
- }
|