Can I create a not-FPS camera?
Can I create a not-FPS camera?
Hi to all! I want to create a camera not-fps, but I don't know the procedures. Can you explain to me the procedures?
thank you very much!
PS: excuse me if I committed several mistakes, but I'm Italian and I know only little bit of English.
thank you very much!
PS: excuse me if I committed several mistakes, but I'm Italian and I know only little bit of English.
-
- Posts: 1186
- Joined: Fri Dec 29, 2006 12:04 am
Have a looke here.
And then you are able to set the parent, position, target to look at, etc. like this:
The API dokumentation is your friend.
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));
Thank you, randomMesh, but my real problem is the input..
I partially solved the problem, for the camera movement foward/Backward, Left/Right:
But now i have a problem whit mouse control fot the target movement:
I pressed the Right Mouse Button, but I can't move the target
can you help me?
I partially solved the problem, for the camera movement foward/Backward, Left/Right:
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;
};
can you help me?
Ok, I solved...but I have another problem:
I move the target, but the target stop at 90 degrees and at -90 degrees. .
the maximum rotation of the target, in my program is 180 degrees ... I post my code:
I want my camera rotation is = 360 degrees and not 180 degrees.
Can you help me?
I move the target, but the target stop at 90 degrees and at -90 degrees. .
the maximum rotation of the target, in my program is 180 degrees ... I post my code:
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);
Can you help me?
No, you don't have 180°, its lesser !!!
The problem is you're looking just at one axis, you'll have to look in a circle around you...
look at this pic, it should show you what's wrong with your code:
(same for the Y-axis)
The problem is you're looking just at one axis, you'll have to look in a circle around you...
look at this pic, it should show you what's wrong with your code:
(same for the Y-axis)
while(!asleep) sheep++;
IrrExtensions:
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
IrrExtensions:
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
Well, Pythagoras is the wrong guy for this
you should use an view angle and then triangulate X and Z...
you should do something like this:then you should define a view distance that always is the same, this can be any value so we simply can take 1
now you can easily calculate X and Z:
sin(alpha) = X / 1 >>> X = sin(alpha) * 1 >>> X = sin(rotAngle)
cos(alpha) = Z / 1 >>> Z = cos(alpha) * 1 >>> Z = cos(rotAngle)
well, I hope I made no mistakes as I wrote this out of the top of my head and I'm tired...
you should use an view angle and then triangulate X and Z...
you should do something like this:
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;
}
now you can easily calculate X and Z:
sin(alpha) = X / 1 >>> X = sin(alpha) * 1 >>> X = sin(rotAngle)
cos(alpha) = Z / 1 >>> Z = cos(alpha) * 1 >>> Z = cos(rotAngle)
well, I hope I made no mistakes as I wrote this out of the top of my head and I'm tired...
while(!asleep) sheep++;
IrrExtensions:
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
IrrExtensions:
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
Well, I don't know what you're exactly doing there...
but you don't need to multiply cos and sin with any other value than 1, but you have to add your camera position...
for the earthquake it could be that you'll have to update the absolute camera position afterwards:this should work for left/right view, for up/down it's similar...
Maybe sin and cos needs radians instead of degrees (the code I wrote is more a pseudo code)...
but you don't need to multiply cos and sin with any other value than 1, but you have to add your camera position...
for the earthquake it could be that you'll have to update the absolute camera position afterwards:
Code: Select all
vector3df target = cam->getPosition();
target.X += sin(rotAngle);
target.Z += cos(rotAngle);
camera->setTarget(target);
camera->updateAbsolutePosition();
Maybe sin and cos needs radians instead of degrees (the code I wrote is more a pseudo code)...
Last edited by Acki on Mon Aug 20, 2007 9:40 pm, edited 1 time in total.
while(!asleep) sheep++;
IrrExtensions:
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
IrrExtensions:
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
Dont work
this is my loop:
this is my loop:
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;
}
}
ohh, your fast (or I'm to tired) !!!
well, one error in the code:must be:and if I rember right you'll have to use radians, so you'll have to multibly the angle with pi/180:and don't forget to use a float type for the Rotangle var...
as I mentioned, all this I'm doing just out of my head...
well, one error in the code:
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);
as I mentioned, all this I'm doing just out of my head...
while(!asleep) sheep++;
IrrExtensions:
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
IrrExtensions:
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java