(C++) Simple to use Event Receiver class for Irrlicht 1.3
Exactly wat I was planing to code thanx.
But one question do we realy need Init() function?
This function practically just sets all variables to 0 so no effect :/ because those variables becomes zero when object is created plus
it's much nicer to set default values of variables with help of constructor, or do I miss something?
But one question do we realy need Init() function?
This function practically just sets all variables to 0 so no effect :/ because those variables becomes zero when object is created plus
it's much nicer to set default values of variables with help of constructor, or do I miss something?
How? please tell me how do you handle GUI with this receiver?
PS: This is what I tried:
In MastEventReceiver.cpp
In Main.cpp
PS: This is what I tried:
In MastEventReceiver.cpp
Code: Select all
virtual bool OnEvent(SEvent event)
{
bool eventprocessed = false;
//////////////////////////////
// GUI Input Event
//////////////////////////////
if (event.EventType == EET_GUI_EVENT)
{
s32 id = event.GUIEvent.Caller->getID();
switch(event.GUIEvent.EventType)
{
case EGET_BUTTON_CLICKED:
if (id == 101)
{
device->closeDevice();
return true;
}
break;
default:
break;
}
}
//////////////////////////////
// Keyboard Input Event
//////////////////////////////
Code: Select all
MastEventReceiver eventReceiver;
eventReceiver.init();
eventReceiver.getDevice(device);
device->setEventReceiver(&eventReceiver);
changeMasterGod wrote:There is a bug that you can't control GUI events.
Code: Select all
return eventprocessed;
Code: Select all
return false;
-
- Posts: 1638
- Joined: Mon Apr 30, 2007 3:24 am
- Location: Montreal, CANADA
- Contact:
Hi. Mastiff
Could I use that code and be able to align the MOUSEX, MOUSEY with the UPVECTOR of the CAMERA. (I mean, be able to use it and modify it to do that) Can a FPSCamera can use that even handler?
I would like to make the camera walk on walls or ceiling like in "Prey".
You code seem to be a good start for that.
Could I use that code and be able to align the MOUSEX, MOUSEY with the UPVECTOR of the CAMERA. (I mean, be able to use it and modify it to do that) Can a FPSCamera can use that even handler?
I would like to make the camera walk on walls or ceiling like in "Prey".
You code seem to be a good start for that.
I didn't hear from him since long time ago. I have a good feeling you can freely change his code as long as you keep this:
Code: Select all
/// MastEventReceiver code is © (Copyright) Robert E. Demarest, AKA Mastiff or Mastiff Odit
/// This file may be used in any non-commercial or commercial project as long as the following conditions are met:
/// You may not claim this code as being your own.
/// You may not use this code for any harmful, malicious or otherwise damaging programs.
qustion: Does this work with irr 1.4?
It works on 1.3, but stopped functioning when i upgraded to 1.4.
It compiles and runs fine, but it's stopped detecting when i press a key.
eg
will never return true.
Is this just a problem with me, my computer or something wrong with illicht?
It works on 1.3, but stopped functioning when i upgraded to 1.4.
It compiles and runs fine, but it's stopped detecting when i press a key.
eg
Code: Select all
if (eventReceiver.leftMouseDown()==true) {
cout << "Test" << endl;
}
Is this just a problem with me, my computer or something wrong with illicht?
With you.
Try debugging it to see what's happening and if you won't find the problem post here what you get..
It should work just fine with 1.4 although someone rewrote it in a much better way..
I've extended it a little bit, I can give you if you want.. Oh and it works with 1.4.. (If I remember right.., I think I tested it with some pre-beta SVN version at the time..)
Try debugging it to see what's happening and if you won't find the problem post here what you get..
It should work just fine with 1.4 although someone rewrote it in a much better way..
I've extended it a little bit, I can give you if you want.. Oh and it works with 1.4.. (If I remember right.., I think I tested it with some pre-beta SVN version at the time..)
-
- Posts: 1691
- Joined: Sun May 18, 2008 9:42 pm
okay i want it
This is exactly what I need. I use 1.4.1, so if it works with 1.4 then it should work with 1.4.1 to, where's the download for the improved one?.
That would be illogical captain...
My first full game:
http://www.kongregate.com/games/3DModel ... tor#tipjar
My first full game:
http://www.kongregate.com/games/3DModel ... tor#tipjar
[Help]
I need some help to use this code. Well, I have a class named gamecontrol, that do all initialization stuff, camera control and the game loop, something like that:
(How) can I use the MastEventReceiver code among with that?
Code: Select all
gamecontrol::gamecontrol(int RX, int RY, int PB, char WM) {
switch (WM) {
case 'f': windowMode = true;
break;
case 'j': windowMode = false;
}
dispositivo = createDevice(
EDT_SOFTWARE,
dimension2d<s32>(RX, RY),
PB,
windowMode,
false,
false,
0);
driver = dispositivo->getVideoDriver();
smgr = dispositivo->getSceneManager();
guienv = dispositivo->getGUIEnvironment();
ISceneNode* playerNode = smgr->addEmptySceneNode();
scene::ICameraSceneNode * cam = smgr->addCameraSceneNode(
playerNode, //parent
vector3df(0,75,100), //angleX, angleH, distance
playerNode->getPosition(), //vector3df(0,0,0), //look at...
-1);
dispositivo->getCursorControl()->setVisible(true);
LoadChars();
}
void gamecontrol::LoadChars() {
Cviking = new viking(this);
}
void gamecontrol::SetTituloJanela(wchar_t* titulo) {
dispositivo->setWindowCaption(titulo);
}
void gamecontrol::run() {
ControlaMundo();
while(dispositivo->run())
{
driver->beginScene(true, true, SColor(0,255,0,0));
smgr->drawAll();
guienv->drawAll();
driver->endScene();
}
}
gamecontrol::~gamecontrol() {
dispositivo->drop();
}
void gamecontrol::ControlaMundo() {
Cviking->SetMovAndando();
}
-
- Posts: 1691
- Joined: Sun May 18, 2008 9:42 pm
this does'nt work
How come this does'nt work? here's my code
And here's the error that I get Thanks .
Code: Select all
#include <irrlicht.h>
#include "MastEventReceiver.cpp"
using namespace irr;
using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;
//================================================================================
//main function
int main(int argc, char** argv)
{ //the master event receiver
MastEventReceiver eventReceiver;
eventReceiver.init();
//creates an Irrlicht device
IrrlichtDevice *device =
createDevice(EDT_SOFTWARE, dimension2d<s32>(640, 480), 16,
false, false, false, &eventReceiver);
//sets the window caption of the device
device->setWindowCaption(L"Wolfpack.");
// gets a pointer to the video driver scene manager and gui environment.
IVideoDriver* driver = device->getVideoDriver();
ISceneManager* smgr = device->getSceneManager();
IGUIEnvironment* guienv = device->getGUIEnvironment();
//=============================================================================
guienv->addStaticText(L"Hello World! This is the Irrlicht Software renderer!",
rect<int>(10,10,200,22), true);
if ( MastEventReceiver->keyPressed(KEY_ESCAPE ))
{ device->closeDevice(); }
//=============================================================================
//end of main function
while(device->run())
{
eventReceiver.endEventProcess();
//draw the world
driver->beginScene(true, true, SColor(0,200,200,200));
smgr->drawAll();
guienv->drawAll();
driver->endScene();
eventReceiver.startEventProcess();
}
//delete the Irrlicht device
device->drop();
return 0;
}
And here's the error that I get
Code: Select all
error: base operand of `->' has non-pointer type `MastEventReceiver'
That would be illogical captain...
My first full game:
http://www.kongregate.com/games/3DModel ... tor#tipjar
My first full game:
http://www.kongregate.com/games/3DModel ... tor#tipjar
-
- Posts: 368
- Joined: Tue Aug 21, 2007 1:43 am
- Location: The Middle of Nowhere
Code: Select all
MastEventReceiver->keyPressed(KEY_ESCAPE )
Code: Select all
MastEventReceiver.keyPressed(KEY_ESCAPE )
rogerborg wrote:Every time someone learns to use a debugger, an angel gets their wings.