populating a SAnimatedMesh

You discovered a bug in the engine, and you are sure that it is not a problem of your code? Just post it in here. Please read the bug posting guidelines first.
Post Reply
bass21
Posts: 10
Joined: Wed Feb 04, 2009 6:20 pm

populating a SAnimatedMesh

Post by bass21 »

Hello, I'm trying to manually populate a SAnimatedMesh with 3 IMeshe's. The purpose is to animate 3 different (in shape and color) cylinders.

Here's my code:

Code: Select all

    IMesh* cylinder1 = createCylinderMesh(6, 10, 30, video::SColor(0, 255, 0, 0)); //red
    IMesh* cylinder2 = createCylinderMesh(8, 20, 30, video::SColor(0, 0, 255, 0)); //green
    IMesh* cylinder3 = createCylinderMesh(10, 30, 30, video::SColor(0, 0, 0, 255)); //blue

    SAnimatedMesh *smesh = new SAnimatedMesh();
    smesh->addMesh(cylinder1);
    smesh->addMesh(cylinder2);
    smesh->addMesh(cylinder3);

    IAnimatedMeshSceneNode* node = smgr->addAnimatedMeshSceneNode(smesh);

    node->setMaterialFlag(EMF_LIGHTING, false);
	node->setAnimationSpeed(3);
The createCylinderMesh() function I borrowed off of this thread:
http://irrlicht.sourceforge.net/phpBB2/ ... 890#180890

Here I'm creating 3 different cylinders, a small-red, a medium-green and a big-blue cylinder. Then populating a SAnimatedMesh with them (they're being correcly created, i've checked it separately).

My code will work, the animation will start playing, but the blue (the last) cylinder is missing.

It will show the blue cylinder (and the blue cylinder ONLY) if I use:
node->setFrameLoop(2, 2);
Otherwise, only the red and then the green cylinders will appear. What am I doing wrong?

PS. If I add the blue cylinder twice, like this:

Code: Select all

    smesh->addMesh(cylinder1);
    smesh->addMesh(cylinder2);
    smesh->addMesh(cylinder3);
    smesh->addMesh(cylinder3); //duplicated
Then it will also be drawn at the end of the animation cycle, but only once. Perharps is this a SAnimatedMesh bug?

Thanks.
bass21
Posts: 10
Joined: Wed Feb 04, 2009 6:20 pm

Post by bass21 »

bump...
perharps this bug has been adressed already?
bass21
Posts: 10
Joined: Wed Feb 04, 2009 6:20 pm

Post by bass21 »

Bump again. Anyone?
Acki
Posts: 3496
Joined: Tue Jun 29, 2004 12:04 am
Location: Nobody's Place (Venlo NL)
Contact:

Post by Acki »

it seems to be a problem with the addMesh methode...
the last added mesh seems not to be present... :shock:
if you only add the first 2 meshes (red and green) then you get only the 1st one (the last one is always missing)...

EDIT: no it seems to be added correctly...
if you set the animation loop to the last mesh (2,2) then the blue mesh will be shown...
only if you set a range (0,2 or 1,2) then the last mesh doesn't show, even if you set the range to large (e.g. 0,3)... :shock:
so I guess it must depend on the node, maybe when calculating the next frame it doesn't reach the last frame !?!?!
while(!asleep) sheep++;
IrrExtensions:Image
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
bass21
Posts: 10
Joined: Wed Feb 04, 2009 6:20 pm

Post by bass21 »

if you only add the first 2 meshes (red and green) then you get only the 1st one (the last one is always missing)...
Thats right. You can test it and see it for yourselves, the last frame is always missing. (Atleast using the official Irrlicht 1.5 release).
only if you set a range (0,2 or 1,2) then the last mesh doesn't show, even if you set the range to large (e.g. 0,3)...
I wasn't using setFrameLoop actually (supposedly meaning loop through all frames), but if I do, it reflects the situation I'm describing.

For example, calling setFrameLoop(1,2) (without the final repeated call to addMesh(cylinder3)) will only show the green cylinder, which is the middle one. Frame 2 should be the last one - but its being "eaten out" - hence only the green cylinder shows on the screen.

Ive also tried this (again, without the last repeated call to addMesh(cylinder3)):
cout << node ->getEndFrame()

And it says my node has two frames only :(

PS. Using setFrameLoop(0,2) will again only show the red and then the green cylinder.

Help? :)
Post Reply