/* ========================================================================== * ÀÛ ¼º ÀÚ : À̼ø±Ô * ÀÛ ¼º ÀÏ : 2006.12.07 * ³» ¿ë : Àå¸é Æ®¸® * ÁÖÀÇ»çÇ× : *===========================================================================*/ #pragma once #include "Sphere.h" #include "SceneNode.h" class cCamera; class cSceneTree; /// Å×½ºÆ®¿ë ±¸ /// Àå¸é ³ëµå¸¦ ¿ÏÀüÈ÷ Æ÷ÇÔÇÏ´Â Áö¸¦ °Ë»çÇϴµ¥ ¾²ÀδÙ. class cTestSphere : public cSphere { public: /// °Ë»ç °á°ú bool mResult; }; /// Àå¸é Æ®¸® ³ëµå /// ¿©·¯ Àå¸é ³ëµåµéÀ» Æ÷ÇÔÇÏ´Â ÄÁÅ×À̳ÊÀÌ´Ù. class cSceneTreeNode : public cSphere { friend class cSceneTree; public: cSceneTreeNode( cSceneTree* tree, cSceneTreeNode* parent, const NiPoint3& center, float radius ); cSceneTreeNode( cSceneTree* tree, cSceneTreeNode* parent, const cSphere& sphere ); virtual ~cSceneTreeNode(); void* operator new( size_t n ); void operator delete( void* p ); /// Àå¸é ³ëµå¸¦ Ãß°¡ void Push( cSceneNode* node ); /// Àå¸é ³ëµå¸¦ Á¦°Å void Remove( cSceneNode* node ); /// Àå¸é ³ëµåÀÇ À̵¿ ¶Ç´Â Å©±â º¯È­¿¡ ´ëÇØ °»½Å void Update( cSceneNode* node ); /// Äøµ void Cull(); /// ¹ÝÁ÷¼±°ú Ãæµ¹ÇÏ´Â Àå¸é ³ëµåµéÀ» ¼öÁý /// »ï°¢Çü ´ÜÀ§·Î °Ë»çÇÑ´Ù. bool CollideRay_Kind(); /// ±¸¿Í Ãæµ¹ÇÏ´Â Àå¸é ³ëµåµéÀ» ¼öÁý /// ±¸ ´ÜÀ§·Î °Ë»çÇÑ´Ù. bool CollideSphere_Kind(); bool CollideSphere_Type(); protected: /// °¡½Ã ¹è¿­¿¡ Ãß°¡ void AddToVisibleArray() const; void PushDirect( cSceneNode* node ); private: /// Æ®¸® cSceneTree* mTree; /// ºÎ¸ð cSceneTreeNode* mParent; /// ÀÚ½Ä ¹è¿­ cSceneTreeNode* mChild[4]; /// Å×½ºÆ®¿ë ±¸ cTestSphere mTestSpheres[4]; /// Àå¸é ³ëµå ¸®½ºÆ® typedef tPointerList cObjectList; cObjectList mObjectList; /// ¸Þ¸ð¸® Ç® static tPool mPool; /// Äøµ¿ë static NiFrustumPlanes* mFrustum; static cSceneNode::eType mPickType; /// Ãæµ¹ °Ë»ç¿ë static const cRay* mRay; static bool mCameraRay; static float mMaxDistance; static const cSphere* mSphere; static tArray* mCollidedArray; }; /// Àå¸é Æ®¸® /// °ÔÀÓ ³»ÀÇ ¼ö¸¹Àº Àå¸é ³ëµåµéÀ» ÄøµÇϰųª Ãæµ¹ °Ë»ç¸¦ ¼öÇàÇϱâ À§ÇØ »ç¿ëÇÑ´Ù. class cSceneTree { public: cSceneTree(); virtual ~cSceneTree(); /// ¸ðµç Àå¸é ³ëµåµéÀ» Áö¿ò void Clear(); /// ÃʱâÈ­ void Init( const NiPoint3& center, float minRadius, float maxRadius ); /// Àå¸é ³ëµå¸¦ Ãß°¡ void Push( cSceneNode* node ); /// Äøµ void Cull( NiVisibleArray* solidArray, NiVisibleArray* alphaArray, NiVisibleArray* alphaTestArray, cCamera* cam, cSceneNode::eType type ); /// ¹ÝÁ÷¼±°ú Ãæµ¹ÇÏ´Â Àå¸é ³ëµåµéÀ» ¼öÁý /// »ï°¢Çü ´ÜÀ§·Î °Ë»çÇÑ´Ù. bool CollideRay_Kind( tArray* collidableArray, const cRay& ray, float maxDistance, bool sortByDistance, cSceneNode::eType type ); /// ±¸¿Í Ãæµ¹ÇÏ´Â Àå¸é ³ëµåµéÀ» ¼öÁý /// ±¸ ´ÜÀ§·Î °Ë»çÇÑ´Ù. bool CollideSphere_Kind( tArray* collidableArray, const cSphere& sphere, cSceneNode::eType type ); bool CollideSphere_Type( tArray* collidableArray, const cSphere& sphere, cSceneNode::eType type ); /// ÁßÁ¡À» ¸®ÅÏ const NiPoint3& GetCenter() const; /// ÃÖ¼Ò ¹ÝÁö¸§À» ¸®ÅÏ float GetMinRadius() const; /// ÃÖ´ë ¹ÝÁö¸§À» ¸®ÅÏ float GetMaxRadius() const; /// ºñ¾îÀÖ´ÂÁö ¿©ºÎ¸¦ ¸®ÅÏ bool IsEmpty() const; protected: /// ·çÆ® ³ëµå cSceneTreeNode* mRootNode; /// ÁßÁ¡ NiPoint3 mCenter; /// ÃÖ¼Ò ¹ÝÁö¸§ float mMinRadius; /// ÃÖ´ë ¹ÝÁö¸§ float mMaxRadius; }; inline const NiPoint3& cSceneTree::GetCenter() const { return mCenter; } inline float cSceneTree::GetMinRadius() const { return mMinRadius; } inline float cSceneTree::GetMaxRadius() const { return mMaxRadius; } inline bool cSceneTree::IsEmpty() const { return mRootNode ? false : true; }