addTestSceneNode

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.
magisterrivus
Posts: 33
Joined: Sat Aug 05, 2006 9:46 pm

addTestSceneNode

Post by magisterrivus »

Nice day/night to everybody :)

As stated in the topic, i have a question related to the TestSceneNode.

In my code i added some TestNodes within a for loop. The Problem is, that i can only access the first (or last?) SceneNode. For test purposes i tried to let all cubes rotate, but only one does. The other strange thing is that i can't count the generated cubes via getMeshBufferCount, so i needed a workaround.
My Question: Is it that only one TestSceneNode is added, no matter how often i create them, or is there a problem with my code?

Code: Select all

	int steps = 500;

	ITexture* tex = core->getVideo()->getTexture("media/stone.jpg");
	ISceneNodeAnimator* anim = core->getSceneMgr()->createRotationAnimator(vector3df(0,.5,0));

	for (int x = 0; x < 1000; x+=steps)
	{
		for (int y = 0; y < 1000; y+=steps)
		{
			for (int z = 0; z < 1000; z+=steps)
			{
				i++;			
				core->getSceneMgr()->addTestSceneNode(15,0,i,vector3df(x,y,z));
				core->getSceneMgr()->getSceneNodeFromId(i)->setMaterialTexture(0,tex);						core->getSceneMgr()->getSceneNodeFromId(i)->addAnimator(anim);		
			}
		}
	}

cout << "generated " << i << " Cubes" << endl; 
Thanks for reading and help 8)
under construction
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post by JP »

All i can see is the lack of initialisation for i. But i'm sure you just left that out the code snippet, as it wouldn't have compiled without that.... tis a strange one, can't see anything wrong! :lol:
Image Image Image
magisterrivus
Posts: 33
Joined: Sat Aug 05, 2006 9:46 pm

Post by magisterrivus »

Hi JP,

of course i have the i initialization :)

Some hours ago the forum search and i solved my problem with not showing any 3d lines with draw3dline...i had to put that fucktion...erm, function before calling the gui environment stuff :roll:
Maybe this is the same kind of problem...the code is ok, but placed wrong.

Thx anyway JP
under construction
Acki
Posts: 3496
Joined: Tue Jun 29, 2004 12:04 am
Location: Nobody's Place (Venlo NL)
Contact:

Post by Acki »

Hmm, I think the getMeshBufferCount doesn't work, because a testSceneNode has no mesh buffer(s)...

For the animation thing I think you shoud try this:

Code: Select all

i++;         
ISceneNode* node = core->getSceneMgr()->addTestSceneNode(15,0,i,vector3df(x,y,z));
node->setMaterialTexture(0,tex);                  
node->addAnimator(anim);
I don't know if this solves the problem, because your code normaly also should work...
while(!asleep) sheep++;
IrrExtensions:Image
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
magisterrivus
Posts: 33
Joined: Sat Aug 05, 2006 9:46 pm

Post by magisterrivus »

That's exactly what i did before Acki, and thought this was the problem, so i just added the TestSceneNode to the SceneManager directly.
Okay, now i took your code again, and the same thing again....somehow logically.

Is it possible that my code only clones the first cube, animates that cube and the other "clones" are just only copies of it without the possibility to animate them?
But because they are textured, they also need to have an unique ID as i took their ID to texture them, so they actually have to rotate. weird.

Tomorrow i'll try to use a "real" mesh, and add some of it to the scenenode like in the code above. Maybe it's just some strange behaviour with the testscenenode.

Good night for now and thanks :lol:
under construction
magisterrivus
Posts: 33
Joined: Sat Aug 05, 2006 9:46 pm

Post by magisterrivus »

YES!

And again a new Irrlicht version....i'll gonna try that one. Maybe that problem goes away. But first i have to fix my winxp :evil: . I love BSOD. What would life be without them? I guess nicer.


Byebye *usingrecoveryconsolethe5thtimein2month*
under construction
magisterrivus
Posts: 33
Joined: Sat Aug 05, 2006 9:46 pm

Post by magisterrivus »

Erm, OK.

No more addTestSceneNode. Maybe it was a buggy feature. Is there any way to see what was added/removed from the Engine?

Thanks
under construction
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Yes, there's a change.txt in the SDK and also linked from the Irrlicht main page under http://irrlicht.sourceforge.net/changes.txt :wink:
But in your case it's simply a rename to CCubeSceneNode (and maybe disabling lighting if you don't have dynamic lights turned on).
magisterrivus
Posts: 33
Joined: Sat Aug 05, 2006 9:46 pm

Post by magisterrivus »

Thx hybrid. :)

I looked at the svn changes.txt, but found nothing.
Anyways, the problem still exist, but this time my cubes are effected by the light i put into the Scene, which was not the case with Irrlicht 1.0 :roll:


PS:
WHY do i ALWAYS have the "luck" to have faulty RAM, or a faulty HD?
The only computer that works is my beloved notebook with a cool integrated S3 "graphic"card :lol:. It's really big fun using Irrlicht on that killer.

So far
under construction
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

That's why I mentiond the second change to cube nodes: they are affected by light so disable that if you don't want it. BTW: Most (if not all) nodes in Irrlicht are by default affected by light, that's why I changed it also for cube nodes.
magisterrivus
Posts: 33
Joined: Sat Aug 05, 2006 9:46 pm

Post by magisterrivus »

OK, this makes sense.

If you don't mind, could you take a look at my code at the beginning of this thread? Is there anything I did wrong, or why is only one Cube rotating, while the others are not?

Thanks
under construction
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Acki's proposals are definitely correct, your style would be sloooooow. The mesh buffer counting did not make any sense to me, but animating should work. Maybe some matrix setup is confused due to the many nodes using the animator.
magisterrivus
Posts: 33
Joined: Sat Aug 05, 2006 9:46 pm

Post by magisterrivus »

You mean I better go the way with making it a "real" SceneNode first, or what do you mean by sloooow?
Or is there any other way to add those Cubes, like eg. in OpenGL adding Vertices etc to a list, and then display them?
under construction
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

No, searching the scene tree in each cycle would be very slow. If you want to make all nodes into one mesh (i.e. transformations are globally applied to the set of cubes) it would be better to put them into one mesh buffer, but it should also work for all nodes being separated.
magisterrivus
Posts: 33
Joined: Sat Aug 05, 2006 9:46 pm

Post by magisterrivus »

Back from the Dead, fixed my Comp.

So, i tried some time now to get it work, but no luck.
I'll give up on that :roll:

Btw, what if one wants to show a lot of meshes, like birds, trees or whatever,assuming they're all the same mesh. What's the best way to do that?

Thanks
under construction
Post Reply