Esempio n. 1
0
void Client::resize() {

    clientAreaRect_.copy(this);

    if (hasFrame_) {
        ostringstream oss;
        oss << "frame resize: x=" << x() << ", y=" << y() << ", w=" <<
            width() << ", h=" << height();
        LOGDEBUG(oss.str());
        XCORE->moveResize(frameWindow(), this);

        if (frame()) {
            // maximize client window
            clientAreaRect_.setX(0);
            clientAreaRect_.setY(0);
            clientAreaRect_.setWidth(width());
            clientAreaRect_.setHeight(height());
        }
        else {
            label_->setY(borderWidth_); // label fix for toggleBorder
            fitClientArea();
        }
    }
    XCORE->moveResize(clientWindow_, &clientAreaRect_);
    sendConfiguration();
    illuminate();
}
Esempio n. 2
0
COLOR_T trace (SCENE_T scene, RAY_T ray, VP_T *int_pt, VP_T *normal) {
    double t;
    double closest_t = 1000;
    VP_T closest_int_pt;
    VP_T closest_normal;
    int closest_object = -1;
    COLOR_T color;
    int current_object;

    color.R = 0.3;
    color.G = 0.3;
    color.B = 0.5;

    for(current_object = 0; current_object < scene.num_objs; current_object++) {
        if((*scene.objs[current_object].intersect)(scene.objs[current_object], ray, int_pt, normal, &t) == 1) {
            if (t < closest_t) {
                closest_t = t;
                closest_object = current_object;
                closest_int_pt = *int_pt;
                closest_normal = *normal;
            }
        }
    }

    if(closest_object >= 0) color = illuminate (scene, ray, closest_int_pt, closest_normal, closest_object);
    return color;
}
Esempio n. 3
0
Color Renderer::raytrace(Ray const& ronny,unsigned int depth) const
{
  depth --;

  Hit hit = calculateHit(ronny);

  if (hit.impact)
      {
        Color c{1,0,0};
        float ia = 0.10;
        float ip = 0, LN = 0, RV = 0;
        Material mat{hit.shape->getmat()};
        c.r = ia * mat.ka_.r; //die abmienten
        c.g = ia * mat.ka_.g; //terme werden
        c.b = ia * mat.ka_.b; //zugewiesen
        
          for (unsigned int i = 0 ; i < scene_.sizeLight ; i++)
          {
            if(illuminate(hit, scene_.lights[i]->pos))
            {
              ip = scene_.lights[i]->intensity; //intensität des lichts
              LN = skalar(glm::normalize(scene_.lights[i]->pos - hit.point) , glm::normalize(hit.normal)); //winkel normale / blickwinkel
              RV = skalar(glm::normalize(mirror(scene_.lights[i]->pos , Ray{hit.point, hit.normal})) , glm::normalize(ronny.origin - hit.point));

              if(LN < 0) LN = 0;
              if(RV < 0) RV = 0;
              c.r += ip * (LN * mat.kd_.r + mat.ks_.r * pow(RV,mat.m_));
              c.g += ip * (LN * mat.kd_.g + mat.ks_.g * pow(RV,mat.m_));
              c.b += ip * (LN * mat.kd_.b + mat.ks_.b * pow(RV,mat.m_));
            }
          }
        return c;
      } 

}
Esempio n. 4
0
int main() {
   const int height = 2000;
   const int width = 2000;
        
   ofstream image;
   image.open("out.ppm");
   image << "P3" << '\n' << width << ' ' << height << '\n' << 255 << '\n';
        
   Point camera(0,0,0);
        
   Light lights [3] = { Light(Point(1200,0,800), Colour(255,0,0)),
                        Light(Point(1200,800,0), Colour(0,255,0)),
                        Light(Point(1200,-800,0), Colour(0,0,255)) };
        
   Colour background;

   Sphere sphere(Point(2000,0,0),700);

   Point plane_point;
   Point surface_point;
        
   //std::cout << illuminate(Point(0,0,0),Vector(2,2,2),Light(Point(4,4,4),Colour(2,2,2))).convertToString() << std::endl;
        
   //std::cout << Line(Point(0,0,0),Vector(1,0,0)).intersect(Sphere(Point(10,0,0),2)) << std::endl;
        
   Line ray;
   Vector direction;
   Colour point_colour;
   for (int z = 1000; z > -1000; z-=1) {
      for (int y = -1000; y < 1000; y+=1) {
         plane_point = Point(1000,y,z);
         direction = plane_point - camera;

         ray = Line(camera, direction);

         if (ray.intersect(sphere)) {
            surface_point = ray.point_intersect(sphere);
            point_colour = illuminate(surface_point, surface_point - sphere.center(), lights);
            point_colour = boundColour(point_colour, 0, 255);
            image << point_colour.convertToString() << ' ';
            //image << "255 255 255 ";
         } else {
            image << background.convertToString() << ' ';
         }
      }
      image << '\n';
   }

   image.close();

   return 0;
}
Esempio n. 5
0
void Client::handlePropertyNotify(XPropertyEvent *event) {

    if (event->state == PropertyDelete) {
        return; // ignore delete properties
    }

    // WM atoms
    if (event->atom == Atoms::WM_PROTOCOLS) {
        protocols_ = XCORE->protocols(clientWindow_);
        return;
    }
    else if (event->atom == Atoms::MWM_HINTS) {
        if (XCORE->hasDecoration(clientWindow_) && !frameWindow()) {
            hasDecoration_ = true;
        }
        return;
    }

    // default atoms
    static string tmp;
    ostringstream oss;
    switch (event->atom) {
    case XA_WM_ICON_NAME:
        tmp = XCORE->atomValue(clientWindow_, XA_WM_ICON_NAME);
        if (tmp.length() > 0) {
            // update only if the icon name is != 0
            iconName_ = tmp + id_;
        }
        monitor()->clientBar()->illuminate();
        monitor()->statusBar()->illuminate();
        break;
    case XA_WM_NAME:
        tmp = XCORE->atomValue(clientWindow_, XA_WM_NAME);
        if (tmp.length() > 0) {
            // update only if the title is != 0
            setName(tmp + id_);
        }
        illuminate();
        monitor()->statusBar()->illuminate();
        break;
    case XA_WM_TRANSIENT_FOR:
        updateTransient();
        break;
    case XA_WM_NORMAL_HINTS:
        updateSize();
        oss << "git size: x=" << x() << ", y=" << y() << ", w=" <<
            width() << ", h=" << height();
        LOGDEBUG(oss.str());
        break;
    }
}
Esempio n. 6
0
void BSPSector::render(void)
{
    currentSector = this;
    Engine::statistics.bspRendered++;

    illuminate( 0 );

    if( _geometry ) 
    {
        _dxCR( iDirect3DDevice->SetTransform( D3DTS_WORLD, &identity ) );
        _geometry->render();        
    }

    for( AtomicI atomicI = _atomicsInSector.begin();
                 atomicI != _atomicsInSector.end();
                 atomicI++ )
    {
        if( (*atomicI)->flags() & engine::afRender ) (*atomicI)->render();
    }
    currentSector = NULL;
}
Esempio n. 7
0
/**
 * Generate a random dungeon level
 *
 * Hack -- regenerate any "overflow" levels
 *
 * Hack -- allow auto-scumming via a gameplay option.
 *
 * Note that this function resets flow data and grid flags directly.
 * Note that this function does not reset features, monsters, or objects.  
 * Features are left to the town and dungeon generation functions, and 
 * wipe_m_list() and wipe_o_list() handle monsters and objects.
 */
void generate_cave(void)
{
	int y, x, num;

	level_hgt = DUNGEON_HGT;
	level_wid = DUNGEON_WID;
	clear_cave();

	/* The dungeon is not ready */
	character_dungeon = FALSE;

	/* Don't know feeling yet */
	do_feeling = FALSE;

	/* Assume level is not themed. */
	p_ptr->themed_level = 0;

	/* Generate */
	for (num = 0; TRUE; num++) {
		int max = 2;
		bool okay = TRUE;
		const char *why = NULL;

		/* Reset monsters and objects */
		o_max = 1;
		m_max = 1;


		/* Clear flags and flow information. */
		for (y = 0; y < DUNGEON_HGT; y++) {
			for (x = 0; x < DUNGEON_WID; x++) {
				/* No flags */
				sqinfo_wipe(cave_info[y][x]);

				/* No flow */
				cave_cost[y][x] = 0;
				cave_when[y][x] = 0;

			}
		}


		/* Mega-Hack -- no player in dungeon yet */
		cave_m_idx[p_ptr->py][p_ptr->px] = 0;
		p_ptr->px = p_ptr->py = 0;

		/* Reset the monster generation level */
		monster_level = p_ptr->depth;

		/* Reset the object generation level */
		object_level = p_ptr->depth;

		/* Nothing good here yet */
		rating = 0;

		/* Only group is the player */
		group_id = 1;

		/* Set the number of wilderness "vaults" */
		wild_vaults = 0;
		if (OPT(night_mare))
			max += 2;

		if (p_ptr->depth > 10)
			wild_vaults += randint0(max);
		if (p_ptr->depth > 20)
			wild_vaults += randint0(max);
		if (p_ptr->depth > 30)
			wild_vaults += randint0(max);
		if (p_ptr->depth > 40)
			wild_vaults += randint0(max);

		if (no_vault())
			wild_vaults = 0;

		/* Build the town */
		if (!p_ptr->depth) {
			/* Make a town */
			town_gen();
		}

		/* Not town */
		else {
			/* It is possible for levels to be themed. */
			if ((randint0(THEMED_LEVEL_CHANCE) == 0)
				&& build_themed_level()) {
				/* Message. */
				if (OPT(cheat_room))
					msg("Themed level");
			}

			/* Build a real stage */
			else {
				switch (stage_map[p_ptr->stage][STAGE_TYPE]) {
				case CAVE:
					{
						cave_gen();
						break;
					}

				case VALLEY:
					{
						valley_gen();
						break;
					}

				case MOUNTAIN:
					{
						mtn_gen();
						break;
					}

				case MOUNTAINTOP:
					{
						mtntop_gen();
						break;
					}

				case FOREST:
					{
						forest_gen();
						break;
					}

				case SWAMP:
					{
						swamp_gen();
						break;
					}

				case RIVER:
					{
						river_gen();
						break;
					}

				case DESERT:
					{
						desert_gen();
						break;
					}

				case PLAIN:
					{
						plain_gen();
					}
				}
			}
		}

		okay = TRUE;


		/* Extract the feeling */
		if (rating > 50 + p_ptr->depth)
			feeling = 2;
		else if (rating > 40 + 4 * p_ptr->depth / 5)
			feeling = 3;
		else if (rating > 30 + 3 * p_ptr->depth / 5)
			feeling = 4;
		else if (rating > 20 + 2 * p_ptr->depth / 5)
			feeling = 5;
		else if (rating > 15 + 1 * p_ptr->depth / 3)
			feeling = 6;
		else if (rating > 10 + 1 * p_ptr->depth / 5)
			feeling = 7;
		else if (rating > 5 + 1 * p_ptr->depth / 10)
			feeling = 8;
		else if (rating > 0)
			feeling = 9;
		else
			feeling = 10;

		/* Hack -- no feeling in the town */
		if (!p_ptr->depth)
			feeling = 0;


		/* Prevent object over-flow */
		if (o_max >= z_info->o_max) {
			/* Message */
			why = "too many objects";

			/* Message */
			okay = FALSE;
		}

		/* Prevent monster over-flow */
		if (m_max >= z_info->m_max) {
			/* Message */
			why = "too many monsters";

			/* Message */
			okay = FALSE;
		}

		/* Mega-Hack -- "auto-scum" */
		if (OPT(auto_scum) && (num < 100) && !(p_ptr->themed_level)) {
			int fudge = (no_vault()? 3 : 0);

			/* Require "goodness" */
			if ((feeling > fudge + 9)
				|| ((p_ptr->depth >= 5) && (feeling > fudge + 8))
				|| ((p_ptr->depth >= 10) && (feeling > fudge + 7))
				|| ((p_ptr->depth >= 20) && (feeling > fudge + 6))) {
				/* Give message to cheaters */
				if (OPT(cheat_room) || OPT(cheat_hear) || OPT(cheat_peek)
					|| OPT(cheat_xtra)) {
					/* Message */
					why = "boring level";
				}

				/* Try again */
				okay = FALSE;
			}
		}

		/* Message */
		if ((OPT(cheat_room)) && (why))
			msg("Generation restarted (%s)", why);

		/* Accept */
		if (okay)
			break;

		/* Wipe the objects */
		wipe_o_list();

		/* Wipe the monsters */
		wipe_m_list();

		/* A themed level was generated */
		if (p_ptr->themed_level) {
			/* Allow the themed level to be generated again */
			p_ptr->themed_level_appeared &=
				~(1L << (p_ptr->themed_level - 1));

			/* This is not a themed level */
			p_ptr->themed_level = 0;
		}
	}


	/* The dungeon is ready */
	character_dungeon = TRUE;

	/* Reset path_coord */
	p_ptr->path_coord = 0;

	/* Verify the panel */
	verify_panel();

	/* Apply illumination */
	illuminate();

	/* Reset the number of traps, runes, and thefts on the level. */
	num_trap_on_level = 0;
	number_of_thefts_on_level = 0;
	for (num = 0; num < RUNE_TAIL; num++)
		num_runes_on_level[num] = 0;
}
Esempio n. 8
0
void i_illuminate(pob o)
{
    if (o->known < 1) o->known = 1;
    Objects[o->id].known = 1;
    illuminate(o->blessing);
}
Esempio n. 9
0
void Client::handleButtonPress(XButtonEvent *event) {

    LOGDEBUG("entered ClientFrame::handleButtonPress");
#ifdef SLOT_SUPPORT
    if (mode_ == SLOT) {
        monitor()->slot()->focusClient(this);
        return;
    }
#endif
    if (attached() && !isFocused()) {
        attached()->focus(this);
        return;
    }
    else {
        XCORE->raise(window());
    }

    if (frame()) {
        return;
    }

    buttonState_ = NONE;

    if (event->button == Button1) {

        if (titleBarHeight_ && areButtonsVisible_ &&
                (cursor_ == Cursors::NORMAL_CURSOR))
        {
            int xPosition = event->x;
            unsigned int buttonWidth = titleBarHeight_ + 1;
            unsigned int offsetButtonGroup = width() - borderWidth_ - 3 * buttonWidth;
            if ((xPosition > (int)offsetButtonGroup) &&
                    (xPosition < (int)(width() - borderWidth_ - 1)))
            {
                xPosition -= offsetButtonGroup;
                unsigned int buttonNum = xPosition / buttonWidth;
                switch (buttonNum) {
                case 0:
                    buttonState_ = MINCLIENT;
                    break;
                case 1:
                    buttonState_ = DEMAX;
                    break;
                case 2:
                    buttonState_ = CLOSE;
                    break;
                }
                illuminate();
                return;
            }
        }

        if (monitor()->isThingMaximized()) {
            return;
        }

        Direction dir = SOUTH_EAST;
        if (cursor_ == Cursors::RESIZE_LEFT_CURSOR) {
            dir = LEFT;
        }
        else if (cursor_ == Cursors::RESIZE_RIGHT_CURSOR) {
            dir = RIGHT;
        }
        else if (cursor_ == Cursors::RESIZE_UP_CURSOR) {
            dir = UP;
        }
        else if (cursor_ == Cursors::RESIZE_DOWN_CURSOR) {
            dir = DOWN;
        }
        else if (cursor_ == Cursors::RESIZE_NORTH_WEST_CURSOR) {
            dir = NORTH_WEST;
        }
        else if (cursor_ == Cursors::RESIZE_NORTH_EAST_CURSOR) {
            dir = NORTH_EAST;
        }
        else if (cursor_ == Cursors::RESIZE_SOUTH_WEST_CURSOR) {
            dir = SOUTH_WEST;
        }
        else if (cursor_ == Cursors::RESIZE_SOUTH_EAST_CURSOR) {
            dir = SOUTH_EAST;
        }

        KERNEL->runResizeMode(this, event, dir,
                              cursor_ != Cursors::NORMAL_CURSOR);
    }
}
Esempio n. 10
0
void Client::handleConfigureRequest(XConfigureRequestEvent *event) {

    XWindowChanges wc;

    if (event->value_mask & CWStackMode) {
        if (attached()) {
            if (!isFocused()) {
                requestsFocus_ = true;
            }
            if (monitor()->focused() != attached()) {
                attached()->setRequestsFocus(true);
            }
        }
        event->value_mask &= ~CWStackMode;
    }

    event->value_mask &= ~CWSibling;
    if (!frame()
#ifdef SLOT_SUPPORT
        || (mode_ == SLOT)
#endif
       ) {

        // floating client

        gravitate(true);

        if (event->value_mask & CWX) {
            setX(event->x);
        }
        if (event->value_mask & CWY) {
            setY(event->y);
        }
        if (event->value_mask & CWWidth) {
            setWidth(event->width);
        }
        if (event->value_mask & CWHeight) {
            setHeight(event->height);
        }
        if (event->value_mask & CWBorderWidth) {
            clientBorderWidth_ = event->border_width;
        }
        ostringstream oss;
        oss << "configure request: x=" << x() << ", y=" << y()
            << ", w=" << width() << ", h=" << height();
        LOGDEBUG(oss.str());

        gravitate(false);

        // applied patch by Dr. J. Pfefferl
        if (hasFrame_) {

            if((event->value_mask & CWWidth)) {
                setWidth(width() + 2 * borderWidth_);
            }
            if((event->value_mask & CWHeight)) {
                setHeight(height() + titleBarHeight_ + 2 * borderWidth_
                        + (titleBarHeight_ ? 1 : 0));
            }
            if((event->value_mask & CWX)) {
                setX(x() - borderWidth_);
            }
            if((event->value_mask & CWY)) {
                setY(y() - titleBarHeight_ - borderWidth_);
            }

            wc.x = x();
            wc.y = y();
            wc.width = width();
            wc.height = height();
            wc.border_width = 1; // event->border_width
            wc.sibling = None;
            wc.stack_mode = event->detail;
            XCORE->configureWindow(frameWindow(), event->value_mask, &wc);
            fitClientArea();
            sendConfiguration();
        }
        else {
            // save current dimensions to client area
            clientAreaRect_.copy(this);
        }
    }

#ifdef SLOT_SUPPORT
    if (mode_ == SLOT) {
        monitor()->slot()->manage();
    }
    else
#endif // SLOT_SUPPORT
    {
        // If client is attached to a frame, the clientAreaRect_ has
        // the size of the frames client area.
        wc.x = clientAreaRect_.x();
        wc.y = clientAreaRect_.y();
        wc.width = clientAreaRect_.width();
        wc.height = clientAreaRect_.height();
        wc.border_width = 0;
        wc.sibling = None;
        event->value_mask |= CWBorderWidth;

        XCORE->configureWindow(clientWindow_, event->value_mask, &wc);

        illuminate();
    }
}
int main()
{
  global = 0;
  if ( 0 || illuminate() )
    return global;
}