/*
 * undisguise:
 *	player stops looking like a monster
 */
void
undisguise(void)
{
    msg("Your skin feels itchy for a moment.");
    turn_off(player, ISDISGUISE);
    PLAYER = VPLAYER;
    light(&hero);
}
LightGroup* LightingFactory::createGroupLight(Camera* camera){
    LightGroup* light_group = new LightGroup();

    std::unique_ptr<LightDirectional> light(loadDirLight());
    light_group->addLightDirectional(std::move(light));

    return light_group;
}
/*
 * appear:
 *	Become visible again
 */
void
appear(void)
{
    turn_off(player, ISINVIS);
    PLAYER = VPLAYER;
    msg("The tingling feeling leaves your body.");
    light(&hero);
}
Пример #4
0
TEST(LightTest, Color) {
  Light light(std::make_shared<Point3>(),
              std::make_shared<Color>(0.1, 0.2, 0.3));
  const Color* color = light.color();
  EXPECT_EQ(0.1, color->r());
  EXPECT_EQ(0.2, color->g());
  EXPECT_EQ(0.3, color->b());
}
Пример #5
0
    void CurveEditor::InitGrid()
    {
        auto size = mCurveCanvasWidget->getSize();
        auto width = size.width;
        auto height= size.height;

        auto inteveralX = width / (gridNumX + 2);
        auto inteveralY = height / (gridNumY + 2);

        MyGUI::Colour dark(0.1f, 0.1f, 0.1f);
        MyGUI::Colour light(0.2f, 0.2f, 0.2f);

        std::vector<MyGUI::Colour> colors;
        std::vector<MyGUI::FloatPoint> lines;
        for (auto i = 1; i <= gridNumX+1; ++i)
        {
            lines.push_back(MyGUI::FloatPoint(i*inteveralX, 3));
            lines.push_back(MyGUI::FloatPoint(i*inteveralX, height-4));

            colors.push_back(i == 1 ? dark : light);
            colors.push_back(i == 1 ? dark : light);
        }

        lines.push_back(MyGUI::FloatPoint(inteveralX - 1, 3));
        lines.push_back(MyGUI::FloatPoint(inteveralX - 1, height - 4));
        colors.push_back(dark);
        colors.push_back(dark);

        for (auto i = 1; i <= gridNumY + 1; ++i)
        {
            lines.push_back(MyGUI::FloatPoint(3, i*inteveralY));
            lines.push_back(MyGUI::FloatPoint(width - 4, i*inteveralY));

            colors.push_back(i == gridNumY + 1 ? dark : light);
            colors.push_back(i == gridNumY + 1 ? dark : light);
        }

        lines.push_back(MyGUI::FloatPoint(3, (gridNumY + 1)*inteveralY + 1));
        lines.push_back(MyGUI::FloatPoint(width - 4, (gridNumY + 1)*inteveralY + 1));
        colors.push_back(dark);
        colors.push_back(dark);

        mCurveLines->setPoints(lines, true);
        mCurveLines->setColors(colors);

        for (auto i = 1; i <= gridNumX + 1; i += 2)
        {
            MyGUI::TextBox* text = mCurveCanvasWidget->createWidget<MyGUI::TextBox>("TextBox",
                MyGUI::IntCoord(i * inteveralX + 2, height - 19, 30, 15), MyGUI::Align::Default);
            text->setFontHeight(14);
            text->setTextShadow(true);
            text->setTextShadowColour(MyGUI::Colour::Black);
            DiString s;
            s.Format("%.1f", (i - 1) / (float)gridNumX);
            text->setCaption(s.c_str());
            mNumbersX.push_back(text);
        }
    }
Пример #6
0
fuse
unelectrify(fuse_arg *arg)
{
    NOOP(arg);

    turn_off(player, ISELECTRIC);
    msg("The sparks and violet glow from your body fade away.");
    light(&hero);
}
Пример #7
0
LightID Stage::new_light(LightType type) {
    LightID lid = LightManager::manager_new();

    Light& l = light(lid);
    l.set_type(type);

    signal_light_created_(lid);
    return lid;
}
Пример #8
0
void
ring_off(void)
{
    struct object   *obj;
    struct linked_list  *item;

    if (cur_ring[LEFT_1] == NULL && cur_ring[LEFT_2] == NULL &&
        cur_ring[LEFT_3] == NULL && cur_ring[LEFT_4] == NULL &&
        cur_ring[LEFT_5] == NULL &&
        cur_ring[RIGHT_1] == NULL && cur_ring[RIGHT_2] == NULL &&
        cur_ring[RIGHT_3] == NULL && cur_ring[RIGHT_4] == NULL &&
        cur_ring[RIGHT_5] == NULL)
    {
        msg("You aren't wearing any rings.");
        return;
    }
    else if ((item = get_item("remove", RING)) == NULL)
        return;

    mpos = 0;
    obj = OBJPTR(item);

    if ((obj = OBJPTR(item)) == NULL)
        msg("You are not wearing that!");

    if (dropcheck(obj))
    {
        switch (obj->o_which)
        {
            case R_SEEINVIS:
                msg("Your eyes stop tingling.");
                break;

            case R_CARRYING:
                updpack();
                break;

            case R_LEVITATION:
                msg("You float gently to the ground.");
                break;

            case R_LIGHT:
                if (roomin(hero) != NULL)
                {
                    light(&hero);
                    mvwaddch(cw, hero.y, hero.x, PLAYER);
                }
                break;

            case R_TRUESEE:
                msg("Your sensory perceptions return to normal.");
                break;
        }

        msg("Was wearing %s.", inv_name(obj, LOWERCASE));
    }
}
Пример #9
0
void CornellSmall::initialize()
{
    if ( ((m_config & Config::LightArea) != 0) || 
         ((m_config & Config::LightAreaUpwards) != 0) )
    {
        optix::float3 anchor = optix::make_float3( 1.f, 2.499f, 1.f);
        optix::float3 v1 = optix::make_float3( 0.5f, 0.0f, 0.0f);
        optix::float3 v2 = optix::make_float3( 0.0f, 0.0f, 0.5f);
        if ((m_config & Config::LightAreaUpwards) != 0)
        {
            optix::float3 t = v1;
            v1 = v2;
            v2 = t;
            anchor -= optix::make_float3( 0.0f, .1f, 0.f);
        }
        //optix::float3 power = optix::make_float3( 0.5e6f, 0.4e6f, 0.2e6f );
        //optix::float3 power = optix::make_float3( 0.75f * 5.f );
        //optix::float3 power = optix::make_float3( M_PIf );
        optix::float3 power = optix::make_float3( 19.661107023935260172519494336416f );
        Light light(power, anchor, v1, v2);
        m_sceneLights.push_back(light);
    }
    else if ( ((m_config & Config::LightPoint)       != 0) || 
              ((m_config & Config::LightPointStrong) != 0) ||
              ((m_config & Config::LightPointDistant) != 0) )
    {
        // point light
        optix::float3 anchor = optix::make_float3( 1.25f, 2.25f, 1.25f);
        float power = 30.f;
        if ((m_config & Config::LightPointStrong) != 0)
            power = 70.f;
        if ((m_config & Config::LightPointDistant) != 0)
        {
            power = 200.f;
            anchor += optix::make_float3( 0.f, 5.f, 0.f);
        }
            
        Light light(power, anchor);
        m_sceneLights.push_back(light);
    }

    m_sceneAABB.min = Vector3(-0.1f);
    m_sceneAABB.max = Vector3(2.5f, 2.5f, 2.5f) + 0.1f;
}
Пример #10
0
/*!
  Reimplementation from QStyle
 */
void MetalStyle::polish( QApplication *app)
{
    oldPalette = app->palette();

    // we simply create a nice QColorGroup with a couple of fancy
    // pixmaps here and apply to it all widgets

    QFont f("times", app->font().pointSize() );
    f.setBold( TRUE );
    f.setItalic( TRUE );
    app->setFont( f, TRUE, "QMenuBar");
    app->setFont( f, TRUE, "QPopupMenu");



    //    QPixmap button( stonedark_xpm );

    QColor gold("#B9B9A5A54040"); //same as topgrad below
    QPixmap button( 1, 1 ); button.fill( gold );

    QPixmap background(marble_xpm);
    QPixmap dark( 1, 1 ); dark.fill( red.dark() );
    QPixmap mid( stone1_xpm );
    QPixmap light( stone1_xpm );//1, 1 ); light.fill( green );

    QPalette op = app->palette();

    QColor backCol( 227,227,227 );

    // QPalette op(white);
    QColorGroup active (op.active().foreground(),
		     QBrush(op.active().button(),button),
		     QBrush(op.active().light(), light),
		     QBrush(op.active().dark(), dark),
		     QBrush(op.active().mid(), mid),
		     op.active().text(),
		     Qt::white,
		     op.active().base(),//		     QColor(236,182,120),
		     QBrush(backCol, background)
		     );
    active.setColor( QColorGroup::ButtonText,  Qt::white  );
    active.setColor( QColorGroup::Shadow,  Qt::black  );
    QColorGroup disabled (op.disabled().foreground(),
		     QBrush(op.disabled().button(),button),
		     QBrush(op.disabled().light(), light),
		     op.disabled().dark(),
		     QBrush(op.disabled().mid(), mid),
		     op.disabled().text(),
		     Qt::white,
		     op.disabled().base(),//		     QColor(236,182,120),
		     QBrush(backCol, background)
		     );

    QPalette newPalette( active, disabled, active );
    app->setPalette( newPalette, TRUE );
}
Пример #11
0
void Renderer::onDraw(al::Graphics& gl)
{
    int faceIndex = mOmni.face();
    
    {
        
        
        // render cubemap
        if (cubemap && cubemap->getEyesCount() > 0)
        {
            Cubemap* eye = cubemap->getEye(0);
            if (eye->getFacesCount() > faceIndex)
            {
                CubemapFace* face = eye->getFace(faceIndex);
                
                glUseProgram(0);
                glDepthMask(GL_FALSE);
                
                // draw the background
                glDrawPixels(face->getWidth(),
                             face->getHeight(),
                             GL_RGB,
                             GL_UNSIGNED_BYTE,
                             (GLvoid*)face->getPixels());
                
                glDepthMask(GL_TRUE);
                
                
                
                if(newCubemap)
                {
                    if (onDisplayedCubemapFace) onDisplayedCubemapFace(this, faceIndex);
                }
            }
        }
    }
    
    light();
    mShader.begin();
    mOmni.uniforms(mShader);
    
    gl.pushMatrix();
    
    //gl.draw(cube);
    
    gl.pushMatrix();
    // rotate over time:
    gl.rotate(now*30., 0.707, 0.707, 0.);
    gl.translate(1., 1., 1.);
    //gl.draw(sphere);
    gl.popMatrix();
    
    gl.popMatrix();
    
    mShader.end();
}
Пример #12
0
fuse
appear(fuse_arg *arg)
{
    NOOP(arg);

    turn_off(player, ISINVIS);
    PLAYER = VPLAYER;
    msg("The tingling feeling leaves your body.");
    light(&hero);
}
Пример #13
0
sight()
{
    if (on(player, ISBLIND))
    {
	extinguish(sight);
	player.t_flags &= ~ISBLIND;
	light(&hero);
	msg("The veil of darkness lifts");
    }
}
Пример #14
0
sk_sp<SkLights> SkLights::makeColorSpace(SkColorSpaceXformer* xformer) const {
    SkLights::Builder builder;
    for (int i = 0; i < this->numLights(); i++) {
        Light light(fLights[i].type(), xform_color(fLights[i].color(), xformer),
                    fLights[i].fDirOrPos, fLights[i].fIntensity);
        builder.add(light);
    }
    builder.setAmbientLightColor(xform_color(fAmbientLightColor, xformer));
    return builder.finish();
}
Пример #15
0
  Canvas& get_canvas(DrawingTarget target) {
    switch (target)
    {
      case DrawingTarget::LIGHTMAP:
        return light();

      default:
        return color();
    }
  }
Пример #16
0
fuse
undisguise(fuse_arg *arg)
{
    NOOP(arg);

    msg("Your skin feels itchy for a moment.");
    turn_off(player, ISDISGUISE);
    PLAYER = VPLAYER;
    light(&hero);
}
Пример #17
0
//
//  Draw the window
//
void Ex04opengl::paintGL()
{
   //  Wall time (seconds)
   float t = 0.001*time.elapsed();
   if (move) zh = fmod(90*t,360);

   //  Clear screen and Z-buffer
   glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
   glEnable(GL_DEPTH_TEST);

   //  Set view
   glLoadIdentity();
   if (fov) glTranslated(0,0,-2*dim);
   glRotated(ph,1,0,0);
   glRotated(th,0,1,0);

   //  Translate intensity to color vectors
   float Ambient[]  = {0.3,0.3,0.3,1.0};
   float Diffuse[]  = {0.8,0.8,0.8,1.0};
   float Specular[] = {1.0,1.0,1.0,1.0};
   float Position[] = {(float)(3*Cos(zh)),z0,(float)(3*Sin(zh)),1.0};

   //  Draw light position (no lighting yet)
   glColor3f(1,1,1);
   ball(Position[0],Position[1],Position[2] , 0.1);
   //  OpenGL should normalize normal vectors
   glEnable(GL_NORMALIZE);
   //  Enable lighting
   glEnable(GL_LIGHTING);
   //  Enable light 0
   glEnable(GL_LIGHT0);
   //  Set ambient, diffuse, specular components and position of light 0
   glLightfv(GL_LIGHT0,GL_AMBIENT ,Ambient);
   glLightfv(GL_LIGHT0,GL_DIFFUSE ,Diffuse);
   glLightfv(GL_LIGHT0,GL_SPECULAR,Specular);
   glLightfv(GL_LIGHT0,GL_POSITION,Position);

   //  Apply shader
   if (mode) shader[mode].bind();

   //  Draw scene
   glPushMatrix();
   if (obj) obj->display();
   glPopMatrix();

   //  Release shader
   if (mode) shader[mode].release();
   glDisable(GL_LIGHTING);
   glDisable(GL_DEPTH_TEST);
   
   //  Emit angles to display
   emit angles(QString::number(th)+","+QString::number(ph));
   //  Emit light angle
   emit light((int)zh);
}
Пример #18
0
void EditorTerrain::load(QString directory, QWidget *parent) {
	this->directory = directory;

	QDir dir(directory);
	dir.setFilter(QDir::Files);

// Lost World has no terrain files that describe what to load
// Therefore, we just have to detect what files are in the directory
// and create a visible node for each model that has no instances whatsoever
#ifdef SONICGLVL_LOST_WORLD
	vector<LibGens::Model *> terrain_models;
	vector<LibGens::TerrainInstance *> terrain_instances;

	// Load lights
	dir.setNameFilters(QStringList() << "*.light");
	QStringList light_names = dir.entryList();
	if (!light_names.isEmpty()) {
		scene_manager->destroyAllLights();

		QString light_name = light_names.first();
		LibGens::Light light((directory + "/" + light_name).toStdString());
		if (light.getType() == LIBGENS_LIGHT_TYPE_DIRECTIONAL) {
			LibGens::Vector3 dir = light.getPosition();
			LibGens::Vector3 col = light.getColor();
			Ogre::Light *directional_light = scene_manager->createLight();
			directional_light->setDiffuseColour(col.x, col.y, col.z);
			directional_light->setDirection(Ogre::Vector3(dir.x, dir.y, dir.z) * -1.0F);
			directional_light->setType(Ogre::Light::LT_DIRECTIONAL);
		}
	}

	// Get all terrain model filenames
	dir.setNameFilters(QStringList() << "*.terrain-model");
	QStringList terrain_model_names = dir.entryList();

	// Get all terrain instance names
	dir.setNameFilters(QStringList() << "*.terrain-instanceinfo");
	QStringList terrain_instance_names = dir.entryList();

	int progress_count = 0;
	int progress_max_count = terrain_model_names.size() * 2 + terrain_instance_names.size() * 2;
	QProgressDialog progress(QString(), QString(), 0, progress_max_count, parent);
	progress.setWindowTitle("Loading terrain...");
    progress.setWindowModality(Qt::WindowModal);

	// Load all Terrain Models
	terrain_models.reserve(terrain_model_names.size());
	foreach(QString filename, terrain_model_names) {
		progress.setLabelText("Loading model " + filename);
		progress.setValue(progress_count++);

		QString absolute_filename = directory + "/" + filename;
		LibGens::Model *model = new LibGens::Model(absolute_filename.toStdString());
		terrain_models.push_back(model);
	}
void keyboard(GLubyte key, int x, int y) // For keyboard interactive
{
switch ( key )
{
case 'l':
/*xt += 1.2;
glColor3f(0.0,1.0,0.0);
glutPostRedisplay();
break;*/
light();
break;
case 'a':
xt -= 1.0;
glColor3f(1.0,0.0,0.0);
glutPostRedisplay();
break;
case 's':
yt -= 1.0;
glColor3f(0.0,0.0,0.0);
glutPostRedisplay();
break;
case 'w':
yt += 1.0;
glColor3f(0.0,0.0,1.0);
glutPostRedisplay();
break;
/*case 'e':
xt += 1.0;
yt += 1.0;
glColor3f(1.0,0.0,1.0);
glutPostRedisplay();
break;
case 'q':
xt -= 1.0;
yt += 1.0;
glColor3f(0.0,1.0,1.0);
glutPostRedisplay();
break;
case 'c':
xt += 1.0;
yt -= 1.0;
glColor3f(1.0,0.0,1.0);
glutPostRedisplay();
break;
case 'z':
xt -= 1.0;
yt -= 1.0;
glColor3f(0.0,0.0,1.0);
glutPostRedisplay();
break;*/
default:
break;
}
}
void 
SDFLoader::define_light(std::vector<std::string> const& tokens)
{
	std::string name = tokens[2];
	glm::vec3 pos{std::stof(tokens[3]), std::stof(tokens[4]), std::stof(tokens[5])};
	Color La{std::stof(tokens[6]), std::stof(tokens[7]), std::stof(tokens[8])};
	Color Ld{std::stof(tokens[9]), std::stof(tokens[10]), std::stof(tokens[11])};

	Light light(name, pos, La, Ld);
	_scene.add(std::make_shared<Light>(light));
}
/*
 * sight:
 *	He gets his sight back
 */
void
sight(void)
{
    if (on(player, ISBLIND))
    {
	extinguish(sight);
	turn_off(player, ISBLIND);
	light(&hero);
	msg("The veil of darkness lifts.");
    }
}
Пример #22
0
/** Return the RenderMan handle handle for this light.
 */
RtLightHandle liqRibObj::lightHandle() const
{
  LIQDEBUGPRINTF( "-> creating light node handle rep\n");
  //assert( type == MRT_Light );
  RtLightHandle lHandle( NULL );
  if ( type == MRT_Light ) 
  {
    liqRibLightData* light( ( liqRibLightData* )data.get() );
    lHandle = light->lightHandle();
  }
  return lHandle;
}
Пример #23
0
/*ARGSUSED1*/
void
key(unsigned char key, int x, int y) {
    switch(key) {
    case 'l': light(); break;
    case 't': toggle_t(); break;
    case 'w': wire(); break;
    case 'h': help(); break;
    case '\033': exit(EXIT_SUCCESS); break;
    default: break;
    }
    glutPostRedisplay();
}
Пример #24
0
fuse
sight(fuse_arg *arg)
{
    NOOP(arg);

    if (on(player, ISBLIND))
    {
        extinguish_fuse(FUSE_SIGHT);
        turn_off(player, ISBLIND);
        light(&hero);
        msg("The veil of darkness lifts.");
    }
}
Пример #25
0
LightID Stage::new_light(Object &parent, LightType type) {
    LightID lid = LightManager::manager_new();

    {
        auto l = light(lid);
        l->set_type(type);
        l->set_parent(&parent);
    }

    signal_light_created_(lid);

    return lid;
}
Пример #26
0
static void verticalGradientHelper(QPainter *p, const QRect &spanRect, const QRect &rect)
{
    QColor base = StyleHelper::baseColor();
    QLinearGradient grad(spanRect.topRight(), spanRect.topLeft());
    grad.setColorAt(0, StyleHelper::highlightColor());
    grad.setColorAt(0.301, base);
    grad.setColorAt(1, StyleHelper::shadowColor());
    p->fillRect(rect, grad);

    QColor light(255, 255, 255, 80);
    p->setPen(light);
    p->drawLine(rect.topRight() - QPoint(1, 0), rect.bottomRight() - QPoint(1, 0));
}
Пример #27
0
QColor QColor::dark( int factor ) const
{
    if ( factor <= 0 )				// invalid darkness factor
	return *this;
    else if ( factor < 100 )			// makes color lighter
	return light( 10000/factor );
    int h, s, v;
    hsv( &h, &s, &v );
    v = (v*100)/factor;
    QColor c;
    c.setHsv( h, s, v );
    return c;
}
Пример #28
0
void ETHScriptWrapper::AddLight(const Vector3 &v3Pos, const Vector3 &v3Color, const float range, const bool castShadows)
{
	if (WarnIfRunsInMainFunction(GS_L("AddLight")))
		return;

	ETHLight light(true);
	light.castShadows = castShadows;
	light.color = v3Color;
	light.pos = v3Pos;
	light.range = range;
	light.staticLight = false;
	m_pScene->AddLight(light);
}
Пример #29
0
ezQtPin::ezQtPin()
{
  auto palette = QApplication::palette();

  QPen pen(palette.light().color(), 3, Qt::SolidLine);
  setPen(pen);
  setBrush(palette.base());

  setFlag(QGraphicsItem::ItemSendsGeometryChanges);
  setFlag(QGraphicsItem::ItemSendsScenePositionChanges);

  m_pLabel = new QGraphicsTextItem(this);
}
Пример #30
0
int main(int argc, char *argv[])
{
    int result = 0;

    QGuiApplication *app = SailfishApp::application(argc, argv);
    QQuickView *view = SailfishApp::createView();

    qmlRegisterType<PlotWidget>("harbour.messwerk.MesswerkWidgets", 1, 0, "PlotWidget");
    qmlRegisterType<SatellitePosWidget>("harbour.messwerk.MesswerkWidgets", 1, 0, "SatellitePosWidget");
    qmlRegisterType<SatelliteStrengthWidget>("harbour.messwerk.MesswerkWidgets", 1, 0, "SatelliteStrengthWidget");

    QTimer refreshTimer;

    Accelerometer accelerometer(false);
    Gyroscope gyroscope(false);
    Magnetometer magnetometer(false);
    Rotation rotation(false);
    Light light(false);
    Proximity proximity(true);
    SatelliteInfo satelliteinfo;
    Position position;

    // connect not self-refreshing sensors to the global timer
    QObject::connect(&refreshTimer, SIGNAL(timeout()), &accelerometer, SLOT(refresh()));
    QObject::connect(&refreshTimer, SIGNAL(timeout()), &gyroscope, SLOT(refresh()));
    QObject::connect(&refreshTimer, SIGNAL(timeout()), &magnetometer, SLOT(refresh()));
    QObject::connect(&refreshTimer, SIGNAL(timeout()), &rotation, SLOT(refresh()));
    QObject::connect(&refreshTimer, SIGNAL(timeout()), &light, SLOT(refresh()));

    QString qml = QString("qml/%1.qml").arg("Messwerk");
    view->rootContext()->setContextProperty("accelerometer", &accelerometer);
    view->rootContext()->setContextProperty("gyroscope", &gyroscope);
    view->rootContext()->setContextProperty("magnetometer", &magnetometer);
    view->rootContext()->setContextProperty("rotationsensor", &rotation);
    view->rootContext()->setContextProperty("lightsensor", &light);
    view->rootContext()->setContextProperty("proximitysensor", &proximity);
    view->rootContext()->setContextProperty("satelliteinfo", &satelliteinfo);
    view->rootContext()->setContextProperty("positionsensor", &position);
    view->rootContext()->setContextProperty("settings", &(Settings::instance()));
    view->setSource(SailfishApp::pathTo(qml));
    view->show();

    refreshTimer.start(100);

    result = app->exec();

    delete view;
    delete app;

    return result;
}