Page 1 of 2

addTestSceneNode

Posted: Sat Aug 05, 2006 10:06 pm
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)

Posted: Sat Aug 05, 2006 10:55 pm
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:

Posted: Sat Aug 05, 2006 11:28 pm
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

Posted: Sat Aug 05, 2006 11:48 pm
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...

Posted: Sun Aug 06, 2006 12:44 am
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:

Posted: Mon Aug 07, 2006 10:16 am
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*

Posted: Mon Aug 07, 2006 10:29 am
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

Posted: Mon Aug 07, 2006 10:33 am
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).

Posted: Mon Aug 07, 2006 10:51 am
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

Posted: Mon Aug 07, 2006 11:12 am
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.

Posted: Mon Aug 07, 2006 11:19 am
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

Posted: Mon Aug 07, 2006 11:59 am
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.

Posted: Mon Aug 07, 2006 12:11 pm
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?

Posted: Mon Aug 07, 2006 12:18 pm
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.

Posted: Sat Aug 12, 2006 4:16 pm
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