-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
138 additions
and
0 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#include "pch.h" | ||
#include "Mesh.h" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#pragma once | ||
|
||
class Mesh | ||
{ | ||
public: | ||
template<typename VertexType> | ||
inline void SetVertexBuffer(ID3D11Device* inDivice, const std::vector<VertexType>& inVertices); | ||
|
||
inline void SetIndexBuffer(ID3D11Device* inDivice, const std::vector<UINT>& inIndices); | ||
|
||
private: | ||
ComPtr<ID3D11Buffer> m_indexBuffer = nullptr; | ||
ComPtr<ID3D11Buffer> m_vertexBuffer = nullptr; | ||
}; | ||
|
||
template<typename VertexType> | ||
inline void Mesh::SetVertexBuffer(ID3D11Device* inDivice, const std::vector<VertexType>& inVertices) | ||
{ | ||
D3D11_BUFFER_DESC desc = {}; | ||
ZeroMemory(&desc, sizeof(D3D11_BUFFER_DESC)); | ||
desc.BindFlags = D3D11_BIND_VERTEX_BUFFER; | ||
desc.ByteWidth = inVertices.size() * sizeof(VertexType); | ||
desc.Usage = D3D11_USAGE_DEFAULT; | ||
|
||
D3D11_SUBRESOURCE_DATA subData = {}; | ||
subData.pSysMem = inVertices.data(); | ||
|
||
CHECK_FAILED(inDivice->CreateBuffer(&desc, &subData, m_vertexBuffer.GetAddressOf())); | ||
} | ||
|
||
inline void Mesh::SetIndexBuffer(ID3D11Device* inDivice, const std::vector<UINT>& inIndices) | ||
{ | ||
D3D11_BUFFER_DESC desc = {}; | ||
ZeroMemory(&desc, sizeof(D3D11_BUFFER_DESC)); | ||
desc.BindFlags = D3D11_BIND_INDEX_BUFFER; | ||
desc.ByteWidth = inIndices.size() * sizeof(UINT); | ||
desc.Usage = D3D11_USAGE_DEFAULT; | ||
|
||
D3D11_SUBRESOURCE_DATA subData = {}; | ||
subData.pSysMem = inIndices.data(); | ||
|
||
CHECK_FAILED(inDivice->CreateBuffer(&desc, &subData, m_vertexBuffer.GetAddressOf())); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
#include "pch.h" | ||
#include "RenderableObject.h" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#pragma once | ||
|
||
class RenderableObject | ||
{ | ||
public: | ||
RenderableObject() = default; | ||
virtual ~RenderableObject() = default; | ||
|
||
private: | ||
Mesh m_mesh = {}; | ||
|
||
Transform m_transform = {}; | ||
}; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#include "pch.h" | ||
#include "Transform.h" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
#pragma once | ||
|
||
class Transform final | ||
{ | ||
public: | ||
Transform() = default; | ||
~Transform() = default; | ||
|
||
inline void SetPosition(const Vector3& inVector); | ||
inline void SetRotateDegree(float inYaw, float inPitch, float inRoll); | ||
inline void SetRotate(float inYaw, float inPitch, float inRoll); | ||
inline void SetScale(const Vector3& inScale); | ||
|
||
inline void AddPosition(const Vector3& inVector); | ||
inline void AddRotateDegree(float inYaw, float inPitch, float inRoll); | ||
inline void AddRotate(float inYaw, float inPitch, float inRoll); | ||
inline void AddScale(const Vector3& inScale); | ||
|
||
inline Vector3 GetPosition() const { return m_translate; } | ||
inline Quaternion GetRotate() const { return m_rotate; } | ||
inline Vector3 GetScale() const { return m_scaling; } | ||
|
||
private: | ||
Vector3 m_translate = Vector3::Zero; | ||
Quaternion m_rotate = Quaternion::Identity; | ||
Vector3 m_scaling = Vector3::One; | ||
}; | ||
|
||
inline void Transform::SetPosition(const Vector3& inVector) | ||
{ | ||
m_translate = inVector; | ||
} | ||
|
||
inline void Transform::SetRotateDegree(float inYaw, float inPitch, float inRoll) | ||
{ | ||
inYaw = ::XMConvertToRadians(inYaw); | ||
inPitch = ::XMConvertToRadians(inPitch); | ||
inRoll = ::XMConvertToRadians(inRoll); | ||
m_rotate = Quaternion::CreateFromYawPitchRoll(inYaw, inPitch, inRoll); | ||
} | ||
|
||
inline void Transform::SetRotate(float inYaw, float inPitch, float inRoll) | ||
{ | ||
m_rotate = Quaternion::CreateFromYawPitchRoll(inYaw, inPitch, inRoll); | ||
} | ||
|
||
inline void Transform::SetScale(const Vector3& inScale) | ||
{ | ||
m_scaling = inScale; | ||
} | ||
|
||
inline void Transform::AddPosition(const Vector3& inVector) | ||
{ | ||
m_translate += inVector; | ||
} | ||
|
||
inline void Transform::AddRotateDegree(float inYaw, float inPitch, float inRoll) | ||
{ | ||
inYaw = ::XMConvertToRadians(inYaw); | ||
inPitch = ::XMConvertToRadians(inPitch); | ||
inRoll = ::XMConvertToRadians(inRoll); | ||
m_rotate *= Quaternion::CreateFromYawPitchRoll(inYaw, inPitch, inRoll); | ||
} | ||
|
||
inline void Transform::AddRotate(float inYaw, float inPitch, float inRoll) | ||
{ | ||
m_rotate *= Quaternion::CreateFromYawPitchRoll(inYaw, inPitch, inRoll); | ||
} | ||
|
||
inline void Transform::AddScale(const Vector3& inScale) | ||
{ | ||
m_scaling += inScale; | ||
} |
Binary file not shown.
Binary file not shown.
Binary file not shown.