Some errors with the code

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
lisacvuk
Posts: 21
Joined: Thu Apr 17, 2014 4:50 pm

Some errors with the code

Post by lisacvuk »

Hi, i'm new to c++ and irrlicht and i have an problem. When i try to compile this

Code: Select all

 
/*Include file for irrlicht engine*/
#include <irrlicht.h>
/*Include files*/
#include "driverChoice.h"
/*Namespaces*/
using namespace irr;
using namespace scene;
/*Main*/
int main()
{
    // ask user for driver
    video::E_DRIVER_TYPE driverType=driverChoiceConsole();
    if (driverType==video::EDT_COUNT)
        return 1;
        // create device with full flexibility over creation parameters
        irr::SIrrlichtCreationParameters params;
        params.DriverType=driverType;
        params.WindowSize=core::dimension2d<u32>(640, 480);
        IrrlichtDevice* device = createDeviceEx(params);
 
        if (device == 0)
            return 1; // could not create selected driver.
 
            video::IVideoDriver* driver = device->getVideoDriver();
            scene::ISceneManager* smgr = device->getSceneManager();
            gui::IGUIEnvironment* env = device->getGUIEnvironment();
 
            driver->setTextureCreationFlag(video::ETCF_ALWAYS_32_BIT, true);
            //Add camera
            scene::ICameraSceneNode* camera =
            smgr->addCameraSceneNodeFPS(0,100.0f,1.2f);
            camera->setPosition(core::vector3df(10*2,10*2,60*2));
            camera->setTarget(core::vector3df(2397*2,343*2,2700*2));
            camera->setFarValue(42000.0f);
            // disable mouse cursor
            device->getCursorControl()->setVisible(false);
            /*Add arena model*/
            scene::IAnimatedMesh* arena1 = smgr->getMesh("main/models/arenas/arena_1.obj");
            scene::ISceneNode* arena = smgr->addAnimatedMeshSceneNode(arena1);
            smgr->getMeshManipulator()->makePlanarTextureMapping(arena1->getMesh(0),0.004f);
            arena->setMaterialFlag(video::EMF_LIGHTING, false);
            arena->setMaterialTexture(0, driver->getTexture("main/textures/arenas/stone1_z.jpg"));
            arena->setMaterialType(video::EMT_SOLID);
            scene::IAnimatedMesh* lerchem = smgr->getMesh("main/models/caracters/enemy/lerche_1.obj");
            scene::ISceneNode* lerchen = smgr->addAnimatedMeshSceneNode(lerchem);
            lerchen->setMaterialTexture(0, driver->getTexture("main/textures/arenas/stone1_z.jpg"));
            lerchen->setFrameLoop(0, 9);
            lerchem->setAnimationSpeed(5);
            /*
    That's it, draw everything.
    */
 
    int lastFPS = -1;
 
    while(device->run())
    if (device->isWindowActive())
    {
        driver->beginScene(true, true, 0 );
 
        smgr->drawAll();
        env->drawAll();
 
        driver->endScene();
 
        // display frames per second in window title
        int fps = driver->getFPS();
        if (lastFPS != fps)
        {
            core::stringw str = L"The Arena- pre-alpha version. [";
            str += driver->getName();
            str += "] FPS:";
            str += fps;
 
            device->setWindowCaption(str.c_str());
            lastFPS = fps;
        }
    }
 
    device->drop();
 
    return 0;
}
 
i got errors:

Code: Select all

||=== Build: Debug in Arena (compiler: GNU GCC Compiler) ===|
E:\ARENA\src\main.cpp||In function 'int main()':|
E:\ARENA\src\main.cpp|51|error: 'class irr::scene::ISceneNode' has no member named 'setFrameLoop'|
||=== Build failed: 1 error(s), 0 warning(s) (0 minute(s), 1 second(s)) ===|
 
Please help.
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Some errors with the code

Post by CuteAlien »

addAnimatedMeshSceneNode returns a IAnimatedMeshSceneNode * and not just an ISceneNode*. And that has the setFrameLoop member - so use that class for your lerchen variable.
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
Post Reply