i have an question about the rotate"XYZ"By() methods in the vector3d<T> class.
I don't really get the function the center parameter.
I just asking to understand how this method works.
Excsuse my english i'm german.
Code: Select all
vector3df vec(1,0,0);
cout<<"X: "<<vec.X<<" Y: "<<vec.Y<<" Z: "<<vec.Z<<endl;
vec.rotateXZBy(90,vector3df(0,0,0));
cout<<"X: "<<vec.X<<" Y: "<<vec.Y<<" Z: "<<vec.Z<<endl;

Code: Select all
#ifndef EventReceiver
#define EventReceiver
#include <Irrlicht.h>
#include <iostream>
#include "resources.h"
using namespace irr;
using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;
using namespace std;
extern IrrlichtDevice* device;
extern ICameraSceneNode* camera;
extern int auflsungV;
extern int auflsungH;
float movmentSpeed = 1.0;
float strafeSpeed = 0.5;
class EvRecvr : public IEventReceiver{
private:
int mouseX;
int mouseY;
public:
//Konstruktor-------------------------------
EvRecvr(){
mouseX = auflsungH/2;
mouseY = auflsungV/2;
}
//------------------------------------------
bool OnEvent(const SEvent& event){
//Tastaur händler
if(event.EventType == EET_KEY_INPUT_EVENT){
//Händler für gedrückte Tasten
if(event.KeyInput.PressedDown){
//Allgemeine Events----------------
cout<<"your're pressing a button: "<<event.KeyInput.Key<<endl;
//---------------------------------
//W-Taste--------------------------
if (event.KeyInput.Key== KEY_KEY_W){
vector3df rotVec = camera->getRotation();
vector3df posVec = camera->getPosition();
rotVec.setLength(movmentSpeed);
rotVec.rotateXZBy(0, rotVec);
vector3df newVec(posVec.X+rotVec.X, posVec.Y, posVec.Z+rotVec.Z);
camera->setPosition(newVec);
}
//---------------------------------
//A-Taste--------------------------
if (event.KeyInput.Key== KEY_KEY_A){
vector3df rotVec = camera->getRotation();
vector3df posVec = camera->getPosition();
rotVec.setLength(strafeSpeed);
rotVec.rotateXZBy(270, rotVec);
vector3df newVec(posVec.X+rotVec.X, posVec.Y, posVec.Z+rotVec.Z);
camera->setPosition(newVec);
}
//---------------------------------
//S-Taste--------------------------
if (event.KeyInput.Key== KEY_KEY_S){
vector3df rotVec = camera->getRotation();
vector3df posVec = camera->getPosition();
rotVec.setLength(movmentSpeed);
rotVec.rotateXZBy(180, rotVec);
vector3df newVec(posVec.X+rotVec.X, posVec.Y, posVec.Z+rotVec.Z);
camera->setPosition(newVec);
}
//---------------------------------
//D-Taste--------------------------
if (event.KeyInput.Key== KEY_KEY_D){
vector3df rotVec = camera->getRotation();
vector3df posVec = camera->getPosition();
rotVec.setLength(strafeSpeed);
rotVec.rotateXZBy(90, rotVec);
vector3df newVec(posVec.X+rotVec.X, posVec.Y, posVec.Z+rotVec.Z);
camera->setPosition(newVec);
}
//---------------------------------
if(event.KeyInput.Key == KEY_KEY_M){
vector3df vec(1,0,0);
cout<<"X: "<<vec.X<<" Y: "<<vec.Y<<" Z: "<<vec.Z<<endl;
vec.rotateXZBy(90,vector3df(0,0,0));
cout<<"X: "<<vec.X<<" Y: "<<vec.Y<<" Z: "<<vec.Z<<endl;
}
}
//Händler für losgelassene Tasten
else{
//Allgemeine Events----------------
cout<<"your're releasing a button: "<<event.KeyInput.Key<<endl;
//---------------------------------
//ESC-Taste------------------------
if(event.KeyInput.Key == KEY_ESCAPE){
device->closeDevice();
}
//---------------------------------
}
return true;
}
//Maus händler
else if(event.EventType == EET_MOUSE_INPUT_EVENT){
//Allgemeine Events-------------------
cout<<"your're moving the mouse: "<<"X: "<<event.MouseInput.X<<" Y: "<<event.MouseInput.Y<<endl;
//------------------------------------
//Maus XY-Achse-----------------------
//------------------------------------
return true;
}
else{
return false;
}
}
};
#endif