Scene.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. #ifndef SCENE_H_
  2. #define SCENE_H_
  3. #include "Object.h"
  4. #include "Node.h"
  5. #include "FileIO.h"
  6. namespace gameplay
  7. {
  8. class Scene : public Object
  9. {
  10. public:
  11. /**
  12. * Constructor.
  13. */
  14. Scene(void);
  15. /**
  16. * Destructor.
  17. */
  18. virtual ~Scene(void);
  19. virtual unsigned int getTypeId(void) const;
  20. virtual const char* getElementName(void) const;
  21. virtual void writeBinary(FILE* file);
  22. virtual void writeText(FILE* file);
  23. /**
  24. * Adds the given node as a child of this scene.
  25. *
  26. * @param node The node to add.
  27. */
  28. void add(Node* node);
  29. /**
  30. * Sets the activate camera node. This node should contain a camera.
  31. */
  32. void setActiveCameraNode(Node* node);
  33. /**
  34. * Returns the first node the this scene that contains a camera.
  35. */
  36. Node* getFirstCameraNode() const;
  37. /**
  38. * Calculates the ambient color of this scene by combining all of the ambient lights
  39. * that are in this scene.
  40. */
  41. void calcAmbientColor();
  42. /**
  43. * Sets the scene's ambient color.
  44. */
  45. void setAmbientColor(float red, float green, float blue);
  46. private:
  47. /**
  48. * Recursively calculates the ambient color of the scene starting at the given node.
  49. * The ambient light color is added to the given float array.
  50. *
  51. * @param node The node in this scene to traverse from.
  52. * @param values Pointer to 3 floats that contains the calculated ambient color.
  53. */
  54. void calcAmbientColor(const Node* node, float* values) const;
  55. private:
  56. std::list<Node*> _nodes;
  57. Node* _cameraNode;
  58. float _ambientColor[Light::COLOR_SIZE];
  59. Node* _lightNode;
  60. };
  61. }
  62. #endif