dynamic pipeline - render
This commit is contained in:
@@ -21,6 +21,8 @@
|
|||||||
|
|
||||||
- [General] Control generated id to avoid duplication. Maybe Just increment from 0? Add interface IIdentificable?
|
- [General] Control generated id to avoid duplication. Maybe Just increment from 0? Add interface IIdentificable?
|
||||||
|
|
||||||
|
- [General] rsync is excluding folder like "objects" lol XD
|
||||||
|
|
||||||
- [DMA] Check if all chain transfers have end tag!
|
- [DMA] Check if all chain transfers have end tag!
|
||||||
|
|
||||||
- [General] Change libs of sample? (remove -lpng, -lz...), probably they are not required
|
- [General] Change libs of sample? (remove -lpng, -lz...), probably they are not required
|
||||||
|
|||||||
@@ -22,13 +22,8 @@ class DynPipColorBag {
|
|||||||
DynPipColorBag();
|
DynPipColorBag();
|
||||||
~DynPipColorBag();
|
~DynPipColorBag();
|
||||||
|
|
||||||
/** Optional. Single color for all vertices. */
|
/** Mandatory */
|
||||||
Color* singleFrom;
|
Color* single;
|
||||||
Color* singleTo;
|
|
||||||
|
|
||||||
/** Optional. Color per vertex. */
|
|
||||||
Color* manyFrom;
|
|
||||||
Color* manyTo;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Tyra
|
} // namespace Tyra
|
||||||
|
|||||||
@@ -29,6 +29,8 @@ class DynPipLightingBag {
|
|||||||
|
|
||||||
/** Mandatory. Directional lights */
|
/** Mandatory. Directional lights */
|
||||||
PipelineDirLightsBag* dirLights;
|
PipelineDirLightsBag* dirLights;
|
||||||
|
|
||||||
|
void freeNormals();
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Tyra
|
} // namespace Tyra
|
||||||
|
|||||||
@@ -26,6 +26,8 @@ class DynPipTextureBag {
|
|||||||
|
|
||||||
/** Mandatory. Texture image. */
|
/** Mandatory. Texture image. */
|
||||||
Texture* texture;
|
Texture* texture;
|
||||||
|
|
||||||
|
void freeCoords();
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Tyra
|
} // namespace Tyra
|
||||||
|
|||||||
@@ -13,6 +13,8 @@
|
|||||||
#include <tamtypes.h>
|
#include <tamtypes.h>
|
||||||
#include "./bag/dynpip_bag.hpp"
|
#include "./bag/dynpip_bag.hpp"
|
||||||
#include "renderer/core/renderer_core.hpp"
|
#include "renderer/core/renderer_core.hpp"
|
||||||
|
#include "./dynpip_programs_repository.hpp"
|
||||||
|
#include "./dynpip_qbuffer_renderer.hpp"
|
||||||
|
|
||||||
namespace Tyra {
|
namespace Tyra {
|
||||||
|
|
||||||
@@ -21,11 +23,18 @@ class DynPipCore {
|
|||||||
DynPipCore();
|
DynPipCore();
|
||||||
~DynPipCore();
|
~DynPipCore();
|
||||||
|
|
||||||
|
DynPipProgramsRepository repository;
|
||||||
|
|
||||||
void init(RendererCore* t_core);
|
void init(RendererCore* t_core);
|
||||||
|
|
||||||
/** Render 3D via "bags" */
|
/** Render 3D via "bags" */
|
||||||
void render(DynPipBag* data);
|
void render(DynPipBag* data);
|
||||||
|
|
||||||
|
/** Get max vert count of VU1 qbuffer (for optimizations) */
|
||||||
|
u32 getMaxVertCountByParams(const bool& isSingleColor,
|
||||||
|
const bool& isLightingEnabled,
|
||||||
|
const bool& isTextureEnabled);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* - Uploads standard VU1 programs.
|
* - Uploads standard VU1 programs.
|
||||||
* - Sends static "Tyra Renderer3D" VU1 data.
|
* - Sends static "Tyra Renderer3D" VU1 data.
|
||||||
@@ -36,6 +45,7 @@ class DynPipCore {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
RendererCore* rendererCore;
|
RendererCore* rendererCore;
|
||||||
|
DynPipQBufferRenderer qbufferRenderer;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Tyra
|
} // namespace Tyra
|
||||||
|
|||||||
@@ -12,6 +12,7 @@
|
|||||||
|
|
||||||
#include "debug/debug.hpp"
|
#include "debug/debug.hpp"
|
||||||
#include "renderer/core/paths/path1/vu1_program.hpp"
|
#include "renderer/core/paths/path1/vu1_program.hpp"
|
||||||
|
#include "./bag/dynpip_bag.hpp"
|
||||||
|
|
||||||
#include "./programs/dynpip_c_vu1_program.hpp"
|
#include "./programs/dynpip_c_vu1_program.hpp"
|
||||||
#include "./programs/dynpip_d_vu1_program.hpp"
|
#include "./programs/dynpip_d_vu1_program.hpp"
|
||||||
@@ -26,6 +27,9 @@ class DynPipProgramsRepository {
|
|||||||
~DynPipProgramsRepository();
|
~DynPipProgramsRepository();
|
||||||
|
|
||||||
DynPipVU1Program* getProgram(const DynPipProgramName& name);
|
DynPipVU1Program* getProgram(const DynPipProgramName& name);
|
||||||
|
DynPipVU1Program* getProgramByParams(const bool& isLightingEnabled,
|
||||||
|
const bool& isTextureEnabled);
|
||||||
|
DynPipVU1Program* getProgramByBag(const DynPipBag* bag);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
DynPipCVU1Program color;
|
DynPipCVU1Program color;
|
||||||
|
|||||||
@@ -29,9 +29,6 @@ class DynPipQBuffer {
|
|||||||
Vec4* stsFrom;
|
Vec4* stsFrom;
|
||||||
Vec4* stsTo;
|
Vec4* stsTo;
|
||||||
|
|
||||||
Vec4* colorsFrom;
|
|
||||||
Vec4* colorsTo;
|
|
||||||
|
|
||||||
Vec4* normalsFrom;
|
Vec4* normalsFrom;
|
||||||
Vec4* normalsTo;
|
Vec4* normalsTo;
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,68 @@
|
|||||||
|
/*
|
||||||
|
# ______ ____ ___
|
||||||
|
# | \/ ____| |___|
|
||||||
|
# | | | \ | |
|
||||||
|
#-----------------------------------------------------------------------
|
||||||
|
# Copyright 2022, tyra - https://github.com/h4570/tyra
|
||||||
|
# Licenced under Apache License 2.0
|
||||||
|
# Sandro Sobczyński <sandro.sobczynski@gmail.com>
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <tamtypes.h>
|
||||||
|
|
||||||
|
namespace Tyra {
|
||||||
|
|
||||||
|
class DynPipQBufferRenderer {
|
||||||
|
public:
|
||||||
|
DynPipQBufferRenderer();
|
||||||
|
~DynPipQBufferRenderer();
|
||||||
|
|
||||||
|
// void init(RendererCore* t_core);
|
||||||
|
|
||||||
|
// void reinitVU1();
|
||||||
|
|
||||||
|
// DynPipQBuffer* getBuffer();
|
||||||
|
|
||||||
|
// void sendObjectData(DynPipBag* bag, M4x4* mvp,
|
||||||
|
// RendererCoreTextureBuffers* texBuffers) const;
|
||||||
|
|
||||||
|
// void setMaxVertCount(const u32& count);
|
||||||
|
|
||||||
|
// void setInfo(PipelineInfoBag* bag);
|
||||||
|
|
||||||
|
// void render(DynPipQBuffer* buffer);
|
||||||
|
|
||||||
|
// void clearLastProgramName();
|
||||||
|
|
||||||
|
const u16& getBufferSize() { return bufferSize; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
// void sendStaticData() const;
|
||||||
|
// void setProgramsCache();
|
||||||
|
// void uploadPrograms();
|
||||||
|
// void setDoubleBuffer();
|
||||||
|
|
||||||
|
// void addBufferDataToPacket(DynPipVU1Program* program, DynPipQBuffer*
|
||||||
|
// buffer); void sendPacket();
|
||||||
|
|
||||||
|
// packet2_t* packets[2];
|
||||||
|
// packet2_t* programsPacket;
|
||||||
|
// DynPipQBuffer buffers[2];
|
||||||
|
// packet2_t* currentPacket;
|
||||||
|
// packet2_t* staticDataPacket;
|
||||||
|
// packet2_t* objectDataPacket;
|
||||||
|
|
||||||
|
// RendererCore* rendererCore;
|
||||||
|
|
||||||
|
// DynPipProgramName lastProgramName;
|
||||||
|
// Path1* path1;
|
||||||
|
// DynPipClipper clipper;
|
||||||
|
// DynPipProgramsRepository repository;
|
||||||
|
|
||||||
|
u16 bufferSize;
|
||||||
|
// u8 context;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace Tyra
|
||||||
@@ -41,20 +41,27 @@ class DynamicPipeline : public Renderer3DPipeline {
|
|||||||
Vec4* colorsCache;
|
Vec4* colorsCache;
|
||||||
|
|
||||||
void addVertices(DynamicMesh* mesh, MeshMaterial* material, DynPipBag* bag,
|
void addVertices(DynamicMesh* mesh, MeshMaterial* material, DynPipBag* bag,
|
||||||
MeshFrame* frameFrom, MeshFrame* frameTo) const;
|
MeshFrame* frameFrom, MeshFrame* frameTo,
|
||||||
|
const u32& startIndex) const;
|
||||||
PipelineInfoBag* getInfoBag(DynamicMesh* mesh, const DynPipOptions* options,
|
PipelineInfoBag* getInfoBag(DynamicMesh* mesh, const DynPipOptions* options,
|
||||||
M4x4* model) const;
|
M4x4* model) const;
|
||||||
DynPipColorBag* getColorBag(DynamicMesh* mesh, MeshMaterial* material,
|
DynPipColorBag* getColorBag(MeshMaterial* material) const;
|
||||||
MeshFrame* frameFrom, MeshFrame* frameTo) const;
|
|
||||||
DynPipTextureBag* getTextureBag(DynamicMesh* mesh, MeshMaterial* material,
|
DynPipTextureBag* getTextureBag(DynamicMesh* mesh, MeshMaterial* material,
|
||||||
MeshFrame* frameFrom, MeshFrame* frameTo);
|
MeshFrame* frameFrom, MeshFrame* frameTo,
|
||||||
|
const u32& count, const u32& startIndex);
|
||||||
DynPipLightingBag* getLightingBag(DynamicMesh* mesh, MeshMaterial* material,
|
DynPipLightingBag* getLightingBag(DynamicMesh* mesh, MeshMaterial* material,
|
||||||
M4x4* model, MeshFrame* frameFrom,
|
M4x4* model, MeshFrame* frameFrom,
|
||||||
MeshFrame* frameTo,
|
MeshFrame* frameTo,
|
||||||
const DynPipOptions* options) const;
|
const DynPipOptions* options,
|
||||||
void deallocDrawBags(DynPipBag* bag, MeshMaterial* material) const;
|
PipelineDirLightsBag* dirLightsBag,
|
||||||
|
const u32& count,
|
||||||
|
const u32& startIndex) const;
|
||||||
|
|
||||||
void setLightingColorsCache(PipelineLightingOptions* lightingOptions);
|
void setLightingColorsCache(PipelineLightingOptions* lightingOptions);
|
||||||
|
void freeBuffer(DynPipBag* bag);
|
||||||
|
void setBuffersDefaultVars(DynPipBag* buffers, DynamicMesh* mesh,
|
||||||
|
PipelineInfoBag* infoBag);
|
||||||
|
void setBuffersColorBag(DynPipBag* buffers, DynPipColorBag* colorBag);
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Tyra
|
} // namespace Tyra
|
||||||
|
|||||||
@@ -10,22 +10,14 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "renderer/3d/pipeline/shared/pipeline_shading_type.hpp"
|
#include "renderer/3d/pipeline/shared/pipeline_options.hpp"
|
||||||
#include "../shared/pipeline_lighting_options.hpp"
|
|
||||||
|
|
||||||
namespace Tyra {
|
namespace Tyra {
|
||||||
|
|
||||||
class DynPipOptions {
|
class DynPipOptions : public PipelineOptions {
|
||||||
public:
|
public:
|
||||||
DynPipOptions() {}
|
DynPipOptions() {}
|
||||||
~DynPipOptions() {}
|
~DynPipOptions() {}
|
||||||
|
|
||||||
PipelineShadingType shadingType;
|
|
||||||
bool blendingEnabled;
|
|
||||||
bool antiAliasingEnabled;
|
|
||||||
|
|
||||||
/** Optional */
|
|
||||||
PipelineLightingOptions* lighting;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Tyra
|
} // namespace Tyra
|
||||||
|
|||||||
@@ -0,0 +1,31 @@
|
|||||||
|
/*
|
||||||
|
# ______ ____ ___
|
||||||
|
# | \/ ____| |___|
|
||||||
|
# | | | \ | |
|
||||||
|
#-----------------------------------------------------------------------
|
||||||
|
# Copyright 2022, tyra - https://github.com/h4570/tyra
|
||||||
|
# Licenced under Apache License 2.0
|
||||||
|
# Sandro Sobczyński <sandro.sobczynski@gmail.com>
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "renderer/3d/pipeline/shared/pipeline_shading_type.hpp"
|
||||||
|
#include "../shared/pipeline_lighting_options.hpp"
|
||||||
|
|
||||||
|
namespace Tyra {
|
||||||
|
|
||||||
|
class PipelineOptions {
|
||||||
|
public:
|
||||||
|
PipelineOptions() {}
|
||||||
|
~PipelineOptions() {}
|
||||||
|
|
||||||
|
PipelineShadingType shadingType;
|
||||||
|
bool blendingEnabled;
|
||||||
|
bool antiAliasingEnabled;
|
||||||
|
|
||||||
|
/** Optional */
|
||||||
|
PipelineLightingOptions* lighting;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace Tyra
|
||||||
@@ -10,20 +10,15 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "renderer/3d/pipeline/shared/pipeline_shading_type.hpp"
|
#include "renderer/3d/pipeline/shared/pipeline_options.hpp"
|
||||||
#include "../shared/pipeline_lighting_options.hpp"
|
|
||||||
|
|
||||||
namespace Tyra {
|
namespace Tyra {
|
||||||
|
|
||||||
class StaPipOptions {
|
class StaPipOptions : public PipelineOptions {
|
||||||
public:
|
public:
|
||||||
StaPipOptions() {}
|
StaPipOptions() {}
|
||||||
~StaPipOptions() {}
|
~StaPipOptions() {}
|
||||||
|
|
||||||
PipelineShadingType shadingType;
|
|
||||||
bool blendingEnabled;
|
|
||||||
bool antiAliasingEnabled;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief True -> disables "clip against each plane" algorithm.
|
* @brief True -> disables "clip against each plane" algorithm.
|
||||||
* Mandatory, default: false.
|
* Mandatory, default: false.
|
||||||
@@ -33,9 +28,6 @@ class StaPipOptions {
|
|||||||
* for big 3D objects (or objects near camera eyes)
|
* for big 3D objects (or objects near camera eyes)
|
||||||
*/
|
*/
|
||||||
bool noFullClipChecks;
|
bool noFullClipChecks;
|
||||||
|
|
||||||
/** Optional */
|
|
||||||
PipelineLightingOptions* lighting;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Tyra
|
} // namespace Tyra
|
||||||
|
|||||||
@@ -36,31 +36,19 @@ class TextureRepository {
|
|||||||
* For 3D: MeshMaterial id.
|
* For 3D: MeshMaterial id.
|
||||||
* For 2D: Sprite id.
|
* For 2D: Sprite id.
|
||||||
*/
|
*/
|
||||||
Texture* getBySpriteOrMesh(const u32& t_id) {
|
Texture* getBySpriteOrMesh(const u32& t_id) const;
|
||||||
for (u32 i = 0; i < textures.size(); i++)
|
|
||||||
if (textures[i]->isLinkedWith(t_id)) return textures[i];
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns single texture.
|
* Returns single texture.
|
||||||
* nullptr if not found.
|
* nullptr if not found.
|
||||||
*/
|
*/
|
||||||
Texture* getByTextureId(const u32& t_id) const {
|
Texture* getByTextureId(const u32& t_id) const;
|
||||||
for (u32 i = 0; i < textures.size(); i++)
|
|
||||||
if (t_id == textures[i]->getId()) return textures[i];
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns index of link.
|
* Returns index of link.
|
||||||
* -1 if not found.
|
* -1 if not found.
|
||||||
*/
|
*/
|
||||||
const s32 getIndexOf(const u32& t_texId) const {
|
const s32 getIndexOf(const u32& t_texId) const;
|
||||||
for (u32 i = 0; i < textures.size(); i++)
|
|
||||||
if (textures[i]->getId() == t_texId) return i;
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ----
|
// ----
|
||||||
// Setters
|
// Setters
|
||||||
|
|||||||
@@ -19,6 +19,8 @@ DynPipBag::DynPipBag() {
|
|||||||
color = nullptr;
|
color = nullptr;
|
||||||
texture = nullptr;
|
texture = nullptr;
|
||||||
lighting = nullptr;
|
lighting = nullptr;
|
||||||
|
verticesFrom = nullptr;
|
||||||
|
verticesTo = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
DynPipBag::~DynPipBag() {}
|
DynPipBag::~DynPipBag() {}
|
||||||
@@ -56,16 +58,8 @@ std::string DynPipBag::getPrint(const char* name) const {
|
|||||||
res << "Lighting present: " << (lighting != nullptr ? "Yes" : "No") << ", "
|
res << "Lighting present: " << (lighting != nullptr ? "Yes" : "No") << ", "
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
res << "Model matrix: " << info->model->getPrint() << ", " << std::endl;
|
res << "Model matrix: " << info->model->getPrint() << ", " << std::endl;
|
||||||
if (color->singleFrom) {
|
if (color->single) {
|
||||||
res << "Color from single: " << color->singleFrom->getPrint() << ", "
|
res << "Color single: " << color->single->getPrint() << ", " << std::endl;
|
||||||
<< std::endl;
|
|
||||||
res << "Color to single: " << color->singleTo->getPrint() << ", "
|
|
||||||
<< std::endl;
|
|
||||||
} else {
|
|
||||||
res << "Color many from present: "
|
|
||||||
<< (color->manyFrom != nullptr ? "Yes" : "No") << ", " << std::endl;
|
|
||||||
res << "Color many to present: "
|
|
||||||
<< (color->manyTo != nullptr ? "Yes" : "No") << ", " << std::endl;
|
|
||||||
}
|
}
|
||||||
if (texture) {
|
if (texture) {
|
||||||
res << "Texture coords from present: "
|
res << "Texture coords from present: "
|
||||||
|
|||||||
@@ -12,12 +12,7 @@
|
|||||||
|
|
||||||
namespace Tyra {
|
namespace Tyra {
|
||||||
|
|
||||||
DynPipColorBag::DynPipColorBag() {
|
DynPipColorBag::DynPipColorBag() { single = nullptr; }
|
||||||
singleFrom = nullptr;
|
|
||||||
singleTo = nullptr;
|
|
||||||
manyFrom = nullptr;
|
|
||||||
manyTo = nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
DynPipColorBag::~DynPipColorBag() {}
|
DynPipColorBag::~DynPipColorBag() {}
|
||||||
|
|
||||||
|
|||||||
@@ -21,4 +21,9 @@ DynPipLightingBag::DynPipLightingBag() {
|
|||||||
|
|
||||||
DynPipLightingBag::~DynPipLightingBag() {}
|
DynPipLightingBag::~DynPipLightingBag() {}
|
||||||
|
|
||||||
|
void DynPipLightingBag::freeNormals() {
|
||||||
|
if (normalsFrom) delete[] normalsFrom;
|
||||||
|
if (normalsTo) delete[] normalsTo;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace Tyra
|
} // namespace Tyra
|
||||||
|
|||||||
@@ -20,4 +20,9 @@ DynPipTextureBag::DynPipTextureBag() {
|
|||||||
|
|
||||||
DynPipTextureBag::~DynPipTextureBag() {}
|
DynPipTextureBag::~DynPipTextureBag() {}
|
||||||
|
|
||||||
|
void DynPipTextureBag::freeCoords() {
|
||||||
|
if (coordinatesFrom) delete[] coordinatesFrom;
|
||||||
|
if (coordinatesTo) delete[] coordinatesTo;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace Tyra
|
} // namespace Tyra
|
||||||
|
|||||||
@@ -22,6 +22,16 @@ void DynPipCore::init(RendererCore* t_core) { rendererCore = t_core; }
|
|||||||
|
|
||||||
void DynPipCore::reinitVU1Programs() {}
|
void DynPipCore::reinitVU1Programs() {}
|
||||||
|
|
||||||
void DynPipCore::render(DynPipBag* bag) {}
|
u32 DynPipCore::getMaxVertCountByParams(const bool& isSingleColor,
|
||||||
|
const bool& isLightingEnabled,
|
||||||
|
const bool& isTextureEnabled) {
|
||||||
|
return repository.getProgramByParams(isLightingEnabled, isTextureEnabled)
|
||||||
|
->getMaxVertCount(isSingleColor, qbufferRenderer.getBufferSize());
|
||||||
|
}
|
||||||
|
|
||||||
|
void DynPipCore::render(DynPipBag* bag) {
|
||||||
|
// Zrobic bbox
|
||||||
|
// TODO: Potem wrzucic programy i obliczyc bufferSize w qbufferrenderer
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace Tyra
|
} // namespace Tyra
|
||||||
|
|||||||
@@ -16,6 +16,18 @@ DynPipProgramsRepository::DynPipProgramsRepository() {}
|
|||||||
|
|
||||||
DynPipProgramsRepository::~DynPipProgramsRepository() {}
|
DynPipProgramsRepository::~DynPipProgramsRepository() {}
|
||||||
|
|
||||||
|
DynPipVU1Program* DynPipProgramsRepository::getProgramByParams(
|
||||||
|
const bool& isLightingEnabled, const bool& isTextureEnabled) {
|
||||||
|
if (isLightingEnabled && isTextureEnabled)
|
||||||
|
return &textureDirLights;
|
||||||
|
else if (isLightingEnabled)
|
||||||
|
return &dirLights;
|
||||||
|
else if (isTextureEnabled)
|
||||||
|
return &textureColor;
|
||||||
|
else
|
||||||
|
return &color;
|
||||||
|
}
|
||||||
|
|
||||||
DynPipVU1Program* DynPipProgramsRepository::getProgram(
|
DynPipVU1Program* DynPipProgramsRepository::getProgram(
|
||||||
const DynPipProgramName& name) {
|
const DynPipProgramName& name) {
|
||||||
switch (name) {
|
switch (name) {
|
||||||
|
|||||||
@@ -59,18 +59,6 @@ std::string DynPipQBuffer::getPrint(const char* name) const {
|
|||||||
res << i << ": " << stsTo[i].getPrint() << std::endl;
|
res << i << ": " << stsTo[i].getPrint() << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bag->color->manyFrom != nullptr) {
|
|
||||||
res << "Colors from: " << std::endl;
|
|
||||||
for (u32 i = 0; i < size; i++)
|
|
||||||
res << i << ": " << colorsFrom[i].getPrint() << std::endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (bag->color->manyTo != nullptr) {
|
|
||||||
res << "Colors to: " << std::endl;
|
|
||||||
for (u32 i = 0; i < size; i++)
|
|
||||||
res << i << ": " << colorsTo[i].getPrint() << std::endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (bag->lighting != nullptr) {
|
if (bag->lighting != nullptr) {
|
||||||
res << "Normals from: " << std::endl;
|
res << "Normals from: " << std::endl;
|
||||||
for (u32 i = 0; i < size; i++) {
|
for (u32 i = 0; i < size; i++) {
|
||||||
|
|||||||
@@ -0,0 +1,19 @@
|
|||||||
|
/*
|
||||||
|
# ______ ____ ___
|
||||||
|
# | \/ ____| |___|
|
||||||
|
# | | | \ | |
|
||||||
|
#-----------------------------------------------------------------------
|
||||||
|
# Copyright 2022, tyra - https://github.com/h4570/tyra
|
||||||
|
# Licenced under Apache License 2.0
|
||||||
|
# Sandro Sobczyński <sandro.sobczynski@gmail.com>
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "renderer/3d/pipeline/dynamic/core/dynpip_qbuffer_renderer.hpp"
|
||||||
|
#include "renderer/3d/pipeline/dynamic/core/programs/dynpip_vu1_shared_defines.h"
|
||||||
|
|
||||||
|
namespace Tyra {
|
||||||
|
|
||||||
|
DynPipQBufferRenderer::DynPipQBufferRenderer() {}
|
||||||
|
DynPipQBufferRenderer::~DynPipQBufferRenderer() {}
|
||||||
|
|
||||||
|
} // namespace Tyra
|
||||||
@@ -56,14 +56,6 @@ void DynPipTDVU1Program::addProgramQBufferDataToPacket(
|
|||||||
packet2_utils_vu_add_unpack_data(packet, addr, qbuffer->normalsTo,
|
packet2_utils_vu_add_unpack_data(packet, addr, qbuffer->normalsTo,
|
||||||
qbuffer->size, true);
|
qbuffer->size, true);
|
||||||
addr += qbuffer->size;
|
addr += qbuffer->size;
|
||||||
|
|
||||||
// Add colors
|
|
||||||
if (qbuffer->bag->color->singleFrom == nullptr) {
|
|
||||||
packet2_utils_vu_add_unpack_data(packet, addr, qbuffer->colorsFrom,
|
|
||||||
qbuffer->size, true);
|
|
||||||
packet2_utils_vu_add_unpack_data(packet, addr, qbuffer->colorsTo,
|
|
||||||
qbuffer->size, true);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Tyra
|
} // namespace Tyra
|
||||||
|
|||||||
@@ -12,72 +12,108 @@
|
|||||||
|
|
||||||
namespace Tyra {
|
namespace Tyra {
|
||||||
|
|
||||||
DynamicPipeline::DynamicPipeline() {}
|
DynamicPipeline::DynamicPipeline() { colorsCache = new Vec4[4]; }
|
||||||
|
|
||||||
DynamicPipeline::~DynamicPipeline() {}
|
DynamicPipeline::~DynamicPipeline() { delete[] colorsCache; }
|
||||||
|
|
||||||
void DynamicPipeline::init(RendererCore* t_core) {}
|
void DynamicPipeline::init(RendererCore* t_core) { rendererCore = t_core; }
|
||||||
|
|
||||||
void DynamicPipeline::onUse() {}
|
void DynamicPipeline::onUse() {}
|
||||||
|
|
||||||
void DynamicPipeline::render(DynamicMesh* mesh, const DynPipOptions* options) {
|
void DynamicPipeline::render(DynamicMesh* mesh, const DynPipOptions* options) {
|
||||||
auto model = mesh->getModelMatrix();
|
auto model = mesh->getModelMatrix();
|
||||||
|
auto* frameFrom = mesh->getFrame(mesh->getCurrentAnimationFrame());
|
||||||
|
auto* frameTo = mesh->getFrame(mesh->getNextAnimationFrame());
|
||||||
|
auto* infoBag = getInfoBag(mesh, options, &model);
|
||||||
|
PipelineDirLightsBag* dirLights = nullptr;
|
||||||
|
|
||||||
MeshFrame* frameFrom = mesh->getFramesCount() > 0
|
if (options && options->lighting) {
|
||||||
? mesh->getFrame(mesh->getCurrentAnimationFrame())
|
setLightingColorsCache(options->lighting);
|
||||||
: mesh->getFrame(0);
|
dirLights = new PipelineDirLightsBag(true);
|
||||||
|
dirLights->setLightsManually(colorsCache,
|
||||||
|
options->lighting->directionalDirections);
|
||||||
|
}
|
||||||
|
|
||||||
MeshFrame* frameTo = mesh->getFramesCount() > 0
|
DynPipBag buffers[2];
|
||||||
? mesh->getFrame(mesh->getNextAnimationFrame())
|
u8 context = 0;
|
||||||
: nullptr;
|
|
||||||
|
|
||||||
// auto* infoBag = getInfoBag(mesh, options, &model);
|
setBuffersDefaultVars(buffers, mesh, infoBag);
|
||||||
|
|
||||||
if (options && options->lighting) setLightingColorsCache(options->lighting);
|
|
||||||
|
|
||||||
for (u32 i = 0; i < mesh->getMaterialsCount(); i++) {
|
for (u32 i = 0; i < mesh->getMaterialsCount(); i++) {
|
||||||
auto* material = mesh->getMaterial(i);
|
auto* material = mesh->getMaterial(i);
|
||||||
|
auto partSize = core.getMaxVertCountByParams(
|
||||||
|
material->isSingleColorActivated(), options && options->lighting,
|
||||||
|
material->getTextureCoordFaces());
|
||||||
|
u32 partsCount =
|
||||||
|
ceil(material->getFacesCount() / static_cast<float>(partSize));
|
||||||
|
auto* colorBag = getColorBag(material);
|
||||||
|
setBuffersColorBag(buffers, colorBag);
|
||||||
|
|
||||||
// 2x bufory[maxVertCount*2] -> pętla po mniejszych częściach i czestsze
|
for (u32 j = 0; j < partsCount; j++) {
|
||||||
// rendery
|
auto& buffer = buffers[context];
|
||||||
|
|
||||||
// TODO: Double buffering in future
|
freeBuffer(&buffer);
|
||||||
// auto maxVertCount = core->renderer3D.getMaxVertCountByParams(
|
buffer.count = j == partsCount - 1
|
||||||
// material->isSingleColorActivated(), material->getNormalFaces(),
|
? material->getFacesCount() - j * partSize
|
||||||
// material->getTextureCoordFaces());
|
: partSize;
|
||||||
|
|
||||||
DynPipBag bag;
|
u32 startIndex = j * partSize;
|
||||||
addVertices(mesh, material, &bag, frameFrom, frameTo);
|
|
||||||
// bag.info = infoBag;
|
|
||||||
// bag.color = getColorBag(mesh, material, frameFrom, frameTo);
|
|
||||||
// bag.texture = getTextureBag(mesh, material, frameFrom, frameTo);
|
|
||||||
// bag.lighting =
|
|
||||||
// getLightingBag(mesh, material, &model, frameFrom, frameTo, options);
|
|
||||||
|
|
||||||
core.render(&bag);
|
addVertices(mesh, material, &buffer, frameFrom, frameTo, startIndex);
|
||||||
|
buffer.texture = getTextureBag(mesh, material, frameFrom, frameTo,
|
||||||
|
buffer.count, startIndex);
|
||||||
|
buffer.lighting =
|
||||||
|
getLightingBag(mesh, material, &model, frameFrom, frameTo, options,
|
||||||
|
dirLights, buffer.count, startIndex);
|
||||||
|
|
||||||
// deallocDrawBags(&bag, material);
|
core.render(&buffer);
|
||||||
|
|
||||||
|
context = !context;
|
||||||
}
|
}
|
||||||
|
|
||||||
// delete infoBag; // TODO
|
freeBuffer(&buffers[context]);
|
||||||
|
freeBuffer(&buffers[!context]);
|
||||||
|
|
||||||
|
delete colorBag;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DynamicPipeline::addVertices(DynamicMesh* mesh, MeshMaterial* material,
|
delete infoBag;
|
||||||
DynPipBag* bag, MeshFrame* frameFrom,
|
}
|
||||||
MeshFrame* frameTo) const {
|
|
||||||
// bag->count = material->getFacesCount();
|
|
||||||
// bag->vertices = new Vec4[bag->count];
|
|
||||||
|
|
||||||
// for (u32 i = 0; i < bag->count; i++) {
|
void DynamicPipeline::setBuffersDefaultVars(DynPipBag* buffers,
|
||||||
// auto& face = material->getVertexFaces()[i];
|
DynamicMesh* mesh,
|
||||||
// if (frameTo == nullptr) {
|
PipelineInfoBag* infoBag) {
|
||||||
// bag->vertices[i] = frameFrom->getVertices()[face];
|
for (int i = 0; i < 2; i++) {
|
||||||
// } else {
|
buffers[i].info = infoBag;
|
||||||
// Vec4::setLerp(&bag->vertices[i], frameFrom->getVertices()[face],
|
buffers[i].interpolation = mesh->getAnimState().interpolation;
|
||||||
// frameTo->getVertices()[face],
|
}
|
||||||
// mesh->getAnimState().interpolation);
|
}
|
||||||
// }
|
|
||||||
// }
|
void DynamicPipeline::setBuffersColorBag(DynPipBag* buffers,
|
||||||
|
DynPipColorBag* colorBag) {
|
||||||
|
for (int i = 0; i < 2; i++) {
|
||||||
|
buffers[i].color = colorBag;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void DynamicPipeline::freeBuffer(DynPipBag* bag) {
|
||||||
|
if (bag->texture) {
|
||||||
|
bag->texture->freeCoords();
|
||||||
|
delete bag->texture;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (bag->lighting) {
|
||||||
|
bag->lighting->freeNormals();
|
||||||
|
delete bag->lighting;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (bag->verticesFrom) {
|
||||||
|
delete[] bag->verticesFrom;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (bag->verticesTo) {
|
||||||
|
delete[] bag->verticesTo;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PipelineInfoBag* DynamicPipeline::getInfoBag(DynamicMesh* mesh,
|
PipelineInfoBag* DynamicPipeline::getInfoBag(DynamicMesh* mesh,
|
||||||
@@ -100,99 +136,71 @@ PipelineInfoBag* DynamicPipeline::getInfoBag(DynamicMesh* mesh,
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
DynPipColorBag* DynamicPipeline::getColorBag(DynamicMesh* mesh,
|
void DynamicPipeline::addVertices(DynamicMesh* mesh, MeshMaterial* material,
|
||||||
MeshMaterial* material,
|
DynPipBag* bag, MeshFrame* frameFrom,
|
||||||
MeshFrame* frameFrom,
|
MeshFrame* frameTo,
|
||||||
MeshFrame* frameTo) const {
|
const u32& startIndex) const {
|
||||||
// auto* result = new DynPipColorBag();
|
bag->verticesFrom = new Vec4[bag->count];
|
||||||
|
bag->verticesTo = new Vec4[bag->count];
|
||||||
|
|
||||||
// if (material->isSingleColorActivated()) {
|
for (u32 i = startIndex; i < startIndex + bag->count; i++) {
|
||||||
// result->single = &material->singleColor;
|
auto& face = material->getVertexFaces()[i];
|
||||||
// } else {
|
bag->verticesFrom[i] = frameFrom->getVertices()[face];
|
||||||
// result->many = new Color[material->getFacesCount()];
|
bag->verticesTo[i] = frameTo->getVertices()[face];
|
||||||
|
}
|
||||||
// for (u32 i = 0; i < material->getFacesCount(); i++) {
|
|
||||||
// auto& face = material->getColorFaces()[i];
|
|
||||||
// if (frameTo == nullptr) {
|
|
||||||
// result->many[i] = frameFrom->getColors()[face];
|
|
||||||
// } else {
|
|
||||||
// Vec4::setLerp(
|
|
||||||
// reinterpret_cast<Vec4*>(&result->many[i]),
|
|
||||||
// reinterpret_cast<const Vec4&>(frameFrom->getColors()[face]),
|
|
||||||
// reinterpret_cast<const Vec4&>(frameTo->getColors()[face]),
|
|
||||||
// mesh->getAnimState().interpolation);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// return result;
|
|
||||||
return nullptr; // TODO
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DynPipTextureBag* DynamicPipeline::getTextureBag(DynamicMesh* mesh,
|
DynPipColorBag* DynamicPipeline::getColorBag(MeshMaterial* material) const {
|
||||||
MeshMaterial* material,
|
auto* result = new DynPipColorBag();
|
||||||
MeshFrame* frameFrom,
|
result->single = &material->singleColor;
|
||||||
MeshFrame* frameTo) {
|
return result;
|
||||||
// if (!material->getTextureCoordFaces()) return nullptr;
|
}
|
||||||
|
|
||||||
// auto* result = new DynPipTextureBag();
|
DynPipTextureBag* DynamicPipeline::getTextureBag(
|
||||||
|
DynamicMesh* mesh, MeshMaterial* material, MeshFrame* frameFrom,
|
||||||
|
MeshFrame* frameTo, const u32& count, const u32& startIndex) {
|
||||||
|
if (!material->getTextureCoordFaces()) return nullptr;
|
||||||
|
|
||||||
// result->texture =
|
auto* result = new DynPipTextureBag();
|
||||||
// rendererCore->texture.repository.getBySpriteOrMesh(material->getId());
|
result->texture =
|
||||||
// TYRA_ASSERT(result->texture, "Texture for material id: ",
|
rendererCore->texture.repository.getBySpriteOrMesh(material->getId());
|
||||||
// material->getId(),
|
TYRA_ASSERT(result->texture, "Texture for material id: ", material->getId(),
|
||||||
// " was not found in texture repository!");
|
"was not found in texture repository!");
|
||||||
|
|
||||||
// result->coordinates = new Vec4[material->getFacesCount()];
|
result->coordinatesFrom = new Vec4[count];
|
||||||
|
result->coordinatesTo = new Vec4[count];
|
||||||
|
|
||||||
// for (u32 i = 0; i < material->getFacesCount(); i++) {
|
for (u32 i = startIndex; i < startIndex + count; i++) {
|
||||||
// auto& face = material->getTextureCoordFaces()[i];
|
auto& face = material->getTextureCoordFaces()[i];
|
||||||
// if (frameTo == nullptr) {
|
result->coordinatesFrom[i] = frameFrom->getTextureCoords()[face];
|
||||||
// result->coordinates[i] = frameFrom->getTextureCoords()[face];
|
result->coordinatesTo[i] = frameTo->getTextureCoords()[face];
|
||||||
// } else {
|
}
|
||||||
// Vec4::setLerp(&result->coordinates[i],
|
|
||||||
// frameFrom->getTextureCoords()[face],
|
|
||||||
// frameTo->getTextureCoords()[face],
|
|
||||||
// mesh->getAnimState().interpolation);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// return result;
|
return result;
|
||||||
return nullptr; // TODO
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DynPipLightingBag* DynamicPipeline::getLightingBag(
|
DynPipLightingBag* DynamicPipeline::getLightingBag(
|
||||||
DynamicMesh* mesh, MeshMaterial* material, M4x4* model,
|
DynamicMesh* mesh, MeshMaterial* material, M4x4* model,
|
||||||
MeshFrame* frameFrom, MeshFrame* frameTo,
|
MeshFrame* frameFrom, MeshFrame* frameTo, const DynPipOptions* options,
|
||||||
const DynPipOptions* options) const {
|
PipelineDirLightsBag* dirLightsBag, const u32& count,
|
||||||
// if (!material->getNormalFaces() || options == nullptr ||
|
const u32& startIndex) const {
|
||||||
// options->lighting == nullptr)
|
if (!material->getNormalFaces() || options == nullptr ||
|
||||||
// return nullptr;
|
options->lighting == nullptr)
|
||||||
|
return nullptr;
|
||||||
|
|
||||||
// auto* result = new DynPipLightingBag();
|
auto* result = new DynPipLightingBag();
|
||||||
// auto* dirLightsBag = new PipelineDirLightsBag(true);
|
|
||||||
// result->dirLights = dirLightsBag;
|
|
||||||
|
|
||||||
// result->lightMatrix = model;
|
result->lightMatrix = model;
|
||||||
|
result->normalsFrom = new Vec4[count];
|
||||||
|
result->normalsTo = new Vec4[count];
|
||||||
|
|
||||||
// result->dirLights->setLightsManually(
|
for (u32 i = startIndex; i < startIndex + count; i++) {
|
||||||
// colorsCache, options->lighting->directionalDirections);
|
auto& face = material->getNormalFaces()[i];
|
||||||
|
result->normalsFrom[i] = frameFrom->getNormals()[face];
|
||||||
|
result->normalsTo[i] = frameTo->getNormals()[face];
|
||||||
|
}
|
||||||
|
|
||||||
// result->normals = new Vec4[material->getFacesCount()];
|
return result;
|
||||||
|
|
||||||
// for (u32 i = 0; i < material->getFacesCount(); i++) {
|
|
||||||
// auto& face = material->getNormalFaces()[i];
|
|
||||||
// if (frameTo == nullptr) {
|
|
||||||
// result->normals[i] = frameFrom->getNormals()[face];
|
|
||||||
// } else {
|
|
||||||
// Vec4::setLerp(&result->normals[i], frameFrom->getNormals()[face],
|
|
||||||
// frameTo->getNormals()[face],
|
|
||||||
// mesh->getAnimState().interpolation);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// return result;
|
|
||||||
return nullptr; // TODO
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DynamicPipeline::setLightingColorsCache(
|
void DynamicPipeline::setLightingColorsCache(
|
||||||
@@ -204,29 +212,4 @@ void DynamicPipeline::setLightingColorsCache(
|
|||||||
colorsCache[3] = reinterpret_cast<Vec4&>(*lightingOptions->ambientColor);
|
colorsCache[3] = reinterpret_cast<Vec4&>(*lightingOptions->ambientColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DynamicPipeline::deallocDrawBags(DynPipBag* bag,
|
|
||||||
MeshMaterial* material) const {
|
|
||||||
if (bag->color->manyFrom) {
|
|
||||||
delete[] bag->color->manyFrom;
|
|
||||||
delete[] bag->color->manyTo;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (bag->texture) {
|
|
||||||
delete[] bag->texture->coordinatesFrom;
|
|
||||||
delete[] bag->texture->coordinatesTo;
|
|
||||||
delete bag->texture;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (bag->lighting) {
|
|
||||||
delete[] bag->lighting->normalsFrom;
|
|
||||||
delete[] bag->lighting->normalsTo;
|
|
||||||
delete bag->lighting->dirLights;
|
|
||||||
delete bag->lighting;
|
|
||||||
}
|
|
||||||
|
|
||||||
delete[] bag->verticesFrom;
|
|
||||||
delete[] bag->verticesTo;
|
|
||||||
delete bag->color;
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace Tyra
|
} // namespace Tyra
|
||||||
|
|||||||
@@ -172,7 +172,8 @@ StaPipLightingBag* StaticPipeline::getLightingBag(
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
auto* result = new StaPipLightingBag();
|
auto* result = new StaPipLightingBag();
|
||||||
auto* dirLightsBag = new PipelineDirLightsBag(true);
|
auto* dirLightsBag = new PipelineDirLightsBag(true); // TODO: 1 dir
|
||||||
|
// lights per obiekt, dealokowac recznie
|
||||||
result->dirLights = dirLightsBag;
|
result->dirLights = dirLightsBag;
|
||||||
|
|
||||||
result->lightMatrix = model;
|
result->lightMatrix = model;
|
||||||
@@ -218,7 +219,7 @@ void StaticPipeline::deallocDrawBags(StaPipBag* bag,
|
|||||||
|
|
||||||
if (bag->lighting) {
|
if (bag->lighting) {
|
||||||
delete[] bag->lighting->normals;
|
delete[] bag->lighting->normals;
|
||||||
delete bag->lighting->dirLights;
|
delete bag->lighting->dirLights; // TODO
|
||||||
delete bag->lighting;
|
delete bag->lighting;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -162,10 +162,15 @@ std::string Texture::getPrint(const char* objectName) const {
|
|||||||
else if (wrap.horizontal == WRAP_CLAMP)
|
else if (wrap.horizontal == WRAP_CLAMP)
|
||||||
wrapString = "WRAP_CLAMP";
|
wrapString = "WRAP_CLAMP";
|
||||||
|
|
||||||
res << "id: " << id << ", ";
|
res << "id: " << id << ", " << std::endl;
|
||||||
res << "name: " << name << ", ";
|
res << "name: " << name << ", " << std::endl;
|
||||||
res << "core: " << core->getPrint() << ", ";
|
res << "core: " << core->getPrint() << ", " << std::endl;
|
||||||
if (clut != nullptr) res << "clut: " << clut->getPrint() << ", ";
|
if (clut != nullptr) res << "clut: " << clut->getPrint() << ", " << std::endl;
|
||||||
|
if (links.size()) {
|
||||||
|
for (size_t i = 0; i < links.size(); i++) {
|
||||||
|
res << "link " << i << " for id: " << links[i].id << ", " << std::endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
res << "wrap: " << wrapString << ")";
|
res << "wrap: " << wrapString << ")";
|
||||||
return res.str();
|
return res.str();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,9 +22,24 @@ TextureRepository::~TextureRepository() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----
|
Texture* TextureRepository::getBySpriteOrMesh(const u32& t_id) const {
|
||||||
// Methods
|
for (u32 i = 0; i < textures.size(); i++) {
|
||||||
// ----
|
if (textures[i]->isLinkedWith(t_id)) return textures[i];
|
||||||
|
}
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
Texture* TextureRepository::getByTextureId(const u32& t_id) const {
|
||||||
|
for (u32 i = 0; i < textures.size(); i++)
|
||||||
|
if (t_id == textures[i]->getId()) return textures[i];
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
const s32 TextureRepository::getIndexOf(const u32& t_texId) const {
|
||||||
|
for (u32 i = 0; i < textures.size(); i++)
|
||||||
|
if (textures[i]->getId() == t_texId) return i;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
Texture* TextureRepository::add(Texture* texture) {
|
Texture* TextureRepository::add(Texture* texture) {
|
||||||
textures.push_back(texture);
|
textures.push_back(texture);
|
||||||
|
|||||||
@@ -42,7 +42,9 @@ class H4570 : public Game {
|
|||||||
MinecraftPipeline mcPip;
|
MinecraftPipeline mcPip;
|
||||||
DynamicPipeline dynpip;
|
DynamicPipeline dynpip;
|
||||||
StaticPipeline stapip;
|
StaticPipeline stapip;
|
||||||
StaPipOptions* renderOptions;
|
StaPipOptions* staOptions;
|
||||||
|
DynPipOptions* dynOptions;
|
||||||
|
Texture* warriorTex;
|
||||||
Texture* blocksTex;
|
Texture* blocksTex;
|
||||||
|
|
||||||
u32 blocksCount;
|
u32 blocksCount;
|
||||||
|
|||||||
+22
-12
@@ -18,7 +18,9 @@ H4570::H4570(Engine* t_engine) { engine = t_engine; }
|
|||||||
H4570::~H4570() {}
|
H4570::~H4570() {}
|
||||||
|
|
||||||
DynamicMesh* getWarrior(Renderer* renderer);
|
DynamicMesh* getWarrior(Renderer* renderer);
|
||||||
StaPipOptions* getRenderingOptions();
|
StaPipOptions* getStaPipOptions();
|
||||||
|
DynPipOptions* getDynPipOptions();
|
||||||
|
void setPipelineOptions(PipelineOptions* options);
|
||||||
Sprite* get2DPicture(Renderer* renderer);
|
Sprite* get2DPicture(Renderer* renderer);
|
||||||
|
|
||||||
void H4570::init() {
|
void H4570::init() {
|
||||||
@@ -34,8 +36,7 @@ void H4570::init() {
|
|||||||
engine->renderer.setClearScreenColor(Color(64.0F, 64.0F, 64.0F));
|
engine->renderer.setClearScreenColor(Color(64.0F, 64.0F, 64.0F));
|
||||||
|
|
||||||
warrior = getWarrior(&engine->renderer);
|
warrior = getWarrior(&engine->renderer);
|
||||||
|
warriorTex = engine->renderer.core.texture.repository.getBySpriteOrMesh(
|
||||||
auto* warriorTex = engine->renderer.core.texture.repository.getBySpriteOrMesh(
|
|
||||||
warrior->getMaterial(0)->getId());
|
warrior->getMaterial(0)->getId());
|
||||||
|
|
||||||
warrior2 = new DynamicMesh(*warrior);
|
warrior2 = new DynamicMesh(*warrior);
|
||||||
@@ -56,7 +57,8 @@ void H4570::init() {
|
|||||||
warrior4->playAnimation(0, warrior4->getFramesCount() - 1);
|
warrior4->playAnimation(0, warrior4->getFramesCount() - 1);
|
||||||
warrior4->setAnimSpeed(0.5F);
|
warrior4->setAnimSpeed(0.5F);
|
||||||
|
|
||||||
renderOptions = getRenderingOptions();
|
staOptions = getStaPipOptions();
|
||||||
|
dynOptions = getDynPipOptions();
|
||||||
|
|
||||||
cameraPosition = Vec4(0.0F, 0.0F, 20.0F);
|
cameraPosition = Vec4(0.0F, 0.0F, 20.0F);
|
||||||
cameraLookAt = *warrior->getPosition();
|
cameraLookAt = *warrior->getPosition();
|
||||||
@@ -140,14 +142,14 @@ void H4570::loop() {
|
|||||||
|
|
||||||
// engine->renderer.renderer3D.usePipeline(&stapip);
|
// engine->renderer.renderer3D.usePipeline(&stapip);
|
||||||
// {
|
// {
|
||||||
// stapip.render(warrior, renderOptions);
|
// stapip.render(warrior, staOptions);
|
||||||
// // stapip.render(warrior2, renderOptions);
|
// // stapip.render(warrior2, staOptions);
|
||||||
// // stapip.render(warrior3, renderOptions);
|
// // stapip.render(warrior3, staOptions);
|
||||||
// // stapip.render(warrior4, renderOptions);
|
// // stapip.render(warrior4, staOptions);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
engine->renderer.renderer3D.usePipeline(&dynpip);
|
engine->renderer.renderer3D.usePipeline(&dynpip);
|
||||||
{ dynpip.render(warrior); }
|
{ dynpip.render(warrior, dynOptions); }
|
||||||
|
|
||||||
engine->renderer.renderer3D.usePipeline(&mcPip);
|
engine->renderer.renderer3D.usePipeline(&mcPip);
|
||||||
{ mcPip.render(blocks, blocksCount, blocksTex, false); }
|
{ mcPip.render(blocks, blocksCount, blocksTex, false); }
|
||||||
@@ -183,9 +185,19 @@ Sprite* get2DPicture(Renderer* renderer) {
|
|||||||
return sprite;
|
return sprite;
|
||||||
}
|
}
|
||||||
|
|
||||||
StaPipOptions* getRenderingOptions() {
|
StaPipOptions* getStaPipOptions() {
|
||||||
auto* options = new StaPipOptions();
|
auto* options = new StaPipOptions();
|
||||||
|
setPipelineOptions(options);
|
||||||
|
return options;
|
||||||
|
}
|
||||||
|
|
||||||
|
DynPipOptions* getDynPipOptions() {
|
||||||
|
auto* options = new DynPipOptions();
|
||||||
|
setPipelineOptions(options);
|
||||||
|
return options;
|
||||||
|
}
|
||||||
|
|
||||||
|
void setPipelineOptions(PipelineOptions* options) {
|
||||||
auto* ambientColor = new Color(32.0F, 32.0F, 32.0F, 32.0F);
|
auto* ambientColor = new Color(32.0F, 32.0F, 32.0F, 32.0F);
|
||||||
auto* directionalColors = new Color[3];
|
auto* directionalColors = new Color[3];
|
||||||
for (int i = 0; i < 3; i++) directionalColors[i].set(0.0F, 0.0F, 0.0F, 1.0F);
|
for (int i = 0; i < 3; i++) directionalColors[i].set(0.0F, 0.0F, 0.0F, 1.0F);
|
||||||
@@ -208,8 +220,6 @@ StaPipOptions* getRenderingOptions() {
|
|||||||
|
|
||||||
directionalDirections[1].set(1.0F, 0.0F, 0.0F);
|
directionalDirections[1].set(1.0F, 0.0F, 0.0F);
|
||||||
directionalColors[1].set(96.0F, 0.0F, 0.0F);
|
directionalColors[1].set(96.0F, 0.0F, 0.0F);
|
||||||
|
|
||||||
return options;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Tyra
|
} // namespace Tyra
|
||||||
|
|||||||
Reference in New Issue
Block a user