really quick question concerning nodes from .irr file

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
kennypu666
Posts: 26
Joined: Thu Apr 26, 2007 6:57 am

really quick question concerning nodes from .irr file

Post by kennypu666 »

Hello,
I am basicly just trying to control a node that is created in a .irr scene. Just so I know what I am doing, I am just trying to have a sphere created in IrrEdit rotate. The concerning code is right here:

Code: Select all

ISceneNode* sphere1 = 0;
	cout<<"Size of nodes: "<<nodes.size()<<endl;
	for( u32 i=0; i < nodes.size() ; ++i)
	{
         ISceneNode * node = nodes[i];
  .
  .
  .
                 case ESNT_SPHERE:
                      sphere1 = node;
                      selector = smgr->createTriangleSelector(((IMeshSceneNode*)node)->getMesh(),node);
                       cout<<"sphere loaded";
                      break;
  .
  .
  .
	int i = 0;
	while( device->run())
	{
           ++i;
        sphere1->setRotation(vector3df(i,i,0));      
		driver->beginScene(true, true, SColor(255,100,101,140));

		smgr->drawAll();
		guienv->drawAll();

		driver->endScene();
	}
	device->drop();

	return 0;
I did not post the whole code because they are irrelevant. I am assuming the problem lies when I initialize sphere1 and/or when I try to set the rotation. The code does run fine If I leave the setRotation() code, but I am not confident that I did the whole process correctly since I am still iffy with pointer stuff.. If somebody can correct me, it would be very much appreciated. Thank you!!
ken
Brainsaw
Posts: 1177
Joined: Wed Jan 07, 2004 12:57 pm
Location: Bavaria

Post by Brainsaw »

What's the exact problem? No rotation? Crash? For finding a single node in an irr scene I don't iterate the scene, I just use the "getSceneNodeFromName" or "...fromID" in (IIRC) ISceneManager. You just have to give a name (or an ID) to your sphere for that method, and (of course) check the returned pointer for NULL.
Dustbin::Games on the web: https://www.dustbin-online.de/

Dustbin::Games on facebook: https://www.facebook.com/dustbingames/
Dustbin::Games on twitter: https://twitter.com/dustbingames
kennypu666
Posts: 26
Joined: Thu Apr 26, 2007 6:57 am

Post by kennypu666 »

Brainsaw wrote:What's the exact problem? No rotation? Crash? For finding a single node in an irr scene I don't iterate the scene, I just use the "getSceneNodeFromName" or "...fromID" in (IIRC) ISceneManager. You just have to give a name (or an ID) to your sphere for that method, and (of course) check the returned pointer for NULL.
thank you for replying. Sorry I left out the exact problem. The program crashes when I have the setRotation() code in there. So I would add a name/ID to the sphere in irrEdit, then use either function to set it? eg: can I do something like (pseudo):
ISceneNode* sphere = getSceneNodeFromName("name_of_sphere");

then later on: setRotation()?
Brainsaw
Posts: 1177
Joined: Wed Jan 07, 2004 12:57 pm
Location: Bavaria

Post by Brainsaw »

Yes, that should work. But don't forget to check you scenenode for "NULL".
Dustbin::Games on the web: https://www.dustbin-online.de/

Dustbin::Games on facebook: https://www.facebook.com/dustbingames/
Dustbin::Games on twitter: https://twitter.com/dustbingames
randomMesh
Posts: 1186
Joined: Fri Dec 29, 2006 12:04 am

Post by randomMesh »

Brainsaw wrote:But don't forget to check you scenenode for "NULL".
<nitpicking_mode>
In C++98 / C++03 we use 0. NULL is ugly C. Or wait until C++0x comes out, which uses nullptr.
</nitpicking_mode>
"Whoops..."
Brainsaw
Posts: 1177
Joined: Wed Jan 07, 2004 12:57 pm
Location: Bavaria

Post by Brainsaw »

I won't deny my roots, I come from pure C so I'll stick with NULL ;)
Dustbin::Games on the web: https://www.dustbin-online.de/

Dustbin::Games on facebook: https://www.facebook.com/dustbingames/
Dustbin::Games on twitter: https://twitter.com/dustbingames
kennypu666
Posts: 26
Joined: Thu Apr 26, 2007 6:57 am

Post by kennypu666 »

hmm... thank you, I got it it to run without crashing now. However, now, the sphere is not lighted for some reason, all though there are lights in the scene (created using irrEdit, I did not set the lights in the programming), and it does not seem to be rotating. Any thoughts? The code is still the same, just I have changed

Code: Select all

ISceneNode* sphere = node;
to

Code: Select all

ISceneNode* sphere = smgr->getSceneNodeFromName();
I know theres a parameter in that function, I'm just leaving it out. Any thoughts?
kennypu666
Posts: 26
Joined: Thu Apr 26, 2007 6:57 am

Post by kennypu666 »

sorry, can anybody think of any reasons for this behavior? I have no idea :P
Brainsaw
Posts: 1177
Joined: Wed Jan 07, 2004 12:57 pm
Location: Bavaria

Post by Brainsaw »

Are the node's material parameters correct? Just trace them to the console for testing. If that doesn't work check for all parameters of the light source.
Dustbin::Games on the web: https://www.dustbin-online.de/

Dustbin::Games on facebook: https://www.facebook.com/dustbingames/
Dustbin::Games on twitter: https://twitter.com/dustbingames
Post Reply