Camera.cpp 17 KB

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