当前位置: 首页>>代码示例>>C++>>正文


C++ Matrixf::getTrans方法代码示例

本文整理汇总了C++中Matrixf::getTrans方法的典型用法代码示例。如果您正苦于以下问题:C++ Matrixf::getTrans方法的具体用法?C++ Matrixf::getTrans怎么用?C++ Matrixf::getTrans使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Matrixf的用法示例。


在下文中一共展示了Matrixf::getTrans方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: sizeof

/***************************************************************
*  Function: preFrame()
***************************************************************/
void Maze2::preFrame()
{
    /* get pointer position in world space */
    Matrixf invBaseMat = PluginHelper::getWorldToObjectTransform();
    Matrixf viewMat = PluginHelper::getHeadMat(0);
    Matrixf xformMat = PluginHelper::getObjectMatrix();
 
    /* get viewer's position in world space */
    Vec3 viewOrg = viewMat.getTrans() * invBaseMat; 
    Vec3 viewPos = Vec3(0.0, 1.0, 0.0) * viewMat * invBaseMat; 
    Vec3 viewDir = viewPos - viewOrg;
    viewDir.normalize();

    mAudioConfigHandler->updatePoses(viewDir, viewPos);
    mNaviHandler->updateNaviStates(Navigation::instance()->getScale(), viewDir, viewPos);
    // mNaviHandler->updateButtonStates();
    mNaviHandler->updateXformMat();

    /* ECGClient: Master-Slave operations: Read current time for update */
    double frameDuration;
    if(ComController::instance()->isMaster())
    {
		frameDuration = PluginHelper::getLastFrameDuration();
		((double*)mClkBuf)[0] = frameDuration;
		ComController::instance()->sendSlaves((char*) &mClkBuf, sizeof(mClkBuf));
    } else {
		ComController::instance()->readMaster((char*) &mClkBuf, sizeof(mClkBuf));
		frameDuration = ((double*)mClkBuf)[0];
    }
    mECGClient->update(viewMat, invBaseMat, xformMat, frameDuration);

/*
cerr << "viewPos = " << viewPos.x() << " " << viewPos.y() << " " << viewPos.z() << endl;
cerr << "scale = " << PluginHelper::getObjectScale() << endl;
cerr << "invBaseMat: "  << endl;
cerr << invBaseMat(0, 0) << " " << invBaseMat(0, 1) << " " << invBaseMat(0, 2) << " " << invBaseMat(0, 3) << " " << endl;
cerr << invBaseMat(1, 0) << " " << invBaseMat(1, 1) << " " << invBaseMat(1, 2) << " " << invBaseMat(1, 3) << " " << endl;
cerr << invBaseMat(2, 0) << " " << invBaseMat(2, 1) << " " << invBaseMat(2, 2) << " " << invBaseMat(2, 3) << " " << endl;
cerr << invBaseMat(3, 0) << " " << invBaseMat(3, 1) << " " << invBaseMat(3, 2) << " " << invBaseMat(3, 3) << " " << endl;
cerr << "xformMat: "  << endl;
cerr << xformMat(0, 0) << " " << xformMat(0, 1) << " " << xformMat(0, 2) << " " << xformMat(0, 3) << " " << endl;
cerr << xformMat(1, 0) << " " << xformMat(1, 1) << " " << xformMat(1, 2) << " " << xformMat(1, 3) << " " << endl;
cerr << xformMat(2, 0) << " " << xformMat(2, 1) << " " << xformMat(2, 2) << " " << xformMat(2, 3) << " " << endl;
cerr << xformMat(3, 0) << " " << xformMat(3, 1) << " " << xformMat(3, 2) << " " << xformMat(3, 3) << " " << endl;
cerr << "viewMat: "  << endl;
cerr << viewMat(0, 0) << " " << viewMat(0, 1) << " " << viewMat(0, 2) << " " << viewMat(0, 3) << " " << endl;
cerr << viewMat(1, 0) << " " << viewMat(1, 1) << " " << viewMat(1, 2) << " " << viewMat(1, 3) << " " << endl;
cerr << viewMat(2, 0) << " " << viewMat(2, 1) << " " << viewMat(2, 2) << " " << viewMat(2, 3) << " " << endl;
cerr << viewMat(3, 0) << " " << viewMat(3, 1) << " " << viewMat(3, 2) << " " << viewMat(3, 3) << " " << endl;
cerr << endl;
*/

}
开发者ID:aprudhomme,项目名称:calvr_plugins,代码行数:56,代码来源:Maze2.cpp

示例2: preFrame

/***************************************************************
*  Function: preFrame()
***************************************************************/
void EOGCalibration::preFrame()
{
    Matrixf invBaseMat = PluginHelper::getWorldToObjectTransform();
    Matrixf viewMat = PluginHelper::getHeadMat(0);
    Matrixf xformMat = PluginHelper::getObjectMatrix();
 
    /* get viewer's position in world space */
    Vec3 viewOrg = viewMat.getTrans() * invBaseMat; 
    Vec3 viewPos = Vec3(0.0, 1.0, 0.0) * viewMat * invBaseMat; 
    Vec3 viewDir = viewPos - viewOrg;
    viewDir.normalize();

    //mAudioConfigHandler->updatePoses(viewDir, viewPos);
    //mNaviHandler->updateNaviStates(Navigation::instance()->getScale(), viewDir, viewPos);
    //mNaviHandler->updateButtonStates();
    //mNaviHandler->updateXformMat();

    /* ECGClient: Master-Slave operations: Read current time for update */
    double frameDuration;
    if(ComController::instance()->isMaster())
    {
		frameDuration = PluginHelper::getLastFrameDuration();
		((double*)mClkBuf)[0] = frameDuration;
		cvr::ComController::instance()->sendSlaves((char*) &mClkBuf, sizeof(mClkBuf));
    } 
    else 
    {
		cvr::ComController::instance()->readMaster((char*) &mClkBuf, sizeof(mClkBuf));
		frameDuration = ((double*)mClkBuf)[0];
    }

    /* update inverse base matrix for re-aligning calibration field */
    mInvBaseMat = viewMat * invBaseMat;
    mCaliController->updateViewMat(viewMat);

    /*  DEBUGGING OUTPUT: Head position and orientations in CAVE space
    Vec3 rightVec = Vec3(viewMat(0, 0), viewMat(0, 1), viewMat(0, 2));
    Vec3 frontVec= Vec3(viewMat(1, 0), viewMat(1, 1), viewMat(1, 2));
    Vec3 upVec = Vec3(viewMat(2, 0), viewMat(2, 1), viewMat(2, 2));
    Vec3 headPos = Vec3(viewMat(3, 0), viewMat(3, 1), viewMat(3, 2)) / 1000.f;
    cerr << "Right vector = " << rightVec.x() << " " << rightVec.y() << " " << rightVec.z() << endl;
    cerr << "Front vector = " << frontVec.x() << " " << frontVec.y() << " " << frontVec.z() << endl;
    cerr << "Up vector = " << upVec.x() << " " << upVec.y() << " " << upVec.z() << endl;  
    cerr << "Head position = " << headPos.x() << " " << headPos.y() << " " << headPos.z() << endl;
    // cerr << "phi = " << phi << "    theta = " << theta << "    rad = " << rad << endl;
    cerr << endl; 

    DEBUGGING OUTPUT: Viewer positions and orientations in world space
    Vec3 rightVec = Vec3(xformMat(0, 0), xformMat(0, 1), xformMat(0, 2));
    Vec3 frontVec= Vec3(xformMat(1, 0), xformMat(1, 1), xformMat(1, 2));
    Vec3 upVec = Vec3(xformMat(2, 0), xformMat(2, 1), xformMat(2, 2));
    Vec3 headPos = Vec3(xformMat(0, 3), xformMat(1, 3), xformMat(2, 3)) / 1000.f * (-1);
    cerr << "Right vector = " << rightVec.x() << " " << rightVec.y() << " " << rightVec.z() << endl;
    cerr << "Front vector = " << frontVec.x() << " " << frontVec.y() << " " << frontVec.z() << endl;
    cerr << "Up vector = " << upVec.x() << " " << upVec.y() << " " << upVec.z() << endl;  
    cerr << "Head position = " << headPos.x() << " " << headPos.y() << " " << headPos.z() << endl;
    cerr << endl; */

	float phi, theta, rad;
    if (mCaliController->isCaliBallVisible())
	{
    	mCaliController->updateCaliTime(frameDuration);
    	mCaliController->updateCaliBallPos(phi, theta, rad);
	}
	if (mCaliController->isPlaybackBallVisible())
	{
		mCaliController->updatePlaybackTime(frameDuration);
		mCaliController->updatePlaybackBallPos();
		playbackTimerLabel->setText(mCaliController->getPlaybackTimeLabel());
	}

    /* create client message and send to data server */
    if (mFlagConnected && mFlagMaster && mCaliController->isCalibrationStarted() && mCaliController->isCaliBallVisible())
    {
        Vec3 headPos = Vec3(viewMat(3, 0), viewMat(3, 1), viewMat(3, 2)) / 1000.f;
        struct MSGClient msg(viewMat(0, 0), viewMat(0, 1), viewMat(0, 2), viewMat(1, 0), viewMat(1, 1), viewMat(1, 2),
                     viewMat(2, 0), viewMat(2, 1), viewMat(2, 2), headPos.x(), headPos.y(), headPos.z(),
                     phi, theta, rad);

        int nBytes = send(mSockfd, &msg, sizeof (MSGClient), 0);
        if (nBytes != sizeof (MSGClient)) 
        {
            std::cerr << "EOGCalibration Warning: Lost data transmission. nBytes = " << nBytes << std::endl;
        }
    }

}
开发者ID:Peachychan,项目名称:calvr_plugins,代码行数:90,代码来源:EOGCalibration.cpp

示例3: preFrame

/***************************************************************
*  Function: preFrame()
***************************************************************/
void CaveCADBeta::preFrame()
{
    /* get pointer position in world space */
    Matrixf invBaseMat = PluginHelper::getWorldToObjectTransform();
    Matrixf baseMat = PluginHelper::getObjectToWorldTransform();
    Matrixf viewMat = PluginHelper::getHeadMat(0);
	Matrixf pointerMat = TrackingManager::instance()->getHandMat(0);

    Vec3 pointerPos = Vec3(0.0, 1000.0, 0.0) * pointerMat * invBaseMat;
    Vec3 pointerOrg = Vec3(0.0, 0.0, 0.0) * pointerMat * invBaseMat;

    /* get viewer's position in world space */
    Vec3 viewOrg = viewMat.getTrans() * invBaseMat; 
    Vec3 viewPos = Vec3(0.0, 1000.0, 0.0) * viewMat * invBaseMat; 
    Vec3 viewDir = viewPos - viewOrg;
    viewDir.normalize(); 

    /* handle pointer/update events */
    // coPointerButton* pointerBtn = cover->getPointerButton();
	unsigned int btn = TrackingManager::instance()->getRawButtonMask();
    // if (pointerBtn->wasPressed())
	if (btn)
    {
		if (!pointerPressFlag)
		{
	    	pointerPressFlag = true;
	    	pointerPressEvent(pointerOrg, pointerPos);
		}	
    }
	// else if (pointerBtn->wasReleased()) 
    else if (!btn)
    {
		pointerReleaseEvent();
		pointerPressFlag = false;
    }
    else
    {
		pointerMoveEvent(pointerOrg, pointerPos);
    }
    mCAVEDesigner->update(viewDir, viewPos);

    /* spin wheel and top pointer buttons */
    float spinX = PluginHelper::getValuator(0, 0);
    float spinY = PluginHelper::getValuator(0, 1);
    int pointerStat = TrackingManager::instance()->getRawButtonMask();

    spinWheelEvent(spinX, spinY, pointerStat);

    /* Debugging codes for model calibration
    float scale = PluginHelper::getObjectScale();
    Matrix xMat = PluginHelper::getObjectMatrix();

    cerr << endl << "Scale = " << scale << endl;
    cerr << xMat(0, 0) << " " << xMat(0, 1) << " " << xMat(0, 2) << " " << xMat(0, 3) << endl;
    cerr << xMat(1, 0) << " " << xMat(1, 1) << " " << xMat(1, 2) << " " << xMat(1, 3) << endl;
    cerr << xMat(2, 0) << " " << xMat(2, 1) << " " << xMat(2, 2) << " " << xMat(2, 3) << endl;
    cerr << xMat(3, 0) << " " << xMat(3, 1) << " " << xMat(3, 2) << " " << xMat(3, 3) << endl;

    cerr << " Frame Count = " << frameCnt++ << endl;
    */
}
开发者ID:aprudhomme,项目名称:calvr_plugins,代码行数:64,代码来源:CaveCADBeta.cpp


注:本文中的Matrixf::getTrans方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。