From: <de...@us...> - 2003-01-11 11:07:00
|
Update of /cvsroot/csp/APPLICATIONS/CSPFlightSim/Source In directory sc8-pr-cvs1:/tmp/cvs-serv26778 Modified Files: BaseObject.cpp Log Message: quaternion for attitude Index: BaseObject.cpp =================================================================== RCS file: /cvsroot/csp/APPLICATIONS/CSPFlightSim/Source/BaseObject.cpp,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** BaseObject.cpp 15 Dec 2002 00:48:45 -0000 1.6 --- BaseObject.cpp 11 Jan 2003 11:06:57 -0000 1.7 *************** *** 231,235 **** } ! void BaseObject::setOrientation(StandardQuaternion & qOrientation) { m_qOrientation = qOrientation; --- 231,235 ---- } ! void BaseObject::setOrientation(StandardQuaternion const & qOrientation) { m_qOrientation = qOrientation; *************** *** 242,248 **** void BaseObject::setOrientation(double heading, double pitch, double roll) { ! m_Orientation.FromEulerAnglesZXY (DegreesToRadians(heading), ! DegreesToRadians(-pitch), ! DegreesToRadians(roll) ); m_Direction = m_Orientation*m_InitialDirection; m_CurrentNormDir = m_Orientation*m_InitialNormDir; --- 242,248 ---- void BaseObject::setOrientation(double heading, double pitch, double roll) { ! m_Orientation.FromEulerAnglesZXY (osg::DegreesToRadians(heading), ! osg::DegreesToRadians(-pitch), ! osg::DegreesToRadians(roll) ); m_Direction = m_Orientation*m_InitialDirection; m_CurrentNormDir = m_Orientation*m_InitialNormDir; *************** *** 360,370 **** unsigned short i; ! osg::Vec3Array* pl = osgNew osg::Vec3Array; ! for (i = 0; i<10; ++i) ! pl->push_back(osg::Vec3(0.0,-(0.8+i/20.0) * r,0.0)); ! osgParticle::ParticleSystemUpdater *psu = osgNew osgParticle::ParticleSystemUpdater; for (i = 0; i<pl->size();++i) --- 360,370 ---- unsigned short i; ! osg::Vec3Array* pl = new osg::Vec3Array; ! for (i = 0; i<5; ++i) ! pl->push_back(osg::Vec3(0.0,-(0.6+i/20.0) * r,0.0)); ! osgParticle::ParticleSystemUpdater *psu = new osgParticle::ParticleSystemUpdater; for (i = 0; i<pl->size();++i) *************** *** 374,378 **** osg::Vec4(0,0.5,1,1), (*pl)[i],0.05); ! osg::Geode *geode = osgNew osg::Geode; geode->setName("PlayerParticleSystem"); geode->addDrawable(ps); --- 374,378 ---- osg::Vec4(0,0.5,1,1), (*pl)[i],0.05); ! osg::Geode *geode = new osg::Geode; geode->setName("PlayerParticleSystem"); geode->addDrawable(ps); *************** *** 387,391 **** osg::Vec4(0.2, 0.5, 1, 0.8), (*pl)[i],0.01); ! osg::Geode *geode = osgNew osg::Geode; geode->setName("PlayerParticleSystem"); geode->addDrawable(ps); --- 387,391 ---- osg::Vec4(0.2, 0.5, 1, 0.8), (*pl)[i],0.01); ! osg::Geode *geode = new osg::Geode; geode->setName("PlayerParticleSystem"); geode->addDrawable(ps); *************** *** 394,399 **** } ! //g_pBattlefield->addNodeToScene(psu); ! m_rpTransform.get()->addChild(psu); } --- 394,399 ---- } ! g_pBattlefield->addNodeToScene(psu); ! //m_rpTransform.get()->addChild(psu); } *************** *** 403,412 **** // master object to which all others ones are linked ! m_rpTransform = osgNew osg::MatrixTransform; m_rpTransform->setName("m_sObjectName"); if (m_sObjectName == "PLAYER" ) { ! //AddSmoke(); } --- 403,412 ---- // master object to which all others ones are linked ! m_rpTransform = new osg::MatrixTransform; m_rpTransform->setName("m_sObjectName"); if (m_sObjectName == "PLAYER" ) { ! AddSmoke(); } *************** *** 446,450 **** { // this needs 2 upgrades; // first one is: working with quat and only quat; ! // second is: make an osg app() callback CSP_LOG(CSP_APP, CSP_DEBUG, "BaseObject::updateScene() ID:" << m_iObjectID ); --- 446,450 ---- { // this needs 2 upgrades; // first one is: working with quat and only quat; ! // second is: make an osg update() callback CSP_LOG(CSP_APP, CSP_DEBUG, "BaseObject::updateScene() ID:" << m_iObjectID ); *************** *** 474,481 **** m_rpTransform->setMatrix(worldMat); */ osg::Quat q = osg::Quat(m_qOrientation.x,m_qOrientation.y,m_qOrientation.z, m_qOrientation.w); m_rpTransform->setMatrix(osg::Matrix::rotate(q) ! * osg::Matrix::translate(m_LocalPosition.x,m_LocalPosition.y, m_LocalPosition.z)); CSP_LOG(CSP_APP, CSP_DEBUG, "BaseObject::updateScene() - Position: " << --- 474,495 ---- m_rpTransform->setMatrix(worldMat); */ + osg::Quat q = osg::Quat(m_qOrientation.x,m_qOrientation.y,m_qOrientation.z, m_qOrientation.w); m_rpTransform->setMatrix(osg::Matrix::rotate(q) ! * osg::Matrix::translate(m_LocalPosition.x,m_LocalPosition.y, m_LocalPosition.z)); ! ! /* ! double round = 10000.0; ! osg::Quat q = osg::Quat(floor(round * m_qOrientation.x) / round, ! floor(round * m_qOrientation.y) / round, ! floor(round * m_qOrientation.z) / round, ! floor(round * m_qOrientation.w) / round); ! osg::Vec3 t = osg::Vec3(floor(round * m_LocalPosition.x) / round, ! floor(round * m_LocalPosition.y) / round, ! floor(round * m_LocalPosition.z) / round); ! m_rpTransform->setMatrix(osg::Matrix::rotate(q) ! * osg::Matrix::translate(t)); ! */ CSP_LOG(CSP_APP, CSP_DEBUG, "BaseObject::updateScene() - Position: " << |