Camera.cpp 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648
  1. //
  2. // Copyright (c) 2008-2015 the Urho3D project.
  3. //
  4. // Permission is hereby granted, free of charge, to any person obtaining a copy
  5. // of this software and associated documentation files (the "Software"), to deal
  6. // in the Software without restriction, including without limitation the rights
  7. // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  8. // copies of the Software, and to permit persons to whom the Software is
  9. // furnished to do so, subject to the following conditions:
  10. //
  11. // The above copyright notice and this permission notice shall be included in
  12. // all copies or substantial portions of the Software.
  13. //
  14. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  19. // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  20. // THE SOFTWARE.
  21. //
  22. #include "../Precompiled.h"
  23. #include "../Core/Context.h"
  24. #include "../Graphics/Camera.h"
  25. #include "../Graphics/DebugRenderer.h"
  26. #include "../Graphics/Drawable.h"
  27. #include "../Scene/Node.h"
  28. #include "../DebugNew.h"
  29. namespace Atomic
  30. {
  31. extern const char* SCENE_CATEGORY;
  32. static const char* fillModeNames[] =
  33. {
  34. "Solid",
  35. "Wireframe",
  36. "Point",
  37. 0
  38. };
  39. static const Matrix4 flipMatrix(
  40. 1.0f, 0.0f, 0.0f, 0.0f,
  41. 0.0f, -1.0f, 0.0f, 0.0f,
  42. 0.0f, 0.0f, 1.0f, 0.0f,
  43. 0.0f, 0.0f, 0.0f, 1.0f
  44. );
  45. Camera::Camera(Context* context) :
  46. Component(context),
  47. viewDirty_(true),
  48. projectionDirty_(true),
  49. frustumDirty_(true),
  50. orthographic_(false),
  51. nearClip_(DEFAULT_NEARCLIP),
  52. farClip_(DEFAULT_FARCLIP),
  53. fov_(DEFAULT_CAMERA_FOV),
  54. orthoSize_(DEFAULT_ORTHOSIZE),
  55. aspectRatio_(1.0f),
  56. zoom_(1.0f),
  57. lodBias_(1.0f),
  58. viewMask_(DEFAULT_VIEWMASK),
  59. viewOverrideFlags_(VO_NONE),
  60. fillMode_(FILL_SOLID),
  61. projectionOffset_(Vector2::ZERO),
  62. reflectionPlane_(Plane::UP),
  63. clipPlane_(Plane::UP),
  64. autoAspectRatio_(true),
  65. flipVertical_(false),
  66. useReflection_(false),
  67. useClipping_(false)
  68. {
  69. reflectionMatrix_ = reflectionPlane_.ReflectionMatrix();
  70. }
  71. Camera::~Camera()
  72. {
  73. }
  74. void Camera::RegisterObject(Context* context)
  75. {
  76. context->RegisterFactory<Camera>(SCENE_CATEGORY);
  77. ACCESSOR_ATTRIBUTE("Is Enabled", IsEnabled, SetEnabled, bool, true, AM_DEFAULT);
  78. ACCESSOR_ATTRIBUTE("Near Clip", GetNearClip, SetNearClip, float, DEFAULT_NEARCLIP, AM_DEFAULT);
  79. ACCESSOR_ATTRIBUTE("Far Clip", GetFarClip, SetFarClip, float, DEFAULT_FARCLIP, AM_DEFAULT);
  80. ACCESSOR_ATTRIBUTE("FOV", GetFov, SetFov, float, DEFAULT_CAMERA_FOV, AM_DEFAULT);
  81. ACCESSOR_ATTRIBUTE("Aspect Ratio", GetAspectRatio, SetAspectRatioInternal, float, 1.0f, AM_DEFAULT);
  82. ENUM_ATTRIBUTE("Fill Mode", fillMode_, fillModeNames, FILL_SOLID, AM_DEFAULT);
  83. ATTRIBUTE("Auto Aspect Ratio", bool, autoAspectRatio_, true, AM_DEFAULT);
  84. ACCESSOR_ATTRIBUTE("Orthographic", IsOrthographic, SetOrthographic, bool, false, AM_DEFAULT);
  85. ACCESSOR_ATTRIBUTE("Orthographic Size", GetOrthoSize, SetOrthoSizeAttr, float, DEFAULT_ORTHOSIZE, AM_DEFAULT);
  86. ACCESSOR_ATTRIBUTE("Zoom", GetZoom, SetZoom, float, 1.0f, AM_DEFAULT);
  87. ACCESSOR_ATTRIBUTE("LOD Bias", GetLodBias, SetLodBias, float, 1.0f, AM_DEFAULT);
  88. ATTRIBUTE("View Mask", int, viewMask_, DEFAULT_VIEWMASK, AM_DEFAULT);
  89. ATTRIBUTE("View Override Flags", int, viewOverrideFlags_, VO_NONE, AM_DEFAULT);
  90. ACCESSOR_ATTRIBUTE("Projection Offset", GetProjectionOffset, SetProjectionOffset, Vector2, Vector2::ZERO, AM_DEFAULT);
  91. MIXED_ACCESSOR_ATTRIBUTE("Reflection Plane", GetReflectionPlaneAttr, SetReflectionPlaneAttr, Vector4,
  92. Vector4(0.0f, 1.0f, 0.0f, 0.0f), AM_DEFAULT);
  93. MIXED_ACCESSOR_ATTRIBUTE("Clip Plane", GetClipPlaneAttr, SetClipPlaneAttr, Vector4, Vector4(0.0f, 1.0f, 0.0f, 0.0f),
  94. AM_DEFAULT);
  95. ACCESSOR_ATTRIBUTE("Use Reflection", GetUseReflection, SetUseReflection, bool, false, AM_DEFAULT);
  96. ACCESSOR_ATTRIBUTE("Use Clipping", GetUseClipping, SetUseClipping, bool, false, AM_DEFAULT);
  97. }
  98. void Camera::DrawDebugGeometry(DebugRenderer* debug, bool depthTest)
  99. {
  100. debug->AddFrustum(GetFrustum(), Color::WHITE, depthTest);
  101. }
  102. void Camera::SetNearClip(float nearClip)
  103. {
  104. nearClip_ = Max(nearClip, M_MIN_NEARCLIP);
  105. frustumDirty_ = true;
  106. projectionDirty_ = true;
  107. MarkNetworkUpdate();
  108. }
  109. void Camera::SetFarClip(float farClip)
  110. {
  111. farClip_ = Max(farClip, M_MIN_NEARCLIP);
  112. frustumDirty_ = true;
  113. projectionDirty_ = true;
  114. MarkNetworkUpdate();
  115. }
  116. void Camera::SetFov(float fov)
  117. {
  118. fov_ = Clamp(fov, 0.0f, M_MAX_FOV);
  119. frustumDirty_ = true;
  120. projectionDirty_ = true;
  121. MarkNetworkUpdate();
  122. }
  123. void Camera::SetOrthoSize(float orthoSize)
  124. {
  125. orthoSize_ = orthoSize;
  126. aspectRatio_ = 1.0f;
  127. frustumDirty_ = true;
  128. projectionDirty_ = true;
  129. MarkNetworkUpdate();
  130. }
  131. void Camera::SetOrthoSize(const Vector2& orthoSize)
  132. {
  133. autoAspectRatio_ = false;
  134. orthoSize_ = orthoSize.y_;
  135. aspectRatio_ = orthoSize.x_ / orthoSize.y_;
  136. frustumDirty_ = true;
  137. projectionDirty_ = true;
  138. MarkNetworkUpdate();
  139. }
  140. void Camera::SetAspectRatio(float aspectRatio)
  141. {
  142. autoAspectRatio_ = false;
  143. SetAspectRatioInternal(aspectRatio);
  144. }
  145. void Camera::SetZoom(float zoom)
  146. {
  147. zoom_ = Max(zoom, M_EPSILON);
  148. frustumDirty_ = true;
  149. projectionDirty_ = true;
  150. MarkNetworkUpdate();
  151. }
  152. void Camera::SetLodBias(float bias)
  153. {
  154. lodBias_ = Max(bias, M_EPSILON);
  155. MarkNetworkUpdate();
  156. }
  157. void Camera::SetViewMask(unsigned mask)
  158. {
  159. viewMask_ = mask;
  160. MarkNetworkUpdate();
  161. }
  162. void Camera::SetViewOverrideFlags(unsigned flags)
  163. {
  164. viewOverrideFlags_ = flags;
  165. MarkNetworkUpdate();
  166. }
  167. void Camera::SetFillMode(FillMode mode)
  168. {
  169. fillMode_ = mode;
  170. MarkNetworkUpdate();
  171. }
  172. void Camera::SetOrthographic(bool enable)
  173. {
  174. orthographic_ = enable;
  175. frustumDirty_ = true;
  176. projectionDirty_ = true;
  177. MarkNetworkUpdate();
  178. }
  179. void Camera::SetAutoAspectRatio(bool enable)
  180. {
  181. autoAspectRatio_ = enable;
  182. MarkNetworkUpdate();
  183. }
  184. void Camera::SetProjectionOffset(const Vector2& offset)
  185. {
  186. projectionOffset_ = offset;
  187. projectionDirty_ = true;
  188. MarkNetworkUpdate();
  189. }
  190. void Camera::SetUseReflection(bool enable)
  191. {
  192. useReflection_ = enable;
  193. viewDirty_ = true;
  194. frustumDirty_ = true;
  195. MarkNetworkUpdate();
  196. }
  197. void Camera::SetReflectionPlane(const Plane& plane)
  198. {
  199. reflectionPlane_ = plane;
  200. reflectionMatrix_ = reflectionPlane_.ReflectionMatrix();
  201. viewDirty_ = true;
  202. frustumDirty_ = true;
  203. MarkNetworkUpdate();
  204. }
  205. void Camera::SetUseClipping(bool enable)
  206. {
  207. useClipping_ = enable;
  208. projectionDirty_ = true;
  209. MarkNetworkUpdate();
  210. }
  211. void Camera::SetClipPlane(const Plane& plane)
  212. {
  213. clipPlane_ = plane;
  214. projectionDirty_ = true;
  215. MarkNetworkUpdate();
  216. }
  217. void Camera::SetFlipVertical(bool enable)
  218. {
  219. flipVertical_ = enable;
  220. projectionDirty_ = true;
  221. MarkNetworkUpdate();
  222. }
  223. float Camera::GetNearClip() const
  224. {
  225. // Orthographic camera has always near clip at 0 to avoid trouble with shader depth parameters,
  226. // and unlike in perspective mode there should be no depth buffer precision issue
  227. if (!orthographic_)
  228. return nearClip_;
  229. else
  230. return 0.0f;
  231. }
  232. Frustum Camera::GetSplitFrustum(float nearClip, float farClip) const
  233. {
  234. Frustum ret;
  235. Matrix3x4 worldTransform = GetEffectiveWorldTransform();
  236. nearClip = Max(nearClip, GetNearClip());
  237. farClip = Min(farClip, farClip_);
  238. if (farClip < nearClip)
  239. farClip = nearClip;
  240. if (!orthographic_)
  241. ret.Define(fov_, aspectRatio_, zoom_, nearClip, farClip, worldTransform);
  242. else
  243. ret.DefineOrtho(orthoSize_, aspectRatio_, zoom_, nearClip, farClip, worldTransform);
  244. return ret;
  245. }
  246. Frustum Camera::GetViewSpaceFrustum() const
  247. {
  248. Frustum ret;
  249. if (!orthographic_)
  250. ret.Define(fov_, aspectRatio_, zoom_, GetNearClip(), farClip_);
  251. else
  252. ret.DefineOrtho(orthoSize_, aspectRatio_, zoom_, GetNearClip(), farClip_);
  253. return ret;
  254. }
  255. Frustum Camera::GetViewSpaceSplitFrustum(float nearClip, float farClip) const
  256. {
  257. Frustum ret;
  258. nearClip = Max(nearClip, GetNearClip());
  259. farClip = Min(farClip, farClip_);
  260. if (farClip < nearClip)
  261. farClip = nearClip;
  262. if (!orthographic_)
  263. ret.Define(fov_, aspectRatio_, zoom_, nearClip, farClip);
  264. else
  265. ret.DefineOrtho(orthoSize_, aspectRatio_, zoom_, nearClip, farClip);
  266. return ret;
  267. }
  268. Ray Camera::GetScreenRay(float x, float y) const
  269. {
  270. Ray ret;
  271. // If projection is invalid, just return a ray pointing forward
  272. if (!IsProjectionValid())
  273. {
  274. ret.origin_ = node_ ? node_->GetWorldPosition() : Vector3::ZERO;
  275. ret.direction_ = node_ ? node_->GetWorldDirection() : Vector3::FORWARD;
  276. return ret;
  277. }
  278. Matrix4 viewProjInverse = (GetProjection(false) * GetView()).Inverse();
  279. // The parameters range from 0.0 to 1.0. Expand to normalized device coordinates (-1.0 to 1.0) & flip Y axis
  280. x = 2.0f * x - 1.0f;
  281. y = 1.0f - 2.0f * y;
  282. Vector3 near(x, y, 0.0f);
  283. Vector3 far(x, y, 1.0f);
  284. ret.origin_ = viewProjInverse * near;
  285. ret.direction_ = ((viewProjInverse * far) - ret.origin_).Normalized();
  286. return ret;
  287. }
  288. Vector2 Camera::WorldToScreenPoint(const Vector3& worldPos) const
  289. {
  290. Vector3 eyeSpacePos = GetView() * worldPos;
  291. Vector2 ret;
  292. if (eyeSpacePos.z_ > 0.0f)
  293. {
  294. Vector3 screenSpacePos = GetProjection(false) * eyeSpacePos;
  295. ret.x_ = screenSpacePos.x_;
  296. ret.y_ = screenSpacePos.y_;
  297. }
  298. else
  299. {
  300. ret.x_ = (-eyeSpacePos.x_ > 0.0f) ? -1.0f : 1.0f;
  301. ret.y_ = (-eyeSpacePos.y_ > 0.0f) ? -1.0f : 1.0f;
  302. }
  303. ret.x_ = (ret.x_ / 2.0f) + 0.5f;
  304. ret.y_ = 1.0f - ((ret.y_ / 2.0f) + 0.5f);
  305. return ret;
  306. }
  307. Vector3 Camera::ScreenToWorldPoint(const Vector3& screenPos) const
  308. {
  309. Ray ray = GetScreenRay(screenPos.x_, screenPos.y_);
  310. return ray.origin_ + ray.direction_ * screenPos.z_;
  311. }
  312. const Frustum& Camera::GetFrustum() const
  313. {
  314. if (frustumDirty_)
  315. {
  316. Matrix3x4 worldTransform = GetEffectiveWorldTransform();
  317. if (!orthographic_)
  318. frustum_.Define(fov_, aspectRatio_, zoom_, GetNearClip(), farClip_, worldTransform);
  319. else
  320. frustum_.DefineOrtho(orthoSize_, aspectRatio_, zoom_, GetNearClip(), farClip_, worldTransform);
  321. frustumDirty_ = false;
  322. }
  323. return frustum_;
  324. }
  325. const Matrix4& Camera::GetProjection() const
  326. {
  327. if (projectionDirty_)
  328. {
  329. projection_ = GetProjection(true);
  330. projectionDirty_ = false;
  331. }
  332. return projection_;
  333. }
  334. Matrix4 Camera::GetProjection(bool apiSpecific) const
  335. {
  336. Matrix4 ret(Matrix4::ZERO);
  337. // Whether to construct matrix using OpenGL or Direct3D clip space convention
  338. #ifdef ATOMIC_OPENGL
  339. bool openGLFormat = apiSpecific;
  340. #else
  341. bool openGLFormat = false;
  342. #endif
  343. if (!orthographic_)
  344. {
  345. float nearClip = GetNearClip();
  346. float h = (1.0f / tanf(fov_ * M_DEGTORAD * 0.5f)) * zoom_;
  347. float w = h / aspectRatio_;
  348. float q, r;
  349. if (openGLFormat)
  350. {
  351. q = (farClip_ + nearClip) / (farClip_ - nearClip);
  352. r = -2.0f * farClip_ * nearClip / (farClip_ - nearClip);
  353. }
  354. else
  355. {
  356. q = farClip_ / (farClip_ - nearClip);
  357. r = -q * nearClip;
  358. }
  359. ret.m00_ = w;
  360. ret.m02_ = projectionOffset_.x_ * 2.0f;
  361. ret.m11_ = h;
  362. ret.m12_ = projectionOffset_.y_ * 2.0f;
  363. ret.m22_ = q;
  364. ret.m23_ = r;
  365. ret.m32_ = 1.0f;
  366. }
  367. else
  368. {
  369. // Disregard near clip, because it does not affect depth precision as with perspective projection
  370. float h = (1.0f / (orthoSize_ * 0.5f)) * zoom_;
  371. float w = h / aspectRatio_;
  372. float q, r;
  373. if (openGLFormat)
  374. {
  375. q = 2.0f / farClip_;
  376. r = -1.0f;
  377. }
  378. else
  379. {
  380. q = 1.0f / farClip_;
  381. r = 0.0f;
  382. }
  383. ret.m00_ = w;
  384. ret.m03_ = projectionOffset_.x_ * 2.0f;
  385. ret.m11_ = h;
  386. ret.m13_ = projectionOffset_.y_ * 2.0f;
  387. ret.m22_ = q;
  388. ret.m23_ = r;
  389. ret.m33_ = 1.0f;
  390. }
  391. if (flipVertical_)
  392. ret = flipMatrix * ret;
  393. return ret;
  394. }
  395. void Camera::GetFrustumSize(Vector3& near, Vector3& far) const
  396. {
  397. near.z_ = GetNearClip();
  398. far.z_ = farClip_;
  399. if (!orthographic_)
  400. {
  401. float halfViewSize = tanf(fov_ * M_DEGTORAD * 0.5f) / zoom_;
  402. near.y_ = near.z_ * halfViewSize;
  403. near.x_ = near.y_ * aspectRatio_;
  404. far.y_ = far.z_ * halfViewSize;
  405. far.x_ = far.y_ * aspectRatio_;
  406. }
  407. else
  408. {
  409. float halfViewSize = orthoSize_ * 0.5f / zoom_;
  410. near.y_ = far.y_ = halfViewSize;
  411. near.x_ = far.x_ = near.y_ * aspectRatio_;
  412. }
  413. if (flipVertical_)
  414. {
  415. near.y_ = -near.y_;
  416. far.y_ = -far.y_;
  417. }
  418. }
  419. float Camera::GetHalfViewSize() const
  420. {
  421. if (!orthographic_)
  422. return tanf(fov_ * M_DEGTORAD * 0.5f) / zoom_;
  423. else
  424. return orthoSize_ * 0.5f / zoom_;
  425. }
  426. float Camera::GetDistance(const Vector3& worldPos) const
  427. {
  428. if (!orthographic_)
  429. {
  430. const Vector3& cameraPos = node_ ? node_->GetWorldPosition() : Vector3::ZERO;
  431. return (worldPos - cameraPos).Length();
  432. }
  433. else
  434. return Abs((GetView() * worldPos).z_);
  435. }
  436. float Camera::GetDistanceSquared(const Vector3& worldPos) const
  437. {
  438. if (!orthographic_)
  439. {
  440. const Vector3& cameraPos = node_ ? node_->GetWorldPosition() : Vector3::ZERO;
  441. return (worldPos - cameraPos).LengthSquared();
  442. }
  443. else
  444. {
  445. float distance = (GetView() * worldPos).z_;
  446. return distance * distance;
  447. }
  448. }
  449. float Camera::GetLodDistance(float distance, float scale, float bias) const
  450. {
  451. float d = Max(lodBias_ * bias * scale * zoom_, M_EPSILON);
  452. if (!orthographic_)
  453. return distance / d;
  454. else
  455. return orthoSize_ / d;
  456. }
  457. Quaternion Camera::GetFaceCameraRotation(const Vector3& position, const Quaternion& rotation, FaceCameraMode mode)
  458. {
  459. if (!node_)
  460. return rotation;
  461. switch (mode)
  462. {
  463. default:
  464. return rotation;
  465. case FC_ROTATE_XYZ:
  466. return node_->GetWorldRotation();
  467. case FC_ROTATE_Y:
  468. {
  469. Vector3 euler = rotation.EulerAngles();
  470. euler.y_ = node_->GetWorldRotation().EulerAngles().y_;
  471. return Quaternion(euler.x_, euler.y_, euler.z_);
  472. }
  473. case FC_LOOKAT_XYZ:
  474. {
  475. Quaternion lookAt;
  476. lookAt.FromLookRotation(position - node_->GetWorldPosition());
  477. return lookAt;
  478. }
  479. case FC_LOOKAT_Y:
  480. {
  481. // Make the Y-only lookat happen on an XZ plane to make sure there are no unwanted transitions
  482. // or singularities
  483. Vector3 lookAtVec(position - node_->GetWorldPosition());
  484. lookAtVec.y_ = 0.0f;
  485. Quaternion lookAt;
  486. lookAt.FromLookRotation(lookAtVec);
  487. Vector3 euler = rotation.EulerAngles();
  488. euler.y_ = lookAt.EulerAngles().y_;
  489. return Quaternion(euler.x_, euler.y_, euler.z_);
  490. }
  491. }
  492. }
  493. Matrix3x4 Camera::GetEffectiveWorldTransform() const
  494. {
  495. Matrix3x4 worldTransform = node_ ? Matrix3x4(node_->GetWorldPosition(), node_->GetWorldRotation(), 1.0f) : Matrix3x4::IDENTITY;
  496. return useReflection_ ? reflectionMatrix_ * worldTransform : worldTransform;
  497. }
  498. bool Camera::IsProjectionValid() const
  499. {
  500. return farClip_ > GetNearClip();
  501. }
  502. const Matrix3x4& Camera::GetView() const
  503. {
  504. if (viewDirty_)
  505. {
  506. // Note: view matrix is unaffected by node or parent scale
  507. view_ = GetEffectiveWorldTransform().Inverse();
  508. viewDirty_ = false;
  509. }
  510. return view_;
  511. }
  512. void Camera::SetAspectRatioInternal(float aspectRatio)
  513. {
  514. aspectRatio_ = aspectRatio;
  515. frustumDirty_ = true;
  516. projectionDirty_ = true;
  517. MarkNetworkUpdate();
  518. }
  519. void Camera::SetOrthoSizeAttr(float orthoSize)
  520. {
  521. orthoSize_ = orthoSize;
  522. frustumDirty_ = true;
  523. projectionDirty_ = true;
  524. MarkNetworkUpdate();
  525. }
  526. void Camera::SetReflectionPlaneAttr(const Vector4& value)
  527. {
  528. SetReflectionPlane(Plane(value));
  529. }
  530. void Camera::SetClipPlaneAttr(const Vector4& value)
  531. {
  532. SetClipPlane(Plane(value));
  533. }
  534. Vector4 Camera::GetReflectionPlaneAttr() const
  535. {
  536. return reflectionPlane_.ToVector4();
  537. }
  538. Vector4 Camera::GetClipPlaneAttr() const
  539. {
  540. return clipPlane_.ToVector4();
  541. }
  542. void Camera::OnNodeSet(Node* node)
  543. {
  544. if (node)
  545. node->AddListener(this);
  546. }
  547. void Camera::OnMarkedDirty(Node* node)
  548. {
  549. frustumDirty_ = true;
  550. viewDirty_ = true;
  551. }
  552. }