123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230 |
- #ifndef __CCSCENE_H__
- #define __CCSCENE_H__
- #include <string>
- #include "2d/CCNode.h"
- NS_CC_BEGIN
- class Camera;
- class BaseLight;
- class Renderer;
- class EventListenerCustom;
- class EventCustom;
- #if CC_USE_PHYSICS
- class PhysicsWorld;
- #endif
- #if CC_USE_3D_PHYSICS && CC_ENABLE_BULLET_INTEGRATION
- class Physics3DWorld;
- #endif
- #if CC_USE_NAVMESH
- class NavMesh;
- #endif
- class CC_DLL Scene : public Node
- {
- public:
-
- static Scene *create();
-
- static Scene *createWithSize(const Size& size);
- using Node::addChild;
- virtual std::string getDescription() const override;
-
-
- const std::vector<Camera*>& getCameras();
-
- Camera* getDefaultCamera() const { return _defaultCamera; }
-
- const std::vector<BaseLight*>& getLights() const { return _lights; }
-
- virtual void render(Renderer* renderer, const Mat4& eyeTransform, const Mat4* eyeProjection = nullptr);
-
- virtual void render(Renderer* renderer, const Mat4* eyeTransforms, const Mat4* eyeProjections, unsigned int multiViewCount);
-
- virtual void removeAllChildren() override;
-
- CC_CONSTRUCTOR_ACCESS:
- Scene();
- virtual ~Scene();
-
- bool init() override;
- bool initWithSize(const Size& size);
-
- void setCameraOrderDirty() { _cameraOrderDirty = true; }
-
- void onProjectionChanged(EventCustom* event);
- protected:
- friend class Node;
- friend class ProtectedNode;
- friend class SpriteBatchNode;
- friend class Camera;
- friend class BaseLight;
- friend class Renderer;
-
- std::vector<Camera*> _cameras;
- Camera* _defaultCamera;
- bool _cameraOrderDirty;
- EventListenerCustom* _event;
- std::vector<BaseLight *> _lights;
-
- private:
- CC_DISALLOW_COPY_AND_ASSIGN(Scene);
-
- #if (CC_USE_PHYSICS || (CC_USE_3D_PHYSICS && CC_ENABLE_BULLET_INTEGRATION))
- public:
-
- #if CC_USE_PHYSICS
-
- PhysicsWorld* getPhysicsWorld() const { return _physicsWorld; }
- #endif
-
- #if CC_USE_3D_PHYSICS && CC_ENABLE_BULLET_INTEGRATION
-
- Physics3DWorld* getPhysics3DWorld() { return _physics3DWorld; }
-
-
- void setPhysics3DDebugCamera(Camera* camera);
- #endif
-
-
- static Scene *createWithPhysics();
-
- CC_CONSTRUCTOR_ACCESS:
- bool initWithPhysics();
-
- protected:
- void addChildToPhysicsWorld(Node* child);
- #if CC_USE_PHYSICS
- PhysicsWorld* _physicsWorld;
- #endif
-
- #if CC_USE_3D_PHYSICS && CC_ENABLE_BULLET_INTEGRATION
- Physics3DWorld* _physics3DWorld;
- Camera* _physics3dDebugCamera;
- #endif
- #endif
-
- #if CC_USE_NAVMESH
- public:
-
- void setNavMesh(NavMesh* navMesh);
-
- NavMesh* getNavMesh() const { return _navMesh; }
-
- void setNavMeshDebugCamera(Camera *camera);
- protected:
- NavMesh* _navMesh;
- Camera * _navMeshDebugCamera;
- #endif
-
- #if (CC_USE_PHYSICS || (CC_USE_3D_PHYSICS && CC_ENABLE_BULLET_INTEGRATION) || CC_USE_NAVMESH)
- public:
- void stepPhysicsAndNavigation(float deltaTime);
- #endif
- };
- NS_CC_END
- #endif
|