오늘의 내용:
1) 배경 (gameobject의 depth 활용)
2) 카메라
카메라행렬은 모든 행렬의 역행렬로 보내버린다.
WVP 에서 V의 역할은 W 즉 모든 오브젝트를 전체적으로 움직여버리게 만든다.
★ 오른쪽으로 100만큼이동한 행렬과 왼쪽으로 100만큼 이동한 행렬은 서로 역행렬관계를 가진다
더보기
void Environment::Update()
{
Matrix view;
static float x = 0.0f;
if (KEY->Press(VK_RIGHT))
x += 100 * DELTA;
if (KEY->Press(VK_LEFT))
x -= 100 * DELTA;
view = XMMatrixTranslation(x,0,0);
viewBuffer->Set(view);
viewBuffer->SetVS(1);
}
전체 Camera.cpp
더보기
#include "Framework.h"
Camera::Camera()
{
tag = "Camera";
viewBuffer = new MatrixBuffer();
viewBuffer->SetVS(1);
}
Camera::~Camera()
{
delete viewBuffer;
}
void Camera::Update()
{
if (target)
FollowMode();
else
FreeMode();
SetView();
}
void Camera::RenderUI()
{
if (ImGui::TreeNode("Camera Option"))
{
ImGui::DragFloat("Speed", &speed);
ImGui::DragFloat("OffSet", (float*)&targetOffSet);
ImGui::TreePop();
}
}
void Camera::SetView()
{
UpdateWorld();
view = XMMatrixInverse(nullptr, world);
viewBuffer->Set(view);
viewBuffer->SetVS(1);
}
void Camera::FreeMode()
{
if (KEY->Press(VK_RBUTTON))
{
if (KEY->Press('W'))
Translate(Vector2::Up() * speed * DELTA);
if (KEY->Press('S'))
Translate(Vector2::Down() * speed * DELTA);
if (KEY->Press('A'))
Translate(Vector2::Left() * speed * DELTA);
if (KEY->Press('D'))
Translate(Vector2::Right() * speed * DELTA);
}
FixPosition(localPosition);
}
void Camera::FollowMode()
{
Vector2 targetPos = target->GetGlobalPosition()-targetOffSet;
FixPosition(targetPos);
localPosition = Lerp(localPosition, targetPos, speed * DELTA);
}
void Camera::FixPosition(Vector2& pos)
{
if (pos.x < leftBottom.x)
pos.x = leftBottom.x;
if (pos.x > rightTop.x - SCREEN_WIDTH)
pos.x = rightTop.x - SCREEN_WIDTH;
if (pos.y < leftBottom.y)
pos.y = leftBottom.y;
if (pos.y > rightTop.y - SCREEN_HEIGHT)
pos.y = rightTop.y - SCREEN_HEIGHT;
}
camera.h
#pragma once
class Camera : public Transform
{
public:
Camera();
~Camera();
void Update();
void RenderUI();
void SetView();
void SetLeftBottom(float x, float y) { leftBottom = { x, y }; }
void SetLeftBottom(Vector2 pos) { leftBottom = pos; }
void SetRightTop(float x, float y) { rightTop = { x, y }; }
void SetRightTop(Vector2 pos) { rightTop = pos; }
void SetTarget(Transform* target) { this->target = target; }
private:
void FreeMode();
void FollowMode();
void FixPosition(Vector2& pos);
private:
MatrixBuffer* viewBuffer;
Matrix view;
float speed = 100.0f;
Vector2 leftBottom;
Vector2 rightTop = { SCREEN_WIDTH, SCREEN_HEIGHT };
Transform* target = nullptr;
Vector2 targetOffSet = CENTER;
};
3) 프러스텀컬링== 절두체 출력 , 밖에있는 물체는 랜더 off
오큘루젼 컬링 : 벽뒤에 있는애들 랜더 꺼두는 방법
4) 비선형구조의 대표적인 형식
더보기
1. 트리 (블랙 이진 트리== 자식이 2개인 트리)
장점:
1)Heap 화 : 부조자식간을 정렬하는것 ->Log n의 효율밖에 안들기에 효율적
2) key값에 따라 자동으로 정렬해준다.
->O표기값으로 n값을 가진다 한번 검색해야하기때문에
2. 해쉬테이블 :정렬x
표를의미한다.
해쉬값을 알고 바로 데이터메모리의 주소로 접근할수 있기 때문에 한번 거치지않아서 효과적이다.
굉장히 효율적 해쉬값을 바로 받으면 O표기값으로 1을 가진다(효율최고)
'개인공부 > DirectX' 카테고리의 다른 글
| Directx_20일차_애니메이션 (0) | 2024.03.26 |
|---|---|
| DirectX 장비창 조합 구현 (0) | 2024.03.25 |
| DirectX 9일차 (0) | 2024.03.08 |
| DirectX8일차_RectCollision (0) | 2024.03.07 |
| DirectX 7일차 _Collision (0) | 2024.03.06 |