/**------------------------------------------------------------------------------- update @brief @return void ---------------------------------------------------------------------------------*/ void SensorDecoratorVector::update() { mSensor->update(); if (getDataValid()) { std::vector<Ogre::Vector3> out; getValue(out); Ogre::Vector3 pos(out[0].x, out[0].y, out[0].z); Ogre::Vector3 force(out[1].x, out[1].y, out[1].z); getParentNode()->setPosition(pos); setVisible(true); Ogre::Vector3 posA(0, 0, 0); Ogre::Vector3 posB = force / force.length() * 5; Ogre::Vector3 t0 = posB - posA; NxVec3 tan1, tan2; NxVec3 v3 = NxOgre::NxConvert<NxVec3, Ogre::Vector3>(t0); NxNormalToTangents(v3, tan1, tan2); t0.normalise(); Ogre::Vector3 t1 = NxOgre::NxConvert<Ogre::Vector3, NxVec3>(tan1); Ogre::Vector3 t2 = NxOgre::NxConvert<Ogre::Vector3, NxVec3>(tan2); Ogre::Vector3 lobe1 = posB - t0 * ARROW_H + t1 * ARROW_H; Ogre::Vector3 lobe2 = posB - t0 * ARROW_H - t1 * ARROW_H; Ogre::Vector3 lobe3 = posB - t0 * ARROW_H + t2 * ARROW_H; Ogre::Vector3 lobe4 = posB - t0 * ARROW_H - t2 * ARROW_H; beginUpdate(0); position(posA); position(posB); position(posB); position(lobe1); position(posB); position(lobe2); position(posB); position(lobe3); position(posB); position(lobe4); end(); } else { setVisible(false); } // if drawing is not persistent remove it after one draw if (getVisible() && !mPersistent && getDataValid()) { setDataValid(false); } }
void DestructibleWallsDemo::drawBrick( const hkVector4& position, const hkVector4& halfsize) const { hkVector4 posA=position; hkVector4 posC=position; posA.sub4( halfsize ); posC.add4( halfsize ); hkVector4 posB=posA; posB(0) = posC(0); hkVector4 posD=posA; posD(1) = posC(1); posA(2) = posB(2) = posC(2)= posD(2) = .0f; HK_DISPLAY_LINE(posA, posB , 0xffffffff); HK_DISPLAY_LINE(posB, posC , 0xffffffff); HK_DISPLAY_LINE(posC, posD , 0xffffffff); HK_DISPLAY_LINE(posD, posA , 0xffffffff); HK_DISPLAY_LINE(posA, posC , 0xffffffff); }
void MovableObject::store(char * snapshot) const { //store pos phy::RecordableFloatPoint<2>::Store(snapshot, posA()); snapshot += phy::RecordableFloatPoint<2>::SnapshotSize(); phy::RecordableFloatPoint<2>::Store(snapshot, posB()); snapshot += phy::RecordableFloatPoint<2>::SnapshotSize(); //store tMatrix phy::RecordableFloatMatrix<4, 4>::Store(snapshot, m_tMatrix.active()); snapshot += phy::RecordableFloatMatrix<4, 4>::SnapshotSize(); phy::RecordableFloatMatrix<4, 4>::Store(snapshot, m_tMatrix.background()); snapshot += phy::RecordableFloatMatrix<4, 4>::SnapshotSize(); //store tMatrixInv phy::RecordableFloatMatrix<4, 4>::Store(snapshot, m_tMatrixInv.active()); snapshot += phy::RecordableFloatMatrix<4, 4>::SnapshotSize(); phy::RecordableFloatMatrix<4, 4>::Store(snapshot, m_tMatrixInv.background()); snapshot += phy::RecordableFloatMatrix<4, 4>::SnapshotSize(); }
void DemoApplication::render() { OVector3 posA(0.0f); OVector3 posB(0.0f); OMatrixStack mtx; /* calculating displacement vectors */ posA.setX(_movRadiusA*cosf(_thetaA)); posA.setZ(_movRadiusA*sinf(_thetaA)); posB.setX(_movRadiusB*cosf(_thetaB)); posB.setZ(_movRadiusB*sinf(_thetaB)); /* Get initial matrix from camera related transforms */ mtx = *(camera()->transform()); /* render cube */ mtx.push(); mtx.translate(posA); mtx.scale(0.5f); _cube->render(&mtx); mtx.pop(); /* render torus */ mtx.push(); mtx.translate(posB); mtx.scale(0.25f); mtx.rotateX(45.0f); _torus->render(&mtx); mtx.pop(); /* render text */ _title->render(); _fpsText->render(); _perfText->render(); _idleText->render(); _cameraText->render(); _renderText->render(); }
real_t MovableObject::pos(std::size_t i) { return posA(i); }
math::const_PointRef<2> MovableObject::pos() const { return posA(); }