Пример #1
0
Light::Light(LIGHT_TYPE type)
{
    lights.push_back(this);

    if(availableLights.size() > 0)
    {
        lightNum = availableLights[0];
        availableLights.erase(availableLights.begin());
        Visible(true);
        setLightType(type);
        setPosition(0, 0, 0);
        setCutoff(45);
        setExponent(12);
        setSpotDirection(0, -1, 0);
        setAmbient(0, 0, 0, 1);
        setDiffuse(1, 1, 1, 1);
        setSpecular(1, 1, 1, 1);

        updateLight();
    }

    else
    {
        lightNum = 0;
        Visible(false);
    }
}
Пример #2
0
void CLight::init()
{
	D3DMATERIAL9 mtrlInitializer;
	ZeroMemory( &_Light, sizeof(D3DLIGHT9));	//メモリの零クリア
	ZeroMemory( &mtrlInitializer, sizeof(D3DMATERIAL9));	//メモリの零クリア
	_Light.Type = D3DLIGHT_DIRECTIONAL;		//ライトタイプの設定
	_Light.Diffuse.r = 1.0f;					//ディフューズ色赤
	_Light.Diffuse.g = 1.0f;					//			  青
	_Light.Diffuse.b = 1.0f;					//			  緑
	_Light.Diffuse.a = 1.0f;					//			  アルファ
	_Light.Direction.x = 0.0f;					//光の向きX
	_Light.Direction.y = -1.0f;					//       Y
	_Light.Direction.z = 0.0f;					//		 Z
	_Light.Position.y = 0.0f;					//発光点X
	_Light.Position.x = 0.0f;					//      Y
	_Light.Position.z = 0.0f;					//		Z
	_Light.Range = 1000.0f;					//光の届く距離
	_Light.Attenuation0 = 0.0f;
	_Light.Attenuation1 = 1.0f;
	_Light.Attenuation2 = 0.0f;
	_Light.Phi   = D3DX_PI;
	_Light.Theta = D3DX_PI;	//0 〜 phi
	_Light.Falloff = 1.0f;

	
	mtrlInitializer.Ambient.a = mtrlInitializer.Diffuse.a = 1.0f;
	mtrlInitializer.Ambient.r = mtrlInitializer.Diffuse.r = 1.0f;
	mtrlInitializer.Ambient.g = mtrlInitializer.Diffuse.g = 1.0f;
	mtrlInitializer.Ambient.b = mtrlInitializer.Diffuse.b = 1.0f;
	D3DDEVICE->SetMaterial( &mtrlInitializer );
	setLightType(D3DLIGHT_DIRECTIONAL);
	activeLight();
}
Пример #3
0
 // helper function, which creates a gameobject and attaches a ambient light
 std::shared_ptr<Light> Scene::createAmbientLight(float intensity, glm::vec3 color){
     GameObject *gameObject = createGameObject("AmbientLight");
     auto light = gameObject->addComponent<Light>();
     light->setLightType(LightType::Ambient);
     light->setIntensity(intensity);
     light->setColor(color);
     return light;
 }
Пример #4
0
 std::shared_ptr<Light> Scene::createDirectionalLight(GameObject *gameObject){
     if (!gameObject){
         gameObject = createGameObject("DirectionalLight");
     }
     auto light = gameObject->addComponent<Light>();
     light->setLightType(LightType::Directional);
     return light;
 }
Пример #5
0
void Seed::populate(History &history){
    this->history = &history;
    this->history->setPresent();
    setTraversal();
    setSurfaceShape();
    setSurfaceType();
    setMedium();
    setLightType();
}
Пример #6
0
RenderObjectPtr
Light::clone() const noexcept
{
	auto light = std::make_shared<Light>();
	light->setLightType(this->getLightType());
	light->setLightColor(this->getLightColor());
	light->setLightIntensity(this->getLightIntensity());
	light->setLightRange(this->getLightRange());
	light->setTransform(this->getTransform(), this->getTransformInverse());
	light->setBoundingBox(this->getBoundingBox());

	light->_spotInnerCone = _spotInnerCone;
	light->_spotOuterCone = _spotOuterCone;

	return light;
}
Пример #7
0
gxLight::gxLight():
object3d(OBJECT3D_LIGHT)
{
	setName("Point Light");
	setLightType(LIGHT_POINT);
	m_cOOBB.set(vector3f(-5, -5, -5), vector3f(5, 5, 5));

	m_cDiffuse.set(0.7f, 0.7f, 0.7f, 1.0f);
	m_cAmbient.set(0.05f, 0.05f, 0.05f, 1.0f);
	m_cSpecular.set(0.2f, 0.2f, 0.2f, 1.0f);
	setPosition(0, 0, 1);

	m_fConstantAttenuation = 0.1f;
	m_fLinearAttenuation = 0.0025f;
	m_fQuadraticAttenuation = 0.0006f;
}
Пример #8
0
LightPtr
Light::clone() const noexcept
{
	auto light = std::make_shared<Light>();
	light->setLightType(this->getLightType());
	light->setLightColor(this->getLightColor());
	light->setIntensity(this->getIntensity());
	light->setRange(this->getRange());
	light->setCastShadow(this->getCastShadow());
	light->setSpotInnerCone(this->getSpotInnerCone());
	light->setSpotOuterCone(this->getSpotOuterCone());
	light->setTransform(this->getTransform());
	light->setBoundingBox(this->getBoundingBox());

	return light;
}
Пример #9
0
/**
* @internal
* @brief Initializes the class so it becomes valid.
*
* @param[in] r Red component of the diffuse color of the light.    Value Range: 0..255
* @param[in] g Green component of the diffuse color of the light.  Value Range: 0..255
* @param[in] b Blue component of the diffuse color of the light.   Value Range: 0..255
* @param[in] nx x direction(horizontal axis) of the light in the scene
* @param[in] ny y direction (vertical axis) of the light in the scene
* @param[in] nz z direction (depth) of the light in the scene
* @return true if the initialization was ok | false otherwise
*/
bool DirectionalLight::init( float r, float g, float b, float nx, float ny, float nz )
{
	// Check if the class is already initialized
	if ( isValid() )
		return true;

	// Init base light
	BaseLight::init( r, g, b, nx, ny, nz );

	// Setup light
	setDirection( nx, ny, nz );
	setDiffuseColor( r, g, b );

	// Set light type
	setLightType( Light::LT_DIRECTIONAL );

	// The class is now initialized
	m_bIsValid = true;

	return true;
}
Пример #10
0
/**
* @internal
* @brief Initializes the class so it becomes valid.
*
* @param[in] r Red component of the diffuse color of the light.    Value Range: 0..255
* @param[in] g Green component of the diffuse color of the light.  Value Range: 0..255
* @param[in] b Blue component of the diffuse color of the light.   Value Range: 0..255
* @param[in] x x coordinate (horizontal axis) of the light in the scene
* @param[in] y y coordinate (vertical axis) of the light in the scene
* @param[in] z z coordinate (depth) of the light in the scene
* @return true if the initialization was ok | false otherwise
*/
bool PointLight::init( float r, float g, float b, float x, float y, float z )
{
	// Check if the class is already initialized
	if ( isValid() )
		return true;

	// Init base light
	BaseLight::init( r, g, b, x, y, z );

	// Setup light
	setPosition( x, y, z );
	setDiffuseColor( r, g, b );

	// Set light type
	setLightType( Light::LT_POINT );

	// The class is now initialized
	m_bIsValid = true;

	return true;
}
Пример #11
0
/**
* @internal
* @brief Initializes the class so it becomes valid.
*
* @param[in] r Red component of the diffuse color of the light.    Value Range: 0..255
* @param[in] g Green component of the diffuse color of the light.  Value Range: 0..255
* @param[in] b Blue component of the diffuse color of the light.   Value Range: 0..255
* @param[in] x x coordinate (horizontal axis) of the light in the scene
* @param[in] y y coordinate (vertical axis) of the light in the scene
* @param[in] z z coordinate (depth) of the light in the scene
* @param[in] nx x direction(horizontal axis) of the light in the scene
* @param[in] ny y direction (vertical axis) of the light in the scene
* @param[in] nz z direction (depth) of the light in the scene
* @param[in] angleRad angle in radians of the spotlight cone. It is possible tolater control inner and outer angle of the light.
* @param[in] concentration fall off of the light (Range: 0.0-1.0). Less means slower falloff, higher means faster falloff.
* @return true if the initialization was ok | false otherwise
*/
bool SpotLight::init( float r, float g, float b, float x, float y, float z, float nx, float ny, float nz, float angleRad, float concentration )
{
	// Check if the class is already initialized
	if ( isValid() )
		return true;

	// Init base light
	BaseLight::init( r, g, b, x, y, z );

	// Set light type
	setLightType( Light::LT_SPOTLIGHT );

	// Setup light
	setDirection( nx, ny, nz );
	setDiffuseColor( r, g, b );
	Ogre::Light* light = getOgreLight();
	if ( light )
		light->setSpotlightRange( Ogre::Radian(angleRad), Ogre::Radian(angleRad), concentration );

	// The class is now initialized
	m_bIsValid = true;

	return true;
}