Ogre Version: :1.11.4:
Operating System: :ubuntu 16.04
Render System:
Hello, I am working on a project, but I have some problems with setting my orientation. It would be a great help if I can visualize my cameras orientation. But how do I do that?
Visualise Orientation of camera Topic is solved
-
- Gnoll
- Posts: 619
- Joined: Wed Mar 18, 2009 3:03 am
- x 353
Re: Visualise Orientation of camera
What problem do you have exactly?
If you want to visualize the orientation of a camera, I guess it is not your main camera, as the main cameras orientation is shown anyway in your view.
To visualize the orientation/position of another camera, you could just create 3 entities and nodes and place them at the cameras position, but offset it with its orientation, like:
Run this code every frame.
Replace "barrel0.mesh" with any mesh you have and play with the scale/offset variables.
If you want to visualize the orientation of a camera, I guess it is not your main camera, as the main cameras orientation is shown anyway in your view.
To visualize the orientation/position of another camera, you could just create 3 entities and nodes and place them at the cameras position, but offset it with its orientation, like:
Code: Select all
static SceneNode* node1 = NULL;
static SceneNode* node2 = NULL;
static SceneNode* node3 = NULL;
String meshName = "barrel0.mesh";
float offset = 0.5f;
Vector3 scale = Vector3(0.1f, 0.1f, 0.1f);
if (!node1)
{
node1 = app->m_SceneManager->getRootSceneNode()->createChildSceneNode();
node2 = app->m_SceneManager->getRootSceneNode()->createChildSceneNode();
node3 = app->m_SceneManager->getRootSceneNode()->createChildSceneNode();
Entity* ent = app->m_SceneManager->createEntity(meshName);
node1->attachObject(ent);
node1->setScale(scale);
ent = app->m_SceneManager->createEntity(meshName);
node2->attachObject(ent);
node2->setScale(scale);
ent = app->m_SceneManager->createEntity(meshName);
node3->attachObject(ent);
node3->setScale(scale);
}
node1->setPosition(app->m_Camera->getDerivedPosition() + (app->m_Camera->getDerivedOrientation().xAxis() * offset)); // Right
node2->setPosition(app->m_Camera->getDerivedPosition() + (app->m_Camera->getDerivedOrientation().yAxis() * offset)); // Up
node3->setPosition(app->m_Camera->getDerivedPosition() + (-app->m_Camera->getDerivedOrientation().zAxis() * offset)); // Forward
Replace "barrel0.mesh" with any mesh you have and play with the scale/offset variables.
My project: https://imagindar.com/
-
- Gnoblar
- Posts: 7
- Joined: Wed Nov 28, 2018 10:15 am
Re: Visualise Orientation of camera
Yes, I was looking for something like that thanks!