finished tutorial 7

This commit is contained in:
h4570
2022-08-23 22:31:07 +02:00
parent 9f831c7a6f
commit 989d2702e8
24 changed files with 439 additions and 25 deletions
@@ -30,11 +30,11 @@ MeshMaterial::MeshMaterial(const MeshBuilderData& data,
id = rand() % 1000000;
if (data.lightMapEnabled) {
lightmapFlag = false;
lightmapFlag = true;
TYRA_ASSERT(material->frames[0]->colors != nullptr,
"Colors faces are required");
} else {
lightmapFlag = true;
lightmapFlag = false;
}
ambient.set(material->ambient);
@@ -112,9 +112,10 @@ void DynamicPipeline::render(const DynamicMesh* mesh,
auto* texture =
rendererCore->texture.repository.getByMeshMaterialId(material->id);
TYRA_ASSERT(
texture, "Texture for material: ", material->name, "Id: ", material->id,
"Was not found in texture repository! Did you forget to add texture?");
TYRA_ASSERT(texture, "Texture for material: ", material->name,
"Id: ", material->id,
"Was not found in texture repository! Did you forget to add "
"texture or disable texture coords loading in mesh?");
for (u32 k = 0; k < partsCount; k++) {
auto& buffer = buffers[bufferIndex];
@@ -96,7 +96,7 @@ void StaticPipeline::render(const StaticMesh* mesh,
u32 maxVertCount = core.getMaxVertCountByBag(&bag);
StaPipBagPackagesBBox* bbox = nullptr;
if (bag.info->frustumCulling == PipelineFrustumCulling_Precise) {
if (bag.info->frustumCulling == PipelineInfoBagFrustumCulling_Precise) {
bbox = cacher.getBBoxesByMesh(materialFrame, maxVertCount);
}
@@ -143,9 +143,9 @@ StaPipColorBag* StaticPipeline::getColorBag(
auto* result = new StaPipColorBag();
if (material->lightmapFlag) {
result->single = &material->ambient;
} else {
result->many = materialFrame->colors;
} else {
result->single = &material->ambient;
}
return result;
@@ -160,10 +160,10 @@ StaPipTextureBag* StaticPipeline::getTextureBag(
result->texture =
rendererCore->texture.repository.getByMeshMaterialId(material->id);
TYRA_ASSERT(
result->texture, "Texture for material: ", material->name,
"Id: ", material->id,
"Was not found in texture repository! Did you forget to add texture?");
TYRA_ASSERT(result->texture, "Texture for material: ", material->name,
"Id: ", material->id,
"Was not found in texture repository! Did you forget to add "
"texture or disable texture coords loading in mesh?");
result->coordinates = materialFrame->textureCoords;
+24
View File
@@ -47,6 +47,30 @@ void Color::operator/=(const float& v) {
a /= v;
}
Color Color::operator+(const float& v) const {
Color result = *this;
result += v;
return result;
}
Color Color::operator-(const float& v) const {
Color result = *this;
result -= v;
return result;
}
Color Color::operator*(const float& v) const {
Color result = *this;
result *= v;
return result;
}
Color Color::operator/(const float& v) const {
Color result = *this;
result /= v;
return result;
}
void Color::set(const float& t_r, const float& t_g, const float& t_b,
const float& t_a) {
r = t_r;