Translation and rotation

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Anthony
Posts: 121
Joined: Sun Jan 09, 2011 12:03 pm

Post by Anthony »

Have never used two smgrs yet but I think you have to do something like:

Code: Select all

driver->beginScene(true, true, video::SColor(0,100,100,100));
smgr1->drawAll();
driver->endScene();

driver->beginScene(false, false, video::SColor(0,100,100,100));
smgr2->drawAll();
driver->endScene();
It's a long shot
No :shock: I am no noob, just checking if your not one too :roll:

Thanks to Niko and all others that made Irrlicht possible.
wsw1231
Posts: 148
Joined: Fri Oct 01, 2010 7:55 am

Post by wsw1231 »

I think using separate scene manager may not do the job.
Using 2 scene managers means there should be 2 cameras.
So confused -,-

Code: Select all

#include <irrlicht.h> 

using namespace irr; 

using namespace core; 
using namespace scene; 
using namespace video; 
using namespace io; 
using namespace gui; 


#ifdef _IRR_WINDOWS_ 
#pragma comment(lib, "Irrlicht.lib") 
#pragma comment(linker, "/subsystem:windows /ENTRY:mainCRTStartup") 
#endif 

int main() 
{ 

   IrrlichtDevice *device = 
      createDevice( video::EDT_OPENGL, dimension2d<u32>(640, 480), 16, 
         false, false, false, 0); 

   if (!device) 
      return 1; 

   device->setWindowCaption(L"Hello World! - Irrlicht Engine Demo"); 

   IVideoDriver* driver = device->getVideoDriver(); 
   ISceneManager* smgr = device->getSceneManager(); 
   IGUIEnvironment* guienv = device->getGUIEnvironment(); 

   ISceneManager* smgr2 = smgr->createNewSceneManager();


   guienv->addStaticText(L"Hello World! This is the Irrlicht Software renderer!", 
      rect<s32>(10,10,260,22), true); 

   ICameraSceneNode *camera=smgr->addCameraSceneNodeFPS(0, 100.0f, .3f, -1, 0, 0, false, 3.f); 
   camera->setPosition(core::vector3df(0,0,-50)); 
   camera->setTarget(core::vector3df(0,0,0)); 
   device->getCursorControl()->setVisible(false); 




   smgr->addLightSceneNode(0, core::vector3df(200,200,200),
		video::SColorf(.3f,.3f,.3f),2000);
	//smgr->setAmbientLight(video::SColorf(0.3f,0.3f,0.3f));
 

   

   ISceneNode* n1=smgr->addCubeSceneNode();
   n1->setMaterialTexture(0, driver->getTexture("../../media/portal1.bmp"));

   ISceneNode* n2=smgr2->addCubeSceneNode();
   n2->setMaterialTexture(0, driver->getTexture("../../media/fire.bmp"));

   ICameraSceneNode *camera2=smgr2->addCameraSceneNodeFPS(0, 100.0f, .3f, -1, 0, 0, false, 3.f); 
   camera2->setPosition(core::vector3df(0,0,-50)); 
   camera2->setTarget(core::vector3df(0,0,0)); 



   while(device->run()) 
   { 
      driver->beginScene(true, true, SColor(255,100,101,140)); 
      smgr->drawAll(); 
      guienv->drawAll(); 
	  smgr2->drawAll();
	  driver->endScene(); 
	 
   } 

   device->drop(); 

   return 0; 
} 

Anthony
Posts: 121
Joined: Sun Jan 09, 2011 12:03 pm

Post by Anthony »

Code: Select all

smgr2->setActiveCamera( smgr1->getActiveCamera() );
maybe this could work. Taking the active camera of the first scene and set it active to the second.

or;

Code: Select all

   ICameraSceneNode *camera=smgr->addCameraSceneNodeFPS(0, 100.0f, .3f, -1, 0, 0, false, 3.f); 
   smgr->setActiveCamera( camera );
Both actually do the same thing
No :shock: I am no noob, just checking if your not one too :roll:

Thanks to Niko and all others that made Irrlicht possible.
wsw1231
Posts: 148
Joined: Fri Oct 01, 2010 7:55 am

Post by wsw1231 »

Anthony,
have you run the code?

Do you know why the texture cannot be loaded in smgr2.....?
Anthony
Posts: 121
Joined: Sun Jan 09, 2011 12:03 pm

Post by Anthony »

nope, I don't know. But why are you adding a cube twice? Shouldn't you have the cube in smgr1 and then that pivot of the cube (I assume this is what you are trying) in smgr2 to render it over the cube.

And nope I haven't run it.
No :shock: I am no noob, just checking if your not one too :roll:

Thanks to Niko and all others that made Irrlicht possible.
wsw1231
Posts: 148
Joined: Fri Oct 01, 2010 7:55 am

Post by wsw1231 »

Hey!!! It seems the arrow is in front of the cube now:D
But......I still dont know why the texture cannot be loaded in smgr2 =,=

Code: Select all

#include <irrlicht.h> 

using namespace irr; 

using namespace core; 
using namespace scene; 
using namespace video; 
using namespace io; 
using namespace gui; 


#ifdef _IRR_WINDOWS_ 
#pragma comment(lib, "Irrlicht.lib") 
#pragma comment(linker, "/subsystem:windows /ENTRY:mainCRTStartup") 
#endif 

int main() 
{ 

   IrrlichtDevice *device = 
      createDevice( video::EDT_OPENGL, dimension2d<u32>(640, 480), 16, 
         false, false, false, 0); 

   if (!device) 
      return 1; 

   device->setWindowCaption(L"Hello World! - Irrlicht Engine Demo"); 

   IVideoDriver* driver = device->getVideoDriver(); 
   ISceneManager* smgr = device->getSceneManager(); 
   IGUIEnvironment* guienv = device->getGUIEnvironment(); 

   ISceneManager* smgr2 = smgr->createNewSceneManager();


   guienv->addStaticText(L"Hello World! This is the Irrlicht Software renderer!", 
      rect<s32>(10,10,260,22), true); 

   ICameraSceneNode *camera=smgr->addCameraSceneNodeFPS(0, 100.0f, .3f, -1, 0, 0, false, 3.f); 
   camera->setPosition(core::vector3df(0,0,-50)); 
   camera->setTarget(core::vector3df(0,0,0)); 
   device->getCursorControl()->setVisible(false); 




   smgr->addLightSceneNode(0, core::vector3df(200,200,200),
		video::SColorf(.3f,.3f,.3f),2000);
	//smgr->setAmbientLight(video::SColorf(0.3f,0.3f,0.3f));
 

   

   ISceneNode* n1=smgr->addCubeSceneNode();
   n1->setMaterialTexture(0, driver->getTexture("../../media/portal1.bmp"));

   ISceneNode * arrowX = smgr2->addAnimatedMeshSceneNode(smgr2->addArrowMesh("arrowX",
		SColor(255, 255, 0, 0), SColor(255, 255, 0, 0),4,8,1.0f,0.6f,0.05f,0.2f)); 
	arrowX->setMaterialFlag(video::EMF_LIGHTING, true); 
	arrowX->setScale(vector3df(10, 10, 10));
	arrowX->setRotation(vector3df(0,0,-90));
	arrowX->setMaterialFlag(video::EMF_ZBUFFER, false);

   ICameraSceneNode *camera2=smgr2->addCameraSceneNodeFPS(0, 100.0f, .3f, -1, 0, 0, false, 3.f); 
   camera2->setPosition(core::vector3df(0,0,-50)); 
   camera2->setTarget(core::vector3df(0,0,0)); 
   smgr2->setActiveCamera( smgr->getActiveCamera() );



   while(device->run()) 
   { 
      driver->beginScene(true, true, SColor(255,100,101,140)); 
      smgr->drawAll(); 
      guienv->drawAll(); 
	  smgr2->drawAll();
	  driver->endScene(); 
	 
   } 

   device->drop(); 

   return 0; 
} 

Anthony
Posts: 121
Joined: Sun Jan 09, 2011 12:03 pm

Post by Anthony »

Don't know that either but do you need it? Think you are creating some sort of editor where you have pivots wich only are coloured. If so you don't need any texture in that manager.

Have seen some topic about it though, can't remember how the thread is called or in wich forum.
No :shock: I am no noob, just checking if your not one too :roll:

Thanks to Niko and all others that made Irrlicht possible.
wsw1231
Posts: 148
Joined: Fri Oct 01, 2010 7:55 am

Post by wsw1231 »

Code: Select all

arrowX->setMaterialFlag(video::EMF_LIGHTING, false); 
This can solve!!!
Anthony
Posts: 121
Joined: Sun Jan 09, 2011 12:03 pm

Post by Anthony »

yes, well it depends on how you colour the things.

If you use the S3DVertex colour that works.

If you use it with a light (diffuse, emissive or ambient...don't know) you need lighting ofcourse.

Think the first would be the fastest to use. Anyone, please correct me if I am wrong.
No :shock: I am no noob, just checking if your not one too :roll:

Thanks to Niko and all others that made Irrlicht possible.
wsw1231
Posts: 148
Joined: Fri Oct 01, 2010 7:55 am

Post by wsw1231 »

Now I can do this
Image


But now, the problem for me to handle is to let the program now I am clicking on one of the arrows to perform object translation about one of the axes.

I think I need to add another collision manager for smgr2

Any suggestions?
Post Reply