Dreikblack Posted December 27, 2023 Share Posted December 27, 2023 1. Create brush and material. 2. Apply texture to material: Saved locally this texture for test purpose https://raw.githubusercontent.com/UltraEngine/Documentation/master/Assets/Materials/tiles.dds 3. Save a map with a brush. 4. Load map - no texture on brush. I can see it in a map file with a text editor. #include "UltraEngine.h" using namespace UltraEngine; int main(int argc, const char* argv[]) { //Get the displays auto displays = GetDisplays(); //Create a window auto window = CreateWindow("Ultra Engine", 0, 0, 1280, 720, displays[0], WINDOW_CENTER | WINDOW_TITLEBAR); //Load FreeImage plugin auto plg = LoadPlugin("Plugins/FITextureLoader"); //Create a world auto world = CreateWorld(); //Create a framebuffer auto framebuffer = CreateFramebuffer(window); //Create a camera auto camera = CreateCamera(world); camera->SetClearColor(0.125); camera->SetPosition(0, 1, -4); //Create light auto light = CreateBoxLight(world); light->SetRange(-10, 10); light->SetArea(15, 15); light->SetRotation(45, 35, 0); light->SetColor(2); //Create a scene auto scene = CreateMap(); scene->entities.push_back(camera); scene->entities.push_back(light); //Load model auto t = CreateBoxBrush(world, 1, 1, 1); auto texture = LoadTexture("tiles.dds"); auto material = CreateMaterial(); material->SetTexture(texture); t->SetMaterial(material); scene->entities.push_back(t); scene->Save("game.sav"); //Main loop while (window->Closed() == false and window->KeyDown(KEY_ESCAPE) == false) { if (window->KeyHit(KEY_SPACE)) { scene = LoadMap(world, "game.sav"); } world->Update(); world->Render(framebuffer); } return 0; } Quote Link to comment Share on other sites More sharing options...
Josh Posted December 30, 2023 Share Posted December 30, 2023 Can you upload your map file please? Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Dreikblack Posted December 31, 2023 Author Share Posted December 31, 2023 I create a map in code of this example. Quote Link to comment Share on other sites More sharing options...
Dreikblack Posted December 31, 2023 Author Share Posted December 31, 2023 Uploaded what i got with this code just in casegame.zip Quote Link to comment Share on other sites More sharing options...
Josh Posted January 16 Share Posted January 16 Map file appears to have all the info: "scene": { "ambientlight": [ 0.25, 0.25, 0.25 ], "base": "", "entities": [ { "camera": { "clearcolor": [ 0.125, 0.125, 0.125 ], "clearmode": 3, "fov": 90.0, "range": [ 0.10000000149011612, 1000.0 ] }, "castshadows": false, "collisiontype": 0, "friction": [ 0.5, 0.8999999761581421 ], "matrix": [ "0x3f800000", "0x0", "0x0", "0x0", "0x0", "0x3f800000", "0x0", "0x0", "0x0", "0x0", "0x3f800000", "0x0", "0x0", "0x3f800000", "0xc0800000", "0x3f800000" ], "physicsmode": 0, "pickmode": 0, "position": [ "0x0", "0x3f800000", "0xc0800000" ], "reflection": true, "uuid": "daad0d12-ac3e-41cf-968b-84119150c110" }, { "boxlight": { "area": [ 15.0, 15.0 ], "range": [ -10.0, 10.0 ] }, "castshadows": true, "collisiontype": 0, "color": [ 2.0, 2.0, 2.0, 1.0 ], "friction": [ 0.5, 0.8999999761581421 ], "matrix": [ "0x3f51b3f3", "0xb2800000", "0xbf12d5e7", "0x0", "0x3ecfa828", "0x3f3504f2", "0x3f144849", "0x0", "0x3ecfa826", "0xbf3504f3", "0x3f144848", "0x0", "0x0", "0x0", "0x0", "0x3f800000" ], "physicsmode": 0, "pickmode": 0, "quaternion": [ "0xbebadd92", "0xbe8e3de3", "0x3debac83", "0x3f61910d" ], "reflection": true, "rotation": [ "0x42340000", "0x420c0000", "0x0" ], "uuid": "f414b4a1-c817-4d48-9861-e3e605146623" }, { "brush": { "faces": [ { "indicecount": 4, "indices": 96, "mappingplane": [ [ 1.0, -0.0, -0.0, 0.0 ], [ -0.0, -0.0, -1.0, 0.0 ] ], "mappingscale": [ 400.0, 400.0 ] }, { "indicecount": 4, "indices": 104, "mappingplane": [ [ -1.0, -0.0, -0.0, 0.0 ], [ -0.0, -0.0, -1.0, 0.0 ] ], "mappingscale": [ 400.0, 400.0 ] }, { "indicecount": 4, "indices": 112, "mappingplane": [ [ -1.0, -0.0, -0.0, 0.0 ], [ -0.0, -1.0, -0.0, 0.0 ] ], "mappingscale": [ 400.0, 400.0 ] }, { "indicecount": 4, "indices": 120, "mappingplane": [ [ 1.0, -0.0, -0.0, 0.0 ], [ -0.0, -1.0, -0.0, 0.0 ] ], "mappingscale": [ 400.0, 400.0 ] }, { "indicecount": 4, "indices": 128, "mappingplane": [ [ -0.0, -0.0, -1.0, 0.0 ], [ -0.0, -1.0, -0.0, 0.0 ] ], "mappingscale": [ 400.0, 400.0 ] }, { "indicecount": 4, "indices": 136, "mappingplane": [ [ -0.0, -0.0, 1.0, 0.0 ], [ -0.0, -1.0, -0.0, 0.0 ] ], "mappingscale": [ 400.0, 400.0 ] } ], "material": 1, "vertexcount": 8, "vertices": 0 }, "castshadows": true, "collisiontype": 2, "friction": [ 0.5, 0.8999999761581421 ], "physicsmode": 1, "pickmode": 1, "reflection": true, "uuid": "e8571be5-05a9-4c18-a137-f115abdd2605" } ], "gravity": [ 0.0, -9.8100004196167, 0.0 ], "iblintensity": 1.0, "materials": [ { "displacement": [ 0.05000000074505806, -0.02500000037252903 ], "metallic": 0.0, "roughness": 1.0, "shadow": true, "texture0": "https://raw.githubusercontent.com/UltraEngine/Documentation/master/Assets/Materials/tiles.dds" } ] } Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Solution Josh Posted January 16 Solution Share Posted January 16 Okay, I added some code so that embedded materials will be loaded correctly. It does appear that brush texcoords are not getting reloaded correctly, but I think that is a separate issue. Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Josh Posted January 16 Share Posted January 16 Ah, it was just because the brush was not being rebuilt after applying the material. This is a little bit better code: #include "UltraEngine.h" using namespace UltraEngine; int main(int argc, const char* argv[]) { //Get the displays auto displays = GetDisplays(); //Create a window auto window = CreateWindow("Ultra Engine", 0, 0, 1280, 720, displays[0], WINDOW_CENTER | WINDOW_TITLEBAR); //Load FreeImage plugin auto plg = LoadPlugin("Plugins/FITextureLoader"); //Create a world auto world = CreateWorld(); //Create a framebuffer auto framebuffer = CreateFramebuffer(window); //Create a camera auto camera = CreateCamera(world); camera->SetClearColor(0.125); camera->SetPosition(0, 1, -4); //Create light auto light = CreateBoxLight(world); light->SetRange(-10, 10); light->SetArea(15, 15); light->SetRotation(45, 35, 0); light->SetColor(2); //Create a scene auto scene = CreateMap(); //Load model auto t = CreateBoxBrush(world, 4, 4, 4); auto texture = LoadTexture("https://raw.githubusercontent.com/UltraEngine/Documentation/master/Assets/Materials/tiles.dds"); auto material = CreateMaterial(); material->SetTexture(texture); t->SetMaterial(material); t->Build(); scene->AddEntity(t); scene->Save(GetPath(PATH_DESKTOP) + "/game.sav"); t = nullptr; //Main loop while (window->Closed() == false and window->KeyDown(KEY_ESCAPE) == false) { if (window->KeyHit(KEY_SPACE)) { scene = LoadMap(world, GetPath(PATH_DESKTOP) + "/game.sav"); } world->Update(); world->Render(framebuffer); } return 0; } Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.