Problem with creating an ISceneNode

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
Peter Müller
Posts: 292
Joined: Sun Mar 14, 2004 5:28 pm
Location: Germany
Contact:

Problem with creating an ISceneNode

Post by Peter Müller »

Code: Select all

// This method initializes the CObject object with the values, which were given in as parameters
bool CObject::init(CIrrlichtVar *ivIrrlicht, CList *lObjects, vector3df *vMotion, double dMass, double dGravitationRange)
{
 if ( (!ivIrrlicht) || (!ivIrrlicht->device) || (!lObjects) || (!vMotion) )
  return false;

 this->ivIrrlicht = ivIrrlicht;

 /////////////////////////////////////////////////
 If I'm creating an local object, it will be displayed on screen
 /////////////////////////////////////////////////

 /*ISceneNode *snLocalNode = this->ivIrrlicht->smgr->addTestSceneNode();
 snLocalNode->setPosition(vector3df( RANDOM_DOUBLE * RANDOM_DOUBLE * MULTI_FACTOR, RANDOM_DOUBLE * RANDOM_DOUBLE * MULTI_FACTOR, RANDOM_DOUBLE * RANDOM_DOUBLE * MULTI_FACTOR));
 snLocalNode->setMaterialTexture(0, this->ivIrrlicht->driver->getTexture("t351sml.jpg"));


 /////////////////////////////////////////////////
 But if I want to save it as an member attribute, or creating it in this, the ISceneNode ist calculated, but not displayed on screen
 /////////////////////////////////////////////////

 this->snNode = snLocalNode;

 // Creating the SceneNode
 this->snNode = this->ivIrrlicht->smgr->addTestSceneNode();
 this->snNode->setPosition(vector3df( RANDOM_DOUBLE * RANDOM_DOUBLE * MULTI_FACTOR, RANDOM_DOUBLE * RANDOM_DOUBLE * MULTI_FACTOR, RANDOM_DOUBLE * RANDOM_DOUBLE * MULTI_FACTOR));
 this->snNode->setMaterialTexture(0, this->ivIrrlicht->driver->getTexture("t351sml.jpg"));

 // Testausgabe der Position
 vector3df vPosition = this->snNode->getPosition();
 printf("Position des neuen Objektes [%.1f,%.1f,%.1f]\n", vPosition.X, vPosition.Y, vPosition.Z);


Please help!!!
http://www.games-forge.de - Die Community für Nachwuchsprogrammierer
schick
Posts: 230
Joined: Tue Oct 07, 2003 3:55 pm
Location: Germany
Contact:

Post by schick »

Its always quite hard to help you if there are only a few lines code.

1. you do not need to call this-> within a function
2. please, try to format your code


Well, if there are no exceptions, you have a logic error.
Please send me an e-mail instead of a private message.
Peter Müller
Posts: 292
Joined: Sun Mar 14, 2004 5:28 pm
Location: Germany
Contact:

Post by Peter Müller »

At fist: thanks that you helped me one more time *thanks*


If I'm creating an object like this

Code: Select all

 ISceneNode *snLocalNode = this->ivIrrlicht->smgr->addTestSceneNode(); 
 snLocalNode->setPosition(vector3df(something,something,something));
 snLocalNode->setMaterialTexture(0, tTexture); 
The node ist displayed on screen. But if I'm saving the pointer

Code: Select all

snLocalNode
in an member attribute

Code: Select all

this->snNode
The nodes weren't displayed. Can somebody imagine why?




To your answer:
1. I know, but its easier to see, where the varible is from
2. Is this formated enouth? If not, please say it
http://www.games-forge.de - Die Community für Nachwuchsprogrammierer
jox
Bug Slayer
Posts: 726
Joined: Thu Apr 22, 2004 6:55 pm
Location: Germany

Post by jox »

I find also

1. your code hard to read
2. your problem difficult to understand

sorry... :?
Peter Müller
Posts: 292
Joined: Sun Mar 14, 2004 5:28 pm
Location: Germany
Contact:

Post by Peter Müller »

hm, yes.
This code snip is really hard to read and to understand. Using many classes, which nobody else knews.

But I got it. This method isn't wrong. I think, the problem is CObject::run, because, if I'm marking it out (= /* */) the nodes were drawn.

Thanks for trying to help me, anyway.
http://www.games-forge.de - Die Community für Nachwuchsprogrammierer
Post Reply