use a class of irrlicht and make additions how?

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
Mutter
Posts: 11
Joined: Mon Jul 10, 2006 6:05 pm

use a class of irrlicht and make additions how?

Post by Mutter »

I want to make additions to the normal SceneNode like a virtual x and y position for game purposes.
i have a struct position with x and y.

Code: Select all

class HQNode: public ISceneNode
{
public:

	position getBrettPosition(void){return pos;}
	void setBrettPosition(int newx, int newy){pos.x = newx; pos.y = newy;}

private:
	position pos;
};
HQNode* test;
if i want to call test->setBrettPosition(1, 1); it causes an error.
can't i make additions this way to classes of irrlicht?
und wieder ein deutscher :)
Saku
Posts: 158
Joined: Wed Jan 05, 2005 8:48 am
Location: Denmark

Post by Saku »

Im pretty sure you can make additons that way. I've personally made an extra camera node like that.

Did you make a 'test = new HQNode();' ?
Also I think you might have to include a constructor and such.
Call me Wice, Miami Wice!
Mutter
Posts: 11
Joined: Mon Jul 10, 2006 6:05 pm

hmm

Post by Mutter »

thx for answer...

i've done this now:

Code: Select all

class HQNode: public ISceneNode
{
public:
	HQNode() {};
	position getBrettPosition(void){return pos;}
	void setBrettPosition(int newx, int newy){pos.x = newx; pos.y = newy;}

private:
	position pos;
};
HQNode* test;

-----------------------
in main():
-----------------------
test = new HQNode();

test->setBrettPosition(1, 2);

compiler gives me 2 errors:
- no suitable standard constructor available...
- Instance of abstract class cannot be built because of
following memers:
"void irr::scene::ISceneNode::render(void)": is abstract
...

i have no clue how to solve this
und wieder ein deutscher :)
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

If you're implementing an interface (or abstract class as it is called in C++) you have to implement all pure virtual methods. These are methods which are not already implemented in the base class (read the interface class and search all methods with =0 in their declaration). You have tim implement them in your own class or otherwise it is still just an interface which cannot be instantiated. That is a good thing becauise otherwise Irrlicht would try to call render() on your node and wouldn't find a suitable method.
The constructor problem is similar. The interface defines a constructor which has to be used and therefore has to be implemented in your code. Read the API for the parameters to add.
Saku
Posts: 158
Joined: Wed Jan 05, 2005 8:48 am
Location: Denmark

Post by Saku »

yeah, I had the same experience when making my camera. Basicly you have to copy most members from the "sister classes" - I simply copied the members from the Maya cam and modified the parts needed.

GL HF ;)
Call me Wice, Miami Wice!
Mutter
Posts: 11
Joined: Mon Jul 10, 2006 6:05 pm

ok

Post by Mutter »

ill try it...

o my o my o my :shock: will be some work...lets see

thx
und wieder ein deutscher :)
Post Reply