오늘의 내용:
1. 벡터의 내적
1) 두 벡터를 단위벡터로 정규화시키고 acos(cos값)을 계산하면 두 벡터의 내각을 구할수 있다.
2) 내각의 크기 판단으로 기준 상 물체의 앞 뒤 판단
3) 벡터 자신을 내적한 값의 루트값은 벡터의 크기와 같다 => 따라서 자신의 크기를 구할때 쓰인다.
4) 두 벡터 중 하나를 단위벡터로 정규화시키고 내적하면 나머지 벡터의 투영된 길이를 구할 수 있다
2. 벡터의 외적
1) 물체가 기준이되는 벡터의 좌우에 있는지 판단할 때
2) 어떤 벡터, 어떤 점이 두 벡터의 외적(사이)에있는지 판단 할때
3) 법선 벡터를 구할때
3. OBB 충돌
분리 축 이론 : 각 축에 대하여 두 물체를 투영했을 때 생기는 두 그림자가 모두 겹칠 때 충돌이 일어나는 것이다
볼록 다각형은 충족하지만 오목 다각형은 충족안할 수 있다 ( cuz 들어간부분에 물체가 존재한다면 그림자 상으론 충돌 ,but 실질적으론 충돌x)
4. Multimap 자료구조
하나의 key에 여러 데이터를 가질 수 있는 구조 (vs) map은 중복 key를 가지면 마지막 데이터가 할당됨.
GameObject & Object Manager 생성하기 ( plane, enemy등 Update() & Render()를 가지는 물체의 중복을 피하기위해 묶기)
class ObjectManager : public Singleton<ObjectManager> { private: friend class Singleton; ObjectManager(); ~ObjectManager(); public: void Update(); void Render(); void Add(GameObject* object); private: multimap<int, GameObject*> objects; }; //.cpp// ObjectManager::ObjectManager() { } ObjectManager::~ObjectManager() { for (pair<int, GameObject*> object : objects) delete object.second; } void ObjectManager::Update() { for (pair<int, GameObject*> object : objects) object.second->Update(); } void ObjectManager::Render() { for (pair<int, GameObject*> object : objects) { object.second->Render(); } } void ObjectManager::Add(GameObject* object) { objects.insert({ object->GetDepth(), object }); }
class GameObject : public Transform { public: GameObject(int depth = 0); virtual ~GameObject(); virtual void Update() = 0; virtual void Render() = 0; int GetDepth() { return depth; } protected: int depth; Material* material; MatrixBuffer* worldBuffer; }; //.cpp// GameObject::GameObject(int depth) : depth(depth) { material = new Material(); worldBuffer = new MatrixBuffer(); ObjectManager::Get()->Add(this); } GameObject::~GameObject() { delete material; delete worldBuffer; }
Pooling Manager (Manager 기능)
template <typename T> class PoolingManager { protected: PoolingManager() = default; ~PoolingManager() = default; public: void CreateObjects(string key, UINT poolSize); T* Pop(string key); protected: map<string, vector<GameObject*>> totalObject; }; template<typename T> inline void PoolingManager<T>::CreateObjects(string key, UINT poolSize) { vector<GameObject*> objects(poolSize); for (GameObject*& object : objects) object = new T(); totalObject[key] = objects; } template<typename T> inline T* PoolingManager<T>::Pop(string key) { for (GameObject* object : totalObject[key]) { if (!object->IsActive()) { return (T*)object; } } return nullptr; }
다중상속은 상속하는 클래스 내부에서 중복되는 함수가 존재할 위험이 있어 조심히 사용해야 한다
다이아몬드 구조를 형성할때 함수가 겹칠경우 에러를 불러일으킬수 있다.
추가공부내용:
1) 오늘내용 복습 (o)
4) 순수가상함수 / override 쓰임새 (o)
5)다중 상속 (o)
과제:


'개인공부 > DirectX' 카테고리의 다른 글
| DirectX 장비창 조합 구현 (0) | 2024.03.25 |
|---|---|
| DirectX 13일차 Camera (0) | 2024.03.14 |
| DirectX8일차_RectCollision (0) | 2024.03.07 |
| DirectX 7일차 _Collision (0) | 2024.03.06 |
| DirectX 6일차 (0) | 2024.03.05 |