firat.yuzbasioglu Posted March 6, 2015 Share Posted March 6, 2015 Hi All, I have a project similar to the Unigine's Driving examples.I want to start the level into the C++ side. How can i do this? Link to comment
unclebob Posted March 6, 2015 Share Posted March 6, 2015 Hello, Firat! All you need to do is to get pointer to Unigine::Console class and then run console command "world_load" as you do in the script or in the engine's console. Unigine::Console *console = Unigine::Console::get(); console->run("world_load name_of_your_world"); Don't forget to include UnigineConsole.h file. Link to comment
firat.yuzbasioglu Posted March 9, 2015 Author Share Posted March 9, 2015 Hi Andrey, Thanks for your answer.I want to start level (game framework) inside C++ side. Can your answer be applied to my situation? Link to comment
unclebob Posted March 10, 2015 Share Posted March 10, 2015 Yup, it's possible yet you'll need to do some work. First of all, you have to have created and initialized Game instance in the code. Your task is to call its loadLevel method. There might be many ways how to call it. For example, you can write a simple function in UnigineScript which will do the job and will take one string argument like this: // UnigineScript Game game = ...; // have to be initialized (via startup arguments or manually) void cppLoadLevel(string name) { if(game == NULL) return; game.loadLevel(name); } // C++ Unigine::Engine *engine = Unigine::Engine::get(); if(engine->isWorldLoaded() && engine->isWorldFunction("cppLoadLevel",1)) { engine->runWorldFunction(Unigine::Variable("cppLoadLevel"),Unigine::Variable("MyLevelName")); } Link to comment
Paul.Brodin Posted March 10, 2015 Share Posted March 10, 2015 sorry,didnt following that i can see in some of the c++ examples things like TrackerTrack track = tracker.loadTrack("samples/tracker/tracks/materials_00.track"); can i get access to something like that, in the same sort of way that ive got access to the players Player myCamera = Player.create(editor.getNode(iNodeID)); Game game = Game.get(); game.setPlayer(myCamera); i cant find the Tracker classes from visual studio, Link to comment
unclebob Posted March 10, 2015 Share Posted March 10, 2015 Tracker is high-level system written entirely on UnigineScript. So the only possible way to interact between C++/C# and Tracker is to call functions from UnigineScript or from C++. Here's how to export and call C++ function from UnigineScript: https://developer.unigine.com/en/docs/1.0/cpp_api/usage/functions And I showed above how to call UnigineScript function from C++, also we have a C++ sample located in source\samples\Api\Scripts\Callbacks. Link to comment
firat.yuzbasioglu Posted March 16, 2015 Author Share Posted March 16, 2015 Hi Andrey, Thanks for your answer.I have one question about where to call your UnigineScript code. Do i put your uniginescript code into the level cpp file? Link to comment
silent Posted March 16, 2015 Share Posted March 16, 2015 Hi Firat, You should keep UnigineScript code separetely from the C++ code (please, don't mix them up!). You can also check our documentation on Callbacks. 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
firat.yuzbasioglu Posted March 20, 2015 Author Share Posted March 20, 2015 Hi Silent, Thanks for your answer.But i dont mean it.I know to separate UnigineScript code from the C++ code.I asked where i put code snippets that uncleboo suggests. Do i have to put it into level file or somewhere else? Link to comment
unclebob Posted March 21, 2015 Share Posted March 21, 2015 Firat! Usually, level logic is located in the world script. So if you have level.world then you need level.cpp file which will contain world script. Inside that file you can write your code snippets. We have a cool article about "where to out your code" here: https://developer.unigine.com/en/docs/1.0/code/execution_sequence/code_update Link to comment
Recommended Posts