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


C++ CCamera类代码示例

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


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

示例1: SetupMonitorFace

int SetupMonitorFace (short nSegment, short nSide, short nCamera, CSegFace *faceP)
{
	CCamera		*cameraP = cameraManager.Camera (nCamera);
	int			bHaveMonitorBg, bIsTeleCam = cameraP->GetTeleport ();
#if !DBG
	int			i;
#endif
#if RENDER2TEXTURE
	int			bCamBufAvail = cameraP->HaveBuffer (1) == 1;
#else
	int			bCamBufAvail = 0;
#endif

if (!gameStates.render.bDoCameras)
	return 0;
bHaveMonitorBg = cameraP->Valid () && /*!cameraP->bShadowMap &&*/
					  (cameraP->Texture ().Texture () || bCamBufAvail) &&
					  (!bIsTeleCam || EGI_FLAG (bTeleporterCams, 0, 1, 0));
if (bHaveMonitorBg) {
	cameraP->GetUVL (faceP, NULL, FACES.texCoord + faceP->nIndex, FACES.vertices + faceP->nIndex);
	if (bIsTeleCam) {
#if DBG
		faceP->bmBot = &cameraP->Texture ();
		gameStates.render.grAlpha = 1.0f;
#else
		faceP->bmTop = &cameraP->Texture ();
		for (i = 0; i < 4; i++)
			gameData.render.color.vertices [faceP->index [i]].color.alpha = 0.7f;
#endif
		}
	else if (/*gameOpts->render.cameras.bFitToWall ||*/ (faceP->nOvlTex == 0) || !faceP->bmBot)
		faceP->bmBot = &cameraP->Texture ();
	else
		faceP->bmTop = &cameraP->Texture ();
	faceP->pTexCoord = cameraP->TexCoord ();
	}
faceP->bTeleport = bIsTeleCam;
cameraP->SetVisible (1);
return bHaveMonitorBg || gameOpts->render.cameras.bFitToWall;
}
开发者ID:paud,项目名称:d2x-xl,代码行数:40,代码来源:renderlib.cpp

示例2: CPoint

void CResourceScene10yCubeNest::play(float _time) {
    //glEnable(GL_DEPTH_TEST);
    //glClear(GL_DEPTH_BUFFER_BIT);
    //m_Render->enableDepthMask();
    // set transparency
    m_Render->enableBlend();

    // Apply the blending (if appropiate)
    if(m_hasCustomBlending) {
        m_Render->blendFunc(this->m_renderBlendingPos);
    }

    // temp set view
    CCamera myCam;

    m_Render->setLineWidth(0.8);
    m_Render->setProjectionMatrix();
    m_Render->pushMatrix();
    m_Render->loadIdentity();
    //myCam.SetLook(120,1,0);
    myCam.SetFar(1,10000);
    //myCam.SetFov(30);
    //myCam.Place(CPoint(100*sin(_time),0,100*cos(_time)), CPoint(0,0,0), CPoint(0,1,0));
    float dist = 50 + 20*sin(_time);
    float height = dist*cos(_time);
    float period = _time * 4;
    myCam.Place(CPoint(dist*sin(period),height,dist*cos(period)), CPoint(0,0,0), CPoint(0,1,0));
    //myCam.Place(CPoint(30,10,30), CPoint(0,0,0), CPoint(0,1,0));
    myCam.toOGL();

    //m_Render->setActiveCamera(&myCam);


    //m_Render->auxAxis();

    // Apply the calculated alpha to our plane color (this alpha is set outside by an "Effect")
    CPoint currColor = this->m_Color;
    currColor.w*=this->m_alpha;
    //cout << currColor.w << endl;
    // set the current vertex color
    m_Render->setColor(currColor);

    // draw & update
    unsigned int i;

    CPoint vup, vright;


    //m_Render->setColor(0.6,0.6,1,0.035);
    float decay, s=0.1;
    for(i=0; i<m_numCubes; i++) {
        m_Render->setModelMatrix();
        m_Render->pushMatrix();

        s+=0.25;
        //m_Render->translate(20+10*sin(_time+i*5),0,20+10*cos(_time+i*5));
        m_Render->scale(s,s,s);
        m_Render->rotate(i*(20+10*sin(_time)) + (_time-m_startTime)*80, i*i,i,-i);
        m_Render->drawCube(true);

        m_Render->setModelMatrix();
        m_Render->popMatrix();
    }
    //m_Render->popMatrix();

    // temp set view
    m_Render->setProjectionMatrix();
    m_Render->popMatrix();


    m_Render->disableBlend();

    glDisable(GL_DEPTH_TEST);
}
开发者ID:jeperez,项目名称:demoscene,代码行数:74,代码来源:ResourceScene10yCubeNest.cpp

示例3: switch

void CSphericalLight::Render( uint32 i_iPass )
{
	switch( i_iPass )
	{
	case ePass_Leaf: return;
	case ePass_SphericalLight: break;
	}

	CGraphics *pGraphics = m_pParent->pGetParent()->pGetGraphics();

	float32 fX = 1.2f * sinf( 1.5f * pGraphics->pGetParent()->fGetElapsedTime() );

	CCamera *pCurCamera = pGraphics->pGetCurCamera();
	matrix44 matWorld; matMatrix44Translation( matWorld, fX, 0.0f, 0.0f );
	pCurCamera->SetWorldMatrix( matWorld );

	m_pVertexShader->SetMatrix( m3dsc_wvpmatrix, pCurCamera->matGetWorldMatrix() * pCurCamera->matGetViewMatrix() * pCurCamera->matGetProjectionMatrix() );

	m_pPixelShader->SetVector( 0, m_vColor );

	m_pVertexShader->SetFloat( 0, 0.0f );
	m_pPixelShader->SetFloat( 0, 0.0f );

	pGraphics->SetVertexFormat( m_pVertexFormatSphere );
	pGraphics->SetVertexStream( 0, m_pVertexBufferSphere, 0, sizeof( vertexformatsphere ) );
	pGraphics->SetVertexShader( m_pVertexShader );
	pGraphics->SetPixelShader( m_pPixelShader );

	pGraphics->SetPrimitiveAssembler( m_pPrimitiveAssemblerSphere );

	if( !m_iMaxVisiblePixels )
	{
		// determine maximum number of pixels that can be rendered - colorwriteenable is false
		pGraphics->SetRenderState( m3drs_zenable, false );
		pGraphics->SetRenderState( m3drs_colorwriteenable, false );

		pGraphics->pGetM3DDevice()->DrawDynamicPrimitive( 0, m_iNumVertices );

		m_iMaxVisiblePixels = pGraphics->pGetM3DDevice()->iGetRenderedPixels();

		pGraphics->SetRenderState( m3drs_zenable, true );
		pGraphics->SetRenderState( m3drs_colorwriteenable, true );
	}

	pGraphics->pGetM3DDevice()->DrawDynamicPrimitive( 0, m_iNumVertices );

	uint32 iRenderedPixels = pGraphics->pGetM3DDevice()->iGetRenderedPixels();
	if( !iRenderedPixels )
		return;

	// Now render the flare ---------------------------------------------------
	m_pVertexShader->SetFloat( 0, 1.0f );
	m_pPixelShader->SetFloat( 0, 1.0f );

	pGraphics->SetVertexFormat( m_pVertexFormatFlare );
	pGraphics->SetVertexStream( 0, m_pVertexBufferFlare, 0, sizeof( vertexformatflare ) );

	CResManager *pResManager = m_pParent->pGetParent()->pGetResManager();
	CTexture *pFlare = (CTexture *)pResManager->pGetResource( m_hFlare );
	pGraphics->SetTexture( 0, pFlare->pGetTexture() );

	pGraphics->SetTextureSamplerState( 0, m3dtss_addressu, m3dta_clamp );
	pGraphics->SetTextureSamplerState( 0, m3dtss_addressv, m3dta_clamp );

	pGraphics->SetRenderState( m3drs_zenable, false );

	m_pPixelShader->SetFloat( 1, (float32)iRenderedPixels / (float32)m_iMaxVisiblePixels );

	pGraphics->pGetM3DDevice()->DrawPrimitive( m3dpt_trianglefan, 0, 2 );
}
开发者ID:stephanreiter,项目名称:muli3d,代码行数:70,代码来源:sphericallight.cpp

示例4: glPushAttrib

void CAdvWater::UpdateWater(CGame* game)
{
	if (!waterRendering->forceRendering && !readMap->HasVisibleWater())
		return;

	glPushAttrib(GL_FOG_BIT | GL_COLOR_BUFFER_BIT);
	glEnable(GL_TEXTURE_2D);
	glEnable(GL_BLEND);
	glBlendFunc(GL_ONE, GL_ONE);

	{
		bumpFBO.Bind();
		glViewport(0, 0, 128, 128);

		glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
		glClear(GL_COLOR_BUFFER_BIT);

		glSpringMatrix2dSetupPV(0.0f, 1.0f, 0.0f, 1.0f, -1.0f, 1.0f);

		glColor3f(0.2f, 0.2f, 0.2f);

		CVertexArray* va = GetVertexArray();
		va->Initialize();
		va->EnlargeArrays(12, 0, VA_SIZE_T);

		glBindTexture(GL_TEXTURE_2D, rawBumpTexture[0]);

		va->AddVertexQT(ZeroVector, 0, 0 + gs->frameNum*0.0046f);
		va->AddVertexQT(  UpVector, 0, 2 + gs->frameNum*0.0046f);
		va->AddVertexQT(  XYVector, 2, 2 + gs->frameNum*0.0046f);
		va->AddVertexQT( RgtVector, 2, 0 + gs->frameNum*0.0046f);

		va->AddVertexQT(ZeroVector, 0, 0 + gs->frameNum*0.0026f);
		va->AddVertexQT(  UpVector, 0, 4 + gs->frameNum*0.0026f);
		va->AddVertexQT(  XYVector, 2, 4 + gs->frameNum*0.0026f);
		va->AddVertexQT( RgtVector, 2, 0 + gs->frameNum*0.0026f);

		va->AddVertexQT(ZeroVector, 0, 0 + gs->frameNum*0.0012f);
		va->AddVertexQT(  UpVector, 0, 8 + gs->frameNum*0.0012f);
		va->AddVertexQT(  XYVector, 2, 8 + gs->frameNum*0.0012f);
		va->AddVertexQT( RgtVector, 2, 0 + gs->frameNum*0.0012f);

		va->DrawArrayT(GL_QUADS);

		va = GetVertexArray();
		va->Initialize();
		glBindTexture(GL_TEXTURE_2D, rawBumpTexture[1]);

		va->AddVertexQT(ZeroVector, 0, 0 + gs->frameNum*0.0036f);
		va->AddVertexQT(  UpVector, 0, 1 + gs->frameNum*0.0036f);
		va->AddVertexQT(  XYVector, 1, 1 + gs->frameNum*0.0036f);
		va->AddVertexQT( RgtVector, 1, 0 + gs->frameNum*0.0036f);

		va->DrawArrayT(GL_QUADS);

		va = GetVertexArray();
		va->Initialize();
		glBindTexture(GL_TEXTURE_2D, rawBumpTexture[2]);

		va->AddVertexQT(ZeroVector, 0, 0 + gs->frameNum*0.0082f);
		va->AddVertexQT(  UpVector, 0, 1 + gs->frameNum*0.0082f);
		va->AddVertexQT(  XYVector, 1, 1 + gs->frameNum*0.0082f);
		va->AddVertexQT( RgtVector, 1, 0 + gs->frameNum*0.0082f);

		va->DrawArrayT(GL_QUADS);

		// this fixes a memory leak on ATI cards
		glBindTexture(GL_TEXTURE_2D, 0);
		glColor3f(1.0f, 1.0f, 1.0f);
	}


	reflectFBO.Bind();
	glClearColor(sky->fogColor[0], sky->fogColor[1], sky->fogColor[2], 1.0f);
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

	const double clipPlaneEqs[2 * 4] = {
		0.0, 1.0, 0.0, 0.0,
		0.0, 1.0, 0.0, 0.0,
	};

	CCamera* prvCam = CCamera::GetSetActiveCamera(CCamera::CAMTYPE_UWREFL);
	CCamera* curCam = CCamera::GetActiveCamera();

	{
		curCam->CopyStateReflect(prvCam);
		curCam->UpdateLoadViewPort(0, 0, 512, 512);

		DrawReflections(&clipPlaneEqs[0], true, true);
	}

	CCamera::SetActiveCamera(prvCam->GetCamType());
	prvCam->Update();
	prvCam->LoadViewPort();

	FBO::Unbind();

	glPopAttrib();
	glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
}
开发者ID:sprunk,项目名称:spring,代码行数:100,代码来源:AdvWater.cpp

示例5: switch

void CModel::Render()
{	
	LPDIRECT3DDEVICE9 pDevice = rd::CRenderDevice::GetInstance()->GetRawDevice();
	DWORD delta = bc::ut::CTimer::GetInstance()->GetFrameTime();
	D3DXVECTOR3 vPosCamera = eg::CEngine::GetInstance()->GetActiveCamera()->GetPosition();
	D3DXVECTOR3 vView = eg::CEngine::GetInstance()->GetActiveCamera()->GetView();
	DWORD dwCurrentTime = bc::ut::CTimer::GetSystemTime();

	CTerrainMesh::SGrid & grid = CXFile::GetInstance()->GetTerrainMesh()->GetGrid(FIX_GRID);
							
	m_vCenter = grid.vCenter;
	
	switch ( m_eCenterType )
	{
	case ECT_CENTER:
	break;
	
	case ECT_CORNER:
		m_vCenter.x -= GRID_SPACE/2.0f;
		m_vCenter.z -= GRID_SPACE/2.0f;
	break;
		
	case ECT_XMIDWAY:
		m_vCenter.z -= GRID_SPACE/2.0f;
	break;

	case ECT_ZMIDWAY:
		m_vCenter.x -= GRID_SPACE/2.0f;
	break;
	}

	D3DXMatrixTranslation(&m_matWorldOff, m_vCenter.x + m_fShiftX, m_vCenter.y + m_fLift, m_vCenter.z + m_fShiftZ);
	m_mat = m_matSelfOff*m_matRotY*m_matWorldOff;
	
	////////////////////////////////////////////////////////////////////////
	
	//// for wire box
	//
	//if ( this->IsSubUnit() )
	//{
	//	D3DXVECTOR3 v = m_vOffset - m_vOffsetOverall;
	//	D3DXVec3TransformCoord(&v,&v,&m_matRotY);
	//	this->SetRelativePos(D3DXVECTOR3(m_matWorldOff._41 + v.x, m_matWorldOff._42 - m_vScale.y/2 + v.y, m_matWorldOff._43 + v.z));
	//}
	//else
	//{
	//	this->SetRelativePos(D3DXVECTOR3(m_matWorldOff._41, m_matWorldOff._42, m_matWorldOff._43));
	//}
	//
	//this->SetRelativeRotation(D3DXVECTOR3(0.0f,m_fRotation,0.0f));
	//this->UpdateAbsolute();
	
	////////////////////////////////////////////////////////////////////////
	
	ICoreGraphic * pCoreGraphic = CXFile::GetInstance()->GetOperator()->GetCoreGraphic();

	CXFile::GetInstance()->GetOperator()->GetGraphicModule()->ResetGraphicRenderStyle(CXFile::GetInstance()->GetOperator()->GetCoreGraphic());

	ICamera * pCamera;

	pCoreGraphic->GetCamera(&pCamera);

	D3DXVECTOR3 vecPos = eg::CEngine::GetInstance()->GetActiveCamera()->GetPosition();

	D3DXVECTOR3 vecView = eg::CEngine::GetInstance()->GetActiveCamera()->GetView();

	pCamera->SetCamera(CVector3f(vecPos.x,vecPos.y,vecPos.z),CVector3f(vecView.x,vecView.y,vecView.z));

	sc:CCamera * pMyCamera = eg::CEngine::GetInstance()->GetActiveCamera();
	
	pCamera->SetProject(D3DXToRadian(pMyCamera->GetFOVY()), pMyCamera->GetNearPlane(),pMyCamera->GetFarPlane());
	
	m_pModel->Render(*(CMatrix*)(&m_mat),dwCurrentTime,false);
	m_pModel->Render(*(CMatrix*)(&m_mat),dwCurrentTime,true);
	
	//int i = 0;
	
	//for ( std::vector<int>::iterator iter = m_vecBlockGrids.begin(); iter != m_vecBlockGrids.end(); ++iter, ++i )
	//{
	//	m_vecpWireBox[i]->Render();
	//}
	
	if ( sc::CXFile::GetInstance()->GetOperator()->GetSelectMode() )
	{
		if ( this->GetLocked() || this->GetSelected() )
		{
//			m_pWireBox->Render();
		}
		
		//D3DXMATRIX mat;
		//D3DXMatrixIdentity(&mat);
		//pDevice->SetTransform(D3DTS_WORLD,&mat);
		//DWORD color[4] = {0xffffff};
		//rd::CRenderDevice::GetInstance()->GetLayer3D()->DrawLineStrip(3, vCorners, color);
		//rd::CRenderDevice::GetInstance()->GetLayer3D()->DrawLineStrip(3, &vCorners[4], color);
	}
	
	ISceneNode::Render();
}
开发者ID:LaoZhongGu,项目名称:RushGame,代码行数:99,代码来源:Model.cpp

示例6: D3DXMatrixIdentity

bool CScreen::SetDefaultGraphicsSettings3D()
{
	HRESULT hr;

	D3DXMATRIX identityTransform, projTransform;
	D3DXMatrixIdentity(&identityTransform);
	D3DXMatrixPerspectiveFovLH(&projTransform, D3DX_PI / 4, 1.0f, 1.0f, 100.0f);

    D3DXVECTOR3 vEyePt(-10.0f, -10.0f, 10.0f);
    D3DXVECTOR3 vLookatPt(0.0f, 0.0f, 0.0f);
    D3DXVECTOR3 vUpVec(0.0f, 0.0f, 1.0f);
    D3DXMATRIXA16 matView;
    D3DXMatrixLookAtLH(&matView, &vEyePt, &vLookatPt, &vUpVec);

	D3DCOLORVALUE lightColor = {1.0f, 1.0f, 1.0f, 1.0f};
	D3DXVECTOR3 lightDir(-1.0f, 0.7f, -0.2f);

	D3DLIGHT9 light;
	setupDirectionalLight(light, lightColor, lightDir);

	D3DMATERIAL9 mtrl;
	ZeroMemory( &mtrl, sizeof( D3DMATERIAL9 ) );
	mtrl.Diffuse = lightColor;
	mtrl.Ambient = lightColor;
	mtrl.Ambient.g = 0.0f;

	CGraphicsManager *pGraphicsManager = CGraphicsManager::GetInstance();
	IDirect3DDevice9 *pDevice = pGraphicsManager->GetDevice();
	CCamera * pCamera = CCamera::GetInstance();

	hr = pDevice->SetTransform(D3DTS_WORLD, &identityTransform);
	if(FAILED(hr))
	{
		LogErrorHr("Failed to set world transform", hr);
		return false;
	}
		
	D3DXMATRIX camViewMat = pCamera->GetViewMatrix();
	hr = pDevice->SetTransform(D3DTS_VIEW, &camViewMat);
	if(FAILED(hr))
	{
		LogErrorHr("Failed to set view transform", hr);
		return false;
	}

	D3DXMATRIX camProjMat = pCamera->GetProjectionMatrix();
	hr = pDevice->SetTransform(D3DTS_PROJECTION, &camProjMat);
	if(FAILED(hr))
	{
		LogErrorHr("Failed to set projection transform", hr);
		return false;
	}

	hr = pDevice->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE);
	if(FAILED(hr))
	{
		LogErrorHr("Failed to set cull mode render state", hr);
		return false;
	}

	hr = pDevice->SetLight(0, &light);
	if(FAILED(hr))
	{
		LogErrorHr("Failed to set light 0", hr);
		return false;
	}

	hr = pDevice->SetMaterial(&mtrl);
	if(FAILED(hr))
	{
		LogErrorHr("Failed to set material", hr);
		return false;
	}

	hr = pDevice->LightEnable(0, TRUE);
	if(FAILED(hr))
	{
		LogErrorHr("Failed to enable light", hr);
		return false;
	}

	hr = pDevice->SetRenderState(D3DRS_AMBIENT, 0x00202020);
	if(FAILED(hr))
	{
		LogErrorHr("Failed to set ambient color", hr);
		return false;
	}

	hr = pDevice->SetRenderState(D3DRS_ZENABLE, D3DZB_TRUE);
	if(FAILED(hr))
	{
		LogErrorHr("Failed to enable z", hr);
		return false;
	}

	hr = pDevice->SetRenderState(D3DRS_ZWRITEENABLE , TRUE);
	if(FAILED(hr))
	{
		LogErrorHr("Failed to set z write enabled", hr);
		return false;
//.........这里部分代码省略.........
开发者ID:svdmaar,项目名称:Coop,代码行数:101,代码来源:Screen.cpp

示例7: DrawGizmoAxis

void CGizmo::DrawGizmoAxis(CRender3D *pRender, Vector& Origin, 
						   Vector& EndPoint, int red, int green, int blue, 
						   unsigned int uAxisHandle)
{
	CCamera *pCamera = pRender->GetCamera();

	Vector ViewUp;
	pCamera->GetViewUp(ViewUp);

	Vector ViewPoint;
	Vector ViewForward;
	pCamera->GetViewPoint(ViewPoint);
	VectorSubtract(Origin, ViewPoint, ViewForward);

	Vector Axis;
	VectorSubtract(EndPoint, Origin, Axis);

	CrossProduct(ViewForward, Axis, ViewUp);
	VectorNormalize(ViewUp);

	Vector Start;
	Vector End;

	//
	// Draw the first segment of the gizmo axis.
	//
	VectorMA(Origin, 0.1, Axis, Start);
	VectorMA(Origin, 0.25, Axis, End);
	
	pRender->BindTexture( g_pAxisTexture );
	
	CMeshBuilder meshBuilder;

	CMatRenderContextPtr pRenderContext( MaterialSystemInterface() );
	IMesh* pMesh = pRenderContext->GetDynamicMesh( );
	meshBuilder.Begin( pMesh, MATERIAL_POLYGON, 4 );

	meshBuilder.TexCoord2f(0, 0, 0);
	meshBuilder.Position3f(Start[0] - ViewUp[0] * GIZMO_AXIS_WIDTH, Start[1] - ViewUp[1] * GIZMO_AXIS_WIDTH, Start[2] - ViewUp[2] * GIZMO_AXIS_WIDTH);
	meshBuilder.Color3ub(red, green, blue);
	meshBuilder.AdvanceVertex();

	meshBuilder.TexCoord2f(0, 2, 0);
	meshBuilder.Position3f(End[0] - ViewUp[0] * GIZMO_AXIS_WIDTH, End[1] - ViewUp[1] * GIZMO_AXIS_WIDTH, End[2] - ViewUp[2] * GIZMO_AXIS_WIDTH);
	meshBuilder.Color3ub(red, green, blue);
	meshBuilder.AdvanceVertex();

	meshBuilder.TexCoord2f(0, 2, 1);
	meshBuilder.Position3f(End[0] + ViewUp[0] * GIZMO_AXIS_WIDTH, End[1] + ViewUp[1] * GIZMO_AXIS_WIDTH, End[2] + ViewUp[2] * GIZMO_AXIS_WIDTH);
	meshBuilder.Color3ub(red, green, blue);
	meshBuilder.AdvanceVertex();

	meshBuilder.TexCoord2f(0, 0, 1);
	meshBuilder.Position3f(Start[0] + ViewUp[0] * GIZMO_AXIS_WIDTH, Start[1] + ViewUp[1] * GIZMO_AXIS_WIDTH, Start[2] + ViewUp[2] * GIZMO_AXIS_WIDTH);
	meshBuilder.Color3ub(red, green, blue);
	meshBuilder.AdvanceVertex();

	meshBuilder.End();
	pMesh->Draw();

	//
	// Draw the scale handle.
	//
	Start = End;
	VectorMA(Origin, 0.35, Axis, End);
	
	pRender->BeginRenderHitTarget(this, uAxisHandle + GIZMO_HANDLE_SCALE);

	pRender->BindTexture( g_pScaleHandleTexture );

	pMesh = pRenderContext->GetDynamicMesh( );
	meshBuilder.Begin( pMesh, MATERIAL_POLYGON, 4 );

	meshBuilder.TexCoord2f( 0, 0, 0);
	meshBuilder.Position3f(Start[0] - ViewUp[0] * GIZMO_HANDLE_WIDTH, Start[1] - ViewUp[1] * GIZMO_HANDLE_WIDTH, Start[2] - ViewUp[2] * GIZMO_HANDLE_WIDTH);
	meshBuilder.Color3ub(red, green, blue);
	meshBuilder.AdvanceVertex();

	meshBuilder.TexCoord2f( 0, 1, 0);
	meshBuilder.Position3f(End[0] - ViewUp[0] * GIZMO_HANDLE_WIDTH, End[1] - ViewUp[1] * GIZMO_HANDLE_WIDTH, End[2] - ViewUp[2] * GIZMO_HANDLE_WIDTH);
	meshBuilder.Color3ub(red, green, blue);
	meshBuilder.AdvanceVertex();

	meshBuilder.TexCoord2f( 0, 1, 1);
	meshBuilder.Position3f(End[0] + ViewUp[0] * GIZMO_HANDLE_WIDTH, End[1] + ViewUp[1] * GIZMO_HANDLE_WIDTH, End[2] + ViewUp[2] * GIZMO_HANDLE_WIDTH);
	meshBuilder.Color3ub(red, green, blue);
	meshBuilder.AdvanceVertex();

	meshBuilder.TexCoord2f( 0, 0, 1);
	meshBuilder.Position3f(Start[0] + ViewUp[0] * GIZMO_HANDLE_WIDTH, Start[1] + ViewUp[1] * GIZMO_HANDLE_WIDTH, Start[2] + ViewUp[2] * GIZMO_HANDLE_WIDTH);
	meshBuilder.AdvanceVertex();

	meshBuilder.End();
	pMesh->Draw();

	pRender->EndRenderHitTarget();

	//
	// Draw the second segment of the gizmo axis.
	//
//.........这里部分代码省略.........
开发者ID:DeadZoneLuna,项目名称:SourceEngine2007,代码行数:101,代码来源:gizmo.cpp

示例8: SetTarget

void CBoss3::Update(int delta_time)
{
	CResourcesManager* rs = CResourcesManager::GetInstance();
	CCamera* c = rs->_camera;
	if (c->view_port.x + c->getWidth() + 5 >= rs->m_widthMap) _enable = true;

	if (_hp == 0) SetStatus(EDie);
	if (!_enable || _hp <= 0) return;	
	//Target mục tiêu
	D3DXVECTOR3 pos_target = CResourcesManager::GetInstance()->m_posBill;
	SetTarget(pos_target.x, pos_target.y);

	//Cập nhật lại những viên đạn có thể bắn trong list của enemy
	_weapon->UpdateQueueIdBullet(_queue_id_bullet);

	if (!_is_hide)
	{
		if (_last_time_hide == 0) _last_time_hide = GetTickCount();
		DWORD now = GetTickCount();

		if (now - _last_time_hide >= BOSS3_ELAPSED_TIME_HIDE)
		{
			_enemy_status = EWait;
			_is_hide = true;
			_ready_shoot = false;
			_last_time_hide = 0;

			//Random tọa độ xuất hiện tiếp theo
			CCamera* c = CResourcesManager::GetInstance()->_camera;

			_x_random = (_target.x - BOSS3_RANDOM_DISTANCE_APPEAR_X) + rand() % (2 * BOSS3_RANDOM_DISTANCE_APPEAR_X);
			_y_random = c->getWidth() * 2 / 3 + rand() % BOSS3_RANDOM_DISTANCE_APPEAR_Y;

			D3DXVECTOR3 pos_check = c->Transform(_x_random, _y_random);
			if (pos_check.x - 60 < 0) _x_random = c->view_port.x + 60;
			if (pos_check.x + 60 > c->getWidth()) _x_random = c->view_port.x + c->getWidth() - 60;
		}
	}
	else
	{
		if (_last_time_appear == 0) _last_time_appear = GetTickCount();
		DWORD now = GetTickCount();
		
		if (now - _last_time_appear >= BOSS3_ELAPSED_TIME_APPEAR)
		{
			_enemy_status = EAttack;
			_is_hide = false;
			_last_time_appear = 0;

			_physical.x = _x_random;
			_physical.y = _y_random;
		}
	}

	switch (_enemy_status)
	{
	case EWait:
	case EDie:
		_can_impact = false;
		_physical.SetBounds(0, 0, 0, 0);
		break;
	case EAttack:
		_can_impact = true;
		_physical.SetBounds(_physical.x, _physical.y, 40, 40);
		break;
	}
}
开发者ID:tranletuan,项目名称:game-castlevaina,代码行数:67,代码来源:CBoss3.cpp

示例9: CalcMinMaxView

void CShadowHandler::CalcMinMaxView()
{
	// derive the size of the shadow-map from the
	// intersection points of the camera frustum
	// with the xz-plane
	CCamera* cam = CCamera::GetCamera(CCamera::CAMTYPE_VISCUL);

	cam->GetFrustumSides(0.0f, 0.0f, 1.0f, true);
	cam->ClipFrustumLines(true, -20000.0f, mapDims.mapy * SQUARE_SIZE + 20000.0f);

	shadowProjMinMax.x = -100.0f;
	shadowProjMinMax.y =  100.0f;
	shadowProjMinMax.z = -100.0f;
	shadowProjMinMax.w =  100.0f;

	//if someone could figure out how the frustum and nonlinear shadow transform really works (and not use the SJan trial and error method)
	//so that we can skip this sort of fudge factors it would be good
	float borderSize = 270.0f;
	float maxSize = globalRendering->viewRange * 0.75f;

	if (shadowMapSize == 1024) {
		borderSize *= 1.5f;
		maxSize *= 1.2f;
	}

	const std::vector<CCamera::FrustumLine>& negSides = cam->GetNegFrustumSides();
	const std::vector<CCamera::FrustumLine>& posSides = cam->GetPosFrustumSides();
	std::vector<CCamera::FrustumLine>::const_iterator fli;

	if (!negSides.empty()) {
		for (fli = negSides.begin(); fli != negSides.end(); ++fli) {
			if (fli->minz < fli->maxz) {
				float3 p[5];
				p[0] = float3(fli->base + fli->dir * fli->minz, 0.0f, fli->minz);
				p[1] = float3(fli->base + fli->dir * fli->maxz, 0.0f, fli->maxz);
				p[2] = float3(fli->base + fli->dir * fli->minz, readMap->initMaxHeight + 200, fli->minz);
				p[3] = float3(fli->base + fli->dir * fli->maxz, readMap->initMaxHeight + 200, fli->maxz);
				p[4] = projMidPos[2];

				for (int a = 0; a < 5; ++a) {
					const float xd = (p[a] - projMidPos[2]).dot(sunDirX);
					const float yd = (p[a] - projMidPos[2]).dot(sunDirY);

					if (xd + borderSize > shadowProjMinMax.y) { shadowProjMinMax.y = xd + borderSize; }
					if (xd - borderSize < shadowProjMinMax.x) { shadowProjMinMax.x = xd - borderSize; }
					if (yd + borderSize > shadowProjMinMax.w) { shadowProjMinMax.w = yd + borderSize; }
					if (yd - borderSize < shadowProjMinMax.z) { shadowProjMinMax.z = yd - borderSize; }
				}
			}
		}

		if (shadowProjMinMax.x < -maxSize) { shadowProjMinMax.x = -maxSize; }
		if (shadowProjMinMax.y >  maxSize) { shadowProjMinMax.y =  maxSize; }
		if (shadowProjMinMax.z < -maxSize) { shadowProjMinMax.z = -maxSize; }
		if (shadowProjMinMax.w >  maxSize) { shadowProjMinMax.w =  maxSize; }
	} else {
		shadowProjMinMax.x = -maxSize;
		shadowProjMinMax.y =  maxSize;
		shadowProjMinMax.z = -maxSize;
		shadowProjMinMax.w =  maxSize;
	}

	// xScale = (shadowProjMinMax.y - shadowProjMinMax.x) * 1.5f;
	// yScale = (shadowProjMinMax.w - shadowProjMinMax.z) * 1.5f;
}
开发者ID:DoctorEmmettBrown,项目名称:spring,代码行数:65,代码来源:ShadowHandler.cpp

示例10: defined


//.........这里部分代码省略.........
		m_pSoundObj->AppendObject( new CSoundEffect("mouse.WAV"), "Mouse", true );
		m_pSoundObj->AppendObject( new CSoundEffect("flagrecall.WAV"), "RecallFlag", true );
		m_pSoundObj->AppendObject( new CSoundEffect("flagsetfail.WAV"), "SetFlagFail", true );
		m_pSoundObj->AppendObject( new CSoundEffect("missionclear.WAV"), "MissionClear", true );
		m_pSoundObj->AppendObject( new CSoundEffect("missionfail.WAV"), "MissionFail", true );
		m_pSoundObj->AppendObject( new CSoundEffect("bird.WAV"), "Bird", true );
		m_pSoundObj->AppendObject( new CSoundEffect("select.WAV"), "Select", true );
		m_pSoundObj->AppendObject( new CSoundEffect("DrumRoll.WAV"), "DrumRoll", true );
		m_pSoundObj->AppendObject( new CSoundEffect("decide.WAV"), "Decide", true );
		
		
		
		
		//while( !ifs.eof() )
		//{	
		//	ifs >> Temp >> Temp2;
		//	
		//	strDataName = Temp;
		//	strObjectName = Temp2;
		//	
		//	m_pSoundObj->AppendObject( new CSoundEffect(strDataName), strObjectName, true );
		//	
		//}
		
		#endif
		
		m_pSoundObj->AppendObject( new CBGM("BGM.ogg"), "TitleBGM", true );
		m_pSoundObj->AppendObject( new CBGM("Rolling Railing Hiking!.ogg"), "GameBGM", true );
		m_pSoundObj->AppendObject( new CBGM("TitleBGM.ogg"), "ChatBGM", true );
		
		m_pSoundObj->AppendObject( new CBGM("BGM.ogg"), "ResultBGM", true );
		
		
		m_pGameObj->AppendObject( new CCamera(), "CamMain", true );
		m_pGameObj->AppendObject( new CCamera(), "CamSub", true );
		
		m_pGameObj->AppendObject( new CFontSprite("font.sff", Math::Vector2D( 200, 400 ) ), "TitleFont", true );
		m_pGameObj->AppendObject( new CFontSprite("font2.sff", Math::Vector2D( 200, 400 ) ), "CommonFont", true );
		m_pGameObj->AppendObject( new CFontSprite("MissionFont.sff", Math::Vector2D( 430, 13) ), "MissionFont", true );
		m_pGameObj->AppendObject( new CFontSprite("MenuFont.sff", Math::Vector2D( 220, 100 ) ), "MenuFont", true );
		m_pGameObj->AppendObject( new CFontSprite("ChatFont.sff", Math::Vector2D( 110, 465 ) ), "ChatFont", true );
		m_pGameObj->AppendObject( new CFontSprite("NumFont.sff", Math::Vector2D( 110, 465 ) ), "NumFont", true );
		m_pGameObj->AppendObject( new CFontSprite("MiContFont.sff", Math::Vector2D( 110, 465 ) ), "ContentFont", true );
		m_pGameObj->AppendObject( new CFontSprite("MiContFont2.sff", Math::Vector2D( 110, 465 ) ), "ContentFont2", true );
		m_pGameObj->AppendObject( new CFontSprite("ExplainFont.sff", Math::Vector2D( 110, 465 ) ), "ExplainFont", true );
		
		
		
		
		//m_pGameObj->AppendObject( new Draw2DObject("Build_1.bmp", Math::Vector2D(100, 200) ), "Film", true );
		#if defined( DEBUG_MAP_EDIT ) 
		
		#elif defined( DEBUG_MAP_SEE )
		
		#else
			m_p2DObj->AppendObject( new CSprite("title.png", Math::Vector2D( 0, 0 ) ), "Title", false );
			m_p2DObj->AppendObject( new CSprite("background.png", Math::Vector2D( 0, 0 ) ), "MissionSelect", false );
			m_p2DObj->AppendObject( new CSprite("chat.png", Math::Vector2D( 0, 0 ) ), "Chat", false );
			m_p2DObj->AppendObject( new CSprite("Result.png", Math::Vector2D( 0, 0 ) ), "Result", false );
			m_p2DObj->AppendObject( new CSprite("back.png", Math::Vector2D( 0, 0 ) ), "CalcScore", false );
			m_p2DObj->AppendObject( new CSprite("clear.dds", Math::Vector2D( 0, 0 ) ), "GameClear", false );
			m_p2DObj->AppendObject( new CSprite("failure.dds", Math::Vector2D( 0, 0 ) ), "GameFailure", false );
			
		#endif
		
		const char *pMiniCharaName[] =
开发者ID:Taka03,项目名称:Camerun,代码行数:67,代码来源:Scene.cpp

示例11: CColor

//=============================================================================
//処理
//=============================================================================
//[input]
//	pScene:設定するシーン
//=============================================================================
void CScene::Exec(CScene *pScene)
{
	Renderer::IRender *pRender = pScene->GetAppDevice()->GetRenderer();
	
	CSprite *pSpr = dynamic_cast<CSprite *>( m_p2DObj->FindObjectFromName("Loading") );
	
	pSpr->SetDivnum( Math::Point2DI(6, 1) );
	
	pScene->GetAppDevice()->GetRenderer()->Clear();
	
	pScene->GetAppDevice()->GetRenderer()->Begin();
	
	pSpr->Rendering();
	
	//pScene->GetAppDevice()->GetRenderer()->DebugPrint( Math::Point2DI( 400, 300 ), CColor(255, 255, 255 ), "Npw Loading" );
	
	pScene->GetAppDevice()->GetRenderer()->End();

	pSpr->DrawAnimation( 6, 0 );
	
	/*ロード終わってない*/
	if( !pScene->GetLoadEndFlag() )
	{	
		static string Str = "Now Loading";
		
		static int count = 0;
		
		count ++;
		
		if( count % 10 == 0 )
		{
			Str += ".";
		}
		
		if( count >= 40 )
		{
			count = 0;
			Str = "Now Loading";
		}
		
		pRender->DrawText( Math::Point2DI( 590, 520 ), CColor(255, 255, 255 ), Str.c_str() );
		
		
	}
	
	/*ロード終了*/
	if( pScene->GetLoadEndFlag() )
	{
		pSpr->SetVisibleFlag( false );
		
		m_p3DObj->Init();
		
		CCamera *objCamMain	= dynamic_cast<CCamera *>( m_pGameObj->FindObjectFromName("CamMain") );
		
		objCamMain->Init();
		
		pSpr->Move();
		
		/*キャラが画面外にいったら、次のシーンに*/
		if( pSpr->GetPosition().x <= -100 )
		{
			#if defined( DEBUG_MAP_EDIT ) 
			
				m_eNextScene = SCENE_GAMEMAIN;
			
			
			#elif defined( DEBUG_MAP_SEE )
			
				m_eNextScene = SCENE_DEMO;
				
			#elif defined( DEBUG_CHAT )
			
				m_eNextScene = SCENE_CHAT;
				
			#endif
			
			pScene->SetSceneState( STATE_STANDBY );
			
			pScene->ChangeScene( m_eNextScene );
		}
		
	}
	
}
开发者ID:Taka03,项目名称:Camerun,代码行数:90,代码来源:Scene.cpp

示例12: DrawFromAim

void CNametags::DrawFromAim ( void )
{
    unsigned long ulCurrentTime = CClientTime::GetTime ();

    // Got any players that are not local?
    if ( m_pPlayerManager->Count () > 1 )
    {
        // Grab the local player
        CClientPlayer* pLocalPlayer = m_pPlayerManager->GetLocalPlayer ();
        if ( pLocalPlayer )
        {
            // Grab the current time and the camera
            unsigned long ulCurrentTime = CClientTime::GetTime ();
            CCamera* pCamera = g_pGame->GetCamera ();

            // Grab our controller state
            CControllerState State;
            g_pGame->GetPad ()->GetCurrentControllerState ( &State );

            // Grab our current weapon slot. Use screen center if melee or none
            CVector vecStart;
            CVector vecTarget;
            eWeaponSlot eSlot = pLocalPlayer->GetCurrentWeaponSlot ();
            if ( eSlot == WEAPONSLOT_TYPE_UNARMED ||
                    eSlot == WEAPONSLOT_TYPE_MELEE ||
                    eSlot == WEAPONSLOT_TYPE_RIFLE ||
                    eSlot == WEAPONSLOT_TYPE_THROWN ||
                    eSlot == WEAPONSLOT_TYPE_SPECIAL ||
                    eSlot == WEAPONSLOT_TYPE_GIFT ||
                    eSlot == WEAPONSLOT_TYPE_PARACHUTE ||
                    eSlot == WEAPONSLOT_TYPE_DETONATOR )
            {
                // Grab the active cam
                CCamera* pCamera = g_pGame->GetCamera ();
                CCam* pActive = pCamera->GetCam ( pCamera->GetActiveCam () );

                // Grab the camera matrix
	            CMatrix matCamera;
	            pCamera->GetMatrix ( &matCamera );
                vecStart = matCamera.vPos;

                // Range
                float fRange;
                if ( eSlot == WEAPONSLOT_TYPE_RIFLE && State.RightShoulder1 )
                {
                    fRange = SNIPER_AIM_VISIBLE_RANGE;
                }
                else
                {
                    fRange = MELEE_VISIBLE_RANGE;
                }

                // Find the target position
                CVector vecFront = *pActive->GetFront ();
                vecFront.Normalize ();
                vecTarget = *pActive->GetSource () + vecFront * fRange;
            }
            else
            {
                // Grab the weapon and keysync state. If it exists and he holds Target down
                CWeapon* pPlayerWeapon = pLocalPlayer->GetWeapon ();
                if ( pPlayerWeapon && State.RightShoulder1 )
                {
                    // Grab the gun muzzle position
                    CWeaponInfo* pCurrentWeaponInfo = pPlayerWeapon->GetInfo ();
                    CVector vecGunMuzzle = *pCurrentWeaponInfo->GetFireOffset ();
                    pLocalPlayer->GetTransformedBonePosition ( BONE_RIGHTWRIST, vecGunMuzzle );

                    // Grab the target point
                    pCamera->Find3rdPersonCamTargetVector ( AIM_VISIBLE_RANGE, &vecGunMuzzle, &vecStart, &vecTarget );
                }
                else
                {
                    // Grab the active cam
                    CCam* pActive = pCamera->GetCam ( pCamera->GetActiveCam () );

                    // Grab the camera matrix
	                CMatrix matCamera;
	                pCamera->GetMatrix ( &matCamera );
                    vecStart = matCamera.vPos;

                    // Find the target position
                    CVector vecFront = *pActive->GetFront ();
                    vecFront.Normalize ();
                    vecTarget = *pActive->GetSource () + vecFront * MELEE_VISIBLE_RANGE;
                }
            }

            // Ignore the local player for this
            pLocalPlayer->WorldIgnore ( true );

            // Do the raycast
            CColPoint* pColPoint = NULL;
            CEntity* pEntity = NULL;
            g_pGame->GetWorld ()->ProcessLineOfSight ( &vecStart, &vecTarget, &pColPoint, &pEntity, true, true, true, true, true, true, false, true );
            if ( pColPoint ) pColPoint->Destroy (); 

            // Un-ignore the local player
            pLocalPlayer->WorldIgnore ( false );

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

示例13: KeyBoard

void KeyBoard(unsigned char key, int x, int y)
{
	switch (key) 
	{

	case '1':
		//menentukan koordinat camera
		printf("%f %f %f \n\tat %f %f %f \n\tup %f %f %f",
			myView.position().x,myView.position().y,myView.position().z,
			myView.view().x,myView.view().y,myView.view().z,
			myView.upVector().x,myView.upVector().y,myView.upVector().z);
		break;
	case '2':  
			bbolalampu += 0.4;
			glEnable(GL_LIGHT2);
		break;
	case '3':  
			bbolalampu -= 0.4;
			glDisable(GL_LIGHT2);
		break;
	case 'w': //move forward
		myView.move(speed);
		break;
	case 's': //move back
		myView.move(-speed);
		break;
	case 'a': //strafe left
		myView.strafe(-speed);
		break;
	case 'd': //strafe right
		myView.strafe(speed);
		break;
	
	case 27: // “esc” on keyboard
		exit(0);
		break;
	}
	glutPostRedisplay();
}
开发者ID:luthfiana,项目名称:tugasbesar-grafkom,代码行数:39,代码来源:main.cpp

示例14: CalcShadowMatrices

///////////////////////////////////////////////////////////////////////////////////////////////////
// CalcShadowMatrices: calculate required matrices for shadow map generation - the light's
// projection and transformation matrices
void ShadowMapInternals::CalcShadowMatrices()
{
	float minZ = ShadowBound[0].Z;

	ShadowBound.IntersectFrustumConservative(LightspaceCamera.GetFrustum());

	// ShadowBound might have been empty to begin with, producing an empty result
	if (ShadowBound.IsEmpty())
	{
		// no-op
		LightProjection.SetIdentity();
		TextureMatrix = LightTransform;
		return;
	}

	// round off the shadow boundaries to sane increments to help reduce swim effect
	float boundInc = 16.0f;
	ShadowBound[0].X = floor(ShadowBound[0].X / boundInc) * boundInc;
	ShadowBound[0].Y = floor(ShadowBound[0].Y / boundInc) * boundInc;
	ShadowBound[1].X = ceil(ShadowBound[1].X / boundInc) * boundInc;
	ShadowBound[1].Y = ceil(ShadowBound[1].Y / boundInc) * boundInc;

	// minimum Z bound must not be clipped too much, because objects that lie outside
	// the shadow bounds cannot cast shadows either
	// the 2.0 is rather arbitrary: it should be big enough so that we won't accidentally miss
	// a shadow generator, and small enough not to affect Z precision
	ShadowBound[0].Z = minZ - 2.0;

	// Setup orthogonal projection (lightspace -> clip space) for shadowmap rendering
	CVector3D scale = ShadowBound[1] - ShadowBound[0];
	CVector3D shift = (ShadowBound[1] + ShadowBound[0]) * -0.5;

	if (scale.X < 1.0)
		scale.X = 1.0;
	if (scale.Y < 1.0)
		scale.Y = 1.0;
	if (scale.Z < 1.0)
		scale.Z = 1.0;

	scale.X = 2.0 / scale.X;
	scale.Y = 2.0 / scale.Y;
	scale.Z = 2.0 / scale.Z;

	// make sure a given world position falls on a consistent shadowmap texel fractional offset
	float offsetX = fmod(ShadowBound[0].X - LightTransform._14, 2.0f/(scale.X*EffectiveWidth));
	float offsetY = fmod(ShadowBound[0].Y - LightTransform._24, 2.0f/(scale.Y*EffectiveHeight));

	LightProjection.SetZero();
	LightProjection._11 = scale.X;
	LightProjection._14 = (shift.X + offsetX) * scale.X;
	LightProjection._22 = scale.Y;
	LightProjection._24 = (shift.Y + offsetY) * scale.Y;
	LightProjection._33 = scale.Z;
	LightProjection._34 = shift.Z * scale.Z;
	LightProjection._44 = 1.0;

	// Calculate texture matrix by creating the clip space to texture coordinate matrix
	// and then concatenating all matrices that have been calculated so far

	float texscalex = scale.X * 0.5f * (float)EffectiveWidth / (float)Width;
	float texscaley = scale.Y * 0.5f * (float)EffectiveHeight / (float)Height;
	float texscalez = scale.Z * 0.5f;

	CMatrix3D lightToTex;
	lightToTex.SetZero();
	lightToTex._11 = texscalex;
	lightToTex._14 = (offsetX - ShadowBound[0].X) * texscalex;
	lightToTex._22 = texscaley;
	lightToTex._24 = (offsetY - ShadowBound[0].Y) * texscaley;
	lightToTex._33 = texscalez;
	lightToTex._34 = -ShadowBound[0].Z * texscalez;
	lightToTex._44 = 1.0;

	TextureMatrix = lightToTex * LightTransform;
}
开发者ID:Valvador,项目名称:PyroSpaceFork,代码行数:78,代码来源:ShadowMap.cpp

示例15: Init

void Init(HWND hWnd)
{
	g_hWnd = hWnd;										// Assign the window handle to a global window handle
	GetClientRect(g_hWnd, &g_rRect);					// Assign the windows rectangle to a global RECT
	InitializeOpenGL(g_rRect.right, g_rRect.bottom);	// Init OpenGL with the global rect

	// Here we open the config file and init some variables
	ifstream fin("Config.ini");
	string strLevel = "";
	string strTemp = "";

	// Check if the file was not found or could not be opened
	if(fin.fail())
	{
		// Display an error message and quit the program if file wasn't found
		MessageBox(g_hWnd, "Could not find Config.ini file!", "Error", MB_OK);
		PostQuitMessage(0);
		return;
	}

	// Read in the name of the level that will be loaded 
	fin >> strLevel >> strLevel;
	
	// Now we need to read in the gamma level for our lightmaps
	fin >> strTemp  >> g_Gamma;

	// Initialize the multitexturing function pointers
	glActiveTextureARB		 = (PFNGLACTIVETEXTUREARBPROC)	 wglGetProcAddress("glActiveTextureARB");
    glClientActiveTextureARB = (PFNGLACTIVETEXTUREARBPROC)   wglGetProcAddress("glClientActiveTextureARB");

	// Here we make sure that the functions were loaded properly
	if(!glActiveTextureARB || !glClientActiveTextureARB)
	{
		// Display an error message and quit
		MessageBox(g_hWnd, "Your video card doesn't support multitexturing", "Error", MB_OK);
		PostQuitMessage(0);
	}

	// Close the file
	fin.close();

	// Here we load the level and get the result (true == success)
	bool bResult = g_Level.LoadBSP(strLevel.c_str());

	// Make sure the file was found and we received a success
	if(bResult == false)
	{
		// Quit the application
		PostQuitMessage(0);
		return;
	}

	// Position the camera to the starting point since we have
	// not read in the entities yet, which gives the starting points.
	g_Camera.PositionCamera( 80, 320, 55,	80, 320, 155,	0, 1, 0);

	// Turn on depth testing and texture mapping
	glEnable(GL_DEPTH_TEST);	
	glEnable(GL_TEXTURE_2D);

	// Enable front face culling, since that's what Quake3 does
	glCullFace(GL_FRONT);
 	glEnable(GL_CULL_FACE);
}
开发者ID:88er,项目名称:tutorials,代码行数:64,代码来源:Main.cpp


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