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


C++ GfxStats::update方法代码示例

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


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

示例1: updateScene

void AmbientDiffuseDemo::updateScene(float dt)
{
    mGfxStats->setVertexCount(mTeapot->GetNumVertices());
    mGfxStats->setTriCount(mTeapot->GetNumFaces());
    mGfxStats->update(dt);

    // Get snapshot of input devices.
    gDInput->poll();

    // Check input.
    if( gDInput->keyDown(DIK_W) )
        mCameraHeight   += 25.0f * dt;
    if( gDInput->keyDown(DIK_S) )
        mCameraHeight   -= 25.0f * dt;

    // Divide by 50 to make mouse less sensitive.
    //mCameraRotationY += gDInput->mouseDX() / 100.0f;
    //mCameraRadius    += gDInput->mouseDY() / 25.0f;
    if( gDInput->keyDown(DIK_LEFT) )
        mCameraRotationY += 1.0f * dt;
    if( gDInput->keyDown(DIK_RIGHT) )
        mCameraRotationY -= 1.0f * dt;

    if( gDInput->keyDown(DIK_UP) )
        mCameraRadius -= 3.0f * dt;
    if( gDInput->keyDown(DIK_DOWN) )
        mCameraRadius += 3.0f * dt;


    // If we rotate over 360 degrees, just roll back to 0
    if( fabsf(mCameraRotationY) >= 2.0f * D3DX_PI )
        mCameraRotationY = 0.0f;

    // Don't let radius get too small.
    if( mCameraRadius < 5.0f )
        mCameraRadius = 5.0f;

    // The camera position/orientation relative to world space can
    // change every frame based on input, so we need to rebuild the
    // view matrix every frame with the latest changes.
    buildViewMtx();
}
开发者ID:erickterri,项目名称:3dlearn,代码行数:42,代码来源:AmbientDiffuseDemo.cpp

示例2: updateScene

void StencilMirrorDemo::updateScene(float dt)
{
	mGfxStats->update(dt);

	gDInput->poll();

	if (gDInput->keyDown(DIK_W))
		mCameraHeight += 25.0f * dt;
	if (gDInput->keyDown(DIK_S))
		mCameraHeight -= 25.0f * dt;

	// divide by 50 to make mouse less sensitive
	mCameraRotationY += gDInput->mouseDX() / 100.0f;
	mCameraRadius    += gDInput->mouseDY() / 25.0f;

	if (fabsf(mCameraRotationY) >= 2.0f * D3DX_PI)
		mCameraRotationY = 0.0f;

	if (mCameraRadius < 3.0f)
		mCameraRadius = 3.0f;

	buildViewMtx();
}
开发者ID:kasicass,项目名称:introdx9,代码行数:23,代码来源:StencilMirror.cpp

示例3: updateScene

void Evolution::updateScene(float dt)
{
    gDInput->poll();

    mTrueTime = dt;
    mCoolTime += mTrueTime;

    //mBellyFoods = 0;

    mGfxStats->setTriCount((lifeformList.size()+foodList.size()+eggList.size())*2);
    mGfxStats->setVertexCount((lifeformList.size()+foodList.size()+eggList.size())*4);
    mGfxStats->update(mTrueTime);

    dt *= mTimeSpeed;

    if (gDInput->keyDown(DIK_LEFT) && mCoolTime > 0.1f)
    {
        --mTimeSpeed;
        if (mTimeSpeed < 1.0f)
            mTimeSpeed = 1.0f;
        mCoolTime = 0.0f;
    }

    if (gDInput->keyDown(DIK_RIGHT) && mCoolTime > 0.1f)
    {
        ++mTimeSpeed;
        if (mTimeSpeed > 30.0f)
            mTimeSpeed = 30.0f;
        mCoolTime = 0.0f;
    }


    POINT mpos;
    GetCursorPos(&mpos);
    ScreenToClient(mhMainWnd, &mpos);
    //mpos.x -= 400;
    ////mpos.y = -mpos.y + 300;
    //D3DXVECTOR4 mousePos;
    //D3DXVec3Transform(&mousePos, &(D3DXVECTOR3(mpos.x, mpos.y, 0.0f)), &(mView*mProj));

    //Mouse position and clicking stuff
    D3DXVECTOR3 mousePos(0.0f, 0.0f, 0.0f);
    static float w = (float)md3dPP.BackBufferWidth;
    static float h = (float)md3dPP.BackBufferHeight;
    float x = (2.0f*mpos.x/w - 1.0f) / mProj(0,0);
    float y = (-2.0f*mpos.y/h + 1.0f) / mProj(1,1);

    D3DXVECTOR3 dir(x, y, 1.0f);

    D3DXMATRIX invView;
    D3DXMatrixInverse(&invView, 0, &mView);

    D3DXVec3TransformNormal(&mousePos, &dir, &invView);
    D3DXVec3Normalize(&mousePos, &mousePos);

    float ratio = -mCameraPos.z/mousePos.z;

    mousePos.x = mousePos.x*ratio + mCameraPos.x;
    mousePos.y = mousePos.y*ratio + mCameraPos.y;

    //Zooming in/out
    // Try making a ray to each of the four corners and go from there
    if (gDInput->mouseDZ() != 0.0f)
    {
        mCameraPos.z += gDInput->mouseDZ()*mTrueTime*400.000f;
        mCameraPos.x += (gDInput->mouseDZ()*0.5000f*(mousePos.x-mCameraPos.x))*mTrueTime;
        mCameraPos.y += (gDInput->mouseDZ()*0.5000f*(mousePos.y-mCameraPos.y))*mTrueTime;
    }

    if (mbFollow)
    {
        mCameraPos.x = mFollowPos.x;
        mCameraPos.y = mFollowPos.y;
    }

    if (mCameraPos.z > -300.0f)
        mCameraPos.z = -300.0f;
    if (mCameraPos.z < -MapX)
        mCameraPos.z = -MapX;

    if (mCameraPos.x < -HalfMapX-mCameraPos.z/2.0f)
        mCameraPos.x = -HalfMapX-mCameraPos.z/2.0f;
    if (mCameraPos.x > HalfMapX+mCameraPos.z/2.0f)
        mCameraPos.x = HalfMapX+mCameraPos.z/2.0f;

    if (mCameraPos.y < -HalfMapY-mCameraPos.z*3.0f/8.0f)
        mCameraPos.y = -HalfMapY-mCameraPos.z*3.0f/8.0f;
    if (mCameraPos.y > HalfMapY+mCameraPos.z*3.0f/8.0f)
        mCameraPos.y = HalfMapY+mCameraPos.z*3.0f/8.0f;

    if (gDInput->mouseButtonDown(0) && mCoolTime > 1.0f)
    {
        mbDrawInfo = false;
    }

    if (gDInput->mouseButtonDown(1) && mCoolTime > 1.0f)
    {
        mbFollow = false;
    }

//.........这里部分代码省略.........
开发者ID:DKennedyNS,项目名称:Evolution_Sim,代码行数:101,代码来源:Evolution.cpp

示例4: updateScene

void GfxStatsDemo::updateScene(float dt)
{
	mGfxStats->update(dt);
}
开发者ID:kasicass,项目名称:introdx9,代码行数:4,代码来源:GfxStatsDemo.cpp


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