Irrlicht basics tutorial [Note: HUGE POST]

A forum to store posts deemed exceptionally wise and useful

How would you rate this tutorial?

Great
57
42%
Good
51
38%
Fine
21
15%
Bad
7
5%
 
Total votes : 136

Postby dudMaN » Mon Nov 26, 2007 8:43 pm

Oh, sorry about that, some users have been having problems with the code snippets because i used 1.2 for the code and not 1.3+.

To fix this error, you will need to replace:
Code: Select all
 bool OnEvent(SEvent event) {


with

Code: Select all
 virtual bool OnEvent(const SEvent& event) {


and that should fix it :)

Sorry for any inconvienence!!!

-DudMan
Complete Irrlicht Beginners Tutorial
http://irrlicht.sourceforge.net/phpBB2/ ... hp?t=24898
User avatar
dudMaN
 
Posts: 111
Joined: Fri Mar 02, 2007 6:37 pm

Postby dudMaN » Thu Nov 29, 2007 5:06 pm

joshcryer & fireside,

yup, it's made to be quite simple, but it also fixes the key-repeat problem where holding down a key presses key once, then waits, then presses the rest of the time.

Thanks for reading/commenting on my tutorial :)

-dudMan
Complete Irrlicht Beginners Tutorial
http://irrlicht.sourceforge.net/phpBB2/ ... hp?t=24898
User avatar
dudMaN
 
Posts: 111
Joined: Fri Mar 02, 2007 6:37 pm

Postby Yustme » Sat Dec 01, 2007 11:22 pm

Hi dudMaN,

First of all, very nice tutorial!

I just started a new project using your tutorial. At the end of chapter 1, I compiled the code snippet and it gave me the following error:

'driver' undeclared identifier.'

This was the code I compiled:

Code: Select all
int main() {

 IrrlichtDevice *device = createDevice(ETD_OPENGL);
 IVideoDriver* video = device->getVideoDriver();
 ISceneManager* smgr = device->getSceneManager();

 while(device->run() && device) {
  driver->beginScene(true, true, video::SColor(255,0,0,255));
  smgr->drawAll();
  driver->endScene();
 }
}



If you change "video" in "driver" in this line:

IVideoDriver* video = device->getVideoDriver();

Everything should work fine :D

You might also wanna add "int argc, char **argv" in the argument body of the main:

int main(int argc, char **argv)

And adding "return 0" at the end of main() is good programming practice :P

Keep up doing the good work dudMaN!

Yustme
Yustme
 
Posts: 107
Joined: Sat Dec 01, 2007 10:50 pm

Postby dudMaN » Sun Dec 09, 2007 11:20 pm

Thanks for the help yustme :D

-dudMan
Complete Irrlicht Beginners Tutorial
http://irrlicht.sourceforge.net/phpBB2/ ... hp?t=24898
User avatar
dudMaN
 
Posts: 111
Joined: Fri Mar 02, 2007 6:37 pm

Postby wizecoder » Thu Jan 03, 2008 9:42 pm

Hi I am new to irrlicht and was using your tutorial. I finished lesson 3 but when i run the program it only shows a black screen until i press A,S,W or D and after that it only shows a totally blue screen. please help me see the cube, here is my code so far copied and pasted to be sure.

#include <Irrlicht.h>

using namespace irr;
using namespace video;
using namespace core;
using namespace gui;
using namespace scene;

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

bool keys[irr::KEY_KEY_CODES_COUNT];

class MyEventReceiver : public IEventReceiver {
public:
virtual bool OnEvent(const SEvent& event) {
if(event .EventType == irr::EET_KEY_INPUT_EVENT){
keys[event.KeyInput.Key] = event.KeyInput.PressedDown;
return false;
}
return false;
}
};

int main()
{
IrrlichtDevice *device = createDevice(EDT_OPENGL);
IVideoDriver* video = device->getVideoDriver();
ISceneManager* smgr = device->getSceneManager();

MyEventReceiver rv;
device->setEventReceiver(&rv);

for(int x=0; x<irr::KEY_KEY_CODES_COUNT; x++) keys[x] = false;

ISceneNode* cube = smgr->addCubeSceneNode();
cube->setPosition(vector3df(0, 0, 5));

while(device->run() && device) {
if(keys[KEY_KEY_W]) {
cube->setPosition(cube->getPosition()+vector3df(0, 0, 5));
}
if(keys[KEY_KEY_S]) {
cube->setPosition(cube->getPosition()-vector3df(0, 0, 5));
}
if(keys[KEY_KEY_A]) {
cube->setPosition(cube->getPosition()-vector3df(5, 0, 0));
}
if(keys[KEY_KEY_D]) {
cube->setPosition(cube->getPosition()+vector3df(5, 0, 0));
}
video->beginScene(true, true, video::SColor(255,0,0,255));
smgr->drawAll();
video->endScene();
}
}


THANKS :)
wizecoder
 
Posts: 13
Joined: Thu Jan 03, 2008 9:36 pm

Postby dbest » Thu Jan 03, 2008 9:51 pm

I faced the same issue yesterday, but managed to sort it out by adding a camera scene node to the code.

Code: Select all
ICameraSceneNode* cam = smgr->addCameraSceneNode(0, vector3df(0,30,-45));


add this before the while loop, and the code should work.

I suppose you are using version 1.4
dbest
 
Posts: 10
Joined: Wed Jan 02, 2008 4:45 pm

Postby dudMaN » Sun Feb 10, 2008 6:45 pm

Hi.

Your problem is because the cube is in the camera, making it appear black, due to the fact that the cube is black.

When you move it forward, it moves too far forward, making the screen appear blue again.

Add a camera scene node and change the move increments to 0.3 or something low instead of 5.0, and it should work better

-DudMan
Complete Irrlicht Beginners Tutorial
http://irrlicht.sourceforge.net/phpBB2/ ... hp?t=24898
User avatar
dudMaN
 
Posts: 111
Joined: Fri Mar 02, 2007 6:37 pm

Postby MasterGod » Thu Mar 27, 2008 8:14 pm

or, another more "accurate" collision function:
Code:

bool collision(ISceneNode* one, ISceneNode* two) {
if(one->getBoundingBox().intersectsWithBox(two->getBoundingBox())) {
return true;
return false;
}


havent tested this one but it should work.

It doesn't seem to work.
Add those lines to example 4:
Code: Select all
   int lastFPS = -1;

   anms->setDebugDataVisible(scene::EDS_FULL);
   node->setDebugDataVisible(scene::EDS_FULL);
   n->setDebugDataVisible(scene::EDS_FULL);

   while(device->run())
   {

      if(n->getBoundingBox().intersectsWithBox(node->getBoundingBox()))
         printf("Collision Detected");

You'll see what I mean by doing it..
Image
Dev State: Abandoned (For now..)
Requirements Analysis Doc: ~87%
UML: ~0.5%
User avatar
MasterGod
 
Posts: 2060
Joined: Fri May 25, 2007 8:06 pm
Location: Israel

Postby MasterGod » Thu Apr 03, 2008 10:53 pm

MasterGod wrote:
or, another more "accurate" collision function:
Code:

bool collision(ISceneNode* one, ISceneNode* two) {
if(one->getBoundingBox().intersectsWithBox(two->getBoundingBox())) {
return true;
return false;
}


havent tested this one but it should work.

It doesn't seem to work.
Add those lines to example 4:
Code: Select all
   int lastFPS = -1;

   anms->setDebugDataVisible(scene::EDS_FULL);
   node->setDebugDataVisible(scene::EDS_FULL);
   n->setDebugDataVisible(scene::EDS_FULL);

   while(device->run())
   {

      if(n->getBoundingBox().intersectsWithBox(node->getBoundingBox()))
         printf("Collision Detected");

You'll see what I mean by doing it..

dudMaN, (or anyone else), you know why it doesn't work?
Image
Dev State: Abandoned (For now..)
Requirements Analysis Doc: ~87%
UML: ~0.5%
User avatar
MasterGod
 
Posts: 2060
Joined: Fri May 25, 2007 8:06 pm
Location: Israel

Postby shadowslair » Fri Apr 04, 2008 7:30 pm

This is a really nice tutorial. Still can be improved though. Adding fixed and working versions of the codes will be really nice. I don`t think that there are much guys so fallen in love with the old versions to use it. :lol:
or, another more "accurate" collision function:
Code:

bool collision(ISceneNode* one, ISceneNode* two) {
if(one->getBoundingBox().intersectsWithBox(two->getBoundingBox())) {
return true;
return false;
}

havent tested this one but it should work.


Yeah, actually this always returns "true". I would like to know what`s wrong with it too (if possible).

Anyway, this tut is really useful, since it helped me understand some basic stuff. "Working and learning" seems to be a good startegy :wink:
User avatar
shadowslair
 
Posts: 758
Joined: Mon Mar 31, 2008 3:32 pm
Location: Bulgaria

Postby MasterGod » Wed Apr 09, 2008 6:29 am

So, does anyone knows what's wrong with it?
Image
Dev State: Abandoned (For now..)
Requirements Analysis Doc: ~87%
UML: ~0.5%
User avatar
MasterGod
 
Posts: 2060
Joined: Fri May 25, 2007 8:06 pm
Location: Israel

Postby dudMaN » Sat Apr 19, 2008 7:35 pm

shadowslair wrote:This is a really nice tutorial. Still can be improved though. Adding fixed and working versions of the codes will be really nice. I don`t think that there are much guys so fallen in love with the old versions to use it. :lol:
or, another more "accurate" collision function:
Code:

bool collision(ISceneNode* one, ISceneNode* two) {
if(one->getBoundingBox().intersectsWithBox(two->getBoundingBox())) {
return true;
return false;
}

havent tested this one but it should work.


Yeah, actually this always returns "true". I would like to know what`s wrong with it too (if possible).

Anyway, this tut is really useful, since it helped me understand some basic stuff. "Working and learning" seems to be a good startegy :wink:


Yeah, tested that out on something(dont remember what) and it always returns true. I'm ganna remove that sometime :shock: .

-DudMan
Complete Irrlicht Beginners Tutorial
http://irrlicht.sourceforge.net/phpBB2/ ... hp?t=24898
User avatar
dudMaN
 
Posts: 111
Joined: Fri Mar 02, 2007 6:37 pm

Postby MasterGod » Sun Apr 20, 2008 3:30 pm

But it Should work, doesn't it?
We need to find why it is almost always true (I somehow had few falses in some cases)..
Image
Dev State: Abandoned (For now..)
Requirements Analysis Doc: ~87%
UML: ~0.5%
User avatar
MasterGod
 
Posts: 2060
Joined: Fri May 25, 2007 8:06 pm
Location: Israel

Postby BlindSide » Sun Apr 20, 2008 3:48 pm

You should use ->getTransformedBoundingBox()

Infact, I went over this months ago on IRC with you dudMaN, didn't I?

But it Should work, doesn't it?


No, no it shouldn't, if you dont return the Transformed bounding box, it just gives you one thats always placed at 0,0.
ShadowMapping for Irrlicht!: Get it here
Need help? Come on the IRC!: #irrlicht on irc://irc.freenode.net
BlindSide
Admin
 
Posts: 2812
Joined: Thu Dec 08, 2005 9:09 am
Location: NZ!

Postby MasterGod » Sun Apr 20, 2008 4:06 pm

"Transformed":?:
Could you explain please what do you mean. I guess you're right and I'll try that tomorrow when I get home but I'm not familiar with the term 'Transformed' in relation to graphics.

Thanks.
Image
Dev State: Abandoned (For now..)
Requirements Analysis Doc: ~87%
UML: ~0.5%
User avatar
MasterGod
 
Posts: 2060
Joined: Fri May 25, 2007 8:06 pm
Location: Israel

PreviousNext

Return to FAQs, Tutorials, Howtos, and external tool lists

Who is online

Users browsing this forum: No registered users and 0 guests