<commit_before>/*!
 * \copyright (c) Nokia Corporation and/or its subsidiary(-ies) (<EMAIL>) and/or contributors
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 *
 * \license{This source file is part of QmlOgre abd subject to the BSD license that is bundled
 * with this source code in the file LICENSE.}
 */

#include "cameranodeobject.h"
#include <OgreRoot.h>
#include <OgreSceneNode.h>
#include <OgreCamera.h>
#include <QDebug>


CameraNodeObject::CameraNodeObject(QObject *parent) :
    OgreCameraWrapper(parent),
    m_yaw(0),
    m_pitch(0),
    m_roll(0),
    m_position(0, 0, 0)
{
}

void CameraNodeObject::setCamera(Ogre::Camera* cam)
{
  m_camera = cam;
  m_node = Ogre::Root::getSingleton().getSceneManager("mySceneManager")->getRootSceneNode()->createChildSceneNode();
  m_node->attachObject(cam);
  m_position = m_node->getPosition();
  //m_node->setPosition(0, 14.9733, 2.13904);
  //setPitch(-6);
  qDebug() << "CamPos" << m_camera->getPosition().x << m_camera->getPosition().y << m_camera->getPosition().z;
  qDebug() << "NodePos" << m_position.x << m_position.y << m_position.z;
}

Ogre::SceneNode* CameraNodeObject::sceneNode() const
{
    return m_node;
}

qreal CameraNodeObject::yaw() const
{
    return m_yaw;
}

qreal CameraNodeObject::pitch() const
{
    return m_pitch;
}

qreal CameraNodeObject::roll() const
{
    return m_roll;
}

qreal CameraNodeObject::x() const
{
   return m_position.x;
}

qreal CameraNodeObject::y() const
{
    return m_position.y;
}

qreal CameraNodeObject::z() const
{
    return m_position.z;
}

void CameraNodeObject::setYaw(qreal y)
{
    m_yaw = y;
    updateRotation();
}

void CameraNodeObject::setPitch(qreal p)
{
    m_pitch = p;
    updateRotation();
}

void CameraNodeObject::setRoll(qreal r)
{
    m_roll = r;
    updateRotation();
}

void CameraNodeObject::setX(qreal x)
{
    m_position.x = x;
    updatePosition();
}

void CameraNodeObject::setY(qreal y)
{
    m_position.y = y;
    updatePosition();
}

void CameraNodeObject::setZ(qreal z)
{
    m_position.z = z;
    updatePosition();
}

void CameraNodeObject::updateRotation()
{
    m_node->resetOrientation();
    m_node->yaw(Ogre::Radian(Ogre::Degree(m_yaw)));
    m_node->pitch(Ogre::Radian(Ogre::Degree(m_pitch)));
    m_node->roll(Ogre::Radian(Ogre::Degree(m_roll)));
}

void CameraNodeObject::updatePosition()
{
    m_node->resetOrientation();
    m_node->setPosition(m_position);
    qDebug() << "CamPos" << m_camera->getPosition().x << m_camera->getPosition().y << m_camera->getPosition().z;
    qDebug() << "NodePos" << m_position.x << m_position.y << m_position.z;
}<commit_msg>Camera yaw, roll and pitch modify entity node instead of root node<commit_after>/*!
 * \copyright (c) Nokia Corporation and/or its subsidiary(-ies) (<EMAIL>) and/or contributors
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 *
 * \license{This source file is part of QmlOgre abd subject to the BSD license that is bundled
 * with this source code in the file LICENSE.}
 */

#include "cameranodeobject.h"
#include <OgreRoot.h>
#include <OgreSceneNode.h>
#include <OgreCamera.h>
#include <QDebug>


CameraNodeObject::CameraNodeObject(QObject *parent) :
    OgreCameraWrapper(parent),
    m_yaw(0),
    m_pitch(0),
    m_roll(0),
    m_position(0, 0, 0)
{
}

void CameraNodeObject::setCamera(Ogre::Camera* cam)
{
  m_camera = cam;
  m_node = Ogre::Root::getSingleton().getSceneManager("mySceneManager")->getRootSceneNode()->createChildSceneNode();
  m_node->attachObject(cam);
  m_position = m_node->getPosition();
  //m_node->setPosition(0, 14.9733, 2.13904);
  //setPitch(-6);
  qDebug() << "CamPos" << m_camera->getPosition().x << m_camera->getPosition().y << m_camera->getPosition().z;
  qDebug() << "NodePos" << m_position.x << m_position.y << m_position.z;
}

Ogre::SceneNode* CameraNodeObject::sceneNode() const
{
    return m_node;
}

qreal CameraNodeObject::yaw() const
{
    return m_yaw;
}

qreal CameraNodeObject::pitch() const
{
    return m_pitch;
}

qreal CameraNodeObject::roll() const
{
    return m_roll;
}

qreal CameraNodeObject::x() const
{
   return m_position.x;
}

qreal CameraNodeObject::y() const
{
    return m_position.y;
}

qreal CameraNodeObject::z() const
{
    return m_position.z;
}

void CameraNodeObject::setYaw(qreal y)
{
    m_yaw = y;
    updateRotation();
}

void CameraNodeObject::setPitch(qreal p)
{
    m_pitch = p;
    updateRotation();
}

void CameraNodeObject::setRoll(qreal r)
{
    m_roll = r;
    updateRotation();
}

void CameraNodeObject::setX(qreal x)
{
    m_position.x = x;
    updatePosition();
}

void CameraNodeObject::setY(qreal y)
{
    m_position.y = y;
    updatePosition();
}

void CameraNodeObject::setZ(qreal z)
{
    m_position.z = z;
    updatePosition();
}

void CameraNodeObject::updateRotation()
{
    Ogre::Node* myNode = Ogre::Root::getSingleton().getSceneManager("mySceneManager")->getRootSceneNode()->getChild("Human");

    myNode->resetOrientation();;
    myNode->yaw(Ogre::Radian(Ogre::Degree(m_yaw)));
    myNode->pitch(Ogre::Radian(Ogre::Degree(m_pitch)));
    myNode->roll(Ogre::Radian(Ogre::Degree(m_roll)));

    /*m_node->resetOrientation();
    m_node->yaw(Ogre::Radian(Ogre::Degree(m_yaw)));
    m_node->pitch(Ogre::Radian(Ogre::Degree(m_pitch)));
    m_node->roll(Ogre::Radian(Ogre::Degree(m_roll)));*/
}

void CameraNodeObject::updatePosition()
{
    m_node->resetOrientation();
    m_node->setPosition(m_position);
    qDebug() << "CamPos" << m_camera->getPosition().x << m_camera->getPosition().y << m_camera->getPosition().z;
    qDebug() << "NodePos" << m_position.x << m_position.y << m_position.z;
}
{'fraction_non_alphanumeric': 0.15670604586518416, 'fraction_numerical': 0.006949270326615705, 'mean_word_length': 4.705649157581764, 'pattern_counts': {'":': 0, '<': 77, '<?xml version=': 0, '>': 53, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6435511', 'n_tokens_mistral': 2125, 'n_tokens_neox': 2058, 'n_words': 394}