Mesh rotation erratic - RESOLVED

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.
Post Reply
bdpdonp
Posts: 68
Joined: Sat Oct 10, 2009 6:35 am

Mesh rotation erratic - RESOLVED

Post by bdpdonp »

I apologize if this is answered on the forums, my search I did not find anything.

I load my 3D model (.x) and textures (.DDS) and yes dds is enabled. I also apply a rotation to the model. The model loads but the rotation has not taken effect. Once I move the camera the model immediately switches and has the rotation applied. I have debugged and verified the rotation code is applied properly and only ones just after the model is loaded.

Code: Select all

        
irr::core::stringc modelPath = path + "\\models\\" + selectedRace + "\\" + selectedShip + "\\" + textureData[0];
        irr::scene::IMesh * playerModel = smgr->getMesh(modelPath);
        node = smgr->addMeshSceneNode(playerModel);
        if (node != nullptr) {
            node->setMaterialFlag(irr::video::EMF_LIGHTING, false);
            for (int i = 0; i < numTextures; i++) {
                modelPath = path + "\\models\\" + selectedRace + "\\" + selectedShip + "\\" + textureData[i + 1];
                node->setMaterialTexture(i, driver->getTexture(modelPath));
            }
            if (player) {
                node->setScale(irr::core::vector3df(scale[SCALING], scale[SCALING], scale[SCALING]));
                node->setRotation(irr::core::vector3df(scale[ROTX], scale[ROTY], scale[ROTZ]));
                node->setPosition(irr::core::vector3df(scale[TRAX], scale[TRAY], scale[TRAZ]));
                cControl->InitCameraPosition(scale[CAMX], scale[CAMY], scale[CAMZ]);
            } else {
                node->setScale(irr::core::vector3df(scale[SCALING], scale[SCALING], scale[SCALING]));
                node->setRotation(irr::core::vector3df(scale[ROTX], scale[ROTY] + 180.0, scale[ROTZ]));
                node->setPosition(irr::core::vector3df(scale[TRAX] - 15.0, scale[TRAY] + 5.0, scale[TRAZ] + 200));
            }
        }
Last edited by bdpdonp on Sun Jun 16, 2013 1:57 am, edited 1 time in total.
CuteAlien
Admin
Posts: 9664
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Mesh rotation erratic

Post by CuteAlien »

It sounds like you don't render maybe when you don't move the camera. Or don't call run() for the irrlicht device.
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
bdpdonp
Posts: 68
Joined: Sat Oct 10, 2009 6:35 am

Re: Mesh rotation erratic

Post by bdpdonp »

When I create the model and add the camera if there is no rotation everything is fine.

If I had a rotation when the model is first created it looks like the model did not rotate. The moment I move the camera there is a quick jerk of orientation and the model is rotated properly and from then on everything is good.

I create the camera after the model is created and the camera is part of the root node, not part of the model.
bdpdonp
Posts: 68
Joined: Sat Oct 10, 2009 6:35 am

Re: Mesh rotation erratic

Post by bdpdonp »

Got it, thanks, needed to add the device->run() in my game loop.
Post Reply