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


C++ Matrixf类代码示例

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


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

示例1: difference

float  difference(const Descriptor* desc1, const Descriptor* desc2, Descriptor& desc, float (*diff) (float, float) )
{
    // assuming desc is valid
    if( desc2 == 0){
        desc.clear();
        desc.m_na = desc1->size_a();
        desc.m_nz = desc1->size_z();
        desc.m_nr = desc1->size_r();
        Matrixf *pm = new Matrixf( * desc1->getPage(0)  );
        pm->clone();
        desc.m_vHistPtr.push_back(pm);
        return 0.0f;
    }
    else if( desc1 == desc2 ){
        desc.clear();
        desc.m_na = desc1->size_a();
        desc.m_nz = desc1->size_z();
        desc.m_nr = desc1->size_r();
        Matrixf *pm = new Matrixf( desc.m_na * desc.m_nz, desc.m_nr  );
        pm->setAllZeros();
        desc.m_vHistPtr.push_back(pm);
        return 0.0f;
    }
    else
        return difference(*desc1, *desc2, desc, diff);
}
开发者ID:xiaochuanq,项目名称:NeuronMatch,代码行数:26,代码来源:desc.cpp

示例2: m_fSumWeight

Descriptor::Descriptor( const Neuron& neuron, const SphericalMesh& mesh)
    : m_fSumWeight(0)
{
    m_na = mesh.numAzimuth();
    m_nz = mesh.numZenith();
    m_nr = mesh.numRadius();
    vector<Vector3> points;
    vector<float> weights;
    gatherPoints( neuron, points, weights );
    Matrixf* pHist = new Matrixf(height(), width());
    pHist->setAllZeros();
    for( size_t i = 0; i < points.size(); ++i){
        vector<Index3D> index;
        mesh.get_index( points[i].spherical(), index );
        for( size_t j = 0; j < index.size(); ++j){
            float weight = 1.0f;// weights[i];
            assert(weight);
            (*pHist)( index[j].aidx * m_nz +
                      index[j].zidx, index[j].ridx) +=  weight;
            m_fSumWeight += weight;
        }

    }
    m_vHistPtr.push_back( pHist);
    vFlip(true);
    hFlip(true);
    rotate(0); // rotate the original histogram
    rotate(1); // rotate the virtically flipped one
    rotate(2); // rotate the horizontically flipped one
}
开发者ID:xiaochuanq,项目名称:NeuronMatch,代码行数:30,代码来源:desc.cpp

示例3: setCenterPos

/***************************************************************
* Function: setCenterPos()
***************************************************************/
void CAVEGroupReference::setCenterPos(const Vec3 &center)
{
    mCenter = center;
    Matrixf transMat;
    transMat.makeTranslate(mCenter);
    mMatrixTrans->setMatrix(transMat);
}
开发者ID:aprudhomme,项目名称:calvr_plugins,代码行数:10,代码来源:CAVEGroupReference.cpp

示例4: cvCreateVideoWriter

void			Tracker::replayTracker(vector<Matrixu> &vid, string statesfile, string outputvid, uint R, uint G, uint B)
{
	Matrixf states;
	states.DLMRead(statesfile.c_str());
	Matrixu colorframe;

	// save video file
	CvVideoWriter* w = NULL;
	if( ! outputvid.empty() ){
		w = cvCreateVideoWriter( outputvid.c_str(), CV_FOURCC('I','Y','U','V'), 15, cvSize(vid[0].cols(), vid[0].rows()), 3 );
		if( w==NULL ) abortError(__LINE__,__FILE__,"Error opening video file for output");
	}

	for( uint k=0; k<vid.size(); k++ )
	{	
		vid[k].conv2RGB(colorframe);
		colorframe.drawRect(states(k,2),states(k,3),states(k,0),states(k,1),1,0,2,R,G,B);
		colorframe.drawText(("#"+int2str(k,3)).c_str(),1,25,255,255,0);
		colorframe._keepIpl=true;
		colorframe.display(1,2);
		cvWaitKey(1);
		if( w != NULL )
			cvWriteFrame( w, colorframe.getIpl() );
		colorframe._keepIpl=false; colorframe.freeIpl();
	}

	// clean up
	if( w != NULL )
		cvReleaseVideoWriter( &w );
}
开发者ID:caomw,项目名称:MILTracker1.01,代码行数:30,代码来源:Tracker.cpp

示例5: if

/***************************************************************
* Function: applyEditorInfo()
***************************************************************/
void CAVEGroupEditGeodeWireframe::applyEditorInfo(CAVEGeodeShape::EditorInfo **infoPtr)
{
    /* reset root offset only when the shape is moved */
    if ((*infoPtr)->getTypeMasking() == CAVEGeodeShape::EditorInfo::MOVE)
    {
	/* apply translations on 'mAccRootMat' */
	const Vec3 offset = (*infoPtr)->getMoveOffset();

	Matrixd transMat;
	transMat.makeTranslate(offset);
	mAccRootMat = mAccRootMat * transMat;
    }
    else if ((*infoPtr)->getTypeMasking() == CAVEGeodeShape::EditorInfo::ROTATE)
    {
	/* apply rotations on 'mAccRootMat' */
	const float angle = (*infoPtr)->getRotateAngle();
	const Vec3 axis = (*infoPtr)->getRotateAxis();

	Matrixf rotateMat;
	rotateMat.makeRotate(angle, axis);
	mAccRootMat = mAccRootMat * rotateMat;
    }
    else if ((*infoPtr)->getTypeMasking() == CAVEGeodeShape::EditorInfo::SCALE)
    {
	const Vec3f scaleVect = (*infoPtr)->getScaleVect();
	const Vec3f scaleCenter = (*infoPtr)->getScaleCenter();

	Matrixd scalingMat, transMat, revTransMat;
	scalingMat.makeScale(scaleVect);
	transMat.makeTranslate(scaleCenter);
	revTransMat.makeTranslate(-scaleCenter);

	mAccRootMat = mAccRootMat * scalingMat;
    }
}
开发者ID:aprudhomme,项目名称:calvr_plugins,代码行数:38,代码来源:CAVEGroupEditGeodeWireframe.cpp

示例6: GetMatrixRow

/**
* Extract a row from a matrix
* @param matrix The matrix that we are extracting the row for
* @param rowNumber The number of the row that we are working
* @return The matrix row that we are retrieving
*/
Matrixf GetMatrixRow(Matrixf & matrix, int rowNumber)
{
	Matrixf result(matrix.ncols(), 1);
	for (int column = 0; column<matrix.ncols(); column++)
	{
		float value = matrix.get(rowNumber, column);
		result.set(column, 0, value);
	}
	return result;
}
开发者ID:1and1get2,项目名称:cs373ass1,代码行数:16,代码来源:test.cpp

示例7: 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

示例8: Solve

Matrixf XSAdjoint::Solve(const Matrixf& A, const Matrixf& Y) const
{
	if (A.rows() == A.columns())
	{
		return A.inverse() * Y;
	}
	else
	{
		std::cerr
			<< "Error!! Code: Matrixf aries::utility::XSAdjoint::Solve(const Matrixf&, const Matrixf&)" << std::endl
			<< "        Note: Nonsquare matrix cannot bo solved."                                       << std::endl;
		exit(-1);
	}
}
开发者ID:IAries,项目名称:VEDO,代码行数:14,代码来源:XSAdjoint.cpp

示例9: Matrixf

void Descriptor::hFlip(bool duplicate)
{
    Matrixf *pm = m_vHistPtr[0];
    if( duplicate ){
        pm = new Matrixf( *m_vHistPtr[0] );
        pm->clone();
        m_vHistPtr.push_back(pm);
    }
    for( size_t z = 0; z < size_z(); ++z){
        for( size_t a = 0; a < size_a()/2; ++a){
            pm->swaprows(a * size_z() + z, ( size_a() - a -1 )* size_z() + z);
        }
    }
}
开发者ID:xiaochuanq,项目名称:NeuronMatch,代码行数:14,代码来源:desc.cpp

示例10: 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

示例11: acceptCAVEGeodeShape

/***************************************************************
* Function: acceptCAVEGeodeShape()
*
* Compared with original coordinates data in 'CAVEGeodeShape', 
* generated coordinates in 'CAVEGeodeIconSurface' is eaxctly the
* the same as those appeared in 'CAVEGeodeShape'. The scaling and
* translation to 'gIconCenter' effects are impletemented by its
* acendent 'PositionAltitudeTransform' object.
* 
***************************************************************/
void CAVEGroupIconSurface::acceptCAVEGeodeShape(CAVEGeodeShape *shapeGeode, CAVEGeodeShape *shapeGeodeRef)
{
    mCAVEGeodeShapeOriginPtr = shapeGeode;

    CAVEGeometryVector &orgGeomVector = shapeGeode->getCAVEGeometryVector();
    CAVEGeometryVector &refGeomVector = shapeGeodeRef->getCAVEGeometryVector();
    int nGeoms = orgGeomVector.size();
    if (nGeoms <= 0) return;

    /* re-generate vertex coordinate list, keep normal and texcoords the same from 'CAGEGeodeShape' */
    mSurfVertexArray = new Vec3Array;
    mSurfNormalArray = new Vec3Array;
    mSurfUDirArray = new Vec3Array;
    mSurfVDirArray = new Vec3Array;
    mSurfTexcoordArray = new Vec2Array;

    Vec3Array* geodeVertexArray = shapeGeode->mVertexArray;
    Vec3Array* geodeNormalArray = shapeGeode->mNormalArray;
    Vec3Array* geodeUDirArray = shapeGeode->mUDirArray;
    Vec3Array* geodeVDirArray = shapeGeode->mVDirArray;
    Vec2Array* geodeTexcoordArray = shapeGeode->mTexcoordArray;

    Vec3 *geodeVertexDataPtr, *geodeNormalDataPtr, *geodeUDirDataPtr, *geodeVDirDataPtr;
    Vec2 *geodeTexcoordDataPtr;

    /* check the valid status of all data field from 'CAVEGeodeShape' */
    if (geodeVertexArray->getType() == Array::Vec3ArrayType)
        geodeVertexDataPtr = (Vec3*) (geodeVertexArray->getDataPointer());
    else return;

    if (geodeNormalArray->getType() == Array::Vec3ArrayType)
        geodeNormalDataPtr = (Vec3*) (geodeNormalArray->getDataPointer());
    else return;

    if (geodeUDirArray->getType() == Array::Vec3ArrayType)
        geodeUDirDataPtr = (Vec3*) (geodeUDirArray->getDataPointer());
    else return;

    if (geodeVDirArray->getType() == Array::Vec3ArrayType)
        geodeVDirDataPtr = (Vec3*) (geodeVDirArray->getDataPointer());
    else return;

    if (geodeTexcoordArray->getType() == Array::Vec2ArrayType)
        geodeTexcoordDataPtr = (Vec2*) (geodeTexcoordArray->getDataPointer());
    else return;

    /* convert vertex coordinates from CAVEGeodeShape space to CAVEGeodeIcon space */
    int nVerts = shapeGeode->mNumVertices;
    for (int i = 0; i < nVerts; i++) mSurfVertexArray->push_back(geodeVertexDataPtr[i]);

    /* preserve the same normals and texture coordinates */
    int nNormals = shapeGeode->mNumNormals;
    for (int i = 0; i < nNormals; i++)
    {
	mSurfNormalArray->push_back(geodeNormalDataPtr[i]);
	mSurfUDirArray->push_back(geodeUDirDataPtr[i]);
	mSurfVDirArray->push_back(geodeVDirDataPtr[i]);
    }

    int nTexcoords = shapeGeode->mNumTexcoords;
    for (int i = 0; i < nTexcoords; i++) mSurfTexcoordArray->push_back(geodeTexcoordDataPtr[i]);

    /* apply offset from 'gShapeCenter' to Vec3(0, 0, 0) on root level */
    Matrixf transMat;
    transMat.makeTranslate(-gShapeCenter);
    mRootTrans->setMatrix(transMat);

    /* copy CAVEGeometry objects into separate 'CAVEGeodeIconSurface' */
    for (int i = 0; i < nGeoms; i++)
    {
	CAVEGeodeIconSurface *iconSurface = new CAVEGeodeIconSurface(&mSurfVertexArray, &mSurfNormalArray,
					&mSurfTexcoordArray, &(orgGeomVector[i]), &(refGeomVector[i]));

	/* 1) take record of 'iconSurface' in mCAVEGeodeIconVector; 2) add it to 'this' group */
	mCAVEGeodeIconVector.push_back(iconSurface);
	mRootTrans->addChild(iconSurface);
    }
}
开发者ID:aprudhomme,项目名称:calvr_plugins,代码行数:88,代码来源:CAVEGroupIconSurface.cpp

示例12: get

void Quat::get(Matrixf& matrix) const
{
    matrix.makeRotate(*this);
}
开发者ID:Kurdakov,项目名称:emscripten_OSG,代码行数:4,代码来源:Quat.cpp

示例13: set

void Quat::set(const Matrixf& matrix)
{
    *this = matrix.getRotate();
}
开发者ID:Kurdakov,项目名称:emscripten_OSG,代码行数:4,代码来源:Quat.cpp

示例14: Render

void Render(float dt)
{
    static unsigned int frameIndex = 0;
    frameIndex++;
    ovrFrameTiming timing = ovrHmd_BeginFrame(s_hmd, 0);

    // ovrSensorState ss = ovrHmd_GetSensorState(s_hmd, timing.ScanoutMidpointSeconds);
    // TODO: Use this for head tracking...
    // TODO: Use player height from SDK

    glBindBuffer(GL_ARRAY_BUFFER, 0);
    glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);

    // render into fbo
    glBindFramebuffer(GL_FRAMEBUFFER, s_fbo);

    // TODO: enable this when we have more complex rendering.
    glEnable(GL_DEPTH_TEST);
    glDisable(GL_CULL_FACE);
    glEnable(GL_BLEND);
    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

    static float t = 0.0;
    t += dt;

    // clear render target
    glViewport(0, 0, s_renderTargetSize.w, s_renderTargetSize.h);
    glClearColor(s_clearColor.x, s_clearColor.y, s_clearColor.z, s_clearColor.w);
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    for (int i = 0; i < 2; i++)
    {
        ovrEyeType eye = s_hmdDesc.EyeRenderOrder[i];
        ovrPosef pose = ovrHmd_BeginEyeRender(s_hmd, eye);

        glViewport(s_eyeTexture[eye].Header.RenderViewport.Pos.x,
                   s_eyeTexture[eye].Header.RenderViewport.Pos.y,
                   s_eyeTexture[eye].Header.RenderViewport.Size.w,
                   s_eyeTexture[eye].Header.RenderViewport.Size.h);

        Quatf q(pose.Orientation.x, pose.Orientation.y, pose.Orientation.z, pose.Orientation.w);
        Vector3f p(pose.Position.x, pose.Position.y, pose.Position.z);

        Matrixf cameraMatrix = Matrixf::QuatTrans(q, s_cameraPos);
        Matrixf viewCenter = cameraMatrix.OrthoInverse();

        // let ovr compute projection matrix, cause it's hard.
        ovrMatrix4f ovrProj = ovrMatrix4f_Projection(s_eyeRenderDesc[eye].Fov, 0.1f, 10000.0f, true);

        // convert to abaci matrix
        Matrixf projMatrix = Matrixf::Rows(Vector4f(ovrProj.M[0][0], ovrProj.M[0][1], ovrProj.M[0][2], ovrProj.M[0][3]),
                                           Vector4f(ovrProj.M[1][0], ovrProj.M[1][1], ovrProj.M[1][2], ovrProj.M[1][3]),
                                           Vector4f(ovrProj.M[2][0], ovrProj.M[2][1], ovrProj.M[2][2], ovrProj.M[2][3]),
                                           Vector4f(ovrProj.M[3][0], ovrProj.M[3][1], ovrProj.M[3][2], ovrProj.M[3][3]));

        // use EyeRenderDesc.ViewAdjust to do eye offset.
        Matrixf viewMatrix = viewCenter * Matrixf::Trans(Vector3f(s_eyeRenderDesc[eye].ViewAdjust.x,
                                                                  s_eyeRenderDesc[eye].ViewAdjust.y,
                                                                  s_eyeRenderDesc[eye].ViewAdjust.z));

        // compute model matrix for terminal
        const float kTermScale = 0.001f;
        const Vector3f termOrigin(-2 * kFeetToMeters, 6.75f * kFeetToMeters, -2.5 * kFeetToMeters);
        Matrixf modelMatrix = Matrixf::ScaleQuatTrans(Vector3f(kTermScale, -kTermScale, kTermScale),
                                                      Quatf::AxisAngle(Vector3f(0, 1, 0), 0),
                                                      termOrigin);
        RenderBegin();

        RenderFloor(projMatrix, viewMatrix, 0.0f);

        RenderTextBegin(projMatrix, viewMatrix, modelMatrix);
        for (int j = 0; j < win_get_text_count(); j++)
        {
            gb::Text* text = (gb::Text*)win_get_text(j);
            if (text)
            {
                RenderText(text->GetQuadVec());
            }
        }
        RenderTextEnd();

        RenderEnd();
        ovrHmd_EndEyeRender(s_hmd, eye, pose, &s_eyeTexture[eye]);
    }

    ovrHmd_EndFrame(s_hmd);
}
开发者ID:kkawamura,项目名称:riftty,代码行数:87,代码来源:riftty.cpp

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