This commit is contained in:
Vladislav Khorev committed 2026-05-01 20:01:06 +03:00
1 parent 16d250a51d
commit 519d780b3c
9 files changed
+25 -126

No files matched your search

+1 -27
View File
@@ -127,15 +127,7 @@ void Character::setTexture(std::shared_ptr<ZL::Texture> texture)
void Character::setTexture(const std::string& meshName, std::shared_ptr<Texture> tex) {
meshTextures[meshName] = std::move(tex);
}
/*
void Character::setTexture(std::shared_ptr<Texture> tex) {
for (auto& animEntry : animations) {
for (const auto& name : animEntry.second.model.meshNamesOrdered) {
meshTextures[name] = tex;
}
}
}
*/
AnimationState Character::resolveActiveState() const {
if (animations.count(currentState)) return currentState;
@@ -174,14 +166,6 @@ void Character::update(int64_t deltaMs) {
deltaMs = static_cast<int64_t>(static_cast<float>(deltaMs) * speedMultiplier);
}
//weaponInitialRotation = Eigen::AngleAxisf(x/180.0, Eigen::Vector3f::UnitZ()).toRotationMatrix();
//weaponInitialRotation = Eigen::AngleAxisf(-M_PI*0.5, Eigen::Vector3f::UnitZ()).toRotationMatrix();
//weaponInitialPosition = Eigen::Vector3f(0, 0.09, 0.016);
/*if (deltaMs > 200)
{
deltaMs = 200;
}*/
Eigen::Vector3f activeTarget;
Eigen::Vector3f lookTarget;
@@ -373,14 +357,8 @@ void Character::update(int64_t deltaMs) {
resetAnim = false;
anim.currentFrame = 0;
}
//19
int prevFrame = anim.currentFrame;
anim.currentFrame += static_cast<float>(deltaMs) / 24.f;
/*
if (npcId == "ghost_01x")
{
std::cout << "Current animation frame: " << anim.currentFrame << " / " << anim.totalFrames << " -- " << anim.lastFrame << std::endl;
}*/
if (static_cast<int>(anim.currentFrame) >= 20 && currentState == AnimationState::STAND_TO_ACTION)
{
@@ -436,25 +414,21 @@ void Character::update(int64_t deltaMs) {
if (currentState == AnimationState::STAND_TO_ACTION)
{
currentState = AnimationState::ACTION_IDLE;
//resetAnim = true;
}
if (currentState == AnimationState::ACTION_TO_STAND)
{
currentState = AnimationState::STAND;
//resetAnim = true;
}
if (currentState == AnimationState::ACTION_ATTACK)
{
currentState = AnimationState::ACTION_IDLE;
//resetAnim = true;
attack = 0;
}
if (currentState == AnimationState::ACTION_TO_DEATH)
{
currentState = AnimationState::DEATH_IDLE;
//resetAnim = true;
}
}
-3
View File
@@ -107,9 +107,6 @@ namespace ZL {
void updatePinchZoom();
void endPinch();
int countNonUiPointers() const;
void handleDown(int64_t fingerId, int mx, int my);
void handleUp(int64_t fingerId, int mx, int my);
void handleMotion(int64_t fingerId, int mx, int my);
void setupQuestJournalUi();
void toggleQuestJournal();
+1 -11
View File
@@ -205,22 +205,12 @@ void DialogueOverlay::drawDialogue(Renderer& renderer, const PresentationModel&
nameRenderer->drawText(model.speaker, nameX, nameY, 1.0f, false, { 1.0f, 0.88f, 0.45f, 1.0f });
}
/*<<<<<<< HEAD
//const std::string wrappedBody = wrapText(model.visibleText, 90);
const std::string wrappedBody = wrapText(model.visibleText, 56);
bodyRenderer->drawText(wrappedBody, bodyX, bodyY, 1.0f, false, { 1.0f, 1.0f, 1.0f, 1.0f });
=======*/
// const std::string wrappedBody = wrapText(model.visibleText, 90);
// bodyRenderer->drawText(wrappedBody, bodyX, bodyY, 1.0f, false, { 1.0f, 1.0f, 1.0f, 1.0f });
// const std::string wrappedBody = wrapText(model.visibleText, 56);
// bodyRenderer->drawText(wrappedBody, bodyX, bodyY, 1.0f, false, { 1.0f, 1.0f, 1.0f, 1.0f });
const float bodyTextScale = 1.0f;
const float bodyMaxWidthPx = textboxRect.w - 48.0f;
const std::string wrappedBody = wrapTextToWidth(model.visibleText, *bodyRenderer, bodyMaxWidthPx, bodyTextScale);
bodyRenderer->drawText(wrappedBody, bodyX, bodyY, bodyTextScale, false, { 1.0f, 1.0f, 1.0f, 1.0f });
//>>>>>>> 4de8f78ecad8b7e2139d593b95aaf9ef01b25ece
lastChoiceRects.clear();
if (model.mode == PresentationMode::Choice) {
+1 -6
View File
@@ -7,14 +7,9 @@
#include "external/nlohmann/json.hpp"
#include "TextModel.h"
#include "InteractiveObject.h"
//#include "Character.h"
//#include "render/TextureManager.h"
namespace ZL {
//struct Texture;
//struct VertexRenderStruct;
//class Renderer;
class Character;
struct GameObjectData {
+1 -3
View File
@@ -9,10 +9,9 @@ namespace ZL {
GLuint fbo = 0;
GLuint textureID = 0;
int width, height;
bool useMipmaps; // ���� ������������� ���-�����
bool useMipmaps;
public:
// ��������� �������� � ����������� �� ��������� false
FrameBuffer(int w, int h, bool useMipmaps = false);
~FrameBuffer();
@@ -22,7 +21,6 @@ namespace ZL {
void Bind();
void Unbind();
// ����� ��� �������������� ��������� ���-����� ����� �������
void GenerateMipmaps();
GLuint getTextureID() const { return textureID; }
-2
View File
@@ -14,8 +14,6 @@ namespace ZL {
GLuint shaderProgram;
std::unordered_map<std::string, GLuint> uniformList;
//std::unordered_map<std::string, std::pair<bool, size_t>> UniformList;
std::map<std::string, GLuint> attribList;
-48
View File
@@ -298,34 +298,6 @@ bool TextRenderer::loadGlyphs(const std::string& ttfPath, int pixelSize, const s
rowHeight = max(rowHeight, gb.height);
}
// // Проходим по стандартным ASCII символам
// for (unsigned char c = 32; c < 128; ++c) {
//
// FT_Load_Char(face, c, FT_LOAD_RENDER);
// TextureDataStruct glyphData;
// glyphData.width = face->glyph->bitmap.width;
// glyphData.height = face->glyph->bitmap.rows;
// glyphData.format = TextureDataStruct::R8;
// glyphData.mipmap = TextureDataStruct::NONE;
// // Копируем буфер FreeType в вектор данных
// size_t dataSize = glyphData.width * glyphData.height;
// glyphData.data.assign(face->glyph->bitmap.buffer, face->glyph->bitmap.buffer + dataSize);
// // Теперь создание текстуры — это одна строка!
// auto tex = std::make_shared<Texture>(glyphData);
//GlyphInfo g;
// g.texture = tex;
// g.size = Eigen::Vector2f((float)face->glyph->bitmap.width, (float)face->glyph->bitmap.rows);
// g.bearing = Eigen::Vector2f((float)face->glyph->bitmap_left, (float)face->glyph->bitmap_top);
// // Advance во FreeType измеряется в 1/64 пикселя
// g.advance = (unsigned int)face->glyph->advance.x;
// glyphs.emplace((char)c, g);
// }
// Создаём Texture из atlasData (R8)
TextureDataStruct atlasTex;
atlasTex.width = atlasWidth;
@@ -466,12 +438,9 @@ void TextRenderer::drawText(const std::string& text, float x, float y, float sca
// Примечание: для текста лучше использовать GL_DYNAMIC_DRAW,
// но RefreshVBO сейчас жестко зашит на GL_STATIC_DRAW.
// Для UI это обычно не критично, если строк не тысячи.
// textMesh.AssignFrom(textData);
// 4. Рендеринг
r->shaderManager.PushShader(shaderName);
//r->PushMatrix();
//r->LoadIdentity();
// Матрица проекции — используем виртуальные проекционные размеры,
// чтобы координаты текста были независимы от физического разрешения экрана.
@@ -498,24 +467,7 @@ void TextRenderer::drawText(const std::string& text, float x, float y, float sca
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
//for (size_t i = 0; i < text.length(); ++i) {
// auto it = glyphs.find(text[i]);
// if (it == glyphs.end()) continue;
// glBindTexture(GL_TEXTURE_2D, it->second.texture->getTexID());
// // Отрисовываем по 6 вершин за раз
// // Нам нужно вручную биндить VBO, так как DrawVertexRenderStruct рисует всё сразу
// glBindBuffer(GL_ARRAY_BUFFER, textMesh.positionVBO->getBuffer());
// r->VertexAttribPointer3fv("vPosition", 0, (const char*)(i * 6 * sizeof(Vector3f)));
// glBindBuffer(GL_ARRAY_BUFFER, textMesh.texCoordVBO->getBuffer());
// r->VertexAttribPointer2fv("vTexCoord", 0, (const char*)(i * 6 * sizeof(Vector2f)));
// glDrawArrays(GL_TRIANGLES, 0, 6);
//}
r->DrawVertexRenderStruct(cached.mesh);
//r->PopMatrix();
glDisable(GL_BLEND);
-5
View File
@@ -12,7 +12,6 @@
namespace ZL {
struct GlyphInfo {
// std::shared_ptr<Texture> texture; // Texture for glyph
Eigen::Vector2f uv; // u,v координата левого верхнего угла в атласе (0..1)
Eigen::Vector2f uvSize; // ширина/высота в UV (0..1)
@@ -42,10 +41,6 @@ private:
std::unordered_map<uint32_t, GlyphInfo> glyphs;
// OpenGL objects for a dynamic quad
//unsigned int vao = 0;
//unsigned int vbo = 0;
// единый атлас для всех глифов
std::shared_ptr<Texture> atlasTexture;
size_t atlasWidth = 0;