yuwen.xiang Posted September 29, 2012 Posted September 29, 2012 I did it in a function for updating the camera position. function code: bool Globe::setPosition(vec3& v3) { Player* player = engine.editor->getPlayer(); Mat4 transform = player->getWorldTransform(); transform.setColumn3(3,v3); player->setWorldTransform(transform); return true; } the function is do.and return position is ok.but do this code .the camera postion is vec3(0,0,0). Unigine::Engine *engine_new = Unigine::Engine::init(UNIGINE_VERSION,argc,argv); setPosition(v3); while(engine_new->isDone() == 0) { //here position is ok. engine_new->update(); //here position is return (0,0,0);why? engine_new->render(); engine_new->swap(); } why can set the camera frist position in uniginescript init() function.but i can not set in unigine resource code. PlayerSpectator player = new PlayerSpectator(); player.setPosition(vec3(-3.5,0.0,1.3)); where code update ???
manguste Posted October 4, 2012 Posted October 4, 2012 When the engine is updated, the editor is updated as well. At the start the editor automatically sets the player's position based on its initial position in the world. So positioning a player in the world in a proper point will do the trick for you.
yuwen.xiang Posted October 9, 2012 Author Posted October 9, 2012 When the engine is updated, the editor is updated as well. At the start the editor automatically sets the player's position based on its initial position in the world. So positioning a player in the world in a proper point will do the trick for you. Sorry,I can't find to set the camera first position in resouce code. particular code file? thanks!
ulf.schroeter Posted October 9, 2012 Posted October 9, 2012 Set game player position within your world script unit() function
yuwen.xiang Posted October 10, 2012 Author Posted October 10, 2012 Set game player position within your world script unit() function I run the program in unigine_vc2010 project for updating resource code.not in uniginescript. worldInterpreter.cpp: node->addFunction("setPosition",node_set_position); static void node_set_position(Node *node,const Vec3 &position) { Mat4 transform = node->getTransform(); transform.setColumn3(3,position); node->setTransform(transform); } this function is not set the camera position???
manguste Posted October 22, 2012 Posted October 22, 2012 It does. The problem is, camera position can be rewritten after that. As Ulf suggested, try setting a player position in the world script init() function.
yuwen.xiang Posted November 22, 2012 Author Posted November 22, 2012 bool Globe::setPosition(vec3& v3) { Player* player = engine.editor->getPlayer(); //cameraPlayer = new PlayerSpectator(); Mat4 transform = player->getWorldTransform(); transform.m00 = -0.996779; transform.m01 = -0.0374037; transform.m02 = 0.0709425; transform.m10 = 0.080199; transform.m11 = -0.464884; transform.m12 = 0.881732; transform.m20 = 4.76964e-009; transform.m21 = 0.884581; transform.m22 = 0.466386; transform.setColumn3(3,v3); player->setWorldTransform(transform); if(engine.game) { engine.game->setPlayer(player); } return true; } this function code can work ok and can set the frist position.but input "editor_quit" in command console for exiting editor model ,display error,null pointer address. why???
frustum Posted November 22, 2012 Posted November 22, 2012 Because the editor's player is NULL when the editor isn't loaded.
Recommended Posts