GeometryNode.h 3.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. //
  2. // Urho3D Engine
  3. // Copyright (c) 2008-2011 Lasse Öörni
  4. //
  5. // Permission is hereby granted, free of charge, to any person obtaining a copy
  6. // of this software and associated documentation files (the "Software"), to deal
  7. // in the Software without restriction, including without limitation the rights
  8. // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  9. // copies of the Software, and to permit persons to whom the Software is
  10. // furnished to do so, subject to the following conditions:
  11. //
  12. // The above copyright notice and this permission notice shall be included in
  13. // all copies or substantial portions of the Software.
  14. //
  15. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  16. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  17. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  18. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  19. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  20. // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  21. // THE SOFTWARE.
  22. //
  23. #ifndef RENDERER_GEOMETRYNODE_H
  24. #define RENDERER_GEOMETRYNODE_H
  25. #include "RendererDefs.h"
  26. #include "ShaderDefs.h"
  27. #include "VolumeNode.h"
  28. class Geometry;
  29. class Light;
  30. class Material;
  31. class OcclusionBuffer;
  32. class Ray;
  33. class Renderer;
  34. //! Abstract base class for renderable scene nodes
  35. class GeometryNode : public VolumeNode
  36. {
  37. public:
  38. //! Write component state to a stream
  39. virtual void save(Serializer& dest);
  40. //! Read component state from a stream
  41. virtual void load(Deserializer& source, ResourceCache* cache);
  42. //! Write component state to an XML element
  43. virtual void saveXML(XMLElement& dest);
  44. //! Read component state from an XML element
  45. virtual void loadXML(const XMLElement& source, ResourceCache* cache);
  46. //! Write a network update
  47. virtual bool writeNetUpdate(Serializer& dest, Serializer& destRevision, Deserializer& baseRevision, const NetUpdateInfo& info);
  48. //! Read a network update
  49. virtual void readNetUpdate(Deserializer& source, ResourceCache* cache, const NetUpdateInfo& info);
  50. //! Calculate distance for rendering
  51. virtual void updateDistance(const FrameInfo& frame);
  52. //! Prepare geometry for rendering
  53. virtual void updateGeometry(const FrameInfo& frame, Renderer* renderer) = 0;
  54. //! Return geometry type, determines vertex shader variation
  55. virtual GeometryType getGeometryType() { return GEOM_STATIC; }
  56. //! Return number of batches
  57. virtual unsigned getNumBatches() = 0;
  58. //! Return geometry by batch index
  59. virtual Geometry* getBatchGeometry(unsigned batchIndex) = 0;
  60. //! Return material by batch index
  61. virtual Material* getBatchMaterial(unsigned batchIndex) = 0;
  62. //! Return vertex shader parameter
  63. virtual bool getVertexShaderParameter(unsigned batchIndex, VSParameter parameter, const float** data, unsigned* count);
  64. //! Draw to occlusion buffer
  65. virtual bool drawOcclusion(OcclusionBuffer* buffer);
  66. //! Set LOD bias
  67. void setLodBias(float bias);
  68. //! Return LOD bias
  69. float getLodBias() const { return mLodBias; }
  70. //! Return LOD scaled distance
  71. float getLodDistance() const { return mLodDistance; }
  72. protected:
  73. //! Construct with the specified node flags, initial octant pointer and name
  74. GeometryNode(unsigned flags, Octant* octant, const std::string& name);
  75. //! LOD bias
  76. float mLodBias;
  77. //! LOD bias
  78. float mLodDistance;
  79. //! LOD needs update flag
  80. bool mLodLevelsDirty;
  81. };
  82. #endif // RENDERER_GEOMETRYNODE_H