Windows form multi-windows

Post those lines of code you feel like sharing or find what you require for your project here; or simply use them as tutorials.
Post Reply
thanhle
Posts: 325
Joined: Wed Jun 12, 2013 8:09 am

Windows form multi-windows

Post by thanhle »

Hi,
I'm just new to Irrlicht. About a day old. So I started to code a small gui app using C++ windows form. Anyway here is a code to show 150+ windows of the same scene.
I have also test to have more than 250 windows showing the same scene from different view.
[img]
http://s2.postimg.org/u2yzyucax/Untitled.jpg
[/img]

Irrlicht is quite simple to use. Congratulation.

Here's the code:

Code: Select all

 
 
               lstForm = gcnew  List<RenderForm^>;    //A list of render windows.
               lstCamera = new irr::core::list<ICameraSceneNode*>();    //A list of cameras.
 
               irr::SIrrlichtCreationParameters params;
               params.WindowId = (void *)this->Handle;         //I point this to the MDI windows.
               params.DriverType = video::EDT_DIRECT3D9;
               params.EventReceiver = 0;
               params.AntiAlias = true;
               device = createDeviceEx(params);      //The device is create but it is hidden.
                  
               if (!device)
                   return;
 
               driver = device->getVideoDriver();     
               smgr = device->getSceneManager();
 
               //Get mesh from path. 
               //I'm using hardcode path since I'm not familiar with the relative path convention in irrlicht yet.
               IAnimatedMesh* mesh = smgr->getMesh("D:\\ProjectCodes\\Irrlicht\\NVuDu\\Project1\\Debug\\media\\sydney.md2");   
               if (!mesh)
               {
                device->drop();
                return;
                }
 
                IAnimatedMeshSceneNode* node = smgr->addAnimatedMeshSceneNode( mesh );
                if (node)
                {
                    node->setMaterialFlag(EMF_LIGHTING, false);
                    node->setMD2Animation(scene::EMAT_STAND);
                    node->setMaterialTexture( 0, driver->getTexture("D:\\ProjectCodes\\Irrlicht\\NVuDu\\Project1\\Debug\\media\\sydney.bmp") );
                }
 
                smgr->addCameraSceneNode(0, vector3df(0,30,-40), vector3df(0,5,0));
 
                 //Rendering loop.
                 //Well since I use the interface thread to do the drawing so I use the DoEvent statement. 
                          
               while (device->run())
                {
                    if(lstForm->Count > 0)   //Render if there a render form in the list of forms.
                    {
                        lstCamera->begin();
                        list<ICameraSceneNode *>::Iterator it;
                        it = lstCamera->begin();
                        for(int i = 0; i < lstForm->Count; i++)
                        {
                            if(!lstForm[i]->IsDisposed)
                            {
                                //Begin render to the window form handle.
                                driver->beginScene( true, true, SColor(255,100,101,140), SExposedVideoData((void*)lstForm[i]->Handle));   
                                
                                //Using the camera view      
                                smgr->setActiveCamera(*it);
                                it++;
                                smgr->drawAll();
                                driver->endScene();
 
                                Threading::Thread::Sleep(1);
                                Application::DoEvents();
                            }
                            else
                            {
                                lstForm->RemoveAt(i);
                                if(i > 0) i--;
                            }         
                        }     
                    }
                    Threading::Thread::Sleep(1);
                    Application::DoEvents();
                }
 
               device->closeDevice();
           device->drop();
 
One question to the expert. Can we get the object in the list by index instead of iterator? e.g. ICameraSceneNode *cam = lstCamera[10];

Cheers,
vu
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Re: Windows form multi-windows

Post by hybrid »

No, this is just a list. Use an array instead for direct access.
thanhle
Posts: 325
Joined: Wed Jun 12, 2013 8:09 am

Re: Windows form multi-windows

Post by thanhle »

Thanks hybrid,
Coming from C# background so I wasn't aware of dynamic list in C++. Now that I learn there is a thing call vector.
Cheers
vu
mant
Posts: 125
Joined: Sun Jan 27, 2013 3:38 pm

Re: Windows form multi-windows

Post by mant »

Just have a look at TUT9 for your question (mình cũng mới học :D cùng trao đổi nào)

Code: Select all

 // add a camera scene node
    Camera[0] = smgr->addCameraSceneNodeMaya();
    Camera[0]->setFarValue(20000.f);
    // Maya cameras reposition themselves relative to their target, so target the location
    // where the mesh scene node is placed.
    Camera[0]->setTarget(core::vector3df(0,30,0));
 
    Camera[1] = smgr->addCameraSceneNodeFPS();
    Camera[1]->setFarValue(20000.f);
    Camera[1]->setPosition(core::vector3df(0,0,-70));
    Camera[1]->setTarget(core::vector3df(0,30,0));
 
    setActiveCamera(Camera[0]);
mant
Posts: 125
Joined: Sun Jan 27, 2013 3:38 pm

Re: Windows form multi-windows

Post by mant »

thanhle wrote:Thanks hybrid,
Coming from C# background so I wasn't aware of dynamic list in C++. Now that I learn there is a thing call vector.
Cheers
vu
Read this if you want to use STL in game programming :D, or you may want to use some data structures come with Irrlicht (see Irrlicht irrlicht 1.71 beginner guide for more)
http://software.intel.com/en-us/article ... -for-games
thanhle
Posts: 325
Joined: Wed Jun 12, 2013 8:09 am

Re: Windows form multi-windows

Post by thanhle »

Thanks mant.
I'm trying to develop a discrete event simulation software in my free time. Irrlicht seems perfect for that.
Well only if I have freetime :). Goodluck with irrlicht programming :).
vu
Post Reply