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


C++ Triangle::SetShader方法代码示例

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


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

示例1: Sphere

Scene::Scene()
    :   m_AmbientLight(0)
{
#if 0
#if 1
    for (int i=0; i < 100; i++) {
        DefaultShader *ds = new DefaultShader;
        Sphere *s = new Sphere(Vector3d(Libvec::Random(-50, 50), Libvec::Random(-50, 50), Libvec::Random(-50, 50)), Libvec::Random(1, 20));
        ds->SetDiffuseColor(colorf::RandColor());
        ds->SetShinyness(0.0f);
        s->SetShader(ShaderPtr(ds));
        s->Prepare();
        m_DrawableList.push_back(s);
    }
#endif

    Sphere *s = new Sphere(Vector3d(0.0, 0.0, 0.0), 50.0);
    {
        DefaultShader *ds = new DefaultShader;
        ds->SetShinyness(0.0f);
        s->SetShader(ShaderPtr(ds));
        s->Prepare();
    }
    m_DrawableList.push_back(s);

    Plane *p = new Plane(Ray(Vector3d(0.0, 0.0, -50.0), Vector3d(0.0, 0.0, 1.0)));
    {
        DefaultShader *ds = new DefaultShader;
        ds->SetShinyness(0.2f);
        p->SetShader(ShaderPtr(ds));
        p->Prepare();
    }
    m_DrawableList.push_back(p);

    p = new Plane(Ray(Vector3d(-50.0, 0.0, 0.0), Vector3d(1.0, 0.0, 0.0)));
    {
        DefaultShader *ds = new DefaultShader;
        ds->SetShinyness(0.0f);
        p->SetShader(ShaderPtr(ds));
        p->Prepare();
    }
    m_DrawableList.push_back(p);

    m_SimpleLightList.push_back(new SimpleLight(Vector3d(0.0, 0.0, 100.0), colorf(1.0, 0.0, 0.0), 100));
    m_SimpleLightList.push_back(new SimpleLight(Vector3d(100.0, 0.0, 5.0), colorf(0.0, 1.0, 0.0), 100));
    m_SimpleLightList.push_back(new SimpleLight(Vector3d(0.0, 100.0, 5.0), colorf(0.0, 0.0, 1.0), 100));
    m_SimpleLightList.push_back(new SimpleLight(Vector3d(0.0, 60.0, 60.0), colorf(1.0, 1.0, 1.0), 100));
#endif
#if 0
    m_AmbientLight = colorf(0.0f, 0.0f, 0.0f);
    {
        Sphere *s = new Sphere(Vector3d(10.0, 10.0, 10.0), 8.0);
        {
            DefaultShader *ds = new DefaultShader;
            ds->SetShinyness(0.8f);
            s->SetShader(ShaderPtr(ds));
            s->Prepare();
        }
        m_DrawableList.push_back(s);
    }

    // bottom
    {
        Plane *p = new Plane(Ray(Vector3d(0.0, 0.0, 0.0), Vector3d(0.0, 0.0, 1.0)));
        DefaultShader *ds = new DefaultShader;
        ds->SetDiffuseColor(colorf(1.0, 0.2, 0.2));
        ds->SetShinyness(0.5f);
        p->SetShader(ShaderPtr(ds));
        p->Prepare();
        m_DrawableList.push_back(p);
    }
    {
        Plane *p = new Plane(Ray(Vector3d(0.0, 0.0, 0.0), Vector3d(0.0, 1.0, 0.0)));
        DefaultShader *ds = new DefaultShader;
        ds->SetDiffuseColor(colorf(0.2, 1.0, 0.2));
        ds->SetShinyness(0.5f);
        p->SetShader(ShaderPtr(ds));
        p->Prepare();
        m_DrawableList.push_back(p);
    }
    // back
    {
        Plane *p = new Plane(Ray(Vector3d(0.0, 0.0, 0.0), Vector3d(1.0, 0.0, 0.0)));
        DefaultShader *ds = new DefaultShader;
        ds->SetDiffuseColor(colorf(0.2, 0.2, 1.0));
        ds->SetShinyness(0.5f);
        p->SetShader(ShaderPtr(ds));
        p->Prepare();
        m_DrawableList.push_back(p);
    }

//  m_SimpleLightList.push_back(new SimpleLight(Vector3d(1.0, 1.0, 100.0), colorf(1.0, 0.0, 0.0), 100));
//  m_SimpleLightList.push_back(new SimpleLight(Vector3d(100.0, 1.0, 5.0), colorf(0.0, 1.0, 0.0), 100));
//  m_SimpleLightList.push_back(new SimpleLight(Vector3d(1.0, 100.0, 5.0), colorf(0.0, 0.0, 1.0), 100));
    m_SimpleLightList.push_back(new SimpleLight(Vector3d(20.0, 10.0, 20), colorf(1.0, 1.0, 1.0), 100));
#endif

#if 1
    m_AmbientLight = colorf(0.0f, 0.0f, 0.2f);
    if (0) {
//.........这里部分代码省略.........
开发者ID:travisg,项目名称:ray,代码行数:101,代码来源:Scene.cpp


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