Lag in child of IBoneSceneNode

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
Post Reply
jwatson1993
Posts: 37
Joined: Fri Nov 04, 2011 12:15 am

Lag in child of IBoneSceneNode

Post by jwatson1993 »

Whenever I attach an animatedmeshscenenode as a child to a bonescenenode, I get a lag. All meshes are .b3d. The camera is a first person shooter camera and is a parent to a mesh of the hands. I get a joint from that node and make it a parent to a node of a gun. But, whenever I turn the camera side to side or move, it causes a lag. I made the hands node a parent and it didn't lag, so it is something with the bonescenenode.

Code: Select all

 
//parameters are not exact
IAnimatedMeshSceneNode* hands = smgr->addaddAnimatedMeshSceneNode(mesh, parent, id, position, rotation, scale);
IAnimatedMeshSceneNode* revolver = smgr->addaddAnimatedMeshSceneNode(mesh, parent, id, position, rotation, scale);
IAnimatedMeshSceneNode* wrist = hands->getJointNode("lWrist");
revolver->setParent(wrist);
ICameraSceneNode* camera = smgr->addCameraSceneNodeFPS(smgr->getRootSceneNode(),100.0,.025f,-1,keyMap, 5, false, 3.0);
hands->setParent(camera);
 
I've tried this with a few different drivers and it doesn't help. I also have a wrapper class for scene nodes, if that is relevant. I had it to where it wouldn't lag for a while,
but now it started up again, and I don't know why.
Edit: I've tested some other models and it seems to be an issue with that specific model. Has anybody had any similar issues with their models not allowing good attachments?
Edit 2: I know why this is happening. In my irrlicht code, there is a line missing in the b3d loader. The weight doesn't get initialized, and it gets an undefined symbol.
christianclavet
Posts: 1638
Joined: Mon Apr 30, 2007 3:24 am
Location: Montreal, CANADA
Contact:

Re: Lag in child of IBoneSceneNode

Post by christianclavet »

How does it work with static objects? I would like to use that feature to attach weapons and armor on characters.

You have a model that fail to initialize the skin weighting? Is it only a specific model? Have you tried to load in a software and re-save it? This could be a corruption of the file...
jwatson1993
Posts: 37
Joined: Fri Nov 04, 2011 12:15 am

Re: Lag in child of IBoneSceneNode

Post by jwatson1993 »

I'm being very contradictory, but that's just me attempting to get to the bottom of things. Now, I think that the problem was I was trying to use a static mesh when I should have used an animated mesh. It's weird, but I used a large rectangular model for the floor, and it's a dae file. When I used my wrapper class for static nodes, it occasionally lagged, but when I do my "Anim3D" wrapper, which generates an animatedmeshscenenode, it has worked every time so far.
InstinctCH
Posts: 16
Joined: Fri Feb 25, 2011 12:48 pm
Location: Switzerland

Re: Lag in child of IBoneSceneNode

Post by InstinctCH »

I don't know if you solved your problem since then but I was experiencing the same issue and here's my solution:

You have to change the joint mode:

Code: Select all

myAnimatedMeshSceneNode->setJointMode(EJUOR_CONTROL);
to

Code: Select all

myAnimatedMeshSceneNode->setJointMode(EJUOR_READ);
jwatson1993
Posts: 37
Joined: Fri Nov 04, 2011 12:15 am

Re: Lag in child of IBoneSceneNode

Post by jwatson1993 »

Thank you so much InstinctCH! I was getting ridiculously discouraged every time I saw a fps game. For clarification, you have to change the joint mode of both nodes.
jwatson1993
Posts: 37
Joined: Fri Nov 04, 2011 12:15 am

Re: Lag in child of IBoneSceneNode

Post by jwatson1993 »

Wait, I'm still having an issue where it is only working if I don't texture the hands. This is odd.
Edit:
Scratch that. I don't exactly have freedom to texture as I please but it is working. I have to set the path in the model file, and I can't just have a material and texture it in the engine. Note that this only works when I am using my derived classes. When I add the same mesh with smgr->addAnimatedMeshSceneNode(...) the opposite is true. Only an untextured model or a model with the ABSOLUTE path set works. The absolute path is useless, though, because I can't have any downloaders using a path to a file on my computer, of course. Interesting side-note: Even though the models lag behind/render in the wrong places, I added text nodes to the knives(which are the children of the joint node) and they are always in the right location, no matter what conditions. A major problem that I am having is that I don't know if an error is coming from the engine itself or the engine's interaction with my models(which I am creating myself).

For example:

this works:

Code: Select all

node = new CPlayerObject(smgr->getMesh("assets//hands_texture.b3d"),this,smgr,vector3df(0,-1.f,-.5f));//textured in the modeling software
but this doesn't:

Code: Select all

node = new CPlayerObject(smgr->getMesh("assets//hands.b3d"),this,smgr,vector3df(0,-1.f,-.5f));//only has a material in the modeling software
and this thing:

Code: Select all

node = smgr->addAnimatedMeshSceneNode(smgr->getMesh("assets//hands.b3d"),smgr->getRootSceneNode(),-1,vector3df(0,-1.f,5.f));
        node->setMaterialTexture(0,driver->getTexture("assets//person.bmp"));//remove this line and it works, but the lag exists if you leave it in.
Last edited by jwatson1993 on Sat Dec 24, 2011 4:06 am, edited 1 time in total.
jwatson1993
Posts: 37
Joined: Fri Nov 04, 2011 12:15 am

Re: Lag in child of IBoneSceneNode

Post by jwatson1993 »

After playing with the textures a bit I got things to reliably work but have yet to come up with a consistent rule aside from "make damn sure every texture is a multiple of 256."
jwatson1993
Posts: 37
Joined: Fri Nov 04, 2011 12:15 am

Re: Lag in child of IBoneSceneNode

Post by jwatson1993 »

Not sure if anybody is still following this, but whenever I have a GUIElement that draws a background, the lag comes back.
jwatson1993
Posts: 37
Joined: Fri Nov 04, 2011 12:15 am

Re: Lag in child of IBoneSceneNode

Post by jwatson1993 »

Well apparently you need to set the texture of the skin's sprite bank to something. I don't know what I'm replacing, though, but I have a hunch that it is an improperly scaled texture.

*guienv->getSkin()->getSpriteBank()->getTexture(0) =*driver->getTexture("assets//title2.jpg");
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Lag in child of IBoneSceneNode

Post by CuteAlien »

This should be the buildin font, but it's already 128x128. Not really sure how this can affect lagging.
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
jwatson1993
Posts: 37
Joined: Fri Nov 04, 2011 12:15 am

Re: Lag in child of IBoneSceneNode

Post by jwatson1993 »

It goes away when I switch drivers. I really need to get a better computer if I want to develop games.
Post Reply