How to return an IAnimatedMeshSceneNode

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
Necrozard
Posts: 14
Joined: Sat Jul 05, 2008 8:49 pm

How to return an IAnimatedMeshSceneNode

Post by Necrozard »

Hi!

Well, im doing a Function for the pj, i want it to return the IAnimatedMeshSceneNode *hero so i can check input, and more, in the Main Loop, this is a little part of the function:

int Pj(IrrlichtDevice *device,IVideoDriver *driver,ISceneManager *smgr)
{
struct{
int HP=1500;
int MP=540;
} self;

IAnimatedMeshSceneNode *hero = smgr->addAnimatedMeshSceneNode(smgr->getMesh("../media/dwarf2.x"));
hero->setMaterialFlag(EMF_LIGHTING,false);
hero->setMaterialTexture(0,driver->getTexture("../media/dwarf2.jpg"));
return hero;
}

Thats is what i need: return hero;

but the function returns INT, so i cant do it.

i tried doing: IAnimatedMeshSceneNode Pj(Irr...)
Like it returns an IAnimatedMeshSceneNode but it doesnt work, can help me please?

Thanks.
Ion Dune
Posts: 453
Joined: Mon Nov 12, 2007 8:29 pm
Location: California, USA
Contact:

Post by Ion Dune »

Did you use

Code: Select all

IAnimatedMeshSceneNode Pj(Irr...)
or

Code: Select all

IAnimatedMeshSceneNode* Pj(Irr...)
You need to use a pointer.
Seven
Posts: 1034
Joined: Mon Nov 14, 2005 2:03 pm

Post by Seven »

cant you just change

int Pj(IrrlichtDevice *device,IVideoDriver *driver,ISceneManager *smgr)

to

IAnimatedMeshSceneNode* Pj(IrrlichtDevice *device,IVideoDriver *driver,ISceneManager *smgr)
Necrozard
Posts: 14
Joined: Sat Jul 05, 2008 8:49 pm

Post by Necrozard »

Thank you very much guys for the answers!
rogerborg
Admin
Posts: 3590
Joined: Mon Oct 09, 2006 9:36 am
Location: Scotland - gonnae no slag aff mah Engleesh
Contact:

Re: How to return an IAnimatedMeshSceneNode

Post by rogerborg »

Necrozard wrote: struct{
int HP=1500;
int MP=540;
} self;
Incidentally, this is not standard C++, either ANSI/ISO/IEC 14882:1998 or (AFAIK) 2003. Out of interest, does this actually compile for you, and if so, with what compiler?
Please upload candidate patches to the tracker.
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
Necrozard
Posts: 14
Joined: Sat Jul 05, 2008 8:49 pm

Post by Necrozard »

Im using Dev-cpp, i think im going to download Code::blocks, and... which is the new syntaxis for STRUCT?
gogo
Posts: 65
Joined: Tue Apr 15, 2008 1:04 am

rep

Post by gogo »

Code: Select all

IrrlichtDevice* device;
IVideoDriver* driver;
ISceneManager* smgr;

class Hero {
int hp, mp;
IAnimatedMeshSceneNode *hero;
public:
Hero();
IAnimatedMeshSceneNode* returnNode();
} self;
Hero::Hero()
{
hp=1500;mp=540;
hero = smgr->addAnimatedMeshSceneNode(smgr->getMesh("../media/dwarf2.x")); 
hero->setMaterialFlag(EMF_LIGHTING,false); 
hero->setMaterialTexture(0,driver->getTexture("../media/dwarf2.jpg")); 
}
Hero::IAnimatedMeshSceneNode* returnNode()
{
	return hero;
}
You can also get node by "self.hero."
Post Reply