színes teáskannák
This commit is contained in:
parent
8b67a40e55
commit
c9fcc60c35
14
Entity.cpp
14
Entity.cpp
@ -16,6 +16,8 @@ eg3d::Entity::Entity(const Entity& other): Geometry(other.device)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void eg3d::Entity::loadDefaults() {
|
void eg3d::Entity::loadDefaults() {
|
||||||
|
mConstBuf.color = { 1.0f, 1.0f, 1.0f, 1.0f };
|
||||||
|
|
||||||
XMStoreFloat4x4(&mConstBuf.worldMatrix, XMMatrixIdentity()); // egységmátrix betöltése a világ-mátrixba
|
XMStoreFloat4x4(&mConstBuf.worldMatrix, XMMatrixIdentity()); // egységmátrix betöltése a világ-mátrixba
|
||||||
mSRTProps.loadDefaults();
|
mSRTProps.loadDefaults();
|
||||||
constructWorldMatrix();
|
constructWorldMatrix();
|
||||||
@ -54,7 +56,7 @@ void eg3d::Entity::constructWorldMatrix() {
|
|||||||
XMStoreFloat4x4(&mConstBuf.worldMatrix, w);
|
XMStoreFloat4x4(&mConstBuf.worldMatrix, w);
|
||||||
|
|
||||||
// konstansbuffer felmásolása a videokártyára
|
// konstansbuffer felmásolása a videokártyára
|
||||||
bufferMapCopy(mConstBufRes, static_cast<void*>(&mConstBuf), sizeof(CB_Entity));
|
updateConstantBuffer();
|
||||||
}
|
}
|
||||||
|
|
||||||
void eg3d::Entity::createConstantBuffer()
|
void eg3d::Entity::createConstantBuffer()
|
||||||
@ -62,6 +64,16 @@ void eg3d::Entity::createConstantBuffer()
|
|||||||
mConstBufRes = createBuffer_UH(device, calc256AlignedSize(sizeof(CB_Entity)));
|
mConstBufRes = createBuffer_UH(device, calc256AlignedSize(sizeof(CB_Entity)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void eg3d::Entity::updateConstantBuffer()
|
||||||
|
{
|
||||||
|
bufferMapCopy(mConstBufRes, static_cast<void*>(&mConstBuf), sizeof(CB_Entity));
|
||||||
|
}
|
||||||
|
|
||||||
|
void eg3d::Entity::setColor(float r, float g, float b)
|
||||||
|
{
|
||||||
|
mConstBuf.color = { r, g, b, 1.0f };
|
||||||
|
updateConstantBuffer();
|
||||||
|
}
|
||||||
|
|
||||||
// ----------------------
|
// ----------------------
|
||||||
|
|
||||||
|
3
Entity.h
3
Entity.h
@ -31,6 +31,7 @@ namespace eg3d {
|
|||||||
|
|
||||||
// TODO konstansbuffer létrehozása, feltöltése
|
// TODO konstansbuffer létrehozása, feltöltése
|
||||||
void createConstantBuffer(); // konstansbuffer létrehozása
|
void createConstantBuffer(); // konstansbuffer létrehozása
|
||||||
|
void updateConstantBuffer(); // konstansbuffer frissítése
|
||||||
public:
|
public:
|
||||||
Entity(const ComPtr<ID3D12Device> &device);
|
Entity(const ComPtr<ID3D12Device> &device);
|
||||||
explicit Entity(const Entity& other); // másolókonstruktor
|
explicit Entity(const Entity& other); // másolókonstruktor
|
||||||
@ -41,6 +42,8 @@ namespace eg3d {
|
|||||||
SRTProps getEntitySRT() const; // SRT-tualjdonságok elkérése
|
SRTProps getEntitySRT() const; // SRT-tualjdonságok elkérése
|
||||||
|
|
||||||
void draw(ComPtr<ID3D12GraphicsCommandList> commandList) const override;
|
void draw(ComPtr<ID3D12GraphicsCommandList> commandList) const override;
|
||||||
|
|
||||||
|
void setColor(float r, float g, float b); // szín beállítása
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,7 @@ cbuffer CFrame : register(b0)
|
|||||||
cbuffer CEntity : register(b1)
|
cbuffer CEntity : register(b1)
|
||||||
{
|
{
|
||||||
float4x4 worldMatrix;
|
float4x4 worldMatrix;
|
||||||
|
float4 color;
|
||||||
}
|
}
|
||||||
|
|
||||||
VSOutput vs_main(VSInput input)
|
VSOutput vs_main(VSInput input)
|
||||||
@ -26,7 +27,7 @@ VSOutput vs_main(VSInput input)
|
|||||||
VSOutput output; // vertex shader kimenete
|
VSOutput output; // vertex shader kimenete
|
||||||
|
|
||||||
output.position_H = mul(float4(input.position_D, 1.0), mul(worldMatrix, mul(viewMatrix, projMatrix)));
|
output.position_H = mul(float4(input.position_D, 1.0), mul(worldMatrix, mul(viewMatrix, projMatrix)));
|
||||||
output.color = float3(1.0, 1.0, 1.0);
|
output.color = color;
|
||||||
|
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
@ -18,6 +18,7 @@ struct CB_Frame
|
|||||||
|
|
||||||
struct CB_Entity {
|
struct CB_Entity {
|
||||||
DirectX::XMFLOAT4X4 worldMatrix; // világ-mátrix (modell-mátrix)
|
DirectX::XMFLOAT4X4 worldMatrix; // világ-mátrix (modell-mátrix)
|
||||||
|
DirectX::XMFLOAT4 color; // szín
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif //CONST_BUFS
|
#endif //CONST_BUFS
|
||||||
|
2
main.cpp
2
main.cpp
@ -83,6 +83,8 @@ void mouseCB(EventHandlerCBData * pCBData)
|
|||||||
pTeapot->loadBinarySTL("assets/utahteapot.stl", ImportAdapters::IAD_SwapYZ_RH);
|
pTeapot->loadBinarySTL("assets/utahteapot.stl", ImportAdapters::IAD_SwapYZ_RH);
|
||||||
pTeapot->setEntitySRT(srtProps);
|
pTeapot->setEntitySRT(srtProps);
|
||||||
|
|
||||||
|
pTeapot->setColor(0.8f, 0.8f, 0.1f);
|
||||||
|
|
||||||
gDrawables.push_back(pTeapot);
|
gDrawables.push_back(pTeapot);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user