Page 3 of 5

Posted: Mon Oct 01, 2007 10:45 pm
by sader
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?

Posted: Thu Oct 04, 2007 1:56 pm
by MasterGod
There is a bug that you can't control GUI events.

Posted: Thu Oct 04, 2007 2:19 pm
by TheMiss
MasterGod wrote:There is a bug that you can't control GUI events.
I can still do that :?

Posted: Thu Oct 04, 2007 2:37 pm
by MasterGod
How? please tell me how do you handle GUI with this receiver?

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
      //////////////////////////////
In Main.cpp

Code: Select all

	MastEventReceiver eventReceiver;
	eventReceiver.init();
	eventReceiver.getDevice(device);
	device->setEventReceiver(&eventReceiver);

Posted: Fri Oct 05, 2007 12:06 am
by MasterGod
I found that if I disable the Whole mouse handling I can control GUI events.
Now, how can I enable both mouse handling and GUI handling?

Posted: Sun Oct 14, 2007 12:23 am
by MasterGod
TheMiss wrote:
MasterGod wrote:There is a bug that you can't control GUI events.
I can still do that :?
Yeah, your version of MastEventReceiver did the job.

PS:
Mastiff, did you neglect the "project"?

Posted: Sun Oct 21, 2007 6:44 am
by yaim031
MasterGod wrote:There is a bug that you can't control GUI events.
change

Code: Select all

return eventprocessed; 
to

Code: Select all

return false; 

Posted: Fri Nov 02, 2007 3:56 am
by christianclavet
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.

Posted: Fri Nov 02, 2007 12:27 pm
by MasterGod
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. 

Posted: Tue Dec 18, 2007 11:50 pm
by Avian
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

Code: Select all

               if (eventReceiver.leftMouseDown()==true) {
               cout << "Test" << endl;
               }
will never return true.

Is this just a problem with me, my computer or something wrong with illicht?

Posted: Wed Dec 19, 2007 2:08 pm
by MasterGod
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..)

okay i want it

Posted: Thu Jul 17, 2008 3:32 pm
by 3DModelerMan
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?.

[Help]

Posted: Thu Jul 24, 2008 8:21 am
by vargero
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:

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();

}
(How) can I use the MastEventReceiver code among with that?

this does'nt work

Posted: Fri Jul 25, 2008 12:41 am
by 3DModelerMan
How come this does'nt work? here's my code

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'
Thanks :D .

Posted: Fri Jul 25, 2008 5:40 am
by Dark_Kilauea

Code: Select all

MastEventReceiver->keyPressed(KEY_ESCAPE )
Should be this:

Code: Select all

MastEventReceiver.keyPressed(KEY_ESCAPE )