Rotating an object which uses getMeshManipulator()

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
nrasool
Posts: 5
Joined: Tue Mar 30, 2004 12:16 pm
Location: London, United Kingdom
Contact:

Rotating an object which uses getMeshManipulator()

Post by nrasool »

Hi All,

I have been looking into the forum which have some very good snippets of code and been very useful. I have tried searching for this issue, but come across a brick wall. I just want to say when I click on the left cursor key, rotate my object by -1 unit

Here is my code which I have

Code: Select all

// INCLUDES ///////////////////////////////////
#include <irrlicht.h>
#include "MastEventReceiver.cpp"
using namespace irr;
using namespace core;
using namespace video;
using namespace scene;

#pragma comment(lib, "Irrlicht.lib")

// irrlicht specific
IrrlichtDevice *device=0;
IVideoDriver *driver=0;
ISceneManager *smgr=0;
scene::ISceneNode* node = 0;


int main()
{
    // create the device
    MastEventReceiver receiver;
    device = irr::createDevice(EDT_DIRECT3D9 ,dimension2d<s32>(800,600),32,false,true,false,&receiver);
    driver = device->getVideoDriver();
    smgr = device->getSceneManager();
    device->setWindowCaption(L"Psionic Normal Mapping Test");



    ILightSceneNode* light1 = smgr->addLightSceneNode();
    light1->setPosition(vector3df(0,0,-100)); 

    
    IAnimatedMesh* mesh = smgr->getMesh("freebeast//beast.b3d");
    IMesh *tmesh = smgr->getMeshManipulator()->createMeshWithTangents(mesh->getMesh(0));


    //scene::IAnimatedMeshSceneNode* scene = smgr->addAnimatedMeshSceneNode(mesh);
    scene::ISceneNode* scene = smgr->addMeshSceneNode(tmesh);

    //IAnimatedMeshSceneNode* node = smgr->addAnimatedMeshSceneNode( mesh );
    scene->setMaterialTexture(0,driver->getTexture("freebeast//beast1.jpg") );
    video::ITexture* NormalMap = driver->getTexture("freebeast//n_beast.png");
    driver->makeNormalMapTexture(NormalMap,20.0f);
    scene->setMaterialTexture(1,NormalMap);
    scene->setMaterialType(video::EMT_NORMAL_MAP_TRANSPARENT_VERTEX_ALPHA );
    // scene->setMD2Animation(EMAT_CROUCH_WALK);
    tmesh->drop();

    smgr->addCameraSceneNode(0, vector3df(0,50,-150), vector3df(0,5,0));

    while(device->run())
    {
                        receiver.endEventProcess(); 
                        if (receiver.keyDown(KEY_LEFT))
                        {
                          tmesh->setrotation(0,+1,0);
                        }

                        
                        driver->beginScene(true, true,SColor(0,55,55,55));
                        smgr->drawAll();
                        driver->endScene();
                        receiver.startEventProcess(); 
    }
    device->drop();
    return 0;
}

As you can see I'm using the class from: http://irrlicht.sourceforge.net/phpBB2/ ... hp?t=21657

The reason for doing:

Code: Select all

   IAnimatedMesh* mesh = smgr->getMesh("freebeast//beast.b3d");
    IMesh *tmesh = smgr->getMeshManipulator()->createMeshWithTangents(mesh->getMesh(0));
Was for applying normal mapping on to this object, which its working. So the part of the code which I getting difficulty in, is

Code: Select all

if (receiver.keyDown(KEY_LEFT))
                        {
                          tmesh->setrotation(0,+1,0);
                        }
I'm getting a compile error which says

Code: Select all

 'class irr::scene::IMesh' has no member named 'setrotation' 
Please could someone give me some guidance on this, it would be much appreciated

Many thanks
A Good programmer never blames his tools, only himself
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post by JP »

Meshes are not movable objects, they're simply the geometry data. What you do with the mesh is then provide it to an ISceneNode (smgr->addSceneNode(...mesh...)) which you CAN move around and rotate.
Image Image Image
nrasool
Posts: 5
Joined: Tue Mar 30, 2004 12:16 pm
Location: London, United Kingdom
Contact:

Post by nrasool »

Hi JP, Thanks for the reply, however I have done it, if you check the code you will see

Code: Select all

IAnimatedMesh* mesh = smgr->getMesh("freebeast//beast.b3d");
    IMesh *tmesh = smgr->getMeshManipulator()->createMeshWithTangents(mesh->getMesh(0));


    scene::ISceneNode* scene = smgr->addMeshSceneNode(tmesh); 
That right? Isn't it?
A Good programmer never blames his tools, only himself
BlindSide
Admin
Posts: 2821
Joined: Thu Dec 08, 2005 9:09 am
Location: NZ!

Post by BlindSide »

scene->setRotation(vector3df(0,-1,0))..

Not only were u trying to rotate the mesh, not the node, but also you were passing your eular angles as three seperate parameters instead of using a vector3df class.

Case closed...
ShadowMapping for Irrlicht!: Get it here
Need help? Come on the IRC!: #irrlicht on irc://irc.freenode.net
nrasool
Posts: 5
Joined: Tue Mar 30, 2004 12:16 pm
Location: London, United Kingdom
Contact:

Post by nrasool »

BlindSide, Thankyou for that.

Much appreciated :)

Works fine now
A Good programmer never blames his tools, only himself
Post Reply