์์ :)
https://github.com/eazuooz/YamYamEngine/commit/89bee1b4401ce4ca8d129cb82cbb1294f0cd26bc
Hirearchy Transform · eazuooz/YamYamEngine@89bee1b
Show file tree Showing 5 changed files with 45 additions and 35 deletions.
github.com
๋ถ๋ชจ-๋ณํ ์ํคํ
์ฒ๋ ๊ฒ์ ์ค๋ธ์ ํธ๋ฅผ ๊ณ์ธต ๊ตฌ์กฐ๋ก ๊ตฌ์ฑํ๋ ๋ฐฉ์์
๋๋ค. ๋ถ๋ชจ๋ผ๋ ๊ฐ๋
์ ํ ์ค๋ธ์ ํธ(์์)๊ฐ ๋ค๋ฅธ ์ค๋ธ์ ํธ(๋ถ๋ชจ)์ ๋ถ์ด ์๊ณ ๋ค๋ฅธ ์ค๋ธ์ ํธ์ ์์ง์์ ๋ฐ๋ฅด๋ ์ค๋ธ์ ํธ๋ฅผ ํจ๊ป ๊ทธ๋ฃนํํ๋ ๋ฐ ์ฌ์ฉ๋ฉ๋๋ค.
ํ ๊ฐ์ฒด๊ฐ ๋ค๋ฅธ ๊ฐ์ฒด์ ์์์ผ๋ก ์ค์ ๋๋ฉด ๋ถ๋ชจ์ ์์น, ํ์ ๋ฐ ๋ฐฐ์จ์ ์์๋ฐ์ต๋๋ค. ์ฆ, ๋ถ๋ชจ ๊ฐ์ฒด์ ์ ์ฉ๋ ๋ชจ๋ ๋ณํ์ด ์์ ๊ฐ์ฒด์๋ ์๋์ผ๋ก ์ ์ฉ๋ฉ๋๋ค. ์ด๋ ๊ฒ์ ์ค๋ธ์ ํธ๋ฅผ ๊ตฌ์ฑํ๊ณ ๋ณต์กํ ์์ง์๊ณผ ์ ๋๋ฉ์ด์
์ ๋ง๋๋ ๋ฐ ๊ฐ๋ ฅํ ๋๊ตฌ๊ฐ ๋ ์ ์์ต๋๋ค.
์๋ฅผ ๋ค์ด ๊ฒ์ ๋ด ์บ๋ฆญํฐ๊ฐ ํ, ๋ค๋ฆฌ, ๋ชธํต ๋ฑ ์ฌ๋ฌ ๋ถ๋ถ์ผ๋ก ๊ตฌ์ฑ๋ ๊ฒฝ์ฐ ์ด๋ฌํ ๋ชจ๋ ๋ถ๋ถ์ ์บ๋ฆญํฐ์ ๋ฉ์ธ ๋ฐ๋ ์ค๋ธ์ ํธ์ ๋ถ๋ชจ๋ก ์ง์ ํ ์ ์์ต๋๋ค. ์ด๋ ๊ฒ ํ๋ฉด ๋ชธ์ฒด ์ค๋ธ์ ํธ๋ง ์์ง์ด๋ฉด ์์ ์ค๋ธ์ ํธ๊ฐ ๋ฐ๋ผ ์์ง์ด๊ธฐ ๋๋ฌธ์ ์บ๋ฆญํฐ์ ์์ง์์ ์ ๋๋ฉ์ด์
ํ๊ธฐ๊ฐ ๋ ์ฌ์์ง๋๋ค.
๋ํ ๋ถ๋ชจ-๋ณํ ์ํคํ
์ฒ๋ฅผ ์ฌ์ฉํ๋ฉด ์ค๋ธ์ ํธ ๊ณ์ธต ๊ตฌ์กฐ๋ฅผ ์ฝ๊ฒ ๊ด๋ฆฌํ ์ ์์ผ๋ฏ๋ก ๊ฐ๋ฐ์๊ฐ ๊ฒ์ ์ค๋ธ์ ํธ๋ฅผ ๋ ์ฝ๊ฒ ๊ตฌ์ฑํ๊ณ ์กฐ์ํ ์ ์์ต๋๋ค.
์ ๋ฐ์ ์ผ๋ก ๋ถ๋ชจ-๋ณํ ์ํคํ
์ฒ๋ ๊ณ์ธต ๊ตฌ์กฐ์์ ๊ฒ์ ์ค๋ธ์ ํธ๋ฅผ ํจ์จ์ ์ด๊ณ ์ ์ฐํ๊ฒ ๊ตฌ์ฑํ ์ ์๋๋ก ํ๋ ๊ธฐ๋ณธ ๊ฐ๋
์
๋๋ค.
void Transform::FixedUpdate()
{
mWorld = Matrix::Identity;
Matrix scale;
scale = Matrix::CreateScale(mScale);
Matrix rotation;
rotation = Matrix::CreateRotationX(mRotation.x);
rotation *= Matrix::CreateRotationY(mRotation.y);
rotation *= Matrix::CreateRotationZ(mRotation.z);
Matrix position;
position.Translation(mPosition);
mWorld = scale * rotation * position;
// ๊ธฐ์ ๋ฒกํฐ ๊ตฌํ๊ธฐ
mUp = Vector3::TransformNormal(Vector3::Up, rotation);
mFoward = Vector3::TransformNormal(Vector3::Forward, rotation);
mRight = Vector3::TransformNormal(Vector3::Right, rotation);
if (mParent)
{
mWorld *= mParent->mWorld;
}
}
'๐ Development Study > ๐ผ GameProgramming 2D' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
Collision check / OBB (0) | 2023.03.02 |
---|---|
Grid ์ค๋ธ์ ํธ (0) | 2023.03.02 |
๋ ๊ฐ ์ด์์ ์นด๋ฉ๋ผ ์ฌ์ฉ (0) | 2023.02.06 |
World View Projection ๋ณํ (0) | 2023.01.11 |
Material ๋ฉํ ๋ฆฌ์ผ (0) | 2023.01.02 |
๋๊ธ