//----------------------------------------------------------------------------------
//
//----------------------------------------------------------------------------------
void Renderer::RecalcProjection()
{
	if( m_projection == PROJECTION_TYPE_PERSPECTIVE )
	{
		SetPerspectiveFov( m_width, m_height );
	}
	else if( m_projection == PROJECTION_TYPE_ORTHOGRAPHIC )
	{
		SetOrthographic( m_width, m_height );
	}
}
//----------------------------------------------------------------------------------
//
//----------------------------------------------------------------------------------
void Renderer::SetProjectionType( eProjectionType type )
{
	m_projection = type;

	if( m_projection == PROJECTION_TYPE_PERSPECTIVE )
	{
		SetPerspectiveFov( m_width, m_height );
	}
	else if( m_projection == PROJECTION_TYPE_ORTHOGRAPHIC )
	{
		SetOrthographic( m_width, m_height );
	}
}
Example #3
0
void Camera::SetFarZ(float val)
{
    RETURN_IF_EQUAL(mFarZ, val);
    mFarZ = val;
    if (mIsOrtho)
    {
        SetOrtho(mWinSize,mNearZ, mFarZ);
    }
    else
    {
        SetPerspectiveFov(mWinSize,mFovY, mNearZ, mFarZ);
    }
}
//----------------------------------------------------------------------------------
//
//----------------------------------------------------------------------------------
bool Renderer::Resize( int width, int height )
{
	m_width = width;
	m_height = height;

	if( m_projection == PROJECTION_TYPE_PERSPECTIVE )
	{
		SetPerspectiveFov( width, height );
	}
	else if( m_projection == PROJECTION_TYPE_ORTHOGRAPHIC )
	{
		SetOrthographic( width, height );
	}

	ResetDevice();

	return true;
}
Example #5
0
void Camera::ResetDefault(const Size2F& winSize, bool isOrtho /*= false*/)
{
    mWinSize = winSize;
    mIsOrtho = isOrtho;
    float zEye = winSize.Height / 1.1566f;//this magic number will show the picture "pixel-to-pixel" on the screen
    mEyePosition = Point3F(winSize.Width / 2.f, winSize.Height / 2.f, zEye);
    mEyeTarget = Vector3F(winSize.Width / 2.f, winSize.Height / 2.f, 0.f);
    mCameraUp=Vector3F(0.f,1.f,0.f);

    if (mIsOrtho)
    {
        SetOrtho(mWinSize, 0.f, 2048.f);
    }
    else
    {
        mFovY = Math::ToRadian(60.f);
        mNearZ = 0.1f;
        mFarZ = zEye * 2;
        SetPerspectiveFov(mWinSize,mFovY, mNearZ, mFarZ);
    }
    LookAt(mEyePosition,mEyeTarget,mCameraUp);
}
//----------------------------------------------------------------------------------
//
//----------------------------------------------------------------------------------
bool Renderer::Initialize( HWND handle, int width, int height )
{
	HRESULT hr;

	D3DPRESENT_PARAMETERS d3dp;
	ZeroMemory(&d3dp, sizeof(d3dp));
	d3dp.BackBufferWidth = width;
	d3dp.BackBufferHeight = height;
	d3dp.BackBufferFormat = D3DFMT_X8R8G8B8;
    d3dp.BackBufferCount = 1;      
	d3dp.SwapEffect = D3DSWAPEFFECT_DISCARD;
	d3dp.Windowed = TRUE;
	d3dp.hDeviceWindow = handle;
	d3dp.EnableAutoDepthStencil = TRUE;
    d3dp.AutoDepthStencilFormat = D3DFMT_D16;

	m_d3d = Direct3DCreate9(D3D_SDK_VERSION);
	if( m_d3d == NULL ) return false;

	D3DDEVTYPE	deviceTypes[4];
	DWORD	flags[4];
	
	deviceTypes[0] = D3DDEVTYPE_HAL;
	flags[0] = D3DCREATE_HARDWARE_VERTEXPROCESSING;
	deviceTypes[1] = D3DDEVTYPE_HAL;
	flags[1] = D3DCREATE_SOFTWARE_VERTEXPROCESSING;
	deviceTypes[2] = D3DDEVTYPE_REF;
	flags[2] = D3DCREATE_HARDWARE_VERTEXPROCESSING;
	deviceTypes[3] = D3DDEVTYPE_REF;
	flags[3] = D3DCREATE_SOFTWARE_VERTEXPROCESSING;

	for( int ind = 0; ind < 4; ind++ )
	{
		hr = m_d3d->CreateDevice( 
			D3DADAPTER_DEFAULT,
			deviceTypes[ind],
			handle,
			flags[ind],
			&d3dp,
			&m_d3d_device );
		if( SUCCEEDED( hr ) ) break;
	}

	if( FAILED( hr ) )
	{
		ES_SAFE_RELEASE( m_d3d_device );
		ES_SAFE_RELEASE( m_d3d );
		return false;
	}

	m_handle = handle;
	m_width = width;
	m_height = height;

	m_renderer = (::EffekseerRendererDX9::RendererImplemented*)::EffekseerRendererDX9::Renderer::Create( m_d3d_device, m_squareMaxCount );
	m_renderer->SetDistortingCallback(new DistortingCallback(this));

	// グリッド生成
	m_grid = ::EffekseerRenderer::Grid::Create( m_renderer );

	// ガイド作成
	m_guide = ::EffekseerRenderer::Guide::Create( m_renderer );

	m_culling = ::EffekseerRenderer::Culling::Create( m_renderer );

	// 背景作成
	m_background = ::EffekseerRenderer::Paste::Create( m_renderer );


	if( m_projection == PROJECTION_TYPE_PERSPECTIVE )
	{
		SetPerspectiveFov( width, height );
	}
	else if( m_projection == PROJECTION_TYPE_ORTHOGRAPHIC )
	{
		SetOrthographic( width, height );
	}

	GenerateRenderTargets(m_width, m_height);

	return true;
}
Example #7
0
void Camera::SetFovY(float val)
{
    mFovY = val;
    SetPerspectiveFov(mWinSize,mFovY, mNearZ, mFarZ);
}