예제 #1
0
void Material::ScaleTextureMatrix(const IvVector3& scale, int idx)
{
	//mUseTextureMatrix = true;
	IvMatrix44 m;
	m.Scaling(scale);
	mTextureMatrices[idx] *= m;
}
예제 #2
0
//-------------------------------------------------------------------------------
// @ 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()
예제 #3
0
void Material::RotateTextureMatrixZ(float angle, int idx)
{
	//mUseTextureMatrix = true;
	IvMatrix44 m;
	m.RotationZ(angle);
	mTextureMatrices[idx] *= m;
}
예제 #4
0
void Material::TranslateTextureMatrix(const IvVector3& p, int idx)
{
	//mUseTextureMatrix = true;
	IvMatrix44 m;
	m.Translation(p);
	mTextureMatrices[idx] *= m;
}
예제 #5
0
void Material::RotateTextureMatrix(IvVector3& axis, float angle, int idx)
{
	//mUseTextureMatrix = true;
	IvMatrix44 m;
	m.Rotation(axis, angle);
	mTextureMatrices[idx] *= m;
}
예제 #6
0
void Material::RotateTextureMatrix(float x_angle, float y_angle, float z_angle, int idx)
{
	//mUseTextureMatrix = true;
	IvMatrix44 m;
	m.Rotation(x_angle, y_angle, z_angle);
	mTextureMatrices[idx] *= m;
}
예제 #7
0
void Material::RotateTextureMatrix(IvQuat& rot, int idx)
{
	//mUseTextureMatrix = true;
	IvMatrix44 m;
	m.Rotation(rot);
	mTextureMatrices[idx] *= m;
}
예제 #8
0
//-------------------------------------------------------------------------------
// @ Player::Update()
//-------------------------------------------------------------------------------
// Main update loop
//-------------------------------------------------------------------------------
void
Player::Update( float dt )
{
    float r = 0.0f;
    static bool lightDirChanged = true;

    // set up rotate
    if (IvGame::mGame->mEventHandler->IsKeyDown('o'))
    {
        r -= kPI*0.25f*dt;
        lightDirChanged = true;
    }
    if (IvGame::mGame->mEventHandler->IsKeyDown('u'))
    {
        r += kPI*0.25f*dt;
        lightDirChanged = true;
    }

    if (lightDirChanged)
    {
        IvMatrix44 rotate;
        rotate.RotationZ(r);
       
        mLightDir = rotate.Transform(mLightDir);
        mLightDir.Normalize();

        lightDirChanged = false;
    }

    // clear transform
    if (IvGame::mGame->mEventHandler->IsKeyDown(' '))
    {
        mRotate.Identity();
    }
}   // End of Player::Update()
예제 #9
0
//-------------------------------------------------------------------------------
// @ Player::Render()
//-------------------------------------------------------------------------------
// Render stuff
//-------------------------------------------------------------------------------
void 
Player::Render()                                    
{   
    // build 4x4 matrix
    IvMatrix44 transform;

    int i,j;
    for (j = 0; j <=0 ; j++)
    {
        for (i = 0; i <= 0; i++)
        {
            transform(0, 3) = 5.0f * i;
            transform(2, 3) = 5.0f * j;
            
            IvVector3 lightDir = transform.AffineInverse().Transform(mLightDir);

            mShader->GetUniform("dirLightPosition")->SetValue(lightDir, 0);

            ::IvSetWorldMatrix(transform);

            // draw geometry
            DrawSphere();
        }
    }

}   // End of Player::Render()
예제 #10
0
//-------------------------------------------------------------------------------
// @ 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 );
}
예제 #11
0
//-------------------------------------------------------------------------------
// @ Player::Render()
//-------------------------------------------------------------------------------
// Render stuff
//-------------------------------------------------------------------------------
void 
Player::Render()                                    
{   
    // build 4x4 matrix
    IvMatrix44 transform;
    transform.Scaling(IvVector3(mRadius, mRadius, mRadius));

    int i,j;
    for (j = -1; j <= 1; j++)
    {
        for (i = -1; i <= 1; i++)
        {
            transform(0, 3) = 5.0f * i;
            transform(2, 3) = 5.0f * j;

            mShader->GetUniform("spotLightPosition")->SetValue(
                mLightPos, 0);
            mShader->GetUniform("spotLightDir")->SetValue(
                mLightDir, 0);

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

            // draw geometry
            IvDrawUnitSphere();
        }
    }
    
}   // End of Player::Render()
예제 #12
0
//-------------------------------------------------------------------------------
// @ Player::Render()
//-------------------------------------------------------------------------------
// Render stuff
//-------------------------------------------------------------------------------
void 
Player::Render()                                    
{   
    mLinearInterp.Render();

    // build 4x4 matrix
    IvMatrix44 transform;
    transform.Translation( mTranslate );
    
    IvSetWorldMatrix( transform );
    IvDrawTeapot();
}
예제 #13
0
//-------------------------------------------------------------------------------
// @ 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();

}
예제 #14
0
//-------------------------------------------------------------------------------
// @ Game::Render()
//-------------------------------------------------------------------------------
// Render stuff
//-------------------------------------------------------------------------------
void 
Game::Render()                                  
{       
    // set perspective matrix
    float aspect = (float)IvRenderer::mRenderer->GetWidth()/(float)IvRenderer::mRenderer->GetHeight();
    if ( mUseOrthographic )
    {
        Orthographic( -aspect*3.0f+mXCenter, aspect*3.0f+mXCenter,
                   -3.0f+mYCenter, 3.0f+mYCenter,
                    IvRenderer::mRenderer->GetNearPlane(), 
                    IvRenderer::mRenderer->GetFarPlane() );
    }
    else
    {
        Frustum( -aspect*3.0f+mXCenter, aspect*3.0f+mXCenter,
                   -3.0f+mYCenter, 3.0f+mYCenter,
                    IvRenderer::mRenderer->GetNearPlane(), 
                    IvRenderer::mRenderer->GetFarPlane() );
    }

    // set viewer
    ::IvSetDefaultViewer( 6.0f, 0.0f, 5.f );

    // draw axes
    ::IvDrawAxes();

    // draw floor
    ::IvDrawFloor();

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

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

    worldTransform.Translation( IvVector3( 0.1f, -2.5f, 1.0f ) );
    ::IvSetWorldMatrix( worldTransform );
    ::IvDrawSphere( 1.0f );

}