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


C++ PointLight::SetColor方法代码示例

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


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

示例1: setTorchLight

void setTorchLight(float x, float y, float z, float radius) {
	//PLight
	PointLight p;
	p.SetColor(fireLightColor[0], fireLightColor[1], fireLightColor[2]);
	p.SetPosition(x, y, z);
	p.SetAttenuation(0.01, 0.1, 0.1);
	//p.SetAttenuation(1.0, 0.05, 0.0);
	p.SetRadius(radius);
	p.SetGrain(10);

	plights.push_back(p);  
}
开发者ID:geekrandom,项目名称:248project,代码行数:12,代码来源:Graphics.cpp

示例2: window

World::World(sf::RenderWindow& inWindow)
: window(inWindow), gbuffer(WINDOW_WIDTH, WINDOW_HEIGHT), hdrDownsampleTexture(WINDOW_WIDTH / 2, WINDOW_HEIGHT / 2, true), hdrBlurTexture(WINDOW_WIDTH / 2, WINDOW_HEIGHT / 2, true), hdrDownsample2Texture(WINDOW_WIDTH / 4, WINDOW_HEIGHT / 4, true), hdrBlur2Texture(WINDOW_WIDTH / 4, WINDOW_HEIGHT / 4, true), fullscreenQuad(0, 0, WINDOW_WIDTH, WINDOW_HEIGHT), aaTexture(WINDOW_WIDTH, WINDOW_HEIGHT)
{
    // OpenGL State
    glBlendEquation(GL_FUNC_ADD);
    glBlendFunc(GL_ONE, GL_ONE);
    glStencilOpSeparate(GL_BACK, GL_KEEP, GL_INCR_WRAP, GL_KEEP);
    glStencilOpSeparate(GL_FRONT, GL_KEEP, GL_DECR_WRAP, GL_KEEP);

    // Seed the PRNG.
    srand(static_cast<unsigned int>(time(0)));

    // Load light meshes.
    pointLightMesh.LoadFromFile("Models/pointlightMesh.obj");
    spotLightMesh.LoadFromFile("Models/spotlightMesh.obj");
    directionalLightMesh.LoadFromFile("Models/directionalMesh.obj");

    // Lighting Shaders.
    pointLightShader.LoadFromFile("Shaders/lightShader.vert", "Shaders/pointlightShader.frag");
    spotLightShader.LoadFromFile("Shaders/lightShader.vert", "Shaders/spotlightShader.frag");
    directionalLightShader.LoadFromFile("Shaders/lightShader.vert", "Shaders/directionalShader.frag");

    // HDR Shaders.
    hdrDownsample.LoadFromFile("Shaders/fsquad.vert", "Shaders/hdrDownsample.frag");
    hdrTonemap.LoadFromFile("Shaders/fsquad.vert", "Shaders/hdrTonemap.frag");
    hdrBlur.LoadFromFile("Shaders/fsquad.vert", "Shaders/hdrBlur.frag");
    hdrBrightness.LoadFromFile("Shaders/fsquad.vert", "Shaders/hdrBrightness.frag");

    // Load Models.
    mdl2.LoadFromFile("Models/sphere.obj");
    mdl.LoadFromFile("Models/floor.obj");
    mdl3.LoadFromFile("Models/sphere.obj");
    quadMesh.LoadFromFile("Models/quad.obj");

    // Load Shaders
    basicShader.LoadFromFile("Shaders/basic.vert", "Shaders/basic.frag");
    pass1Shader.LoadFromFile("Shaders/drpass1.vert", "Shaders/drpass1.frag");
    pass2Shader.LoadFromFile("Shaders/drpass2.vert", "Shaders/drpass2.frag");
    pass2ShaderDirectional.LoadFromFile("Shaders/empty.vert", "Shaders/drpass2directional.frag");
    quadShader.LoadFromFile("Shaders/fsquad.vert", "Shaders/hdrTonemap.frag");
    terrainShader.LoadFromFile("Shaders/terrainshader.vert", "Shaders/terrainshader.frag");
    flatShader.LoadFromFile("Shaders/basic.vert", "Shaders/flatshade.frag");
    emptyShader.LoadFromFile("Shaders/empty.vert", "Shaders/empty.frag");
    sphereShader.LoadFromFile("Shaders/sphere.vert", "Shaders/sphere.frag");

    // Anti-Aliasing Shaders
#if USE_FXAA == 1
    fxaaShader.LoadFromFile("Shaders/fxaa.vert", "Shaders/fxaa.frag");
#endif
    baseAAShader.LoadFromFile("Shaders/baseaa.vert", "Shaders/baseaa.frag");

    // Load textures.
    mdlTex.loadFromFile("Textures/test.png");
    terrainTexture.loadFromFile("Textures/terraintex.png");
    terrainWater.loadFromFile("Textures/terrainwater.png");

    // Main world directional light.
    DirectionalLight worldLight;
    worldLight.SetDirection(Vector3(-1.0f, 0.0f, 0.0f));
    worldLight.SetColor(Color(0.8f, 0.8f, 0.8f));
    worldLight.SetDiffuseIntensity(0.9f);
    worldLight.SetAmbientIntensity(0.4f);
    directionalLights.push_back(worldLight);

    // Lights
    const unsigned int numLights = 40;
    const float lightRadius = 2.0f;
    PointLight l;
    l.SetPosition(Vector3(10.0f, 2.0f, 10.0f));
    l.SetScale(Vector3(3.0f, 3.0f, 3.0f));
    l.SetColor(Color(0.0f, 0.0f, 1.4f, 1.0f));
    l.SetAttenuationConstant(0.4f);
    l.SetDiffuseIntensity(0.4f);
    l.SetAmbientIntensity(0.2f);
    pointLights.push_back(l);

    const int maxXZ = 15;
    const int minXZ = -15;
    const int maxY = 5;
    const float minRad = 0.3f;
    const float maxRad = 2.0f;
    for (int i = 0; i < numLights; i++)
    {
        PointLight l;
        
        // Generate position.
        int x = (rand() % (maxXZ - minXZ)) + minXZ;
        int y = (rand() % maxY);
        int z = (rand() % (maxXZ - minXZ)) + minXZ;
        l.SetPosition(Vector3(x, y, z));

        // Generate Scale
        float frand = ((float)rand() / (float)RAND_MAX);
        float fdiff = maxRad - minRad;

        //l.SetScale(Vector3(scale, scale, scale));

        // Generate Color
        float r = float_rand(0.0f, maxCol);
        float g = float_rand(0.0f, maxCol);
//.........这里部分代码省略.........
开发者ID:aleios,项目名称:3dapp,代码行数:101,代码来源:World.cpp


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