select node

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.
Post Reply
YankzzDev
Posts: 23
Joined: Wed Oct 05, 2011 4:37 am
Location: Indonesia

select node

Post by YankzzDev »

hi, sorry to disturb again...

what the different between AnimatedMeshSceneNode and IAnimatedMesh?

i load my file with IAnimatedMesh.. but i can't use getposition in IAnimatedMesh...

here is my project preview:
preview wrote: Image


Image


Image


Image


Image
i want to ask about load mesh...

u can see in my preview have load file mesh menu strip..
it use for load a mesh file and show in the irrlicht engine..

i use IAnimatedMesh to load it..

and here is my code for loading it..

Code: Select all

 
if (!mesh1.isEmpty())
         {
                 if(this->getIrrlichtWidget()->getIrrlichtDevice())
                 {
                         ISceneManager *smgr = this->getIrrlichtWidget()->getIrrlichtDevice()->getSceneManager();
                         IVideoDriver *driver = this->getIrrlichtWidget()->getIrrlichtDevice()->getVideoDriver();
                         //Just display a simple mesh
                         IAnimatedMesh *mesh = smgr->getMesh(qPrintable(mesh1));
                         //vector3df nodePosition = mesh->getPosition();
 
                         
                         if (!mesh)
                         {
                                 this->getIrrlichtWidget()->getIrrlichtDevice()->drop();
                         }
                         IAnimatedMeshSceneNode *node = smgr->addAnimatedMeshSceneNode(mesh);
                         if (node)
                         {
                                 node->setMaterialFlag(EMF_LIGHTING, false);
                                 node->setMD2Animation(scene::EMAT_STAND);                               
                                 if (!texture.isEmpty())
                                 {
                                         node->setMaterialTexture( 0, driver->getTexture(qPrintable(texture)));
                                 }
                         }
                 }
         }
         else
         {
                this->getIrrlichtWidget()->getIrrlichtDevice()->drop();
         }
 

mesh1 is file path where the mesh file i located...

and after i load the mesh, it will show the mesh file in the left treeview (p.s you can see it in my preview too)..

and i click the text in the treeview, in right hand side about properties.. it will show the properties of this mesh..

my problem is how to let the treeview know which one of the mesh i will select..

for example:
i load 10 mesh with 10 name:
sydney1
sydney2
sydney3
sydney4
sydney5
sydney6
sydney7
sydney8
sydney9
sydney10

i want if i select sydney8 in the treeview, the irrlicht engine know that i select this mesh and return the position of this file..

the mesh have a array? so each time i load a mesh and put in a array, and i can call it back..
Nobody is Perfect!!
YankzzDev
Posts: 23
Joined: Wed Oct 05, 2011 4:37 am
Location: Indonesia

Re: select node

Post by YankzzDev »

i want know the logically of the code..

p.s. i use QT and irrlicht engine to make that..
Nobody is Perfect!!
YankzzDev
Posts: 23
Joined: Wed Oct 05, 2011 4:37 am
Location: Indonesia

Re: select node

Post by YankzzDev »

i figured it out.. i have use AnimatedMeshSceneNode in my code..

in this line

Code: Select all

 
 IAnimatedMeshSceneNode *node = smgr->addAnimatedMeshSceneNode(mesh);
 
 
Nobody is Perfect!!
YankzzDev
Posts: 23
Joined: Wed Oct 05, 2011 4:37 am
Location: Indonesia

Re: select node

Post by YankzzDev »

when i use this code:

Code: Select all

 
vector3df nodePosition = node->getPosition();
ui->LineEdit_X->setText(nodePosition.Y);
 
and i produced this error..

error C2664: 'QLineEdit::setText' : cannot convert parameter 1 from 'irr::f32' to 'const QString &'

how to convert it?



error C2664: 'QLineEdit::setText' : cannot convert parameter 1 from 'irr::f32' to 'const QString &'
Nobody is Perfect!!
CuteAlien
Admin
Posts: 9930
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: select node

Post by CuteAlien »

YankzzDev wrote: what the different between AnimatedMeshSceneNode and IAnimatedMesh?
The mesh contains the geometry data - the polygons (as vertices and indices to the vertices), the materials to be used and in case of animated meshes the animation data.
The SceneNode contains the position, rotation and scale where you place a mesh into your scene. In case of animation-nodes it also contains for example the current frame.
Check the Wiki, it has more information: http://www.irrlicht3d.org/wiki/index.ph ... ommonTerms
YankzzDev wrote: error C2664: 'QLineEdit::setText' : cannot convert parameter 1 from 'irr::f32' to 'const QString &'
The error tells you that QString does not take floating-point numbers. So first you look up in the documentation which type of parameters it accepts (strings likely work...). Then you find functions to convert a irr::f32 to an accepted type. Irrlicht can do for example convert a float to a stringc. And a stringc can return a irr::c8* and if you continue looking you'll find that this is identical to a char* which is what you probably need. If you think a little which class likely offers which conversions you find your way from one type to another mostly quick.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
YankzzDev
Posts: 23
Joined: Wed Oct 05, 2011 4:37 am
Location: Indonesia

Re: select node

Post by YankzzDev »

thanks for the reply.. but i still don't understand..
please tell me a sample of code from how to convert from f32 to stringW ?

Code: Select all

 
  vector3df nodePosition = node->getPosition();
  core::stringw s1 = nodePosition.Y();
 
i get this error from this code..
Nobody is Perfect!!
YankzzDev
Posts: 23
Joined: Wed Oct 05, 2011 4:37 am
Location: Indonesia

Re: select node

Post by YankzzDev »

i have solved it...

Here is my code..


Code: Select all

 
vector3df nodePosition = node->getPosition();
 
core::stringw X1 = core::stringw(nodePosition.X).c_str();
QString X2 = QString::fromWCharArray (X1.c_str ());
ui->LineEdit_X->setText(X2);
 
core::stringw X1 = core::stringw(nodePosition.X).c_str();
this line for converting from f32 to stringw

QString X2 = QString::fromWCharArray (X1.c_str ());
this line for converting from stringw to qstring

ui->LineEdit_X->setText(X2);
this line for set the value to the text
Nobody is Perfect!!
YankzzDev
Posts: 23
Joined: Wed Oct 05, 2011 4:37 am
Location: Indonesia

Re: select node

Post by YankzzDev »

YankzzDev wrote:
mesh1 is file path where the mesh file i located...

and after i load the mesh, it will show the mesh file in the left treeview (p.s you can see it in my preview too)..

and i click the text in the treeview, in right hand side about properties.. it will show the properties of this mesh..

my problem is how to let the treeview know which one of the mesh i will select..

for example:
i load 10 mesh with 10 name:
sydney1
sydney2
sydney3
sydney4
sydney5
sydney6
sydney7
sydney8
sydney9
sydney10

i want if i select sydney8 in the treeview, the irrlicht engine know that i select this mesh and return the position of this file..

the mesh have a array? so each time i load a mesh and put in a array, and i can call it back..
can help me with this question?

and how to clear the scene? for example i have loaded 5 AnimatedMeshSceneNode.. how to clear it all and back to no load any AnimatedMeshSceneNode ?

and how to select AnimatedMeshSceneNode using mouse click and the model will show Wireoverlay? if i have more than 1 model?
Nobody is Perfect!!
YankzzDev
Posts: 23
Joined: Wed Oct 05, 2011 4:37 am
Location: Indonesia

Re: select node

Post by YankzzDev »

no need the mouse click event.. but how to let the mouse now which the model i selected? like in the irredit?
Nobody is Perfect!!
CuteAlien
Admin
Posts: 9930
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: select node

Post by CuteAlien »

Please do check the examples coming with Irrlicht. "07. Collision" will help with selecting objects.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
YankzzDev
Posts: 23
Joined: Wed Oct 05, 2011 4:37 am
Location: Indonesia

Re: select node

Post by YankzzDev »

ok...
Nobody is Perfect!!
Post Reply