Merge branch 'salmon' of github.com:mephi1984/ZeptoLabTest1 into salmon

This commit is contained in:
Vladislav Khorev committed 2025-03-02 14:34:11 +03:00
commit 0fc6b483d1
13 files changed
+17228 -10

No files matched your search

+31
View File
@@ -0,0 +1,31 @@
{
"files.associations": {
"array": "cpp",
"bitset": "cpp",
"string_view": "cpp",
"hash_map": "cpp",
"hash_set": "cpp",
"initializer_list": "cpp",
"span": "cpp",
"regex": "cpp",
"valarray": "cpp",
"__hash_table": "cpp",
"__split_buffer": "cpp",
"__tree": "cpp",
"deque": "cpp",
"list": "cpp",
"map": "cpp",
"queue": "cpp",
"set": "cpp",
"stack": "cpp",
"string": "cpp",
"unordered_map": "cpp",
"unordered_set": "cpp",
"vector": "cpp",
"chrono": "cpp",
"text_encoding": "cpp",
"typeindex": "cpp",
"typeinfo": "cpp",
"*.inc": "cpp"
}
}
+29 -5
View File
@@ -7,12 +7,13 @@
namespace ZL { namespace ZL {
const float GameObjectManager::INVENTORY_ICON_SIZE = 32.0f; const float GameObjectManager::INVENTORY_ICON_SIZE = 64.0f;
const float GameObjectManager::INVENTORY_MARGIN = 10.0f; const float GameObjectManager::INVENTORY_MARGIN = 10.0f;
void GameObjectManager::initialize() { void GameObjectManager::initialize() {
current_room_index = 0; current_room_index = 0;
objects_in_inventory = 0;
coneTexturePtr = std::make_shared<Texture>(CreateTextureDataFromBmp24("./conus.bmp")); coneTexturePtr = std::make_shared<Texture>(CreateTextureDataFromBmp24("./conus.bmp"));
@@ -27,10 +28,15 @@ void GameObjectManager::initialize() {
testObjMeshMutable.data = testObjMesh; testObjMeshMutable.data = testObjMesh;
testObjMeshMutable.RefreshVBO(); testObjMeshMutable.RefreshVBO();
textMesh = ZL::LoadFromTextFile("./mesh_first_room.txt"); // Add ZL:: namespace textMesh = ZL::LoadFromTextFile("./textures/mesh_first_room.txt"); // Add ZL:: namespace
textMesh.Scale(10);
textMesh.SwapZandY();
textMesh.RotateByMatrix(QuatToMatrix(QuatFromRotateAroundX(M_PI * 0.5)));
textMesh.Move(Vector3f{0, 93, 0});
coneMesh = ZL::LoadFromTextFile("./cone001.txt"); // Add ZL:: namespace coneMesh = ZL::LoadFromTextFile("./cone001.txt"); // Add ZL:: namespace
coneMesh.Scale(200); coneMesh.Scale(200);
textMesh.Scale(20);
textMeshMutable.AssignFrom(textMesh); textMeshMutable.AssignFrom(textMesh);
textMeshMutable.RefreshVBO(); textMeshMutable.RefreshVBO();
@@ -99,7 +105,7 @@ void GameObjectManager::initialize() {
// Initialize inventory // Initialize inventory
inventoryIconMesh = CreateRect2D( inventoryIconMesh = CreateRect2D(
{0.0f, 0.0f}, {0.0f, 40.0f},
{INVENTORY_ICON_SIZE/2, INVENTORY_ICON_SIZE/2}, {INVENTORY_ICON_SIZE/2, INVENTORY_ICON_SIZE/2},
0.5f 0.5f
); );
@@ -108,6 +114,12 @@ void GameObjectManager::initialize() {
roomTexturePtr = rooms[current_room_index].roomTexture; roomTexturePtr = rooms[current_room_index].roomTexture;
AddItemToInventory("book1", std::make_shared<Texture>(CreateTextureDataFromBmp24("./Kitchen_ceramics.bmp")), objects_in_inventory+1);
objects_in_inventory++;
AddItemToInventory("book2", std::make_shared<Texture>(CreateTextureDataFromBmp24("./Kitchen_ceramics.bmp")), objects_in_inventory+1);
objects_in_inventory++;
//SDL_ShowCursor(SDL_DISABLE); //SDL_ShowCursor(SDL_DISABLE);
SDL_SetRelativeMouseMode(SDL_TRUE); SDL_SetRelativeMouseMode(SDL_TRUE);
} }
@@ -145,7 +157,8 @@ void GameObjectManager::handleEvent(const SDL_Event& event) {
continue; continue;
} }
AddItemToInventory(ao->name, ao->activeObjectTexturePtr); AddItemToInventory(ao->name, ao->activeObjectTexturePtr, objects_in_inventory+1);
objects_in_inventory++;
aoMgr.removeByName(ao->name); aoMgr.removeByName(ao->name);
} }
@@ -234,6 +247,17 @@ void GameObjectManager::handleEvent(const SDL_Event& event) {
Environment::violaLastWalkFrame = -1; Environment::violaLastWalkFrame = -1;
} }
break; break;
case SDLK_1:
case SDLK_2:
{
int hot_key = (event.key.keysym.sym == SDLK_1) ? 1 : 2;
UnselectAllItems();
if (InventoryItem* item = GetItemByHotkey(hot_key)) {
item->isSelected = true;
}
}
break;
// ...handle other keys... // ...handle other keys...
} }
} }
+1
View File
@@ -55,6 +55,7 @@ public:
static const float INVENTORY_ICON_SIZE; static const float INVENTORY_ICON_SIZE;
static const float INVENTORY_MARGIN; static const float INVENTORY_MARGIN;
ActiveObjectManager aoMgr; ActiveObjectManager aoMgr;
int objects_in_inventory;
private: private:
//int animationCounter = 0; //int animationCounter = 0;
+19 -1
View File
@@ -5,11 +5,12 @@ namespace ZL
// Определяем глобальную переменную // Определяем глобальную переменную
std::unordered_map<std::string, InventoryItem> gInventoryMap; std::unordered_map<std::string, InventoryItem> gInventoryMap;
void AddItemToInventory(const std::string& name, std::shared_ptr<Texture> tex) void AddItemToInventory(const std::string& name, std::shared_ptr<Texture> tex, int hot_key)
{ {
InventoryItem item; InventoryItem item;
item.name = name; item.name = name;
item.texture = tex; item.texture = tex;
item.hot_key = hot_key;
// Вставляем или перезаписываем (operator[] так сделает). // Вставляем или перезаписываем (operator[] так сделает).
gInventoryMap[name] = item; gInventoryMap[name] = item;
@@ -34,6 +35,16 @@ namespace ZL
return nullptr; return nullptr;
} }
InventoryItem* GetItemByHotkey(int hotkey)
{
for (auto& [_, item] : gInventoryMap) {
if (item.hot_key == hotkey) {
return &item;
}
}
return nullptr;
}
void PrintInventory() void PrintInventory()
{ {
std::cout << "Inventory contents:\n"; std::cout << "Inventory contents:\n";
@@ -43,6 +54,13 @@ namespace ZL
} }
} }
void UnselectAllItems()
{
for (auto& [_, item] : gInventoryMap) {
item.isSelected = false;
}
}
const std::unordered_map<std::string, InventoryItem>& ReturnInventory() const std::unordered_map<std::string, InventoryItem>& ReturnInventory()
{ {
return gInventoryMap; return gInventoryMap;
+8 -2
View File
@@ -12,13 +12,15 @@ namespace ZL
{ {
std::string name; std::string name;
std::shared_ptr<Texture> texture; std::shared_ptr<Texture> texture;
bool isSelected = false;
int hot_key;
}; };
// Глобальное хранилище предметов // Глобальное хранилище предметов
extern std::unordered_map<std::string, InventoryItem> gInventory; extern std::unordered_map<std::string, InventoryItem> gInventoryMap; // Changed from gInventory
// Добавить предмет в инвентарь // Добавить предмет в инвентарь
void AddItemToInventory(const std::string& name, std::shared_ptr<Texture> tex); void AddItemToInventory(const std::string& name, std::shared_ptr<Texture> tex, int hot_key);
// Удалить предмет из инвентаря // Удалить предмет из инвентаря
void RemoveItemFromInventory(const std::string& name); void RemoveItemFromInventory(const std::string& name);
@@ -30,4 +32,8 @@ namespace ZL
void PrintInventory(); void PrintInventory();
const std::unordered_map<std::string, InventoryItem>& ReturnInventory(); const std::unordered_map<std::string, InventoryItem>& ReturnInventory();
// Add these new functions
void UnselectAllItems();
InventoryItem* GetItemByHotkey(int hotkey);
} }
+46
View File
@@ -0,0 +1,46 @@
# Script to run:
```
C:\Work\Projects\emsdk\emsdk.bat activate latest
C:\Work\Projects\emsdk\emsdk_env.bat
emcc main.cpp Game.cpp Math.cpp Physics.cpp Renderer.cpp ShaderManager.cpp TextureManager.cpp Utils.cpp OpenGlExtensions.cpp -O2 -std=c++14 -sTOTAL_MEMORY=33554432 -sUSE_SDL_IMAGE=2 -sSDL2_IMAGE_FORMATS="[""png""]" -sUSE_SDL=2 --preload-file background.bmp --preload-file bird.bmp32 --preload-file default.fragment --preload-file default.vertex --preload-file game_over.bmp32 --preload-file pipe.bmp32 -o jumpingbird.html
```
```
zlib-1.3.1:
mkdir build
cd build
cmake -DCMAKE_INSTALL_PREFIX=install ..
then run ALL_BUILD and INSTALL in Visual Studio
lpng1645:
mkdir build
cd build
cmake -DCMAKE_INSTALL_PREFIX=install -DZLIB_ROOT=C:\Work\Projects\zlib-1.3.1\build\install ..
then run ALL_BUILD and INSTALL in Visual Studio
```
https://github.com/Bly7/OBJ-Loader/blob/master/Source/OBJ_Loader.h
https://github.com/gametutorials/tutorials/blob/master/OpenGL/MD3%20Animation/Main.cpp
linux:
```
g++ Game.cpp main.cpp Math.cpp OpenGlExtensions.cpp Physics.cpp Renderer.cpp ShaderManager.cpp TextureManager.cpp Utils.cpp BoneAnimatedModel.cpp ObjLoader.cpp cmakeaudioplayer/src/AudioPlayer.cpp TextModel.cpp Inventory.cpp -o sdl_app -O2 -std=c++17 \
-I cmakeaudioplayer/include \
$(pkg-config --cflags --libs sdl2 gl) \
$(pkg-config --cflags --libs vorbis vorbisfile ogg) \
-lopenal
```
+9 -2
View File
@@ -1,6 +1,5 @@
#include "Renderer.h" #include "Renderer.h"
#include <cmath>
namespace ZL { namespace ZL {
@@ -287,6 +286,13 @@ namespace ZL {
PositionData[i] = PositionData[i] * scale; PositionData[i] = PositionData[i] * scale;
} }
} }
void VertexDataStruct::Move(Vector3f diff)
{
for (int i = 0; i < PositionData.size(); i++)
{
PositionData[i] = PositionData[i] + diff;
}
}
void VertexDataStruct::SwapZandY() void VertexDataStruct::SwapZandY()
{ {
@@ -298,6 +304,7 @@ namespace ZL {
} }
} }
void VertexDataStruct::RotateByMatrix(Matrix3f m) void VertexDataStruct::RotateByMatrix(Matrix3f m)
{ {
+1
View File
@@ -52,6 +52,7 @@ namespace ZL {
void RotateByMatrix(Matrix3f m); void RotateByMatrix(Matrix3f m);
void Scale(float scale); void Scale(float scale);
void Move(Vector3f diff);
void SwapZandY(); void SwapZandY();
}; };
+1
View File
@@ -0,0 +1 @@
/home/albert/Downloads/Telegram Desktop/plain_obj_script.py
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
File renamed without changes.
File diff suppressed because it is too large. Load diff