Problems with camera type.
Problems with camera type.
Hi,
I managed to use MeshViewer tutorial in order to create my application with 2d user interface and 3d presentation window. Okay.
Now the thing is, that in the first version of my program (without menus) I used FPS style camera (smgr->addCameraSceneNodeFPS(0, 100.0f, 100.0f);), and the MeshViewer example uses Maya style camera (smgr->addCameraSceneNodeMaya();). I would like to be able to switch between them, as both have some advantages. My first question is:
- how to change camera type? Do I have to reset scene? How do I do that?
The second problem is as follows :
- when I use the FPS type camera, it blocks mouse cursor movement and mouse input is used for looking around. Is it possible to switch this feature on and off with some command, so that mouse could be used either for navigating 2d menus OR looking around the scene?
I would be grateful for any replies. Thanks in advance.
I managed to use MeshViewer tutorial in order to create my application with 2d user interface and 3d presentation window. Okay.
Now the thing is, that in the first version of my program (without menus) I used FPS style camera (smgr->addCameraSceneNodeFPS(0, 100.0f, 100.0f);), and the MeshViewer example uses Maya style camera (smgr->addCameraSceneNodeMaya();). I would like to be able to switch between them, as both have some advantages. My first question is:
- how to change camera type? Do I have to reset scene? How do I do that?
The second problem is as follows :
- when I use the FPS type camera, it blocks mouse cursor movement and mouse input is used for looking around. Is it possible to switch this feature on and off with some command, so that mouse could be used either for navigating 2d menus OR looking around the scene?
I would be grateful for any replies. Thanks in advance.
I have the same problem!
And i`m sorry, until jet, i don`t have an answer.
At the moment i have no time to play arround in irrlicht to find
the right way to go, but i can tell you what i think you have to do.
Check the event reciever tutorial and make a switch of the camera mods
by pressing a button.
I think from FPS to Maya would be good!
Please, let me know if you have a soulution.
And i`m sorry, until jet, i don`t have an answer.
At the moment i have no time to play arround in irrlicht to find
the right way to go, but i can tell you what i think you have to do.
Check the event reciever tutorial and make a switch of the camera mods
by pressing a button.
I think from FPS to Maya would be good!
Please, let me know if you have a soulution.
Wer andern eine Bratwurst brät, der hat ein Bratwurstbratgerät!
-
- Posts: 206
- Joined: Thu Sep 01, 2005 9:26 pm
- Location: France
First question...
Second Question... You can temporarily disable the camera-follows-mouse behavior of the FPS camera by calling
Travis
Code: Select all
using namespace irr;
using namespace gui;
using namespace scene;
class MyEventReceiver : public IEventReceiver
{
public:
MyEventReceiver(IrrlichtDevice* device)
: Device(device)
{
Device->grab();
}
virtual ~MyEventReceiver()
{
Device->drop();
// remove all cameras
for (irr::s32 c = 0; c < Cameras.size(); ++c)
Cameras[c]->drop();
}
bool InsertCamera(ICameraSceneNode* camera)
{
irr::s32 c = Cameras.linear_search(camera);
if (c == -1)
{
Cameras.push_back(camera);
camera->grab();
return true;
}
return false;
}
bool RemoveCamera(ICameraSceneNode* camera)
{
irr::s32 c = Cameras.linear_search(camera);
if (c != -1)
{
Cameras.erase(c);
camera->drop();
return true;
}
return false;
}
virtual bool OnEvent(SEvent event)
{
if (event.EventType == EET_KEY_INPUT_EVENT &&
event.KeyInput.Key == KEY_KEY_C && event.KeyInput.PressedDown)
{
// if we have a camera to swap to, swap cameras
if (!Cameras.empty())
{
ICameraSceneNode* oldCamera = Device->getSceneManager()->getActiveCamera();
ICameraSceneNode* newCamera = Cameras[0];
// remove the new camera from the list and put it at the end
Cameras.erase(0);
Cameras.push_back(newCamera);
// put the camera where the old camera was
core::vector3df from = oldCamera->getPosition();
newCamera->setPosition(from);
// point the new camera at the same location as the old one
core::vector3df target = oldCamera->getTarget();
newCamera->setTarget(target);
// set the projection matrix (fov and friends)
core::matrix4 proj = oldCamera->getProjectionMatrix();
newCamera->setProjectionMatrix(proj);
// replace old camera with new one
Device->getSceneManager()->setActiveCamera(newCamera);
return true;
}
}
}
private:
IrrlichtDevice* Device;
// queue of cameras known by this event receiver, will cycle through them with C
core::array<ICameraSceneNode*> Cameras;
};
int main(int argc, char* argv[])
{
// ...
// create event receiver that will manage cameras
MyEventReceiver receiver(Device);
Device->setEventReceiver(&receiver);
// add fps camera
ICameraSceneNode* fpsCamera = SceneManager->addCameraSceneNodeFPS();
receiver.InsertCamera(fpsCamera);
// add maya camera
ICameraSceneNode* mayaCamera = SceneManager->addCameraSceneNodeMaya();
receiver.InsertCamera(mayaCamera);
// last camera added to scene manager will be active by default
// ...
return 0;
}
Code: Select all
Camera->setInputReceiverEnabled(false);
I am sorry Vitek, but I haven't checked your solution yet - some other wok piled up, so I will probably approach the problem on Monday. I'll let you know about the progress though and whether it worked or not.
Hmm, it is not only Czech - in Polish it is Witek, written with double-u, but pronounced identically. My cousin's name actually (yup, I'm Polish), so I thought I asked.
Regards,
Hmm, it is not only Czech - in Polish it is Witek, written with double-u, but pronounced identically. My cousin's name actually (yup, I'm Polish), so I thought I asked.
Regards,