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


C++ CLight类代码示例

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


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

示例1: LightRender

void LightRender ()
{

    CLight*     l;

    if (!EntityReady ())
        return;
    if (!angles_done) {
        for (int size = 0; size < MAX_SIZE; size++) {
            for (int i = 0 ; i < 360; i++) {
                angles[size][i].x = cosf ((float)i * DEGREES_TO_RADIANS) * ((float)size + 0.5f);
                angles[size][i].y = sinf ((float)i * DEGREES_TO_RADIANS) * ((float)size + 0.5f);
            }
        }
    }
    glDepthMask (false);
    glEnable (GL_BLEND);
    glDisable (GL_CULL_FACE);
    glBlendFunc (GL_ONE, GL_ONE);
    glBindTexture(GL_TEXTURE_2D, TextureId (TEXTURE_LIGHT));
    glDisable (GL_CULL_FACE);
    glBegin (GL_QUADS);
    for (l = head; l; l = l->_next)
        l->Render ();
    glEnd ();
    glDepthMask (true);

}
开发者ID:MigrenusMaximus,项目名称:pixelcity,代码行数:28,代码来源:Light.cpp

示例2: glEnable

void CShader_Deferred::Render()
{
	glEnable(GL_BLEND);
	glDisable(GL_CULL_FACE);
	glDisable(GL_DEPTH_TEST);

	// Set shader
	GetGame()->GetRenderSystem()->SetShader(GetGame()->GetRenderSystem()->GetShader("deferred"));

	// Enable positions
	glEnableVertexAttribArray(0);
	
	if (GetGame()->GetGLSLVersion() == GLSL_VERSION_130)
	{
		glBindAttribLocation(GetID(), 0, "vertexPos_MS");
		glBindAttribLocation(GetID(), 1, "vertexTexCoords");
	}

	glBindBuffer(GL_ARRAY_BUFFER, GetGame()->GetRenderSystem()->GetScreenQuad());
	glVertexAttribPointer(
		0,
		2,
		GL_FLOAT,
		GL_FALSE,
		0,
		(void*)0
	);

	// Enable UVs
	glEnableVertexAttribArray(1);
	glBindBuffer(GL_ARRAY_BUFFER, GetGame()->GetRenderSystem()->GetScreenUVs());
	glVertexAttribPointer(
		1,
		2,
		GL_FLOAT,
		GL_FALSE,
		0,
		(void*)0
	);

	for (unsigned int i = 0; i < GetGame()->GetSceneManager()->GetLightCount(); i++)
	{
		CLight* light = GetGame()->GetSceneManager()->GetLight(i);
		if (light->Enabled())
		{
			GetGame()->GetRenderSystem()->SetCurLight(light);
			Update();

			glDrawArrays(GL_TRIANGLES, 0, 8);
		}
	}

	// Clean up
	glDisableVertexAttribArray(0);
	glDisableVertexAttribArray(1);

	glEnable(GL_CULL_FACE);
	glEnable(GL_DEPTH_TEST);
	glDisable(GL_BLEND);
}
开发者ID:rrkpp,项目名称:kopengi,代码行数:60,代码来源:CShader_Deferred.cpp

示例3: glVector

void CDeco::CreateRadioTower (GLvector pos, float height)
{

  CLight*   l;
  float     offset;
  GLvertex  v;
  fan       f;

  for(int i=0; i<6; i++)
    f.index_list.push_back(i);

  offset = height / 15.0f;
  _center = pos;
  _use_alpha = true;
  //Radio tower
  v.position = glVector (_center.x, _center.y + height, _center.z);  v.uv = glVector (0,1);
  _mesh->VertexAdd (v);
  v.position = glVector (_center.x - offset, _center.y, _center.z - offset);  v.uv = glVector (1,0);
  _mesh->VertexAdd (v);
  v.position = glVector (_center.x + offset, _center.y, _center.z - offset);  v.uv = glVector (0,0);
  _mesh->VertexAdd (v);
  v.position = glVector (_center.x + offset, _center.y, _center.z + offset);  v.uv = glVector (1,0);
  _mesh->VertexAdd (v);
  v.position = glVector (_center.x - offset, _center.y, _center.z + offset);  v.uv = glVector (0,0);
  _mesh->VertexAdd (v);
  v.position = glVector (_center.x - offset, _center.y, _center.z - offset);  v.uv = glVector (1,0);
  _mesh->VertexAdd (v);
  _mesh->FanAdd (f);
  l = new CLight (glVector (_center.x, _center.y + height + 1.0f, _center.z), glRgba (255,192,160), 1);
  l->Blink ();
  _texture = TextureId (TEXTURE_LATTICE);

}
开发者ID:BryanKadzban,项目名称:pixelcity,代码行数:33,代码来源:Deco.cpp

示例4: CreateLight

HRESULT CEditorScene::CreateLight()
{
	m_vecLight.reserve(10);

	CLight* pLight = new CLight;
	
	D3DLIGHT9 tLight;
	memset(&tLight, 0, sizeof(D3DLIGHT9));

	D3DCOLORVALUE tValue;
	tValue.b = tValue.g = tValue.r = tValue.a = 1.f;

	tLight.Ambient = tValue;
	tLight.Diffuse = tValue;
	tLight.Specular = tValue;
	
	tLight.Direction = D3DXVECTOR3(1.f, 0.f, 1.f);
	tLight.Type = D3DLIGHT_DIRECTIONAL;

	pLight->SetLightInfo(tLight);

	m_vecLight.push_back(pLight);

	return S_OK;
}
开发者ID:qiomoip,项目名称:space-express,代码行数:25,代码来源:EditorScene.cpp

示例5:

// ***************************************************************************
void			CPointLight::computeAttenuationFactors()
{
	// disable attenuation?
	if(_AttenuationBegin==0 && _AttenuationEnd==0)
	{
		// setup for attenuation disabled.
		_ConstantAttenuation= 1;
		_LinearAttenuation= 0;
		_QuadraticAttenuation= 0;
	}
	else
	{
		// precompute attenuation values, with help of CLight formula!!
		CLight	dummyLight;
		dummyLight.setupAttenuation(_AttenuationBegin, _AttenuationEnd);
		_ConstantAttenuation= dummyLight.getConstantAttenuation();
		_LinearAttenuation= dummyLight.getLinearAttenuation();
		_QuadraticAttenuation= dummyLight.getQuadraticAttenuation();

		// setup _OODeltaAttenuation
		_OODeltaAttenuation= _AttenuationEnd - _AttenuationBegin;
		if(_OODeltaAttenuation <=0 )
			_OODeltaAttenuation= 0;
		else
			_OODeltaAttenuation= 1.0f / _OODeltaAttenuation;
	}
}
开发者ID:Darkhunter,项目名称:Tranquillien-HCRP-Project-using-NeL,代码行数:28,代码来源:point_light.cpp

示例6: RenderChunks

//------------------------------------------------------------------------
// isRenderTerrainBuffer : true 이면 m_pTerrainSurf 버퍼에 지형을 출력한다.
// isRenderDeptBuffer : true 이면 깊이버퍼에 깊이값을 저장한다.
// [2011/2/28 jjuiddong]
//------------------------------------------------------------------------
void CChunkManager::RenderChunks(BOOL isRenderTerrainBuffer, BOOL isRenderDeptBuffer)
{
	LPDIRECT3DSURFACE9 pOldBackBuffer = NULL;
	LPDIRECT3DSURFACE9 pOldZBuffer = NULL;
	if (isRenderTerrainBuffer)
	{
		g_pDevice->GetRenderTarget(0, &pOldBackBuffer);
		//g_pDevice->GetDepthStencilSurface(&pOldZBuffer);
		g_pDevice->SetRenderTarget(0, m_pTerrainSurf);
		//g_pDevice->SetDepthStencilSurface(m_pZ);
		g_pDevice->Clear(0L, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0xffffffff, 1.0f, 0L);
	}

	m_pShader->Begin();

	Matrix44 mWVP;
	g_Camera.GetViewProjMatrix(&mWVP);
	m_pShader->SetMatrix("mWVP", mWVP);

	Matrix44 mWVPB = mWVP * m_mScaleBias;
	m_pShader->SetMatrix("mWVPB", mWVPB);

	// 광원방향
	CLight *pLight = m_pTerrain->GetLight();
	Vector3 lightPos = pLight->GetDirection();
	D3DXVECTOR4 v(lightPos.x, lightPos.y, lightPos.z, -0.3f); // -0.3f 환경광의 강도
	m_pShader->SetVector( "vLightDir", v);

	// 시점
	Vector3 eyePos = g_Camera.GetPosition();
	m_pShader->SetVector( "vEyePos", eyePos);

	for (int i=0; i < m_ChunkSize; ++i)
		m_pChunk[ i].Render(m_pShader, 0);

// 	g_pDevice->SetRenderTarget(0, m_pTerrainDepthSurf);
// 	g_pDevice->Clear(0L, NULL, D3DCLEAR_TARGET, 0x00, 1.0f, 0L);

	m_pShader->End();

	m_pWater->Render();

	if (isRenderDeptBuffer)
	{
// 		g_pDevice->SetRenderTarget(0, m_pTerrainDepthSurf);
// 		g_pDevice->Clear(0L, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0x00, 1.0f, 0L);
// 
// 		for (int i=0; i < m_ChunkSize; ++i)
// 			m_pChunk[ i].Render(m_pShader, 1);
	}

	if (isRenderTerrainBuffer)
	{
		g_pDevice->SetRenderTarget(0, pOldBackBuffer);
		//g_pDevice->SetDepthStencilSurface(pOldZBuffer);
		pOldBackBuffer->Release();
		//pOldZBuffer->Release();
	}
}
开发者ID:jjuiddong,项目名称:Dx3D-Study,代码行数:64,代码来源:chunkManager.cpp

示例7: Validate

bool ESceneLightTools::Validate(bool full_test)
{
	if (!inherited::Validate(full_test)) return false;
	bool bRes = !m_Objects.empty();
	for (ObjectIt it=m_Objects.begin(); it!=m_Objects.end(); it++){
    	CLight* L = dynamic_cast<CLight*>(*it);
    	if (!L->GetLControlName()){
        	bRes=false;
            ELog.Msg(mtError,"%s: '%s' - Invalid light control.",ClassDesc(),L->Name);
        }
    }
    return bRes;
}
开发者ID:OLR-xray,项目名称:OLR-3.0,代码行数:13,代码来源:ESceneLightTools.cpp

示例8: ReadWidgetHeader

CGuiLight* CGuiLight::Create(CGuiFrame* frame, CInputStream& in, bool flag)
{
    CGuiWidgetParms parms = ReadWidgetHeader(frame, in, flag);

    ELightType tp = ELightType(in.readUint32Big());
    float distC = in.readFloatBig();
    float distL = in.readFloatBig();
    float distQ = in.readFloatBig();
    float angC = in.readFloatBig();
    float angL = in.readFloatBig();
    float angQ = in.readFloatBig();
    u32 loadedIdx = in.readUint32Big();

    CGuiLight* ret = nullptr;
    switch (tp)
    {
    case ELightType::Spot:
    {
        float cutoff = in.readFloatBig();
        CLight lt = CLight::BuildSpot(zeus::CVector3f::skZero, zeus::CVector3f::skZero,
                                      parms.x10_color, cutoff);
        lt.SetAttenuation(distC, distL, distQ);
        lt.SetAngleAttenuation(angC, angL, angQ);
        lt.x40_loadedIdx = loadedIdx;
        ret = new CGuiLight(parms, lt);
        break;
    }
    case ELightType::Point:
    {
        CLight lt = CLight::BuildPoint(zeus::CVector3f::skZero, parms.x10_color);
        lt.SetAttenuation(distC, distL, distQ);
        lt.x40_loadedIdx = loadedIdx;
        ret = new CGuiLight(parms, lt);
        break;
    }
    case ELightType::Directional:
    {
        CLight lt = CLight::BuildDirectional(zeus::CVector3f::skZero, parms.x10_color);
        lt.x40_loadedIdx = loadedIdx;
        ret = new CGuiLight(parms, lt);
        break;
    }
    default: break;
    }

    ret->ParseBaseInfo(frame, in, parms);
    frame->AddLight(ret);
    return ret;
}
开发者ID:KalDragon,项目名称:urde,代码行数:49,代码来源:CGuiLight.cpp

示例9: switch

void CTriangle::Render( uint32 i_iPass )
{
	switch( i_iPass )
	{
	case ePass_Lighting: break;
	}

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

	CCamera *pCurCamera = pGraphics->pGetCurCamera();
	matrix44 matWorld; matMatrix44Identity( matWorld );
	pCurCamera->SetWorldMatrix( matWorld );

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

	vector3 vCamPos = pCurCamera->vGetPosition();
	m_pVertexShader->SetVector( 0, vector4( vCamPos.x, vCamPos.y, vCamPos.z, 0 ) );

	CLight *pLight = m_pParent->pGetCurrentLight();
	
	vector3 vLightPos = pLight->vGetPosition();
	m_pVertexShader->SetVector( 1, vector4( vLightPos.x, vLightPos.y, vLightPos.z, 0 ) );
	
	m_pPixelShader->SetVector( 0, pLight->vGetColor() );

	pGraphics->SetVertexFormat( m_pVertexFormat );
	pGraphics->SetVertexStream( 0, m_pVertexBuffer, 0, sizeof( vertexformat ) );
	pGraphics->SetVertexShader( m_pVertexShader );
	pGraphics->SetPixelShader( m_pPixelShader );

	CResManager *pResManager = m_pParent->pGetParent()->pGetResManager();
	CTexture *pTexture = (CTexture *)pResManager->pGetResource( m_hTexture );
	pGraphics->SetTexture( 0, pTexture->pGetTexture() );
	
	CTexture *pNormalmap = (CTexture *)pResManager->pGetResource( m_hNormalmap );
	pGraphics->SetTexture( 1, pNormalmap->pGetTexture() );

	for( uint32 i = 0; i < 2; ++i )
	{
		pGraphics->SetTextureSamplerState( i, m3dtss_addressu, m3dta_clamp );
		pGraphics->SetTextureSamplerState( i, m3dtss_addressv, m3dta_clamp );
	}

	pGraphics->pGetM3DDevice()->DrawPrimitive( m3dpt_trianglelist, 0, 1 );
}
开发者ID:stephanreiter,项目名称:muli3d,代码行数:48,代码来源:triangle.cpp

示例10: CMyCamera

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;
}
开发者ID:funcman,项目名称:Muli3D,代码行数:45,代码来源:envsphere.cpp

示例11: BeforeRender

void ESceneLightTools::BeforeRender()
{
    if (psDeviceFlags.is(rsLighting)){
        int l_cnt		= 0;
        // set scene lights
        for(ObjectIt _F = m_Objects.begin();_F!=m_Objects.end();_F++){
            CLight* l 		= (CLight*)(*_F);
            l_cnt++;
            if (l->Visible()&&l->m_UseInD3D&&l->m_Flags.is_any(ELight::flAffectDynamic|ELight::flAffectStatic))
                if (::Render->ViewBase.testSphere_dirty(l->PPosition,l->m_Range))
                	AppendFrameLight(l);
        }
    	// set sun
		if (m_Flags.is(flShowSun)){
            Flight L;
            Fvector C;
            if (psDeviceFlags.is(rsEnvironment)){
	            C			= g_pGamePersistent->Environment().CurrentEnv.sun_color;
            }else{
            	C.set		(1.f,1.f,1.f);
            }
            L.direction.setHP(m_SunShadowDir.y,m_SunShadowDir.x);
            L.diffuse.set	(C.x,C.y,C.z,1.f);
            L.ambient.set	(0.f,0.f,0.f,0.f);
            L.specular.set	(C.x,C.y,C.z,1.f);
            L.type			= D3DLIGHT_DIRECTIONAL;
            Device.SetLight	(frame_light.size(),L);
            Device.LightEnable(frame_light.size(),TRUE);
        }
		// ambient
        if (psDeviceFlags.is(rsEnvironment)){
	        Fvector& V		= g_pGamePersistent->Environment().CurrentEnv.ambient;
            Fcolor C;		C.set(V.x,V.y,V.z,1.f);
            Device.SetRS	(D3DRS_AMBIENT,C.get());
        }else				Device.SetRS(D3DRS_AMBIENT,0x00000000);
        
        Device.Statistic->dwTotalLight 	= l_cnt;
        Device.Statistic->dwLightInScene = frame_light.size();
    }
}
开发者ID:OLR-xray,项目名称:OLR-3.0,代码行数:40,代码来源:ESceneLightTools.cpp

示例12: switch

CLight CGuiLight::BuildLight() const
{
    CLight ret = CLight::BuildLocalAmbient(zeus::CVector3f::skZero, zeus::CColor::skBlack);

    switch (xf8_type)
    {
    case ELightType::Spot:
        ret = CLight::BuildSpot(GetWorldPosition(), x34_worldXF.m_basis[1], xbc_color, xfc_spotCutoff);
        break;
    case ELightType::Point:
        ret = CLight::BuildPoint(GetWorldPosition(), xbc_color);
        break;
    case ELightType::Directional:
        ret = CLight::BuildDirectional(x34_worldXF.m_basis[1], xbc_color);
        break;
    default: break;
    }

    ret.SetAttenuation(x100_distC, x104_distL, x108_distQ);
    ret.SetAngleAttenuation(x10c_angleC, x110_angleL, x114_angleQ);
    return ret;
}
开发者ID:KalDragon,项目名称:urde,代码行数:22,代码来源:CGuiLight.cpp

示例13: Vector4D

void CRenderObjectsManager::ProcessLighting(CRenderObject* pobj,POLYGON& poly)
{
	VERTICESLIST &pointlist = pobj->m_translateverticesList;
	int v_index1 = poly.v[0];
	int v_index2 = poly.v[1];
	int v_index3 = poly.v[2];
	
	//Get the original r,g,b,a
	bool bHasTexture = poly.state & OBJECT_HAS_TEXTURE;
	UCHAR r_base = bHasTexture ?255:poly.color.r;
	UCHAR g_base = bHasTexture ? 255:poly.color.g;
	UCHAR b_base = bHasTexture?255: poly.color.b;
	UCHAR a_base = bHasTexture?0:poly.color.a;//to do.modify here

	int r_sum=0,g_sum = 0,b_sum = 0;

	int ilightsize = m_pLightingManager->GetLightsCount();
	const LIGHTSLIST& lightslist = m_pLightingManager->GetLights();
	CLight *light = NULL;

	//Get the normal direction
	Vector4D P0P1 = pointlist[v_index2].vertex - pointlist[v_index1].vertex;
	Vector4D P1P2 = pointlist[v_index3].vertex - pointlist[v_index1].vertex;
	Vector4D N = P0P1.CrossProduct(P1P2);
	N.Normalize();

	for(int i = 0; i < ilightsize;++i)
	{
		light = lightslist[i];
		if(!light->IsEnable()) continue;
		
		//Get the cos value of the angle between the light and normal
        Vector4D lightdir = light->m_lightdir;
		float coslight2normal = N.DotProduct(-1*lightdir);

		const CLight::LightType lighttype = light->GetLightType();

		if(lighttype == CLight::kAmbientLight)
		{
             r_sum += ((light->m_amblient.r * r_base)/256);
			 g_sum += ((light->m_amblient.g * g_base)/256);
			 b_sum += ((light->m_amblient.b * b_base)/256);
		}
		if(lighttype == CLight::kInfiniteLigtht)
		{
			if(coslight2normal>0)
			{
				r_sum += ((light->m_diffuse.r * r_base *coslight2normal)/256);
				g_sum += ((light->m_diffuse.g * g_base*coslight2normal)/256);
				b_sum += ((light->m_diffuse.b * b_base*coslight2normal)/256);
			}
		
		}
		if(lighttype == CLight::kPointLight)
		{
			// c = c_diffuse * I/(kc+kl*d+kq*d^2);
			//
			Vector4D vertex2lightpos = Vector4D(light->m_lightpos- pointlist[v_index1].vertex);
			float d = vertex2lightpos.GetLength();
			float l = vertex2lightpos.DotProduct(N);
			float cosv = N.DotProduct(vertex2lightpos);
			if(cosv >0)
			{
                cosv = cosv/d;
				float k = light->m_kconst + light->m_klinear * d + light->m_kquadratic*d*d;
				float fDiv = k*256;//k*256
				r_sum += ((light->m_diffuse.r * r_base *cosv)/fDiv);
				g_sum += ((light->m_diffuse.g * g_base*cosv)/fDiv);
				b_sum += ((light->m_diffuse.b * b_base*cosv)/fDiv);
				

			}
		
		}
		if(lighttype == CLight::kSpotLight)
		{
           //use this model
		   // c = c_diffuse * I*MAX(COSa,0)^pf/(kc+kl*d+kq*d^2)
			float l = N.DotProduct(-1*lightdir);
			if(l >0)
			{
				Vector4D vertex2lightpos = Vector4D(light->m_lightpos-pointlist[v_index1].vertex );
				float d = vertex2lightpos.GetLength();

				//calculate the cos value of light direction and vertext->lightpos

				float l = N.DotProduct(vertex2lightpos);
				if(l > 0)
				{
					float cosv = l/d;
					float dl = cosv;
					for(int i = 1; i < light->m_pf;++i)
						dl *= cosv;

					float k = light->m_kconst + light->m_klinear * d + light->m_kquadratic*d*d;
					float fDiv = k*256;//k*256

					r_sum += ((light->m_diffuse.r * r_base *dl)/fDiv);
					g_sum += ((light->m_diffuse.g * g_base*dl)/fDiv);
					b_sum += ((light->m_diffuse.b * b_base*dl)/fDiv);
//.........这里部分代码省略.........
开发者ID:orbv,项目名称:Simple-3D-Software-Render,代码行数:101,代码来源:Projection.cpp

示例14: getSceneManager

//-----------------------------------------------------------------------------------------
TestAnimation::TestAnimation()
{
    // On crée une camera
    m_pCamera = getSceneManager()->createCamera();
    m_pCamera->setEyePosition(QVector3D(2., 1., 2.));
    m_pCamera->setCenter(QVector3D(0., 0., 0.));


#ifdef SOFTWARE_RENDERING
    m_pView = createSoftwareView3D(m_pCamera);
#else
    m_pView = createWidget3D(m_pCamera);
#endif

    m_pCamera->setAspectRatio((real)m_pView->width() / (real)m_pView->height());

    // On charge le modéle
    CSceneNode* pRootNode = m_pSceneManager->getRootNode();

    CSceneNode* pModelNode = pRootNode->createChild("dwarf");

    // anim_test.x
    // rotatingcube.3ds
    // dwarf.x

    if (!CAssimpImporter::mergeScene("://dwarf.x", m_pSceneManager, true, pModelNode).isEmpty())
    {
        // On récupére la bounding box
        CBox3D bbox = pRootNode->getGlobalAxisAlignedBoundingBox();

        real sizeX = bbox.getMaximum().x() - bbox.getMinimum().x();
        real sizeY = bbox.getMaximum().y() - bbox.getMinimum().y();
        real sizeZ = bbox.getMaximum().z() - bbox.getMinimum().z();

        real maxSize = sizeX;
        if (sizeY > maxSize) maxSize = sizeY;
        if (sizeZ > maxSize) maxSize = sizeZ;

        // On redimensionne la scene de façon à ce qu'elle tienne dans une boite de 1x1x1
        pModelNode->scale(1. / maxSize);

        CBox3D scaledBbox = pModelNode->getGlobalAxisAlignedBoundingBox();

        // On la centre
        pModelNode->translate(-scaledBbox.getCenter());

        CSceneNode* pLightNode = pRootNode->createChild("LightNode", QVector3D(8.0, 12.0, 0));

        // On crée une lumiére diffuse blanche
        CLight* pLight = m_pSceneManager->createLight("Light");
        pLight->setDiffuseColor(0.8f, 0.8f, 0.8f);
        pLight->setAmbientColor(0.6f, 0.6f, 0.6f);
        pLight->setSpecularColor(0.4f, 0.4f, 0.4f);
        pLight->setDirection(QVector3D(-1, -1, 0));

        // On l'associe au noeud
        pLightNode->addItem(pLight);

        pRootNode->dumpNodeTree();
        //m_pSceneManager->setSceneGraphVisible(true);

        QList<CAnimation*> anims = m_pSceneManager->getAnimations();

        m_pView->setGeometry(QRect(100, 100, 400, 300));
        m_pView->getRenderer()->run();
        getAnimationManager()->run();

        if (anims.size() > 0)
        {
            QList<CSceneNodeAnimation*> nodeAnimations = anims[0]->getNodeAnimations();

            foreach (CSceneNodeAnimation* pNodeAnim, nodeAnimations)
            {
                pNodeAnim->setAnimationBehavior(eAnimationBehaviourRepeat);
            }
开发者ID:Jbx2-0b,项目名称:Humble3D,代码行数:76,代码来源:TestAnimation.cpp

示例15: Render

void  Render()
{
   Matrix mat,mat1,mat2;
   Bulid_XYZ_RotationMatrix(mat1,0.0,0.0,g_roty);
   BuildTranslateMatrix(mat2,0.0,0.0,g_tranz);
   static bool bDrawNonTextureCube=false;
   if(KEY_DOWN(VK_F1))
   {
	   //Draw the color cube. don't use texture
	   bDrawNonTextureCube = !bDrawNonTextureCube;
   }
 
   int icount = g_RenderManager.RenderObjectSize();
   for(int i = 0; i < icount;++i)
   {
       CRenderObject *pobj = g_RenderManager[i];
	   POLYGONLIST &polygonlist = pobj->m_PolyGonList;
	   int polygonsize = polygonlist.size();
	   for( int j = 0; j < polygonsize;++j)
	   {
		   POLYGON &polygon = polygonlist[j];
		   if(bDrawNonTextureCube)
			   polygon.state &= ~OBJECT_HAS_TEXTURE;
		   else 
			   polygon.state |= OBJECT_HAS_TEXTURE;
	   }
	  
	   pobj->Transform(mat1);//transform local
	   pobj->world_pos *= mat2;
	  
   }
   //local->world,world->camera,camera->screen
   static bool bEnableLighting = false;
   static bool bEableBackfaceRemove =false;
   static bool bEnableInvZBuffer = false;
   if(KEY_DOWN(VK_HOME))
   {
	   //user press p
	   for(int i=0; i< g_lights.GetLightsCount();++i)
	   {
		   CLight* pLight = g_lights.GetLight(i);
		    pLight->EnableLight();
		 /*  if(pLight->GetLightType() == CLight::kAmbientLight)
		   {
			   pLight->EnableLight();
			   break;
		   }*/
	   }
	   bEnableLighting = true;
	   
   }
   else if(KEY_DOWN(VK_END))
   {
	   bEnableLighting = false;
   }
   else if(KEY_DOWN(VK_F2))
   {
	   bEableBackfaceRemove = true;
   }
   else if(KEY_DOWN(VK_F3))
   {
	   bEableBackfaceRemove = false;
   }
   else if(KEY_DOWN(VK_F4))
   {
	   bEnableInvZBuffer = true;
   }
   else if(KEY_DOWN(VK_F5))
   {
	   bEnableInvZBuffer = false;
   }
   if(bEnableInvZBuffer)
    ZBuffer::GetInstance()->Clear(0);
   else
    ZBuffer::GetInstance()->Clear((1<<30)-1);

   g_RenderManager.Render(bEnableLighting,bEableBackfaceRemove,!bEnableInvZBuffer);
   g_fps++;
}
开发者ID:orbv,项目名称:Simple-3D-Software-Render,代码行数:79,代码来源:Main.cpp


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