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

dudMaN
Posts: 111
Joined: Fri Mar 02, 2007 6:37 pm

Post by dudMaN »

[quote=humbrol]
ive got that part working but how do i make the nodes impassible, it tells if they touch each other but doesnt bar them from passing through each other.
[/quote]

You're kind of dumb, arent you?

you'd have to write your own code for that, so FIGURE IT OUT. Seriously, dude, my patience for you has expired. you need to:

1) Learn C++

2) Learn Irrlicht

3) Ask GOOD questions.

-Dudman
Complete Irrlicht Beginners Tutorial
http://irrlicht.sourceforge.net/phpBB2/ ... hp?t=24898
joshcryer
Posts: 46
Joined: Thu Sep 13, 2007 8:57 am
Contact:

Post by joshcryer »

strategy's input method is probably the best way to do input, it or a variation of it. Thanks strategy. :)
SwitchCase
Posts: 170
Joined: Sun Jul 01, 2007 11:41 pm
Location: Manchester, UK

Post by SwitchCase »

dudMaN wrote: You're kind of dumb, arent you?
LMAO!

I'm counting more and more threads where I've wanted to ask the guy the same question.

:lol:
VioletAlixe
Posts: 28
Joined: Thu Oct 04, 2007 9:03 pm

Post by VioletAlixe »

Just a quick glance over and you can already see this tutorial answers the most basic questions in a rather nice order of what someone jumping into the creating-a-game-with-irrlicht world thinks sequentially. Why isn't this stickied?
dudMaN
Posts: 111
Joined: Fri Mar 02, 2007 6:37 pm

Post by dudMaN »

Hey thanks alot VioletAlixe!

Hehe, i kinda wish it was stickied but im sure theres a reason its not, hope i can improve it :)

-DudMan
Complete Irrlicht Beginners Tutorial
http://irrlicht.sourceforge.net/phpBB2/ ... hp?t=24898
fireside
Posts: 158
Joined: Thu Dec 01, 2005 10:55 pm

Post by fireside »

This ended up being the event receiver explanation I could understand. There are too many around and most are too complicated to get started with. Check the program given, though. It didn't work for me, but when I used the instructions, it did.
dudMaN
Posts: 111
Joined: Fri Mar 02, 2007 6:37 pm

Post by dudMaN »

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
dudMaN
Posts: 111
Joined: Fri Mar 02, 2007 6:37 pm

Post by dudMaN »

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
Yustme
Posts: 107
Joined: Sat Dec 01, 2007 10:50 pm

Post by Yustme »

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
dudMaN
Posts: 111
Joined: Fri Mar 02, 2007 6:37 pm

Post by dudMaN »

Thanks for the help yustme :D

-dudMan
Complete Irrlicht Beginners Tutorial
http://irrlicht.sourceforge.net/phpBB2/ ... hp?t=24898
wizecoder
Posts: 13
Joined: Thu Jan 03, 2008 9:36 pm

Post by wizecoder »

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 :)
dbest
Posts: 10
Joined: Wed Jan 02, 2008 4:45 pm

Post by dbest »

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
dudMaN
Posts: 111
Joined: Fri Mar 02, 2007 6:37 pm

Post by dudMaN »

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
MasterGod
Posts: 2061
Joined: Fri May 25, 2007 8:06 pm
Location: Israel
Contact:

Post by MasterGod »

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%
MasterGod
Posts: 2061
Joined: Fri May 25, 2007 8:06 pm
Location: Israel
Contact:

Post by MasterGod »

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%
Post Reply