liu.yan Posted January 3, 2017 Share Posted January 3, 2017 Command “world_load” seems an asynchronous call. And I want to do something right after this command call. Is there a synchronous version of this command, so the calling thread would be blocked until the command is finished? Link to comment
liu.yan Posted January 3, 2017 Author Share Posted January 3, 2017 Or is there some kind of "stop- and-waiting" mechanism for asynchronous commands, by which I can wait for an event to make sure the asynchronous command is done. Link to comment
silent Posted January 6, 2017 Share Posted January 6, 2017 liu.yan, There is no such command available. You can try to check if resources are stopped loading via FileSystem queues methods: https://developer.unigine.com/en/docs/2.3.1/api/library/filesystem/class.filesystem Thanks! How to submit a good bug report --- FTP server for test scenes and user uploads: ftp://files.unigine.com user: upload password: 6xYkd6vLYWjpW6SN Link to comment
lin.xianming Posted January 31, 2017 Share Posted January 31, 2017 Hello Andrey, I attempt to load a new world and then get the information of the world. So I put the follow codes into CMySystemLogic::Update() mothed: int CMySystemLogic::update() { ...... if (bl) { Console::get()->run("world_load ../data/UnigineEng/UnigineEng"); int nNum = Editor::get()->getNumNodes();//nNum is always equal to zero bl = FALSE; } ...... } I do load the world successfully(I can see the objects),but I can't get the currect number of the nodes in the world. Since the command “world_load” is an asynchronous call,It seems understandable. But when I add the code: "pConsole->flush()" as follows: Console::get()->run("world_load ../data/UnigineEng/UnigineEng"); Console::get()->flush(); int nNum = Editor::get()->getNumNodes();//nNum is always equal to zero The result turns to the opposite side: I can see nothing from the output window, but I get the currect return of getNumNodes(); 1>Is it a proper response? what dose "pConsole->flush()" exactly mean? 2>What is the proper way to reach my goal: load a new world and then get the information of the world immediately. Thanks Link to comment
silent Posted January 31, 2017 Share Posted January 31, 2017 Hi Lin, There is no way to get info immediately. You can try to parse .world XML manually to get the nodes info. flush() will try to execute all the console command in the current frame rather than wait for the next one. How to submit a good bug report --- FTP server for test scenes and user uploads: ftp://files.unigine.com user: upload password: 6xYkd6vLYWjpW6SN Link to comment
lin.xianming Posted January 31, 2017 Share Posted January 31, 2017 I try the exact same codes in CMySystemLogic::init() mothed. The outcome of the first one without "flush()" is same: loading is successful,but the return number of nodes is NOT correct. but outcome of the second one with "flush()" is perfect: Both succeeded. Link to comment
silent Posted January 31, 2017 Share Posted January 31, 2017 Hi Lin, Have you tried to get this info in AppWorldLogic instead? SystemLogic is designed for different purpose and may not contain such information. How to submit a good bug report --- FTP server for test scenes and user uploads: ftp://files.unigine.com user: upload password: 6xYkd6vLYWjpW6SN Link to comment
lin.xianming Posted January 31, 2017 Share Posted January 31, 2017 What I want to figure out is Not only the numble of the nodes but also the further details of the nodes(e.g mesh and verteics). So I don't think .XML can give me all of them. Link to comment
lin.xianming Posted January 31, 2017 Share Posted January 31, 2017 I don't think there are some major differences between WorldLogic and SystemLogic. They are at the same thread, aren't they? /// Engine main loop. Replaces while (isDone() == 0) { update(): render(); swap(); } commands. virtual void main(SystemLogic *system = NULL, WorldLogic *world = NULL, EditorLogic *editor = NULL) = 0; Link to comment
ded Posted January 31, 2017 Share Posted January 31, 2017 Hi Lin, As Andrey said, Console::flush() will execute internal command queue immediately, otherwise, the result of some commands may come to effect only the next frame. The sequence: Console::get()->run("world_load scene"); Console::get()->flush(); both in SystemLogic::init() and SystemLogic::update() should fully load the scene and prepare it for any interrogations you have in mind. I've just tried both cases and they've worked fine for me. If you still have issues with loading the scene in the update(), please provide us with a small test scene so that we can reproduce the problem. You're right, the system script and the world script are executed in the main thread. They differ mainly in a callback set and their semantics. In Unigine Script they also differ in their lifetime: system script has a lifetime of the running engine instance and the world script has a lifetime of a world. Link to comment
Recommended Posts