![Very Happy :D](./images/smilies/icon_biggrin.gif)
thank you very much!
PS: excuse me if I committed several mistakes, but I'm Italian and I know only little bit of English.
![Embarassed :oops:](./images/smilies/icon_redface.gif)
Code: Select all
irr::scene::ICameraSceneNode* camera = smgr->addCameraSceneNode();
Code: Select all
camera->setParent(parentNode);
camera->setPosition(irr::core::vector3df(0.0f, 0.0f, 0.0f));
camera->setTarget(irr::core::vector3df(0.0f, 0.0f, 0.0f));
Code: Select all
class MyEventReceiver : public IEventReceiver
{
virtual bool OnEvent(SEvent event)
{
if (event.EventType == irr::EET_KEY_INPUT_EVENT&& event.KeyInput.PressedDown)
{
if(event.KeyInput.Key== KEY_ESCAPE)
{
device->closeDevice();
return true;
}
if(event.KeyInput.Key== KEY_UP )
{
Spostamento_CameraX=Spostamento_CameraX+5;
return true;
}
if(event.KeyInput.Key== KEY_DOWN )
{
Spostamento_CameraX=Spostamento_CameraX-5;
return true;
}
if(event.KeyInput.Key== KEY_RIGHT )
{
Spostamento_CameraZ=Spostamento_CameraZ-5;
return true;
}
if(event.KeyInput.Key== KEY_LEFT )
{
Spostamento_CameraZ=Spostamento_CameraZ+5;
return true;
}
//next ->
Code: Select all
//<-previus
if (event.EventType==irr::EET_MOUSE_INPUT_EVENT){
if(event.MouseInput.Event==EMIE_MOUSE_MOVED&&event.MouseInput.Event==EMIE_RMOUSE_PRESSED_DOWN)
{
if(device->getCursorControl()->getPosition().X>512){
CameraTarX=CameraTarX-3;
return true;
}
}
}
}
}
private:
scene::ISceneNode* Terrain;
};
Code: Select all
camera->setPosition(core::vector3df( Spostamento_CameraX*2,255*2,Spostamento_CameraZ*2));
if (sganctarg==true){
rotazione_iniziale = camera->getTarget() ;
point = device->getCursorControl()->getPosition();
if (point.X >= 645){
rotazione_iniziale.X=rotazione_iniziale.X-50;
}
if (point.X <= 635){
rotazione_iniziale.X=rotazione_iniziale.X+50;
}
if (point.Y >= 390){
rotazione_iniziale.Y=rotazione_iniziale.Y-50;
}
if (point.Y <= 410){
rotazione_iniziale.Y=rotazione_iniziale.Y+50;
}
camera->setTarget(rotazione_iniziale);
Code: Select all
if (point.X >= 645){
rotAngle -= 1; // rotate 1° anti clockwise, but should it not be clockwise?
if(rotAngle < 0) rotAngle += 360;
}
if (point.X <= 635){
rotAngle += 1; // rotate 1° clockwise, but should it not be anti clockwise?
if(rotAngle >= 360) rotAngle -= 360;
}
Code: Select all
vector3df target = cam->getPosition();
target.X += sin(rotAngle);
target.Z += cos(rotAngle);
camera->setTarget(target);
camera->updateAbsolutePosition();
Code: Select all
camera->setPosition(core::vector3df( Spostamento_CameraX*2,255*2,Spostamento_CameraZ*2));
if (sganctarg==true){
//I use the boolean SgancTarg for the right mouse button is pressed.
point = device->getCursorControl()->getPosition();
if (point.X >= 645){
Rotangle = Rotangle - 1;
if(Rotangle < 0) Rotangle =Rotangle + 360;
}
if (point.X <= 635){
Rotangle = Rotangle +1;
if(Rotangle >= 0) Rotangle = Rotangle -360;
}
if (point.Y >= 390){
rotazione_iniziale.Y=rotazione_iniziale.Y-50;
}
if (point.Y <= 410){
rotazione_iniziale.Y=rotazione_iniziale.Y+50;
}
//"rotazione_iniziale" is the target movement.
rotazione_iniziale.X =Spostamento_CameraX + sin(Rotangle) ;
rotazione_iniziale.Z =Spostamento_CameraZ + cos(Rotangle) ;
camera->setTarget(rotazione_iniziale);
camera->updateAbsolutePosition();
}
driver->endScene();
// display frames per second in window title
int fps = driver->getFPS();
if (lastFPS != fps)
{
core::stringw str = L"Terrain Renderer - Irrlicht Engine [";
str += driver->getName();
str += "] FPS:";
str += fps;
// Also print terrain height of current camera position
// We can use camera position because terrain is located at coordinate origin
str += " rot: ";
str += Rotangle;
device->setWindowCaption(str.c_str());
lastFPS = fps;
}
}
Code: Select all
if (point.X <= 635){
Rotangle = Rotangle +1;
if(Rotangle >= 0) Rotangle = Rotangle -360;
}
Code: Select all
if (point.X <= 635){
Rotangle = Rotangle +1;
if(Rotangle >= 360) Rotangle = Rotangle -360;
}
Code: Select all
rotazione_iniziale.X =Spostamento_CameraX + sin(Rotangle * 3.14156 / 180.0);
rotazione_iniziale.Z =Spostamento_CameraZ + cos(Rotangle * 3.14156 / 180.0);