Example #1
0
bool CApp::bCreateWorld()
{
	m_pCamera = 0;
	m_hCrystal = 0;

	// Create and setup camera ------------------------------------------------
	m_pCamera = new CMyCamera( pGetGraphics() );
	if( !m_pCamera->bCreateRenderCamera( iGetWindowWidth(), iGetWindowHeight() ) )
		return false;

	m_pCamera->CalculateProjection( M3D_PI / 6.0f, 2000.0f, 10.0f );

	m_pCamera->SetPosition( vector3( 0, 0, -750 ) );
	m_pCamera->SetLookAt( vector3( 0, 0, 0 ), vector3( 0, 1, 0 ) );
	m_pCamera->CalculateView();

	pGetScene()->SetClearColor( vector4( 0, 0, 0.5f, 0 ) );

	// Register bubble-entity and create an instance --------------------------
	pGetScene()->RegisterEntityType( "crystal", CCrystal::pCreate );
	m_hCrystal = pGetScene()->hCreateEntity( "crystal" );
	if( !m_hCrystal )
		return false;

	CCrystal *pCrystal = (CCrystal *)pGetScene()->pGetEntity( m_hCrystal );
	if( !pCrystal->bInitialize( "headobject.obj", "turtlebase.png", "turtlenormals.png" ) )
		return false;

	return true;
}
Example #2
0
bool CApp::bCreateWorld()
{
	m_pCamera = 0;
	m_hBubble = 0;

	// Create and setup camera ------------------------------------------------
	m_pCamera = new CMyCamera( pGetGraphics() );
	if( !m_pCamera->bCreateRenderCamera( iGetWindowWidth(), iGetWindowHeight() ) )
		return false;

	m_pCamera->CalculateProjection( M3D_PI / 6.0f, 1000.0f, 1.0f );

	m_pCamera->SetPosition( vector3( 0, 0, -100 ) );
	m_pCamera->SetLookAt( vector3( 0, 0, 0 ), vector3( 0, 1, 0 ) );
	m_pCamera->CalculateView();

	pGetScene()->SetClearColor( vector4( 0, 0, 0.5f, 0 ) );

	// Register bubble-entity and create an instance --------------------------
	pGetScene()->RegisterEntityType( "bubble", CBubble::pCreate );
	m_hBubble = pGetScene()->hCreateEntity( "bubble" );
	if( !m_hBubble )
		return false;

	CBubble *pBubble = (CBubble *)pGetScene()->pGetEntity( m_hBubble );
	if( !pBubble->bInitialize( 20.0f, 16, 16 ) )
		return false;

	return true;
}
Example #3
0
bool CApp::bCreateWorld()
{
	m_pCamera = 0;
	m_hBoard = 0;

	// Create and setup camera ------------------------------------------------
	m_pCamera = new CMyCamera( pGetGraphics() );
	if( !m_pCamera->bCreateRenderCamera( iGetWindowWidth(), iGetWindowHeight() ) )
		return false;

	m_pCamera->CalculateProjection( M3D_PI * 0.5f, 2.0f, 0.001f );

	m_pCamera->SetPosition( vector3( -0.01f, 0.025f, 0 ) );
	m_pCamera->SetLookAt( vector3( 0, 0, 0.05f ), vector3( 0, 1, 0 ) );
	m_pCamera->CalculateView();

	// Register board-entity and create an instance ---------------------------
	pGetScene()->RegisterEntityType( "board", CBoard::pCreate );
	m_hBoard = pGetScene()->hCreateEntity( "board" );
	if( !m_hBoard )
		return false;

	CBoard *pBoard = (CBoard *)pGetScene()->pGetEntity( m_hBoard );
	if( !pBoard->bInitialize() )
		return false;

	return true;
}
Example #4
0
bool CApp::bCreateWorld()
{
	m_pCamera = 0;
	m_hTexCube = 0;

	// Create and setup camera ------------------------------------------------
	m_pCamera = new CMyCamera( pGetGraphics() );
	if( !m_pCamera->bCreateRenderCamera( iGetWindowWidth(), iGetWindowHeight(), m3dfmt_r32g32b32f, false ) )
		return false;

	m_pCamera->CalculateProjection( M3D_PI * 0.5f, 10.0f, 1 );

	m_pCamera->SetPosition( vector3( 0, 0, -2.5f ) );
	m_pCamera->SetLookAt( vector3( 0, 0, 0 ), vector3( 0, 1, 0 ) );
	m_pCamera->CalculateView();

	// Register board-entity and create an instance ---------------------------
	pGetScene()->RegisterEntityType( "texcube", CTexCube::pCreate );
	m_hTexCube = pGetScene()->hCreateEntity( "texcube" );
	if( !m_hTexCube )
		return false;

	CTexCube *pTexCube = (CTexCube *)pGetScene()->pGetEntity( m_hTexCube );
	if( !pTexCube->bInitialize() )
		return false;

	return true;
}
Example #5
0
bool CEnvSphere::bCreateWorld()
{
	m_pCamera = 0;
	m_hSphere = 0;
	m_hLight = 0;

	// Create and setup camera ------------------------------------------------
	m_pCamera = new CMyCamera( pGetGraphics() );
	if( !m_pCamera->bCreateRenderCamera( iGetWindowWidth(), iGetWindowHeight() ) )
		return false;

	m_pCamera->CalculateProjection( M3D_PI * 0.5f, 10.0f, 0.1f );

	m_pCamera->SetPosition( vector3( 0, 0, -2 ) );
	m_pCamera->SetLookAt( vector3( 0, 0, 0 ), vector3( 0, 1, 0 ) );
	m_pCamera->CalculateView();

	// Register triangle-entity and create an instance ------------------------
	pGetScene()->RegisterEntityType( "sphere", CSphere::pCreate );
	m_hSphere = pGetScene()->hCreateEntity( "sphere" );
	if( !m_hSphere )
		return false;

	CSphere *pSphere = (CSphere *)pGetScene()->pGetEntity( m_hSphere );
	if( !pSphere->bInitialize( 1.0f, 16, 16, "majestic.cube" ) )
		return false;

	// Create the light -------------------------------------------------------
	m_hLight = pGetScene()->hCreateLight();
	if( !m_hLight )
		return false;

	CLight *pLight = pGetScene()->pGetLight( m_hLight );
	pLight->SetPosition( vector3( 1.5f, 0.25f, 0 ) );
	pLight->SetColor( vector4( 1, 1, 0.75f, 1 ) );

	// Demonstrating smooth-subdivision to get a round sphere
	// disable this and increase sphere-tesselation for better preformance (memory-usage will be higher!)
	pGetGraphics()->SetRenderState( m3drs_subdivisionmode, m3dsubdiv_smooth );
	pGetGraphics()->SetRenderState( m3drs_subdivisionlevels, 1 );
	pGetGraphics()->SetRenderState( m3drs_subdivisionpositionregister, 0 );
	pGetGraphics()->SetRenderState( m3drs_subdivisionnormalregister, 0 );	// using vertex-positions as normals (unit-sphere at origin)

	return true;
}