コード例 #1
0
ファイル: Game.cpp プロジェクト: Angeldude/essentialmath
//-------------------------------------------------------------------------------
// @ Game::Render()
//-------------------------------------------------------------------------------
// Render stuff
//-------------------------------------------------------------------------------
void 
Game::Render()                                  
{       
    // set perspective matrix
    Perspective( IvRenderer::mRenderer->GetFOV(), 
                (float)IvRenderer::mRenderer->GetWidth()/(float)IvRenderer::mRenderer->GetHeight(), 
                IvRenderer::mRenderer->GetNearPlane(), 
                IvRenderer::mRenderer->GetFarPlane() );

    // set viewer
    IvSetDefaultViewer( -10.0f, 0.0f, 5.0f );

    // draw axes
    IvDrawAxes();

    // draw floor
    IvDrawFloor();

    // draw some objects
    IvMatrix44 worldTransform;
    worldTransform.Translation( IvVector3( 0.0f, 0.0f, 1.0f ) );
    IvSetWorldMatrix( worldTransform );
    IvDrawCube();

    worldTransform.Translation( IvVector3( 0.0f, 3.0f, 0.0f ) );
    IvSetWorldMatrix( worldTransform );
    IvDrawTeapot();

    worldTransform.Translation( IvVector3( 0.0f, -2.5f, 1.0f ) );
    IvSetWorldMatrix( worldTransform );
    IvDrawSphere( 1.0f );
}
コード例 #2
0
ファイル: Player.cpp プロジェクト: Angeldude/essentialmath
//-------------------------------------------------------------------------------
// @ Player::Render()
//-------------------------------------------------------------------------------
// Render stuff
//-------------------------------------------------------------------------------
void 
Player::Render()                                    
{   
    // build 4x4 matrix
    IvMatrix44 transform(mRotate);

    transform(0,0) *= mScale;
    transform(1,0) *= mScale;
    transform(2,0) *= mScale;
    transform(0,1) *= mScale;
    transform(1,1) *= mScale;
    transform(2,1) *= mScale;
    transform(0,2) *= mScale;
    transform(1,2) *= mScale;
    transform(2,2) *= mScale;
    transform(0,3) = mTranslate.x;
    transform(1,3) = mTranslate.y;
    transform(2,3) = mTranslate.z;
    
    IvSetWorldMatrix(transform);

    // disable blending
    SetBlendFuncs(kNoneBlendMode);

    // set base texture
    mTextureUniform->SetValue(mBaseTexture);

    // draw inner, opaque cylinder
    DrawCylinder();

    // push transform with larger scale for outside cylinder
    IvMatrix44 transformOutside(mRotate);

    float outerScale = mScale * 1.2f;

    transformOutside(0,0) *= outerScale;
    transformOutside(1,0) *= outerScale;
    transformOutside(2,0) *= outerScale;
    transformOutside(0,1) *= outerScale;
    transformOutside(1,1) *= outerScale;
    transformOutside(2,1) *= outerScale;
    transformOutside(0,2) *= outerScale;
    transformOutside(1,2) *= outerScale;
    transformOutside(2,2) *= outerScale;
    transformOutside(0,3) = mTranslate.x;
    transformOutside(1,3) = mTranslate.y;
    transformOutside(2,3) = mTranslate.z;
    
    IvSetWorldMatrix(transformOutside);

    SetBlendFuncs(mBlendMode);

    // set blending texture
    mTextureUniform->SetValue(mBlendTextures[mCurrentBlendTexIndex]);

    // draw larger, blended cylinder
    DrawCylinder();

}   // End of Player::Render()
コード例 #3
0
ファイル: Player.cpp プロジェクト: dtbinh/essentialmath
//-------------------------------------------------------------------------------
// @ Player::Render()
//-------------------------------------------------------------------------------
// Render stuff
//-------------------------------------------------------------------------------
void 
Player::Render()                                    
{   
    // build 4x4 matrix
    IvMatrix44 transform(mRotate);

    transform(0,0) *= mScale;
    transform(1,0) *= mScale;
    transform(2,0) *= mScale;
    transform(0,1) *= mScale;
    transform(1,1) *= mScale;
    transform(2,1) *= mScale;
    transform(0,2) *= mScale;
    transform(1,2) *= mScale;
    transform(2,2) *= mScale;
    transform(0,3) = mTranslate.x;
    transform(1,3) = mTranslate.y;
    transform(2,3) = mTranslate.z;

    IvSetWorldMatrix(transform);

    // draw geometry
    DrawSphere();

}   // End of Player::Render()
コード例 #4
0
ファイル: Player.cpp プロジェクト: Angeldude/essentialmath
//-------------------------------------------------------------------------------
// @ Player::Render()
//-------------------------------------------------------------------------------
// Render stuff
//-------------------------------------------------------------------------------
void 
Player::Render()                                    
{   
    mLightPosUniform->SetValue(mLightPos[0], 0);
    mLightPosUniform->SetValue(mLightPos[1], 1);

    int i,j;
    for (j = -1; j <= 1; j++)
    {
        for (i = -1; i <= 1; i++)
        {
            // build 4x4 matrix
            IvMatrix44 transform;
            transform.Scaling(IvVector3(mRadius, mRadius, mRadius));
            transform(0, 3) = 5.0f * i;
            transform(2, 3) = 5.0f * j;

            mViewPosUniform->SetValue(IvVector3(0.0f, -10.0f, 0.0f), 0);

            IvSetWorldMatrix(transform);
            mShader->GetUniform("modelMatrix")->SetValue(transform, 0);

            // draw geometry
            IvDrawUnitSphere();
        }
    }

}   // End of Player::Render()
コード例 #5
0
ファイル: Player.cpp プロジェクト: dtbinh/essentialmath
//-------------------------------------------------------------------------------
// @ Player::Render()
//-------------------------------------------------------------------------------
// Render stuff
//-------------------------------------------------------------------------------
void 
Player::Render()                                    
{   
    // build 4x4 matrix
    IvMatrix44 transform(mRotate);

    transform(0,0) *= mScale;
    transform(1,0) *= mScale;
    transform(2,0) *= mScale;
    transform(0,1) *= mScale;
    transform(1,1) *= mScale;
    transform(2,1) *= mScale;
    transform(0,2) *= mScale;
    transform(1,2) *= mScale;
    transform(2,2) *= mScale;
    transform(0,3) = mTranslate.x;
    transform(1,3) = mTranslate.y;
    transform(2,3) = mTranslate.z;

    mShader->GetUniform("dirLightDirection")->SetValue(mLightPos, 0);

    IvSetWorldMatrix(transform);

    // draw geometry
    DrawPlane();

}   // End of Player::Render()
コード例 #6
0
ファイル: Player.cpp プロジェクト: Angeldude/essentialmath
//-------------------------------------------------------------------------------
// @ Player::Render()
//-------------------------------------------------------------------------------
// Render stuff
//-------------------------------------------------------------------------------
void 
Player::Render()                                    
{   
    // build 4x4 matrix
    IvMatrix44 transform(mRotate);
    transform(0,0) *= mScale;
    transform(1,0) *= mScale;
    transform(2,0) *= mScale;
    transform(0,1) *= mScale;
    transform(1,1) *= mScale;
    transform(2,1) *= mScale;
    transform(0,2) *= mScale;
    transform(1,2) *= mScale;
    transform(2,2) *= mScale;
    transform(0,3) = mTranslate.x;
    transform(1,3) = mTranslate.y;
    transform(2,3) = mTranslate.z;
    
    // set current local-to-world matrix
    IvSetWorldMatrix( transform );

    IvRenderer::mRenderer->SetShaderProgram( mUseSkyShader ? mSkyShader : mMarbleShader );

    // draw geometry
    IvDrawTeapot( kWhite, false );
}
コード例 #7
0
ファイル: Player.cpp プロジェクト: dtbinh/essentialmath
//-------------------------------------------------------------------------------
// @ Player::Render()
//-------------------------------------------------------------------------------
// Render stuff
//-------------------------------------------------------------------------------
void 
Player::Render()                                    
{   
    // Draw backdrop quad, which must also write the depth buffer
    IvRenderer::mRenderer->SetDepthWrite(true);
    IvRenderer::mRenderer->SetDepthTest(kLessEqualDepthTest);

    DrawQuad();

    // build 4x4 matrix for left (non-depth-buffered) teapot
    IvMatrix44 transform(mRotate);

    transform(0,0) *= mScale;
    transform(1,0) *= mScale;
    transform(2,0) *= mScale;
    transform(0,1) *= mScale;
    transform(1,1) *= mScale;
    transform(2,1) *= mScale;
    transform(0,2) *= mScale;
    transform(1,2) *= mScale;
    transform(2,2) *= mScale;
    transform(0,3) = mTranslate.x;
    transform(1,3) = mTranslate.y + 4.0f;
    transform(2,3) = mTranslate.z;
    
    IvSetWorldMatrix(transform);

    // draw non-depth-buffered teapot
    IvRenderer::mRenderer->SetDepthWrite(false);
    IvRenderer::mRenderer->SetDepthTest(kDisableDepthTest);
    
    IvDrawTeapot(kRed);
    
    // same as other teapot, but on the right side
    transform(1,3) = mTranslate.y - 4.0f;

    IvSetWorldMatrix(transform);
    
    // draw depth-buffered teapot
    IvRenderer::mRenderer->SetDepthWrite(true);
    IvRenderer::mRenderer->SetDepthTest(kLessEqualDepthTest);

    IvDrawTeapot(kBlue);
    
}   // End of Player::Render()
コード例 #8
0
ファイル: Player.cpp プロジェクト: Angeldude/essentialmath
//-------------------------------------------------------------------------------
// @ Player::Render()
//-------------------------------------------------------------------------------
// Render stuff
//-------------------------------------------------------------------------------
void 
Player::Render()                                    
{   
    mLinearInterp.Render();

    // build 4x4 matrix
    IvMatrix44 transform;
    transform.Translation( mTranslate );
    
    IvSetWorldMatrix( transform );
    IvDrawTeapot();
}
コード例 #9
0
ファイル: SimObject.cpp プロジェクト: Angeldude/essentialmath
//-------------------------------------------------------------------------------
// @ SimObject::Render()
//-------------------------------------------------------------------------------
// Render stuff
//-------------------------------------------------------------------------------
void 
SimObject::Render()                                 
{   
    // build 4x4 matrix
    IvMatrix44 transform( mRotate );
    transform(0,3) = mTranslate.x;
    transform(1,3) = mTranslate.y;
    transform(2,3) = mTranslate.z;

    IvSetWorldMatrix( transform );
    IvDrawCapsule( mLocalCapsule.GetSegment(), mLocalCapsule.GetRadius(), kOrange );
    
}
コード例 #10
0
ファイル: Player.cpp プロジェクト: Angeldude/essentialmath
//-------------------------------------------------------------------------------
// @ Player::Render()
//-------------------------------------------------------------------------------
// Render stuff
//-------------------------------------------------------------------------------
void 
Player::Render()                                    
{   
    // build 4x4 matrix
    IvMatrix44 transform(mRotate);
    IvSetWorldMatrix(transform);
    
    // draw cube
    IvDrawCube( kWhite );
                    
    // draw paths
    if ( mNumPoints < 2 )
        return;

    IvSetWorldIdentity();

    IvDepthTestFunc oldDepthTest = IvRenderer::mRenderer->GetDepthTest();
    IvRenderer::mRenderer->SetDepthTest(kDisableDepthTest);              // Disable Depth Testing

    if ( !mStrip0 )
    {
        mStrip0 = IvRenderer::mRenderer->GetResourceManager()->CreateVertexBuffer(kCPFormat, 1280,
                                                                                  nullptr, kDefaultUsage);
    }

    IvCPVertex* curveDataPtr = (IvCPVertex*) mStrip0->BeginLoadData();
    for (unsigned int i = 0; i < mNumPoints; ++i)
    {
        curveDataPtr[i].position = mStoredPoints[0][i];
        curveDataPtr[i].color = kOrange;
    }
    (void) mStrip0->EndLoadData();
    IvRenderer::mRenderer->Draw( kLineStripPrim, mStrip0, mNumPoints );

    if ( !mStrip1 )
    {
        mStrip1 = IvRenderer::mRenderer->GetResourceManager()->CreateVertexBuffer(kCPFormat, 1280,
                                                                                  nullptr, kDefaultUsage);
    }

    curveDataPtr = (IvCPVertex*) mStrip1->BeginLoadData();
    for (unsigned int i = 0; i < mNumPoints; ++i)
    {
        curveDataPtr[i].position = mStoredPoints[1][i];
        curveDataPtr[i].color = kOrange;
    }
    (void) mStrip1->EndLoadData();
    IvRenderer::mRenderer->Draw( kLineStripPrim, mStrip1, mNumPoints );

    IvRenderer::mRenderer->SetDepthTest(oldDepthTest);
}
コード例 #11
0
ファイル: Player.cpp プロジェクト: Angeldude/essentialmath
//-------------------------------------------------------------------------------
// @ Player::Render()
//-------------------------------------------------------------------------------
// Render stuff
//-------------------------------------------------------------------------------
void 
Player::Render()                                    
{   
    // draw curve
    mCurve.Render();

    // build 4x4 matrix
    IvMatrix44 transform;
    transform.Translation( mTranslate );
    
    IvSetWorldMatrix( transform );

    // draw the teapot
    IvDrawTeapot();

}
コード例 #12
0
ファイル: Player.cpp プロジェクト: Angeldude/essentialmath
//-------------------------------------------------------------------------------
// @ Player::Render()
//-------------------------------------------------------------------------------
// Render stuff
//-------------------------------------------------------------------------------
void 
Player::Render()                                    
{   
    mTurret->Render( mScale, mRotate, mTranslate );

    // build 4x4 matrix
    IvMatrix44 transform( mRotate );
    transform(0,0) *= mScale;
    transform(1,0) *= mScale;
    transform(2,0) *= mScale;
    transform(0,1) *= mScale;
    transform(1,1) *= mScale;
    transform(2,1) *= mScale;
    transform(0,2) *= mScale;
    transform(1,2) *= mScale;
    transform(2,2) *= mScale;
    transform(0,3) = mTranslate.x;
    transform(1,3) = mTranslate.y;
    transform(2,3) = mTranslate.z;
    
    IvSetWorldMatrix( transform );
    IvRenderer::mRenderer->Draw(kTriangleListPrim, mVertices, mIndices);
}