갬장장이
[3DGraphics] 1. Framework overview
갬장장이
갬장장이의 코드 대장간
갬장장이
전체
오늘
어제
  • 분류 전체보기
    • 게임 연구소
    • 게임 제작
      • Banditors (2024~)
      • Rovenhell (2023)
      • Geophyte (2020~2021)
      • 아드레날린 러시 (2021)
      • Treadmill (2019)
      • 습작들 (2019~)
      • 그 외 (~2018)
    • 개발
      • 언리얼 엔진
      • 수학
      • 네트워크
      • 그래픽스
      • OpenGL
      • DirectX
    • 일상
    • 기타 제작

블로그 메뉴

  • 홈
  • 태그
  • 방명록

공지사항

  • [공지] 블로그 안내

인기 글

최근 댓글

최근 글

hELLO · Designed By 정상우.
개발/그래픽스

[3DGraphics] 1. Framework overview

2022. 7. 15. 19:44

본 학습의 목표는 PlanetChili의 프레임워크나 WinAPI, Dx를 이해하는 것보다는 그래픽스의 기반이 되는 지식들을 이해하는 데 있다.
때문에 코드를 세세히 살펴보기보다는 핵심이 되는 이론적 개념들을 이해하고 정리하는 것에 집중할 것이다.

프레임워크에 대한 대략적인 설명은 여기에서 확인 가능하다.

또한 본 프레임워크에서는 행렬을 곱할 때 통상적인 Ax 순서 (행렬 * 벡터)가 아닌 xA(벡터 * 행렬)을 사용한다.
이는 Dx11이 해당 방식을 사용하기 때문이며, 때문에 v * A * B * C의 경우 (((vA)B)*C) 순서로 처리된다.

프레임워크의 실제 사용 모습을 아래 별 그리기 예제와 함께 살펴보자.
(세부적인 내용은 굳이 이해할 필요X)

/******************************************************************************************
*    Chili DirectX Framework Version 16.10.01                                              *
*    Game.cpp                                                                              *
*    Copyright 2016 PlanetChili.net <http://www.planetchili.net>                              *
*                                                                                          *
*    This file is part of The Chili DirectX Framework.                                      *
*                                                                                          *
*    The Chili DirectX Framework is free software: you can redistribute it and/or modify      *
*    it under the terms of the GNU General Public License as published by                  *
*    the Free Software Foundation, either version 3 of the License, or                      *
*    (at your option) any later version.                                                      *
*                                                                                          *
*    The Chili DirectX Framework is distributed in the hope that it will be useful,          *
*    but WITHOUT ANY WARRANTY; without even the implied warranty of                          *
*    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                          *
*    GNU General Public License for more details.                                          *
*                                                                                          *
*    You should have received a copy of the GNU General Public License                      *
*    along with The Chili DirectX Framework.  If not, see <http://www.gnu.org/licenses/>.  *
******************************************************************************************/
#include "MainWindow.h"
#include "Game.h"
#include "Mat2.h"

Game::Game( MainWindow& wnd )
    :
    wnd( wnd ),
    gfx( wnd )
{
    const float dTheta = 2.0f * PI / float( nflares * 2 );
    for( int i = 0; i < nflares * 2; i++ )
    {
        const float rad = (i % 2 == 0) ? radOuter : radInner;
        star.emplace_back(
            rad * cos( float( i ) * dTheta ),
            rad * sin( float( i ) * dTheta )
        );
    }
}

void Game::Go()
{
    gfx.BeginFrame();
    UpdateModel();
    ComposeFrame();
    gfx.EndFrame();
}

void Game::UpdateModel()
{
    if( !wnd.kbd.KeyIsPressed( VK_SPACE ) )
    {
        theta += vRot;
    }
}

void Game::ComposeFrame()
{
    const Vec2 trl = { float( gfx.ScreenWidth ) / 2.0f,float( gfx.ScreenHeight ) / 2.0f };
    const Mat2 trf = Mat2::Rotation( theta ) * Mat2::Scaling( size );
    auto vtx( star );
    for( auto& v : vtx )
    {
        v *= trf; // transformation
        v += trl; // translation
    }
    for( auto i = vtx.cbegin(),end = std::prev( vtx.cend() ); i != end; i++ )
    {
        gfx.DrawLine( *i,*std::next( i ),Colors::White );
    }
    gfx.DrawLine( vtx.front(),vtx.back(),Colors::White );
}
저작자표시 비영리 변경금지 (새창열림)

'개발 > 그래픽스' 카테고리의 다른 글

[3DGraphics] 5. Triangle rasterization  (0) 2022.07.15
[3DGraphics] 4. Perspective projection  (0) 2022.07.15
[3DGraphics] 3. Rotation  (0) 2022.07.15
[3DGraphics] 2. 3D Space  (0) 2022.07.15
[3DGraphics] 0. 안내  (0) 2022.07.15
'개발/그래픽스' 카테고리의 다른 글
  • [3DGraphics] 4. Perspective projection
  • [3DGraphics] 3. Rotation
  • [3DGraphics] 2. 3D Space
  • [3DGraphics] 0. 안내
갬장장이
갬장장이
상단으로

티스토리툴바

단축키

내 블로그

내 블로그 - 관리자 홈 전환
Q
Q
새 글 쓰기
W
W

블로그 게시글

글 수정 (권한 있는 경우)
E
E
댓글 영역으로 이동
C
C

모든 영역

이 페이지의 URL 복사
S
S
맨 위로 이동
T
T
티스토리 홈 이동
H
H
단축키 안내
Shift + /
⇧ + /

* 단축키는 한글/영문 대소문자로 이용 가능하며, 티스토리 기본 도메인에서만 동작합니다.