prob with adding node to other animated bone-joint mesh node

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.
wanliqun
Posts: 26
Joined: Sun Nov 20, 2011 2:23 pm

prob with adding node to other animated bone-joint mesh node

Post by wanliqun »

I'm trying to add some sub-animated mesh node to some other animated bone joint. Here is my code for this:

Code: Select all

 
        IAnimatedMeshSceneNode* node = smgr->addAnimatedMeshSceneNode( mesh );
        if (node)
        {
                node->setMaterialFlag(EMF_LIGHTING, false);
                node->setMaterialTexture( 0, driver->getTexture("f:/qsoccker/data/meshes/outfieldplayer.png") );
 
                IAnimatedMesh* meshGlasses = smgr->getMesh("f:/qsoccker/data/meshes/glasses-2.ms3d");
                ISceneNode* nodeGlasses = smgr->addAnimatedMeshSceneNode(meshGlasses);
                nodeGlasses->setMaterialFlag(EMF_LIGHTING, true);
                nodeGlasses->setMaterialFlag(EMF_FOG_ENABLE, true);
                nodeGlasses->setRotation(vector3df(0, -90 + 180, -90));
                nodeGlasses->setPosition(vector3df(-21 + 21, 0, 0)); //y: 0
                ISceneNode* playerHead = node->getJointNode("Bip01 HeadNub");
                playerHead->addChild(nodeGlasses); //*-/
        }
        ......
        while(device->run())
        {
                driver->beginScene(true, true, SColor(255,100,101,140));
                smgr->drawAll();
                guienv->drawAll();
                driver->endScene();
        }
 
Here are some screenshot for the resultant mesh node animation.
Image
screenshot1 by david.wan, on Flickr
Image
screenshot2 by david.wan, on Flickr
Image
screenshot3 by david.wan, on Flickr
Image
screenshot4 by david.wan, on Flickr

As you can see, The screen1 & screen2 group are not identical with the screen3 & screen4 group. Is there something I'm wrong with this? I'm running this with irrlicht 1.7.2, windows xp, vc2008.
wanliqun
Posts: 26
Joined: Sun Nov 20, 2011 2:23 pm

Re: prob with adding node to other animated bone-joint mesh

Post by wanliqun »

Here is the model view in milkshape 3d for the animated mesh node(player01.ms3d):
Image
player01.ms3d by david.wan, on Flickr

And here is the model view in milkshape 3d for the attached glass mesh node:
Image
glasses.ms3d by david.wan, on Flickr
smso
Posts: 246
Joined: Fri Jun 04, 2010 3:28 pm
Location: Hong Kong

Re: prob with adding node to other animated bone-joint mesh

Post by smso »

Try doing this in the run loop:

Code: Select all

while(device->run())
{
    node->getJointNode("Bip01 HeadNub")->addChild(nodeGlasses);
    //....
}
Regards
smso
wanliqun
Posts: 26
Joined: Sun Nov 20, 2011 2:23 pm

Re: prob with adding node to other animated bone-joint mesh

Post by wanliqun »

Thanks for the reply. But It doesn't work neither.

BTW, I'm trying to port some game with irrlicht 0.14 to irrlicht 1.7.2. The codes run well with the irrlicht 0.14(with some minor api change adaption).
wanliqun
Posts: 26
Joined: Sun Nov 20, 2011 2:23 pm

Re: prob with adding node to other animated bone-joint mesh

Post by wanliqun »

This might be some bug. So I've uploaded the test case to http://www.mediafire.com/?e15cx28mw7wo6u4 for further study.
smso
Posts: 246
Joined: Fri Jun 04, 2010 3:28 pm
Location: Hong Kong

Re: prob with adding node to other animated bone-joint mesh

Post by smso »

The original code works as expected. I'm using svn version of irrlicht.

Regards
smso
wanliqun
Posts: 26
Joined: Sun Nov 20, 2011 2:23 pm

Re: prob with adding node to other animated bone-joint mesh

Post by wanliqun »

Thanks for the reply. But it still happens even I use the svn version of code. This might be because of my graphics card, opengl version or sth else?
Here is some logging info for it:
Irrlicht Engine version 1.8.0-alpha
Microsoft Windows XP Professional Service Pack 3 (Build 2600)
WGL_extensions: WGL_ARB_extensions_string WGL_ARB_pixel_format WGL_ATI_pixel_for
mat_float WGL_ARB_pixel_format_float WGL_ARB_multisample WGL_EXT_swap_control WG
L_ARB_pbuffer WGL_ARB_render_texture WGL_ARB_make_current_read WGL_EXT_extension
s_string WGL_ARB_buffer_region WGL_EXT_framebuffer_sRGB WGL_ATI_render_texture_r
ectangle WGL_EXT_pixel_format_packed_float WGL_I3D_genlock WGL_NV_swap_group WGL
_ARB_create_context WGL_AMD_gpu_association WGL_AMDX_gpu_association WGL_ARB_cre
ate_context_profile WGL_NV_float_buffer
Pixel Format: 2
Using renderer: OpenGL 3.3.10188
ATI Mobility Radeon HD 3400 Series: ATI Technologies Inc.
OpenGL driver version is 1.2 or better.
Free texture memory (kB): 240585
Free VBO memory (kB): 240585
Free render buffer memory (kB): 240585
GLSL version: 3.3
Could not load sprite bank because the file does not exist: #DefaultFont
Loaded header version: 4
Load vertices: 913
Load Triangles: 986
Load Groups: 1
Load Materials: 1
Could not open file of texture: f:/Projects/ITBeing/CGE_proj/Client/trunk/src/Th
irdParty/irrlicht/source/testIrr/player01.tga
FPS: 30.000000
Joints: 36
Joint: Bip01
Rotation keyframes: 209
Translation keyframes: 765
Joint: Bip01 Spine
Rotation keyframes: 466
Translation keyframes: 765
Joint: Bip01 L Thigh
Rotation keyframes: 684
Translation keyframes: 765
Joint: Bip01 L Calf
Rotation keyframes: 732
Translation keyframes: 765
Joint: Bip01 L Foot
Rotation keyframes: 835
Translation keyframes: 765
Joint: Bip01 L Toe0
Rotation keyframes: 797
Translation keyframes: 691
Joint: Bip01 L Toe0Nub
Rotation keyframes: 0
Translation keyframes: 0
Joint: Bip01 R Thigh
Rotation keyframes: 675
Translation keyframes: 765
Joint: Bip01 R Calf
Rotation keyframes: 635
Translation keyframes: 765
Joint: Bip01 R Foot
Rotation keyframes: 538
Translation keyframes: 765
Joint: Bip01 R Toe0
Rotation keyframes: 520
Translation keyframes: 485
Joint: Bip01 R Toe0Nub
Rotation keyframes: 0
Translation keyframes: 0
Joint: Bip01 Spine1
Rotation keyframes: 613
Translation keyframes: 771
Joint: Bip01 Neck
Rotation keyframes: 615
Translation keyframes: 771
Joint: Bip01 Head
Rotation keyframes: 774
Translation keyframes: 771
Joint: Bip01 HeadNub
Rotation keyframes: 0
Translation keyframes: 0
Joint: Bip01 L Clavicle
Rotation keyframes: 572
Translation keyframes: 771
Joint: Bip01 L UpperArm
Rotation keyframes: 995
Translation keyframes: 695
Joint: Bip01 L Forearm
Rotation keyframes: 849
Translation keyframes: 771
Joint: Bip01 L Hand
Rotation keyframes: 779
Translation keyframes: 771
Joint: Bip01 L Finger0
Rotation keyframes: 759
Translation keyframes: 771
Joint: Bip01 L Finger01
Rotation keyframes: 759
Translation keyframes: 771
Joint: Bip01 L Finger0Nub
Rotation keyframes: 0
Translation keyframes: 0
Joint: Bip01 L Finger1
Rotation keyframes: 797
Translation keyframes: 771
Joint: Bip01 L Finger11
Rotation keyframes: 838
Translation keyframes: 771
Joint: Bip01 L Finger1Nub
Rotation keyframes: 0
Translation keyframes: 0
Joint: Bip01 R Clavicle
Rotation keyframes: 445
Translation keyframes: 771
Joint: Bip01 R UpperArm
Rotation keyframes: 1029
Translation keyframes: 695
Joint: Bip01 R Forearm
Rotation keyframes: 850
Translation keyframes: 771
Joint: Bip01 R Hand
Rotation keyframes: 813
Translation keyframes: 771
Joint: Bip01 R Finger0
Rotation keyframes: 771
Translation keyframes: 771
Joint: Bip01 R Finger01
Rotation keyframes: 775
Translation keyframes: 771
Joint: Bip01 R Finger0Nub
Rotation keyframes: 0
Translation keyframes: 0
Joint: Bip01 R Finger1
Rotation keyframes: 801
Translation keyframes: 771
Joint: Bip01 R Finger11
Rotation keyframes: 838
Translation keyframes: 771
Joint: Bip01 R Finger1Nub
Rotation keyframes: 0
Translation keyframes: 0
Skipping comment group: 1
Skipping comment group: 2
Skipping comment group: 3
Skipping comment group: 4
Loaded mesh: ./player01.ms3d
Loaded texture: f:/Projects/ITBeing/CGE_proj/Client/trunk/src/ThirdParty/irrlich
t/source/testIrr/outfieldplayer.png
Loaded header version: 4
Load vertices: 71
Load Triangles: 60
Load Groups: 1
Load Materials: 1
FPS: 30.000000
Joints: 0
Loaded mesh: ./glasses-2.ms3d
Resizing window (1280 752)
wanliqun
Posts: 26
Joined: Sun Nov 20, 2011 2:23 pm

Re: prob with adding node to other animated bone-joint mesh

Post by wanliqun »

I also tried the opengles version of irrlicht on some andorid pad, it is also abnormal with some frame animation there. So strange. Any idea?
wanliqun
Posts: 26
Joined: Sun Nov 20, 2011 2:23 pm

Re: prob with adding node to other animated bone-joint mesh

Post by wanliqun »

I've tried 1.7.3(download form the homepage) both on my pc & android pad. The glass attached to the player head bone node "flies away" with some frames for the node animation. I think it should be some bug here.
wanliqun
Posts: 26
Joined: Sun Nov 20, 2011 2:23 pm

Re: prob with adding node to other animated bone-joint mesh

Post by wanliqun »

Any support for this, please?
CuteAlien
Admin
Posts: 9696
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: prob with adding node to other animated bone-joint mesh

Post by CuteAlien »

Ok, I've only run it on Linux and reduced it to the minimum necessary code, but as far as I can see it works. Glasses are on the right position.

Code is used (identical to yours, I just kicked everything not needed and put the addChild back in the correct place):

Code: Select all

 
#include <irrlicht.h>
 
using namespace irr;
using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;
 
int main()
{
 
        IrrlichtDevice *device = createDevice( video::EDT_OPENGL, (const dimension2du&)dimension2d<u32>(1280, 752), 32, false, false, false, false);
 
        if (!device)
                return 1;
 
        IVideoDriver* driver = device->getVideoDriver();
        ISceneManager* smgr = device->getSceneManager();
        IGUIEnvironment* guienv = device->getGUIEnvironment();
 
        IAnimatedMesh* mesh = smgr->getMesh("./player01.ms3d");
 
        if (!mesh)
        {
                device->drop();
                return 1;
        }
        IAnimatedMeshSceneNode* node = smgr->addAnimatedMeshSceneNode( mesh );
        ISceneNode* nodeGlasses = NULL;
 
        if (node)
        {
                node->setMaterialFlag(EMF_LIGHTING, false);
                node->setMaterialTexture( 0, driver->getTexture("./outfieldplayer.png") );
 
                nodeGlasses = smgr->addAnimatedMeshSceneNode(smgr->getMesh("./glasses-2.ms3d"));
                nodeGlasses->setMaterialFlag(EMF_LIGHTING, true);
                nodeGlasses->setMaterialFlag(EMF_FOG_ENABLE, true);
                nodeGlasses->setRotation(vector3df(0, -90 + 180, -90));
                nodeGlasses->setPosition(vector3df(-21 + 21, 0, 0)); //y: 0
        }
        node->getJointNode("Bip01 HeadNub")->addChild(nodeGlasses);     
 
        ICameraSceneNode* camera = smgr->addCameraSceneNode(0, vector3df(0, 100,-100), vector3df(0,0,0));
        camera->setFarValue(500.0f * 100);
        camera->setNearValue(1.0f * 100);
        smgr->setAmbientLight(video::SColorf(1, 1, 1, 1));
        
        while(device->run())
        {
                driver->beginScene(true, true, SColor(255,100,101,140));
                smgr->drawAll();
                guienv->drawAll();
                driver->endScene();
        }
 
        device->drop();
 
        return 0;
}
 
 
Maybe I can try later on on Windows (but then again, probably not enough time for it today).


edit: Can you please tell the exact environment you use? I see Windows XP and compiler seems to be VS. Which VS version are you using? Is this a 32-bit or 64-bit system? And do you compile for 32-bit or 64-bit? Do you compile debug or release? The thing is that the only reason I could think of right now is that it might run in som floating-point troubles which just don't show up on all systems maybe.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
teto
Posts: 159
Joined: Thu Dec 03, 2009 9:37 pm
Location: /home
Contact:

Re: prob with adding node to other animated bone-joint mesh

Post by teto »

As I was saying on IRC yesterday I have a similar problem but with a b3d bone. I noticed the debug dll of irrlicht didn't produce the same result (my child node is 90% of the time where it should be, it flickers 10% with Y coordiantes going like 4/4/4/4/4/-9/4/-9/4/4/4/4/4/4) as the "accurate" target (child node is 50%of the timenot where it should be, no flickering ). I've disabled -O2 in accurate target and it produced the same effect as with the debug dll. I was advised to check irrlicht for aliasing warnings when compiling with -Wall -Wextra and checking for unitialized memory with valgrind. I might try to do that though I am not that familiar with valgrind.
Using trunk with mingw/gcc 4.6, Windows 7 64 bits driver opengl
Da-Huntha
Posts: 1
Joined: Mon Mar 05, 2012 7:26 pm

Re: prob with adding node to other animated bone-joint mesh

Post by Da-Huntha »

I've tried in with a release build of 1.7.2, 1.7.3 and 1.8.0-alpha (SVN REV 4098) and can confirm this problem. I've toyed around and could not concretely find the cause. Later on I rebuilt 1.8.0 with IRR_FAST_MATH and the problem seems to show different quirks where the glasses rotate off, making me believe it's a precision error and perhaps related with the relative rotation.

Remember you can use node->setDebugDataVisible() to visualize your scenenode. I've tried it with node->setDebugDataVisible(irr::scene::EDS_SKELETON), the skeleton seems to stay in place. I will reply or edit this post when I discover more useful findings.
teto
Posts: 159
Joined: Thu Dec 03, 2009 9:37 pm
Location: /home
Contact:

Re: prob with adding node to other animated bone-joint mesh

Post by teto »

[to delete]
Last edited by teto on Mon Mar 05, 2012 11:44 pm, edited 1 time in total.
Using trunk with mingw/gcc 4.6, Windows 7 64 bits driver opengl
teto
Posts: 159
Joined: Thu Dec 03, 2009 9:37 pm
Location: /home
Contact:

Re: prob with adding node to other animated bone-joint mesh

Post by teto »

I've tried it with node->setDebugDataVisible(irr::scene::EDS_SKELETON),
I've not precised that but in my case too the skeleton animation is perfect, just the bone flickers.

I wanted to test with valgrind today but Ubuntu makes my PC hot (CPU is at 90° 10 mn after the start without doing nothing) so I need to solve that first.
Using trunk with mingw/gcc 4.6, Windows 7 64 bits driver opengl
Post Reply