Page 3 of 3

Posted: Wed Oct 24, 2007 9:54 pm
by FigMan
thanks

Posted: Sat Nov 10, 2007 7:29 am
by omar shaaban
i have updated the link if anywant want it but it is just the main.cpp and i didnt check it for errors so any errors report me!

Posted: Thu Nov 15, 2007 5:41 pm
by cdrwolfe
Has anyone tried this in C# successfully?

Regards Wolfe

Working with 1.4 - Just copy and paste

Posted: Wed Dec 19, 2007 2:52 am
by cyberpunkpor
Working with 1.4 - Just copy and paste

Code: Select all

#include <irrlicht.h>
using namespace irr;
using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;
bool up    = false;
bool down  = false;
bool right = false;
bool left  = false;
int speed=1;
#pragma comment(lib, "Irrlicht.lib")
class MyEventReceiver : public IEventReceiver
{
public:
   virtual bool OnEvent(const SEvent& event)
   {

         if (event.EventType == EET_KEY_INPUT_EVENT)
      {
         switch(event.KeyInput.Key)
         {
         case KEY_KEY_W:

            up = event.KeyInput.PressedDown;
            break;

         case KEY_KEY_S:

            down = event.KeyInput.PressedDown;
            break;

         case KEY_KEY_A:

                     left = event.KeyInput.PressedDown;
            break;

         case KEY_KEY_D:

            right = event.KeyInput.PressedDown;
            break;

         }

         //return true;
      }

      return false;
   }

};
int main(int argc, char** argv)
{
MyEventReceiver receiver;
    IrrlichtDevice *device =
        createDevice(EDT_OPENGL, dimension2d<s32>(640, 480), 16,
            false, false, false, &receiver);

    device->setWindowCaption(L"Hello World! - Irrlicht Engine Demo");


    IVideoDriver* driver = device->getVideoDriver();
    ISceneManager* smgr = device->getSceneManager();
    IGUIEnvironment* guienv = device->getGUIEnvironment();
ISceneNode* hero = smgr->addCubeSceneNode();
IAnimatedMesh * movingplane;
    
movingplane = smgr->addHillPlaneMesh("floor",
		core::dimension2d<f32>(20,20),
		core::dimension2d<u32>(40,40), 0, 0,
		core::dimension2d<f32>(0,0),
		core::dimension2d<f32>(10,10));


 IAnimatedMeshSceneNode *floor=smgr->addAnimatedMeshSceneNode(movingplane);
    if (hero)
    {
        hero->setMaterialFlag(EMF_LIGHTING, false);
    }
ICameraSceneNode* camera = smgr->addCameraSceneNode(0, vector3df(0,30,-40), vector3df(0,5,0));
 while(device->run())
    {
core::vector3df c = hero->getPosition();
         core::vector3df d= hero->getRotation();
float diry = ((d.Y+90)*3.14)/180;
        if (up)
         {

            c.X += speed * cos((d.Y) * 3.14 / 180);
  c.Z -= speed * sin((d.Y) * 3.14 / 180);

         }
         if (down)
         {
                     c.X -= speed * cos((d.Y) * 3.14 / 180);
  c.Z += speed * sin((d.Y) * 3.14 / 180);
         }
         if (left)
         {
            d.Y -= 0.1;
         }
         if (right)
         {
            d.Y += 0.1;
         }
hero->setRotation(d);
    int xf = (c.X-sin(diry)*125);
int yf =(c.Z-cos(diry)*125);
int zf =100;

hero->setPosition(c);


         camera->setTarget(c);

         c.Y +=200.f;
         c.Z -= 150.f;

         camera->setPosition(vector3df(xf,zf,yf));
driver->beginScene(true, true, SColor(0,200,200,200));

        smgr->drawAll();
        guienv->drawAll();

        driver->endScene();
    }     //device->drop();

    return 0;
}

Posted: Wed Dec 19, 2007 12:27 pm
by omar shaaban
:) goood (just posting)

Posted: Fri Aug 29, 2008 2:10 pm
by chaitanyaraghav
Thanks a ton cyberpunkpor for making it compiling in 1.4

and an excellent tutorial Omar
i was banging my head for days and now i perfectly how 3rd person rpg cam works!!
cheers! :lol:

Posted: Fri Jan 16, 2009 8:51 pm
by Pyritie
Is the OP still working on this?

Posted: Tue Sep 08, 2009 10:23 pm
by Tannz0rz
Wow, that's a cool approach to working with a 3rd person camera. Nice work.

Posted: Sat Dec 12, 2009 10:33 am
by omar shaaban
thanks all, i like to keep things simple, anyway i was just making another tutorial for camera special effects...but i have to finish with an equation i am developing. :P