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


C++ KX_LightObject::GetSGNode方法代码示例

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


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

示例1: Update

void RAS_OpenGLLight::Update()
{
	GPULamp *lamp;
	KX_LightObject *kxlight = (KX_LightObject *)m_light;

	if ((lamp = GetGPULamp()) != NULL && kxlight->GetSGNode()) {
		float obmat[4][4];
		// lights don't get their openGL matrix updated, do it now
		if (kxlight->GetSGNode()->IsDirty())
			kxlight->GetOpenGLMatrix();
		float *dobmat = kxlight->GetOpenGLMatrixPtr()->getPointer();

		for (int i = 0; i < 4; i++)
			for (int j = 0; j < 4; j++, dobmat++)
				obmat[i][j] = (float)*dobmat;
		int hide = kxlight->GetVisible() ? 0 : 1;
		GPU_lamp_update(lamp, m_layer, hide, obmat);
		GPU_lamp_update_colors(lamp, m_color[0], m_color[1],
		                       m_color[2], m_energy);
		GPU_lamp_update_distance(lamp, m_distance, m_att1, m_att2, m_coeff_const, m_coeff_lin, m_coeff_quad);
		GPU_lamp_update_spot(lamp, m_spotsize, m_spotblend);
	}
}
开发者ID:UPBGE,项目名称:blender,代码行数:23,代码来源:RAS_OpenGLLight.cpp

示例2: ApplyFixedFunctionLighting

bool RAS_OpenGLLight::ApplyFixedFunctionLighting(KX_Scene *kxscene, int oblayer, int slot)
{
	KX_Scene *lightscene = (KX_Scene *)m_scene;
	KX_LightObject *kxlight = (KX_LightObject *)m_light;
	float vec[4];
	int scenelayer = ~0;

	if (kxscene && kxscene->GetBlenderScene())
		scenelayer = kxscene->GetBlenderScene()->lay;

	/* only use lights in the same layer as the object */
	if (!(m_layer & oblayer))
		return false;
	/* only use lights in the same scene, and in a visible layer */
	if (kxscene != lightscene || !(m_layer & scenelayer))
		return false;

	// lights don't get their openGL matrix updated, do it now
	if (kxlight->GetSGNode()->IsDirty())
		kxlight->GetOpenGLMatrix();

	MT_CmMatrix4x4& worldmatrix = *kxlight->GetOpenGLMatrixPtr();

	vec[0] = worldmatrix(0, 3);
	vec[1] = worldmatrix(1, 3);
	vec[2] = worldmatrix(2, 3);
	vec[3] = 1.0f;

	if (m_type == RAS_ILightObject::LIGHT_SUN) {

		vec[0] = worldmatrix(0, 2);
		vec[1] = worldmatrix(1, 2);
		vec[2] = worldmatrix(2, 2);
		//vec[0] = base->object->obmat[2][0];
		//vec[1] = base->object->obmat[2][1];
		//vec[2] = base->object->obmat[2][2];
		vec[3] = 0.0f;
		glLightfv((GLenum)(GL_LIGHT0 + slot), GL_POSITION, vec);
	}
	else {
		//vec[3] = 1.0;
		glLightfv((GLenum)(GL_LIGHT0 + slot), GL_POSITION, vec);
		glLightf((GLenum)(GL_LIGHT0 + slot), GL_CONSTANT_ATTENUATION, 1.0f);
		glLightf((GLenum)(GL_LIGHT0 + slot), GL_LINEAR_ATTENUATION, m_att1 / m_distance);
		// without this next line it looks backward compatible.
		//attennuation still is acceptable
		glLightf((GLenum)(GL_LIGHT0 + slot), GL_QUADRATIC_ATTENUATION, m_att2 / (m_distance * m_distance));

		if (m_type == RAS_ILightObject::LIGHT_SPOT) {
			vec[0] = -worldmatrix(0, 2);
			vec[1] = -worldmatrix(1, 2);
			vec[2] = -worldmatrix(2, 2);
			//vec[0] = -base->object->obmat[2][0];
			//vec[1] = -base->object->obmat[2][1];
			//vec[2] = -base->object->obmat[2][2];
			glLightfv((GLenum)(GL_LIGHT0 + slot), GL_SPOT_DIRECTION, vec);
			glLightf((GLenum)(GL_LIGHT0 + slot), GL_SPOT_CUTOFF, m_spotsize / 2.0f);
			glLightf((GLenum)(GL_LIGHT0 + slot), GL_SPOT_EXPONENT, 128.0f * m_spotblend);
		}
		else {
			glLightf((GLenum)(GL_LIGHT0 + slot), GL_SPOT_CUTOFF, 180.0f);
		}
	}

	if (m_nodiffuse) {
		vec[0] = vec[1] = vec[2] = vec[3] = 0.0f;
	}
	else {
		vec[0] = m_energy * m_color[0];
		vec[1] = m_energy * m_color[1];
		vec[2] = m_energy * m_color[2];
		vec[3] = 1.0f;
	}

	glLightfv((GLenum)(GL_LIGHT0 + slot), GL_DIFFUSE, vec);
	if (m_nospecular) {
		vec[0] = vec[1] = vec[2] = vec[3] = 0.0f;
	}
	else if (m_nodiffuse) {
		vec[0] = m_energy * m_color[0];
		vec[1] = m_energy * m_color[1];
		vec[2] = m_energy * m_color[2];
		vec[3] = 1.0f;
	}

	glLightfv((GLenum)(GL_LIGHT0 + slot), GL_SPECULAR, vec);
	glEnable((GLenum)(GL_LIGHT0 + slot));

	return true;
}
开发者ID:UPBGE,项目名称:blender,代码行数:90,代码来源:RAS_OpenGLLight.cpp


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