/**
* @file
* @brief Functions used when Bad Things happen to the player.
**/
#include "AppHdr.h"
#include "ouch.h"
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <string>
#ifdef UNIX
#include <fcntl.h>
#include <sys/types.h>
#include <unistd.h>
#endif
#include "artefact.h"
#include "beam.h"
#include "chardump.h"
#include "colour.h"
#include "delay.h"
#include "dgn-event.h"
#include "end.h"
#include "env.h"
#include "fight.h"
#include "files.h"
#include "fineff.h"
#include "god-abil.h"
#include "god-passive.h"
#include "hints.h"
#include "hiscores.h"
#include "invent.h"
#include "item-prop.h"
#include "libutil.h"
#include "message.h"
#include "mgen-data.h"
#include "mon-death.h"
#include "mon-place.h"
#include "mon-util.h"
#include "mutation.h"
#include "nearby-danger.h"
#include "notes.h"
#include "options.h"
#include "output.h"
#include "player.h"
#include "player-stats.h"
#include "potion.h"
#include "prompt.h"
#include "random.h"
#include "religion.h"
#include "shopping.h"
#include "shout.h"
#include "spl-clouds.h"
#include "spl-selfench.h"
#include "state.h"
#include "stringutil.h"
#include "teleport.h"
#include "transform.h"
#include "tutorial.h"
#include "view.h"
#include "xom.h"
void maybe_melt_player_enchantments(beam_type flavour, int damage)
{
if (flavour == BEAM_FIRE || flavour == BEAM_LAVA
|| flavour == BEAM_STICKY_FLAME || flavour == BEAM_STEAM)
{
if (you.has_mutation(MUT_ICEMAIL))
{
if (!you.duration[DUR_ICEMAIL_DEPLETED])
mprf(MSGCH_DURATION, "Your icy envelope dissipates!");
you.duration[DUR_ICEMAIL_DEPLETED] = ICEMAIL_TIME;
you.redraw_armour_class = true;
}
if (you.duration[DUR_ICY_ARMOUR] > 0)
{
you.duration[DUR_ICY_ARMOUR] -= damage * BASELINE_DELAY;
if (you.duration[DUR_ICY_ARMOUR] <= 0)
remove_ice_armour();
else
you.props[MELT_ARMOUR_KEY] = true;
}
}
}
int check_your_resists(int hurted, beam_type flavour, string source,
bolt *beam, bool doEffects)
{
int original = hurted;
dprf("checking resistance: flavour=%d", flavour);
string kaux = "";
if (beam)
{
source = beam->get_source_name();
kaux = beam->name;
}
if (doEffects)
maybe_melt_player_enchantments(flavour, hurted);
switch (flavour)
{
case BEAM_WATER:
hurted = resist_adjust_damage(&you, flavour, hurted);
if (!hurted && doEffects)
mpr("You shrug off the wave.");
break;
case BEAM_STEAM:
hurted = resist_adjust_damage(&you, flavour, hurted);
if (hurted < original && doEffects)
canned_msg(MSG_YOU_RESIST);
else if (hurted > original && doEffects)
{
mpr("The steam scalds you terribly!");
xom_is_stimulated(200);
}
break;
case BEAM_FIRE:
hurted = resist_adjust_damage(&you, flavour, hurted);
if (hurted < original && doEffects)
canned_msg(MSG_YOU_RESIST);
else if (hurted > original && doEffects)
{
mpr("The fire burns you terribly!");
xom_is_stimulated(200);
}
break;
case BEAM_DAMNATION:
break; // sucks to be you (:
case BEAM_COLD:
hurted = resist_adjust_damage(&you, flavour, hurted);
if (hurted < original && doEffects)
canned_msg(MSG_YOU_RESIST);
else if (hurted > original && doEffects)
{
mpr("You feel a terrible chill!");
xom_is_stimulated(200);
}
break;
case BEAM_ELECTRICITY:
hurted = resist_adjust_damage(&you, flavour, hurted);
if (hurted < original && doEffects)
canned_msg(MSG_YOU_RESIST);
break;
case BEAM_POISON:
hurted = resist_adjust_damage(&you, flavour, hurted);
if (doEffects)
{
// Ensure that we received a valid beam object before proceeding.
// See also melee-attack.cc:_print_resist_messages() which cannot be
// used with this beam type (as it does not provide a valid beam).
ASSERT(beam);
int pois = div_rand_round(beam->damage.num * beam->damage.size, 3);
pois = 3 + random_range(pois * 2 / 3, pois * 4 / 3);
poison_player(pois, source, kaux);
if (player_res_poison() > 0)
canned_msg(MSG_YOU_RESIST);
}
break;
case BEAM_POISON_ARROW:
if (doEffects)
{
// Ensure that we received a valid beam object before proceeding.
// See also melee-attack.cc:_print_resist_messages() which cannot be
// used with this beam type (as it does not provide a valid beam).
ASSERT(beam);
int pois = div_rand_round(beam->damage.num * beam->damage.size, 3);
pois = 3 + random_range(pois * 2 / 3, pois * 4 / 3);
const int resist = player_res_poison();
poison_player((resist ? pois / 2 : pois), source, kaux, true);
}
hurted = resist_adjust_damage(&you, flavour, hurted);
if (hurted < original && doEffects)
canned_msg(MSG_YOU_PARTIALLY_RESIST);
break;
case BEAM_NEG:
hurted = resist_adjust_damage(&you, flavour, hurted);
if (doEffects)
{
// drain_player handles the messaging here
drain_player(min(75, 35 + original * 2 / 3), true);
}
break;
case BEAM_ICE:
hurted = resist_adjust_damage(&you, flavour, hurted);
if (hurted < original && doEffects)
canned_msg(MSG_YOU_PARTIALLY_RESIST);
else if (hurted > original && doEffects)
{
mpr("You feel a painful chill!");
xom_is_stimulated(200);
}
break;
case BEAM_LAVA:
hurted = resist_adjust_damage(&you, flavour, hurted);
if (hurted < original && doEffects)
canned_msg(MSG_YOU_PARTIALLY_RESIST);
else if (hurted > original && doEffects)
{
mpr("The lava burns you terribly!");
xom_is_stimulated(200);
}
break;
case BEAM_ACID:
hurted = resist_adjust_damage(&you, flavour, hurted);
if (hurted < original && doEffects)
canned_msg(MSG_YOU_RESIST);
break;
case BEAM_MIASMA:
if (you.res_rotting())
{
if (doEffects)
canned_msg(MSG_YOU_RESIST);
hurted = 0;
}
break;
case BEAM_HOLY:
{
hurted = resist_adjust_damage(&you, flavour, hurted);
if (hurted < original && doEffects)
canned_msg(MSG_YOU_RESIST);
else if (hurted > original && doEffects)
{
mpr("You writhe in agony!");
xom_is_stimulated(200);
}
break;
}
case BEAM_AIR:
{
// Airstrike.
if (you.airborne())
hurted += hurted / 2;
break;
}
default:
break;
} // end switch
return hurted;
}
/**
* Handle side-effects for exposure to element other than damage.
* Historically this handled item destruction, and melting meltable enchantments. Now it takes care of 3 things:
* - triggering qazlal's elemental adaptations
* - slowing cold-blooded players (draconians, hydra form)
* - putting out fires
* This function should be called exactly once any time a player is exposed to the
* following elements/beam types: cold, fire, elec, water, steam, lava, BEAM_FRAG. For the sake of Qazlal's
* elemental adaptation, it should also be called (exactly once) with BEAM_MISSILE when
* receiving physical damage. Hybrid damage (brands) should call it twice with appropriate
* flavours.
*
* @param flavour The beam type.
* @param strength The strength of the attack. Used in different ways for different side-effects.
* For qazlal_elemental_adapt: (i) it is used for the probability of triggering, and (ii) the resulting length of the effect.
* @param slow_cold_blooded If True, the beam_type is BEAM_COLD, and the player
* is cold-blooded and not cold-resistant, slow the
* player 50% of the time.
*/
void expose_player_to_element(beam_type flavour, int strength, bool slow_cold_blooded)
{
dprf("expose_player_to_element, strength %i, flavor %i, slow_cold_blooded is %i", strength, flavour, slow_cold_blooded);
qazlal_element_adapt(flavour, strength);
if (flavour == BEAM_COLD && slow_cold_blooded
&& you.get_mutation_level(MUT_COLD_BLOODED)
&& you.res_cold() <= 0 && coinflip())
{
you.slow_down(0, strength);
}
if (flavour == BEAM_WATER && you.duration[DUR_LIQUID_FLAMES])
{
mprf(MSGCH_WARN, "The flames go out!");
you.duration[DUR_LIQUID_FLAMES] = 0;
you.props.erase("sticky_flame_source");
you.props.erase("sticky_flame_aux");
}
}
static void _lose_level_abilities()
{
if (you.attribute[ATTR_PERM_FLIGHT]
&& !you.racial_permanent_flight()
&& !you.wearing_ego(EQ_ALL_ARMOUR, SPARM_FLYING))
{
you.increase_duration(DUR_FLIGHT, 50, 100);
you.attribute[ATTR_PERM_FLIGHT] = 0;
mprf(MSGCH_WARN, "You feel your flight won't last long.");
}
}
void lose_level()
{
// Because you.experience is unsigned long, if it's going to be
// negative, must die straightaway.
if (you.experience_level == 1)
{
ouch(INSTANT_DEATH, KILLED_BY_DRAINING);
// Return in case death was cancelled via wizard mode
return;
}
you.experience_level--;
mprf(MSGCH_WARN,
"You are now level %d!", you.experience_level);
calc_hp();
calc_mp();
_lose_level_abilities();
char buf[200];
sprintf(buf, "HP: %d/%d MP: %d/%d",
you.hp, you.hp_max, you.magic_points, you.max_magic_points);
take_note(Note(NOTE_XP_LEVEL_CHANGE, you.experience_level, 0, buf));
you.redraw_title = true;
you.redraw_experience = true;
#ifdef USE_TILE_LOCAL
// In case of intrinsic ability changes.
tiles.layout_statcol();
redraw_screen();
#endif
xom_is_stimulated(200);
// Kill the player if maxhp <= 0. We can't just move the ouch() call past
// dec_max_hp() since it would decrease hp twice, so here's another one.
ouch(0, KILLED_BY_DRAINING);
}
/**
* Drain the player.
*
* @param power The amount by which to drain the player.
* @param announce_full Whether to print messages even when fully resisting
* the drain.
* @param ignore_protection Whether to ignore the player's rN.
* @return Whether draining occurred.
*/
bool drain_player(int power, bool announce_full, bool ignore_protection)
{
if (crawl_state.disables[DIS_AFFLICTIONS])
return false;
const int protection = ignore_protection ? 0 : player_prot_life();
if (protection == 3)
{
if (announce_full)
canned_msg(MSG_YOU_RESIST);
return false;
}
if (protection > 0)
{
canned_msg(MSG_YOU_PARTIALLY_RESIST);
power /= (protection * 2);
}
if (power > 0)
{
mpr("You feel drained.");
xom_is_stimulated(15);
you.attribute[ATTR_XP_DRAIN] += power;
// Losing skills may affect AC/EV.
you.redraw_armour_class = true;
you.redraw_evasion = true;
dprf("Drained by %d points (%d total)", power, you.attribute[ATTR_XP_DRAIN]);
return true;
}
return false;
}
static void _xom_checks_damage(kill_method_type death_type,
int dam, mid_t death_source)
{
if (you_worship(GOD_XOM))
{
if (death_type == KILLED_BY_TARGETING
|| death_type == KILLED_BY_BOUNCE
|| death_type == KILLED_BY_REFLECTION
|| death_type == KILLED_BY_SELF_AIMED
&& player_in_a_dangerous_place())
{
// Xom thinks the player accidentally hurting him/herself is funny.
// Deliberate damage is only amusing if it's dangerous.
int amusement = 200 * dam / (dam + you.hp);
if (death_type == KILLED_BY_SELF_AIMED)
amusement /= 5;
xom_is_stimulated(amusement);
return;
}
else if (death_type == KILLED_BY_FALLING_DOWN_STAIRS
|| death_type == KILLED_BY_FALLING_THROUGH_GATE)
{
// Xom thinks falling down the stairs is hilarious.
xom_is_stimulated(200);
return;
}
else if (death_type == KILLED_BY_DISINT)
{
// flying chunks...
xom_is_stimulated(100);
return;
}
else if (death_type != KILLED_BY_MONSTER
&& death_type != KILLED_BY_BEAM
&& death_type != KILLED_BY_DISINT
|| !monster_by_mid(death_source))
{
return;
}
int amusementvalue = 1;
const monster* mons = monster_by_mid(death_source);
if (!mons->alive())
return;
if (mons->wont_attack())
{
// Xom thinks collateral damage is funny.
xom_is_stimulated(200 * dam / (dam + you.hp));
return;
}
int leveldif = mons->get_experience_level() - you.experience_level;
if (leveldif == 0)
leveldif = 1;
// Note that Xom is amused when you are significantly hurt by a
// creature of higher level than yourself, as well as by a
// creature of lower level than yourself.
amusementvalue += leveldif * leveldif * dam;
if (!mons->visible_to(&you))
amusementvalue += 8;
if (mons->speed < 100/player_movement_speed())
amusementvalue += 7;
if (player_in_a_dangerous_place())
amusementvalue += 2;
amusementvalue /= (you.hp > 0) ? you.hp : 1;
xom_is_stimulated(amusementvalue);
}
}
static void _yred_mirrors_injury(int dam, mid_t death_source)
{
if (yred_injury_mirror())
{
// Cap damage to what was enough to kill you. Can matter if
// Yred saves your life or you have an extra kitty.
if (you.hp < 0)
dam += you.hp;
monster* mons = monster_by_mid(death_source);
if (dam <= 0 || !mons)
return;
mirror_damage_fineff::schedule(mons, &you, dam);
}
}
static void _maybe_ru_retribution(int dam, mid_t death_source)
{
if (will_ru_retaliate())
{
// Cap damage to what was enough to kill you. Can matter if
// you have an extra kitty.
if (you.hp < 0)
dam += you.hp;
monster* mons = monster_by_mid(death_source);
if (dam <= 0 || !mons)
return;
ru_retribution_fineff::schedule(mons, &you, dam);
}
}
static void _maybe_spawn_monsters(int dam, kill_method_type death_type,
mid_t death_source)
{
monster* damager = monster_by_mid(death_source);
// We need to exclude acid damage and similar things or this function
// will crash later.
if (!damager)
return;
monster_type mon;
int how_many = 0;
if (have_passive(passive_t::spawn_slimes_on_hit))
{
mon = royal_jelly_ejectable_monster();
if (dam >= you.hp_max * 3 / 4)
how_many = random2(4) + 2;
else if (dam >= you.hp_max / 2)
how_many = random2(2) + 2;
else if (dam >= you.hp_max / 4)
how_many = 1;
}
else if (you_worship(GOD_XOM)
&& dam >= you.hp_max / 4
&& x_chance_in_y(dam, 3 * you.hp_max))
{
mon = MONS_BUTTERFLY;
how_many = 2 + random2(5);
}
if (how_many > 0)
{
int count_created = 0;
for (int i = 0; i < how_many; ++i)
{
mgen_data mg(mon, BEH_FRIENDLY, you.pos(), damager->mindex());
mg.set_summoned(&you, 2, 0, you.religion);
if (create_monster(mg))
count_created++;
}
if (count_created > 0)
{
if (mon == MONS_BUTTERFLY)
{
mprf(MSGCH_GOD, "A shower of butterflies erupts from you!");
take_note(Note(NOTE_XOM_EFFECT, you.piety, -1, "butterfly on damage"), true);
}
else
{
mprf("You shudder from the %s and a %s!",
death_type == KILLED_BY_MONSTER ? "blow" : "blast",
count_created > 1 ? "flood of jellies pours out from you"
: "jelly pops out");
}
}
}
}
static void _powered_by_pain(int dam)
{
const int level = you.get_mutation_level(MUT_POWERED_BY_PAIN);
if (level > 0
&& (random2(dam) > 4 + div_rand_round(you.experience_level, 4)
|| dam >= you.hp_max / 2))
{
switch (random2(4))
{
case 0:
case 1:
{
if (you.magic_points < you.max_magic_points)
{
mpr("You focus on the pain.");
int mp = roll_dice(3, 2 + 3 * level);
canned_msg(MSG_GAIN_MAGIC);
inc_mp(mp);
break;
}
break;
}
case 2:
mpr("You focus on the pain.");
potionlike_effect(POT_MIGHT, level * 20);
break;
case 3:
mpr("You focus on the pain.");
you.be_agile(level * 20);
break;
}
}
}
static void _maybe_fog(int dam)
{
const int minpiety = have_passive(passive_t::hit_smoke)
? piety_breakpoint(rank_for_passive(passive_t::hit_smoke) - 1)
: piety_breakpoint(2); // Xom
const int upper_threshold = you.hp_max / 2;
const int lower_threshold = upper_threshold
- upper_threshold
* (you.piety - minpiety)
/ (MAX_PIETY - minpiety);
if (have_passive(passive_t::hit_smoke)
&& (dam > 0 && you.form == transformation::shadow
|| dam >= lower_threshold
&& x_chance_in_y(dam - lower_threshold,
upper_threshold - lower_threshold)))
{
mpr("You emit a cloud of dark smoke.");
big_cloud(CLOUD_BLACK_SMOKE, &you, you.pos(), 50, 4 + random2(5));
}
else if (you_worship(GOD_XOM) && x_chance_in_y(dam, 30 * upper_threshold))
{
mprf(MSGCH_GOD, "You emit a cloud of colourful smoke!");
big_cloud(CLOUD_XOM_TRAIL, &you, you.pos(), 50, 4 + random2(5), -1);
take_note(Note(NOTE_XOM_EFFECT, you.piety, -1, "smoke on damage"), true);
}
}
static void _deteriorate(int dam)
{
if (x_chance_in_y(you.get_mutation_level(MUT_DETERIORATION), 4)
&& dam > you.hp_max / 10)
{
mprf(MSGCH_WARN, "Your body deteriorates!");
lose_stat(STAT_RANDOM, 1);
}
}
/**
* Maybe corrode the player after taking damage if they're wearing *Corrode.
**/
static void _maybe_corrode()
{
int corrosion_sources = you.scan_artefacts(ARTP_CORRODE);
int degree = binomial(corrosion_sources, 3);
if (degree > 0)
you.corrode_equipment("Your corrosive artefact", degree);
}
/**
* Maybe slow the player after taking damage if they're wearing *Slow.
**/
static void _maybe_slow()
{
int slow_sources = you.scan_artefacts(ARTP_SLOW);
if (x_chance_in_y(slow_sources, 100))
slow_player(10 + random2(5));
}
static void _place_player_corpse(bool explode)
{
if (!in_bounds(you.pos()))
return;
monster dummy;
dummy.type = player_mons(false);
define_monster(dummy); // assumes player_mons is not a zombie
dummy.position = you.pos();
dummy.props["always_corpse"] = true;
dummy.mname = you.your_name;
dummy.set_hit_dice(you.experience_level);
if (explode)
dummy.flags &= MF_EXPLODE_KILL;
if (you.form != transformation::none)
mpr("Your shape twists and changes as you die.");
place_monster_corpse(dummy, false);
}
#if defined(WIZARD) || defined(DEBUG)
static void _wizard_restore_life()
{
if (you.hp_max <= 0)
unrot_hp(9999);
while (you.hp_max <= 0)
you.hp_max_adj_perm++, calc_hp();
if (you.hp <= 0)
set_hp(you.hp_max);
}
#endif
static int _apply_extra_harm(int dam, mid_t source)
{
monster* damager = monster_by_mid(source);
// Don't check for monster amulet if there source isn't a monster
if (damager && damager->extra_harm())
return dam * 13 / 10; // +30% damage when the opponent has harm
else if (you.extra_harm())
return dam * 6 / 5; // +20% damage when you have harm
return dam;
}
void reset_damage_counters()
{
you.turn_damage = 0;
you.damage_source = NON_MONSTER;
you.source_damage = 0;
}
bool can_shave_damage()
{
return you.species == SP_DEEP_DWARF;
}
int do_shave_damage(int dam)
{
if (!can_shave_damage())
return dam;
// Deep Dwarves get to shave any hp loss.
int shave = 1 + random2(2 + random2(1 + you.experience_level / 3));
dprf("HP shaved: %d.", shave);
dam -= shave;
return dam;
}
// Determine what's threatening for purposes of sacrifice drink and reading.
// the statuses are guaranteed not to happen if the incoming damage is less
// than 4% max hp. Otherwise, they scale up with damage taken and with lower
// health, becoming certain at 20% max health damage or <30% max health
// current hp.
static bool _is_damage_threatening (int damage_fraction_of_hp)
{
int hp_fraction = you.hp * 100 / you.hp_max;
return damage_fraction_of_hp > 5
&& hp_fraction <= 85
&& (damage_fraction_of_hp + random2(20) >= 20
|| random2(100) < hp_fraction);
}
/** Hurt the player. Isn't it fun?
*
* @param dam How much damage -- may be INSTANT_DEATH.
* @param death_type how did you get hurt?
* @param source who could do such a thing?
* @param aux what did they do it with?
* @param see_source whether the attacker was visible to you
* @param death_source_name the attacker's name if it is already dead.
*/
void ouch(int dam, kill_method_type death_type, mid_t source, const char *aux,
bool see_source, const char *death_source_name)
{
ASSERT(!crawl_state.game_is_arena());
if (you.duration[DUR_TIME_STEP])
return;
if (you.pending_revival)
return;
int drain_amount = 0;
// Multiply damage if amulet of harm is in play
if (dam != INSTANT_DEATH)
dam = _apply_extra_harm(dam, source);
if (can_shave_damage() && dam != INSTANT_DEATH
&& death_type != KILLED_BY_POISON)
{
dam = max(0, do_shave_damage(dam));
}
if (dam != INSTANT_DEATH)
{
if (you.form == transformation::shadow)
{
drain_amount = (dam - (dam / 2));
dam /= 2;
}
if (you.petrified())
dam /= 2;
else if (you.petrifying())
dam = dam * 10 / 15;
}
ait_hp_loss hpl(dam, death_type);
interrupt_activity(activity_interrupt::hp_loss, &hpl);
// Don't wake the player with fatal or poison damage.
if (dam > 0 && dam < you.hp && death_type != KILLED_BY_POISON)
you.check_awaken(500);
const bool non_death = death_type == KILLED_BY_QUITTING
|| death_type == KILLED_BY_WINNING
|| death_type == KILLED_BY_LEAVING;
// certain effects (e.g. drowned souls) use KILLED_BY_WATER for flavour
// reasons (morgue messages?), with regrettable consequences if we don't
// double-check.
const bool env_death = source == MID_NOBODY
&& (death_type == KILLED_BY_LAVA
|| death_type == KILLED_BY_WATER);
// death's door protects against everything but falling into water/lava,
// excessive rot, leaving the dungeon, or quitting.
if (you.duration[DUR_DEATHS_DOOR] && !env_death && !non_death
&& you.hp_max > 0)
{
return;
}
if (dam > 0 && death_type != KILLED_BY_POISON)
{
int damage_fraction_of_hp = dam * 100 / you.hp_max;
// Check _is_damage_threatening separately for read and drink so they
// don't always trigger in unison when you have both.
if (you.get_mutation_level(MUT_NO_READ))
{
if (_is_damage_threatening(damage_fraction_of_hp))
{
if (!you.duration[DUR_NO_SCROLLS])
mpr("You feel threatened and lose the ability to read scrolls!");
you.increase_duration(DUR_NO_SCROLLS, 1 + random2(dam), 30);
}
}
if (you.get_mutation_level(MUT_NO_DRINK))
{
if (_is_damage_threatening(damage_fraction_of_hp))
{
if (!you.duration[DUR_NO_POTIONS])
mpr("You feel threatened and lose the ability to drink potions!");
you.increase_duration(DUR_NO_POTIONS, 1 + random2(dam), 30);
}
}
}
if (dam != INSTANT_DEATH)
{
if (you.spirit_shield() && death_type != KILLED_BY_POISON
&& !(aux && strstr(aux, "flay_damage")))
{
// round off fairly (important for taking 1 damage at a time)
int mp = div_rand_round(dam * you.magic_points,
max(you.hp + you.magic_points, 1));
// but don't kill the player with round-off errors
mp = max(mp, dam + 1 - you.hp);
mp = min(mp, you.magic_points);
dam -= mp;
dec_mp(mp);
// Wake players who took fatal damage exactly equal to current HP,
// but had it reduced below fatal threshhold by spirit shield.
if (dam < you.hp)
you.check_awaken(500);
if (dam <= 0 && you.hp > 0)
return;
}
if (dam >= you.hp && you.hp_max > 0 && god_protects_from_harm())
{
simple_god_message(" protects you from harm!");
// Ensure divine intervention wakes sleeping players. Necessary
// because we otherwise don't wake players who take fatal damage.
you.check_awaken(500);
return;
}
you.turn_damage += dam;
if (you.damage_source != source)
{
you.damage_source = source;
you.source_damage = 0;
}
you.source_damage += dam;
dec_hp(dam, true);
// Even if we have low HP messages off, we'll still give a
// big hit warning (in this case, a hit for half our HPs) -- bwr
if (dam > 0 && you.hp_max <= dam * 2)
mprf(MSGCH_DANGER, "Ouch! That really hurt!");
if (you.hp > 0 && dam > 0)
{
if (Options.hp_warning
&& you.hp <= (you.hp_max * Options.hp_warning) / 100
&& (death_type != KILLED_BY_POISON || poison_is_lethal()))
{
flash_view_delay(UA_HP, RED, 50);
mprf(MSGCH_DANGER, "* * * LOW HITPOINT WARNING * * *");
dungeon_events.fire_event(DET_HP_WARNING);
}
hints_healing_check();
_xom_checks_damage(death_type, dam, source);
// for note taking
string damage_desc;
if (!see_source)
damage_desc = make_stringf("something (%d)", dam);
else
{
damage_desc = scorefile_entry(dam, source,
death_type, aux, true)
.death_description(scorefile_entry::DDV_TERSE);
}
take_note(Note(NOTE_HP_CHANGE, you.hp, you.hp_max,
damage_desc.c_str()));
_deteriorate(dam);
_yred_mirrors_injury(dam, source);
_maybe_ru_retribution(dam, source);
_maybe_spawn_monsters(dam, death_type, source);
_maybe_fog(dam);
_powered_by_pain(dam);
if (sanguine_armour_valid())
activate_sanguine_armour();
if (death_type != KILLED_BY_POISON)
{
_maybe_corrode();
_maybe_slow();
}
if (drain_amount > 0)
drain_player(drain_amount, true, true);
}
if (you.hp > 0)
return;
}
// Is the player being killed by a direct act of Xom?
if (crawl_state.is_god_acting()
&& crawl_state.which_god_acting() == GOD_XOM
&& crawl_state.other_gods_acting().empty())
{
you.escaped_death_cause = death_type;
you.escaped_death_aux = aux == nullptr ? "" : aux;
// Xom should only kill his worshippers if they're under penance
// or Xom is bored.
if (you_worship(GOD_XOM) && !you.penance[GOD_XOM]
&& you.gift_timeout > 0)
{
return;
}
// Also don't kill wizards testing Xom acts.
if ((crawl_state.repeat_cmd == CMD_WIZARD
|| crawl_state.prev_cmd == CMD_WIZARD)
&& !you_worship(GOD_XOM))
{
return;
}
// Okay, you *didn't* escape death.
you.reset_escaped_death();
// Ensure some minimal information about Xom's involvement.
if (aux == nullptr || !*aux)
{
if (death_type != KILLED_BY_XOM)
aux = "Xom";
}
else if (strstr(aux, "Xom") == nullptr)
death_type = KILLED_BY_XOM;
}
// Xom may still try to save your life.
else if (xom_saves_your_life(death_type))
return;
#if defined(WIZARD) || defined(DEBUG)
if (!non_death && crawl_state.disables[DIS_DEATH])
{
_wizard_restore_life();
return;
}
#endif
crawl_state.cancel_cmd_all();
// Construct scorefile entry.
scorefile_entry se(dam, source, death_type, aux, false,
death_source_name);
#ifdef WIZARD
if (!non_death)
{
if (crawl_state.test || you.wizard || you.suppress_wizard || (you.explore && !you.lives))
{
const string death_desc
= se.death_description(scorefile_entry::DDV_VERBOSE);
dprf("Damage: %d; Hit points: %d", dam, you.hp);
if (crawl_state.test || !yesno("Die?", false, 'n'))
{
mpr("Thought so.");
take_note(Note(NOTE_DEATH, you.hp, you.hp_max,
death_desc.c_str()), true);
_wizard_restore_life();
return;
}
}
}
#endif // WIZARD
if (crawl_state.game_is_tutorial())
{
crawl_state.need_save = false;
if (!non_death)
tutorial_death_message();
screen_end_game("");
}
// Okay, so you're dead.
take_note(Note(NOTE_DEATH, you.hp, you.hp_max,
se.death_description(scorefile_entry::DDV_NORMAL).c_str()),
true);
if (you.lives && !non_death)
{
mark_milestone("death", lowercase_first(se.long_kill_message()).c_str());
you.deaths++;
you.lives--;
you.pending_revival = true;
stop_delay(true);
// You wouldn't want to lose this accomplishment to a crash, would you?
// Especially if you manage to trigger one via lua somehow...
if (!crawl_state.disables[DIS_SAVE_CHECKPOINTS])
save_game(false);
canned_msg(MSG_YOU_DIE);
xom_death_message((kill_method_type) se.get_death_type());
more();
_place_player_corpse(death_type == KILLED_BY_DISINT);
return;
}
// Prevent bogus notes.
activate_notes(false);
end_game(se);
}
string morgue_name(string char_name, time_t when_crawl_got_even)
{
string name = "morgue-" + char_name;
string time = make_file_time(when_crawl_got_even);
if (!time.empty())
name += "-" + time;
return name;
}
int actor_to_death_source(const actor* agent)
{
return agent ? agent->mindex() : NON_MONSTER;
}
int timescale_damage(const actor *act, int damage)
{
if (damage < 0)
damage = 0;
// Can we have a uniform player/monster speed system yet?
if (act->is_player())
return div_rand_round(damage * you.time_taken, BASELINE_DELAY);
else
{
const monster *mons = act->as_monster();
const int speed = mons->speed > 0? mons->speed : BASELINE_DELAY;
return div_rand_round(damage * BASELINE_DELAY, speed);
}
}
↑ V1037 Two or more case-branches perform the same actions. Check lines: 155, 234
↑ V648 Priority of the '&&' operation is higher than that of the '||' operation.
↑ V560 A part of conditional expression is always true: death_type != KILLED_BY_DISINT.


Namespace BonEngineSharp
Classes
BonEngine
Main entry point class.
This is the equivilent of the 'bon' root namespace, and provide the main method to start the engine (Start) and the _Engine getter.
Engine
The main engine class. This object manages all the managers and runs the main loop. Normally you don't need to access it directly.
Scene
A BonEngine scene. This is the main class you use to implement your game logic, by overriding its protected key methods: Load, Unload, Start, Update, FixedUpdate and Draw. These methods are invoked by the Engine while running its main loop.
You can also use multiple scenes to implement different 'screens' or level types in your game (for example a scene for main menu and a scene for actual game).


John Doe
Add new Section
Achievements
Awards
Co-Curricular Activities
Experience
Interests
Projects
Download
Education
-
Skills


{% if info %}
{% for inf in info %}
{{inf}}
{% endfor %}
{% endif %}
Grade Calculator
Input the marks received on any assignment and how much the assigment was worth in the overall scheme.
To add another entry click the "Add" button.
To remove an entry click the "Remove" button. Note: The remove button will remove the bottom most entry.
Marks can be in percentage form or can be in fraction form.
Percentage of grade can only be in percentage form. Note: Please do not add the percentage sign.
When all entries are input press "ENTER" or click "Submit" to calculate.
Any entries with no mark or no percentage or any entries with values other than the ones listed above will not be calculated.


Contains the writers and readers used by EmotionML to write elements to streams and read elements from streams.


Getting Started¶
Welcome to my library! [CIT2019-BARRACHINA-CODE]
Ideology
The idea of this library is just to implement Complex layers (ComplexLayer
) so that everything else stays the same as any Tensorflow code.
The only difference with a Tensorflow code is that you should use cvnn.layers
module instead of tf.keras.layers
.
Although tf.activation
and tf.initializers
could be used, it is HIGHLY recommended (and some times compulsory) to use the cvnn
module options.
Warning
For a reason I ignore, TensorFlow casts the input automatically to floating. To avoid this, always create first a ComplexInput
layer in all your models.
If you are here is because you want to train a Complex-Valued Neural Network (CVNN). However, your situation may vary, this will help you find your use case and guide you how to use the library. The recommended way to go would be 1.2. as the other may easily be done from that.
You already have a complex dataset you want to use
1.1. You want to train a Complex Valued Model as you will do with Keras
- 1.2. You want to compare different models and do statistics with it’s results
You want to feed each model to compare Monte Carlo.
You want a RVNN equivalent to be created automatically and compare it with the feeded CVNN Real Vs Complex.
2. You don’t have a specific dataset, you just want to play with this library
Real-valued case
Although this library is intended to work with complex data type, it also supports real dtype by just using the dtype
parameter in each ComplexLayer
constructor.
All cvnn
activation functions and initializers already work Ok for real and complex inputs, so nothing should change.
This allows me to debug the code (comparing it’s result with keras on real data) but also to easily implement a comparison between a complex and a real network minimizing the error.
You have some examples of this as for example MNIST.
Note
Please, remember to cite me accordingly [CIT2019-BARRACHINA-CODE]


1st - The Virtual Machine
First I created a virtual machine for use with VMware Fusion on OS-X. Once I got a nice clean Ubuntu 14.04 image setup I installed SSH on it so I could manage it as if it were a headless (i.e. no monitor attached) machine (instructions).In addition to installing openssh, these steps also include build-essential, make, and gcc along with instructions for, but don’t worry about installing VMware Tools. The instructions are cumbersome and in parts just wrong, so skip that. The virtual machine is up and running with ssh and a good C compiler at this point, so we’re all set.
2nd - The LAMP Stack
sudo apt-get install apache2
Once installed the default page will be available on the server, so navigate over to 192.168.x.x and view the page to insure it is up and running.
Next install mysql and php5 mysql.
sudo apt-get install mysql-server php5-mysql
During this installation you will be prompted for the mysql root account password. It is advisable to set one.
Then you will be asked to enter the password (the one you just set about 2 seconds ago) for the MySQL root account. Next, it will ask you if you want to change that password. Select ‘n’ so as not to create another password for the root acount since you’ve already created the password just a few seconds before.
For the rest of the questions, you should simply hit the enter key for each prompt. This will accept the default values. This will remove some sample users and databases, disable remote root logins, and load these new rules so that MySQL immediately respects the changes we have made.
Next up is to install PHP. No grumbling, just install PHP.
sudo apt-get install php5 libapache2-mod-php5 php5-mcrypt
Next let’s open up dir.conf and change a small section to change what files apache will provide upon request. Here’s what the edit should look like.
Open up the file to edit. (in vi, to insert or edit, hit the ‘i’ button. To save hit escape and ‘:w’ and to exit vi after saving it escape and then ‘:q’. To force exit without saving hit escape and ‘:q!’)
sudo vi /etc/apache2/mods-enabled/dir.conf
This is what the file will likely look like once opened.
<IfModule mod_dir.c>
DirectoryIndex index.html index.cgi index.pl index.php index.xhtml index.htm
</IfModule>
Move the index.php file to the beginning of the DirectoryIndex list.
<IfModule mod_dir.c>
DirectoryIndex index.php index.html index.cgi index.pl index.xhtml index.htm
</IfModule>
Now restart apache so the changes will take effect.
sudo service apache2 restart
Next let’s setup some public key for authentication. On your local box complete the following.
ssh-keygen
If you don’t enter a passphrase, you will be able to use the private key for auth without entering a passphrase. If you’ve entered one, you’ll need it and the private key to log in. Securing your keys with passphrases is more secure, but either way the system is more secure this way then with basic password authentication. For this particular situation, I’m skipping the passphrase.
What is generated is id_rsa, the private key and the id_rsa.pub the public key. They’re put in a directory called .ssh of the local user.
At this point copy the public key to the remote server. On OS-X grab the easy to use ssh-copy-id script with this command.
brew install ssh-copy-id
or
curl -L https://raw.githubusercontent.com/beautifulcode/ssh-copy-id-for-OSX/master/install.sh | sh
Then use the script to copy the ssh key to the server.
ssh-copy-id<EMAIL_ADDRESS>Next let’s setup some public key for authentication. On your local box complete the following.
ssh-keygen
That should give you the ability to log into the machine without a password everytime. Give it a try.
Ok, so now on to the meat of this entry, Nagios itself.
Nagios Installation
Create a user and group that will be used to run the Nagios process.sudo useradd nagios
sudo groupadd nagcmd
sudo usermod -a -G nagcmd nagios
Install these other essentials.
sudo apt-get install libgd2-xpm-dev openssl libssl-dev xinetd apache2-utils unzip
Download the source and extract it, then change into the directory.
curl -L -O https://assets.nagios.com/downloads/nagioscore/releases/nagios-4.1.1.tar.gz
tar xvf nagios-*.tar.gz
cd nagios-*
Next run the command to configure Nagios with the appropriate user and group.
./configure --with-nagios-group=nagios --with-command-group=nagcmd
When the configuration is done you’ll see a display like this.
Creating sample config files in sample-config/ ...
*** Configuration summary for nagios 4.1.1 08-19-2015 ***:
General Options:
-------------------------
Nagios executable: nagios
Nagios user/group: nagios,nagios
Command user/group: nagios,nagcmd
Event Broker: yes
Install ${prefix}: /usr/local/nagios
Install ${includedir}: /usr/local/nagios/include/nagios
Lock file: ${prefix}/var/nagios.lock
Check result directory: ${prefix}/var/spool/checkresults
Init directory: /etc/init.d
Apache conf.d directory: /etc/httpd/conf.d
Mail program: /bin/mail
Host OS: linux-gnu
IOBroker Method: epoll
Web Interface Options:
------------------------
HTML URL: http://localhost/nagios/
CGI URL: http://localhost/nagios/cgi-bin/
Traceroute (used by WAP):
Review the options above for accuracy. If they look okay,
type 'make all' to compile the main program and CGIs.
Now run the following make commands. First run make all as shown.
make all
Once that runs the following will be displayed upon success. I’ve included it here as there are a few useful commands in it.
*** Compile finished ***
If the main program and CGIs compiled without any errors, you
can continue with installing Nagios as follows (type 'make'
without any arguments for a list of all possible options):
make install
- This installs the main program, CGIs, and HTML files
make install-init
- This installs the init script in /etc/init.d
make install-commandmode
- This installs and configures permissions on the
directory for holding the external command file
make install-config
- This installs *SAMPLE* config files in /usr/local/nagios/etc
You'll have to modify these sample files before you can
use Nagios. Read the HTML documentation for more info
on doing this. Pay particular attention to the docs on
object configuration files, as they determine what/how
things get monitored!
make install-webconf
- This installs the Apache config file for the Nagios
web interface
make install-exfoliation
- This installs the Exfoliation theme for the Nagios
web interface
make install-classicui
- This installs the classic theme for the Nagios
web interface
*** Support Notes *******************************************
If you have questions about configuring or running Nagios,
please make sure that you:
- Look at the sample config files
- Read the documentation on the Nagios Library at:
https://library.nagios.com
before you post a question to one of the mailing lists.
Also make sure to include pertinent information that could
help others help you. This might include:
- What version of Nagios you are using
- What version of the plugins you are using
- Relevant snippets from your config files
- Relevant error messages from the Nagios log file
For more information on obtaining support for Nagios, visit:
https://support.nagios.com
*************************************************************
Enjoy.
After that successfully finishes, then execute the following.
sudo make install
sudo make install-commandmode
sudo make install-init
sudo make install-config
sudo /usr/bin/install -c -m 644 sample-config/httpd.conf /etc/apache2/sites-available/nagios.conf
Now some tinkering to setup the web server user in www-data and nagcmd group.
sudo usermod -G nagcmd www-data
Now some Nagios plugins. You can find the plugins listed for download here: http://nagios-plugins.org/download/ The following are based on the 2.1.1 release of plugins.
Change back out to the user directory on the server and download, tar, and change into the newly unzipped files.
cd ~
curl -L -O http://nagios-plugins.org/download/nagios-plugins-2.1.1.tar.gz
tar xvf nagios-plugins-*.tar.gz
cd nagios-plugins-*
./configure --with-nagios-user=nagios --with-nagios-group=nagios --with-openssl
Now for some ole compilation magic.
make
sudo make install
Now pretty much the same things for NRPE. Look here to insure that 2.15 is the latest version.
cd ~
curl -L -O http://downloads.sourceforge.net/project/nagios/nrpe-2.x/nrpe-2.15/nrpe-2.15.tar.gz
tar xvf nrpe-*.tar.gz
cd nrpe-*
Then configure the NRPE bits.
./configure --enable-command-args --with-nagios-user=nagios --with-nagios-group=nagios --with-ssl=/usr/bin/openssl --with-ssl-lib=/usr/lib/x86_64-linux-gnu
Then get to making it all.
make all
sudo make install
sudo make install-xinetd
sudo make install-daemon-config
Then a little file editing.
sudo vi /etc/xinetd.d/nrpe
Edit the file for the line only_from to include the following where 192.x.x.x is the IP of the Nagios Server.
only_from = <IP_ADDRESS> 192.x.x.x
Save the file, and restart the Nagios server service.
sudo service xinetd restart
Now begins the Nagios Server configuration. Edit the Nagios configuration file.
sudo vi /usr/local/nagios/etc/nagios.cfg
Find this line and uncomment the line.
#cfg_dir=/usr/local/nagios/etc/servers
Save it and exit.
Next creat the configuration file for the servers to monitor.
sudo mkdir /usr/local/nagios/etc/servers
Next configure the contacts config file.
sudo vi /usr/local/nagios/etc/objects/contacts.cfg
Fine this line and set the email address to one you’ll be using.
email<EMAIL_ADDRESS>Now add a Nagios service definition for the check_nrpe command.
sudo vi /usr/local/nagios/etc/objects/commands.cfg
Add this to the end of the file.
define command{
command_name check_nrpe
command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$
}
Save and exit the file.
Now a few last touches for configuration in Apache. We’ll want the Apache rewrite and cgi modules enabled.
sudo a2enmod rewrite
sudo a2enmod cgi
Now create an admin user, we’ll call them ‘nagiosadmin’.
sudo htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
Create a symbolic link of nagios.conf to the sites-enabled directory and then start the Nagios server and restart apache2.
sudo ln -s /etc/apache2/sites-available/nagios.conf /etc/apache2/sites-enabled/
sudo service nagios start
sudo service apache2 restart
Enable Nagios to start on server boot (because, ya know, that’s what this server is going to be used for).
sudo ln -s /etc/init.d/nagios /etc/rcS.d/S99nagios
Now navigate to the server and you’ll be prompted to login to the web user interface.
Now begins the process of setting up servers you want to monitor… stay tuned, more to come.


Hindu Mahasabha wants Godse’s court statements in Madhya Pradesh school syllabus
Members of the right-wing organisation observe Godse's death anniversary
by PTIThe Hindu Mahasabha on November 15 demanded that Nathuram Godse’s statements during the Mahatma Gandhi assassination trial be included in school curriculum in Madhya Pradesh.
The right-wing organisation made the demand while observing Godse’s death anniversary here.
Godse, who assassinated Mahatma Gandhi, was hanged at Ambala jail on November 15, 1949.
Hindu Mahasabha members on November 16 gathered at its office here and performed ‘aarti’ of Godse and Narayan Apte, the co- conspirator who too was hanged for Gandhi’s assassination.
Hindu Mahasabha national vice-president Jaiveer Bharadwaj said the organisation observed the death anniversary of two “leaders”, whose “contribution to Indian freedom struggle has been forgotten”, like every year.
“We also submitted a memorandum, addressed to Madhya Pradesh Chief Minister, and to the district administration. We have demanded inclusion of Godse’s statements, recorded during his trial, in school curriculum,” Mr. Bharadwaj said.
Congress governments at the Centre did not disclose Godse’s court statements for 50 years, he alleged.
On November 15, 2017, the Mahasabha had installed a bust of Godse at its Gwalior office after performing the ritual of ‘pran pratishtha’ (consecration).
Following widespread outrage, the district administration confiscated the bust.
“In the memorandum, we also demanded that the bust, seized by the district administration, be returned to us,” Mr. Bharadwaj said.
The ruling Congress in Madhya Pradesh condemned the event. “The event glorified violence. This is condemnable.
These people don’t believe in the Indian Constitution as Godse himself had filed a mercy petition before the British Queen despite the country having a Supreme Court,” said Bhupendra Gupta, vice president of state Congress Media Cell.


[gecode-users] LDSB : symmetries on value tuples and depending symmetries
Martin Mann
mmann at informatik.uni-freiburg.de
Tue Apr 23 10:55:08 CEST 2013
Hi,
me again on LDSB.
I played around with LDSB for my problem on two sets of variables X1 and
X2 that have different domains and symmetries. X1 and X2 are coupled by
some strong user defined constraints, so not independent.
Actually, my situation is like that:
I have a symmetry function "s" that can generate for each solution "a"
the set of symmetric assignments on X1 and on X2 (independently). The
problem is defined in a way that all symmetries from X1 are
theoretically combineable with symmetric assignments on X2.
Thus I would like to do something like that:
- for each assignment a1 on X1
+ find assignment a2 on X2
+ ensure during remaining search implication
if(a1) --> [X2 not s(a2)] for all symmetries of a2
+ ensure during remaining search
[X1 not s(a1)] for all symmetries of a1
+ continue search
So I am basically looking for a symmetry breaking for value tuples since
I am not sure if simple value symmetry breaking is really doing the job
(at least my first tests dont give me the feeling).
Is there a possibility with LDSB or do you see some way to build such a
framework? I did something similar years back for Gecode 1, but not sure
if I want to reengineer my own code.. ;)
Thanks for any hints,
Martin
--
Dr. Martin Mann, Postdoc
Bioinformatics - Inst. of Computer Science
Albert-Ludwigs-University Freiburg
Tel: ++49-761-203-8254
Fax: ++49-761-203-7462
http://www.bioinf.uni-freiburg.de/~mmann/
More information about the users
mailing list


Tiramisu is a coffee-flavoured Italian dessert. It is made of ladyfingers (savoiardi) dipped in coffee, layered with a whipped mixture of eggs, sugar and mascarpone cheese, flavoured with cocoa.
Ingredients
Eggs yolks
Sugar
Milk
Heavy Cream
Vanilla Extract
Cheese
Coffe
Rum
Cookies
Cocoa Powder
Directions
Step 1 Whisk together egg yolks and sugar until well blended. Whisk in milk and cook over medium heat, stirring constantly, until mixture boils
Step 2 Beat cream with vanilla until stiff peaks form
Step 3 Whisk mascarpone into yolk mixture until smooth
Step 4 Combine coffee and rum
Reviews
Best ever!!! I was really impressed. I will add some maple syrup toward the end next time. in my recipe forever
Nicole
Reviews
My husband and I never had waffles. I made this recipe and it was awesome. I must say, it was better than eating at some famous restuarants. Thanks


Johor Man Hangs On To Trailer To Get A Free Ride, Runs Off When He Arrives At His Destination
by Fadzly HanaffiTap to listen to this article instead: 🔊 Listen to Post
One man gave new meaning to the word hitchhiking as he latched himself to a moving trailer to get to his destination.
The unidentified man, dressed only in jeans was seen hanging on to the back end of a trailer nearby Jalan Kempas Lama, Johor.
The video of the man was however unclear in the beginning but as the video went on the man stepped down from the trailer and ran away from the trailer as it approaches a junction.
Here is the video of the man braving heavy traffic whilst hitching on his grab ride.
We, advice viewers, to not try this at home and not take the word Grab so literally.
One netizen commenting on the Facebook page mentions how she did not notice that the person was there.
In her comments, she writes, “I did not notice the man sitting there until he jumped off the trailer.”
Run Forest Run!
Though the clip may look funny, it is important to highlight the dangers normally associated with hanging on to a moving vehicle.
This is not Hollywood after all.
Also read: Watch: Crazy Aussie Tourist Kicks Motorcyclist Off Bike, Jumps on Moving Car in Bali


There are many companies that will share your private information for marketing purposes, from your banks, financial institutions, grocery stores, to retail outlets and all of their affiliates.
We do NOT sell, give, or share your e-mail address with anyone (with the exception of our shipping companies' software so that you will be notified with a tracking number!).
We also do not provide/give/share/sell your personal name, address (or any other information about you) to anyone or with any business.
We do not do customer "profiling" on you.
We do not track where you were before visiting us or after leaving us.
- No Personal Information Collected
- No Spyware
- No Popups
- No Adware
- No Risk To You!
We absolutely do NOT participate with Advertising Networks (many of which monitor and profile you) such as
DoubleClick,
LinkShare,
Engage,
24/7,
LinkExchange,
ValueClick,
Matchlogic,
FastClick.net,
Mediaplex.com,
AdMonitor.net,
Focalink.com,
LinkSynergy,
TrafficMP,
Centerport,
AdBureau.net,
and Links2go to name just a few.
We do not participate with "Referrers" (information passed along when you move from one site to another or use our search feature or even just sending e-mail).
We do not give your IP address to others.
We do not offer your info to third part databases such as Acxiom and Experian.
We DO treasure and honor your privacy.
We never give/sell/share any of your personal information or your buying habits to anyone.
We do not send spam email.
Because we are very proud of the many "thanks" that we have received from our customers, sometimes we will share your name, city and state, on our satisfied customers page. Because we believe and guarantee your privacy, rest assured that we always ask for your written permission before showing your "thank you" words and notes.
Cookies - Cookies are files with small amount of data, which may include an anonymous unique identifier. Cookies are sent to your browser from a web site and stored on your computer's hard drive. Like many sites, we use "cookies" to collect information. You can instruct your browser to refuse all cookies or to indicate when a cookie is being sent. However, if you do not accept cookies, you may
not be able to use some portions of our site.
Log Data - Like many site operators, we collect information that your browser sends whenever you visit our site
("Log Data"). This Log Data may include information such as your computer's Internet Protocol ("IP") address, browser type, browser version, the pages of our Site that you visit, the time and date of your visit, the time spent on those pages and other statistics. Our site may use third party services such as Google Analytics to monitor and analyze the Log Data.
We respect your privacy!


com.threed.jpct
Class FrameBuffer
java.lang.Object
com.threed.jpct.FrameBuffer
- All Implemented Interfaces:
- java.io.Serializable
- public class FrameBuffer
- extends java.lang.Object
- implements java.io.Serializable
The FrameBuffer class provides a buffer into which jPCT renders the scene.
The result is basically an Image which could be displayed or modified even
further using some post-processing. The FrameBuffer's constructor
automatically distinguishes between JAVA2 and earlier versions. JAVA2 and
higher will use a BufferedImage as FrameBuffer while JAVA1.1 will use a
MemoryImageSource. When using support for OpenGL hardware rendering only, the
image is not rendered into the FrameBuffer's internal pixel-array but
directly into the video-RAM of the graphics card. Therefor, some methods
within this class will execute quite slow if they have to access the VRAM.
This will be mentioned in these methods.
- See Also:
- Serialized Form
|
Field Summary |
static int |
BLITTING_TARGET_BACK
Blitting is done into the back buffer. |
static int |
BLITTING_TARGET_FRONT
Blitting is done into the front buffer. |
static boolean |
BOUNDINGBOX_NOT_USED
Don't use a 2D bounding box. |
static boolean |
BOUNDINGBOX_USED
Use a 2D bounding box for speeding up blitting (only useful when the
rendered scene doesn't cover the whole framebuffer) |
static int |
BUFFER_ACCESS_COMBINED
Access the framebuffer in one way (default)... |
static int |
BUFFER_ACCESS_SPLITTED
Access the framebuffer in another way)... |
static int |
BUFFEREDIMAGE
The type of this FrameBuffer is a BufferedImage (JAVA2) |
static int |
MEMORYIMAGESOURCE
The type of this FrameBuffer is a MemoryImageSource (JAVA1.1) |
static boolean |
OPAQUE_BLITTING
2D texture-blitting into the framebuffer is done by copying the source
1-to-1 into the destination bitmap |
static int |
SAMPLINGMODE_GL_AA_2X
Use 2x anti aliasing when using the OpenGL renderer. |
static int |
SAMPLINGMODE_GL_AA_4X
Use 4x anti aliasing when using the OpenGL renderer. |
static int |
SAMPLINGMODE_HARDWARE_ONLY
A special sampling mode that indicates, that no software rendering will
be used on this framebuffer. |
static int |
SAMPLINGMODE_NORMAL
Normal sampling mode (1-to-1) |
static int |
SAMPLINGMODE_OGSS
Use 2x2 oriented grid oversampling (FSAA using supersampling) for the
software renderer. |
static int |
SAMPLINGMODE_OGSS_FAST
Use 1.5x1.5 oriented grid oversampling (FSAA using supersampling) for the
software renderer. |
static int |
SAMPLINGMODE_OGUS
Use 0.5x0.5 oriented grid undersampling (to upsample an image rendered at
a lower resolution) |
static java.lang.String |
SUPPORT_FOR_RGB_SCALING
Use this to check if all the currently enabled renderers support
RGB-scaling |
static java.lang.String |
SUPPORT_FOR_SHADOW_MAPPING
Use this to check if all the currently enabled renderers support shadow
mapping |
static java.lang.Object |
SYNCHRONIZER
An Object to which jPCT synchronizes all critical calls to Display, Mouse
and Keyboard from LWJGL to. |
static boolean |
TRANSPARENT_BLITTING
2D texture-blitting into the framebuffer is done by copying the source
into the destination bitmap only at places where the sources bitmap has
none-zero color-values. |
|
Constructor Summary |
FrameBuffer(int x,
int y,
int oversample)
Creates a new framebuffer with a width of x and a height of y using the
given samplingmode. |
|
Method Summary |
void |
addPostProcessor(IPostProcessor proc)
Adds an IPostProcessor to run a post processing on the framebuffer. |
void |
blit(int[] src,
int srcWidth,
int srcHeight,
int srcX,
int srcY,
int destX,
int destY,
int width,
int height,
boolean transparent)
Copies a part of a bitmap (taken from an int[] containing pixels in
RGB-format and with no alpha) into the framebuffer. |
void |
blit(Texture src,
int srcX,
int srcY,
int destX,
int destY,
int width,
int height,
boolean transparent)
Copies a part of a bitmap (taken from a Texture in this case) into the
framebuffer. |
void |
blit(Texture src,
int srcX,
int srcY,
int destX,
int destY,
int sourceWidth,
int sourceHeight,
int destWidth,
int destHeight,
int transValue,
boolean additive)
Special version of blit() that allows for scaling, i.e. it doesn't make
1-to-1 copies but can up- or down-scale. |
void |
blit(Texture src,
int srcX,
int srcY,
int destX,
int destY,
int sourceWidth,
int sourceHeight,
int destWidth,
int destHeight,
int transValue,
boolean additive,
java.awt.Color addColor)
Special version of blit() that allows for scaling, i.e. it doesn't make
1-to-1 copies but can up- or down-scale. |
void |
blit(Texture src,
int srcX,
int srcY,
int destX,
int destY,
int sourceWidth,
int sourceHeight,
int destWidth,
int destHeight,
int transValue,
boolean additive,
RGBColor addColor)
Method to maintain compatibility with jPCT-AE. |
void |
clear()
Clears the framebuffer, the optiZ-buffer, the hsr-buffer and the regular
z-buffer if required. |
void |
clear(java.awt.Color col)
Clears the framebuffer, the optiZ-buffer, the hsr-buffer and the regular
z-buffer if required. |
void |
clear(int rgb)
The same as clear(<Color>) but with an int-value instead of a color
instance. |
void |
clearColorBufferOnly(java.awt.Color col)
Clears only the color bufferr, not the depth buffer. |
void |
clearZBufferOnly()
Clears only the ZBuffer, not the color buffer. |
void |
disableRenderer(int renderer)
Disables a renderer for this framebuffer. |
void |
display()
The same as displayGLOnly. |
void |
display(java.awt.Graphics g)
Displays the output Image onto the component with the given Graphics
context. |
void |
display(java.awt.Graphics g,
int yOffset)
Displays the output Image onto the component with the given Graphics
context. |
void |
display(java.awt.Graphics g,
int xOffset,
int yOffset)
Displays the output Image onto the component with the given Graphics
context. |
void |
displayGLOnly()
Displays the output image produced by OpenGL compatible hardware if
OpenGL rendering is in use. |
void |
dispose()
Has to be called before this FrameBuffer won't be used anymore to do some
clean up work. |
java.awt.Canvas |
enableGLCanvasRenderer()
Enables an OpenGL renderer that will render into a canvas. |
void |
enableRenderer(int renderer)
Enables a renderer (OpenGL or software) in OpenGL-lighting mode.
|
void |
enableRenderer(int renderer,
int mode)
Enables a renderer (OpenGL or software) in the desired mode. |
void |
flush()
Does nothing. |
java.awt.Graphics |
getGraphics()
Returns the Graphics object of the output buffer to allow the use of
JAVA's standard graphic methods on the rendered image (like drawString).
|
int |
getHeight()
The same as getOutputHeight(). |
java.lang.Long |
getID()
Returns a unique ID for this FrameBuffer. |
java.lang.Object |
getLock()
Returns the lock object for the frame buffer. |
int |
getMaxTextureSize()
Gets the maximum texture size that the current renderers support. |
float |
getMiddleX()
Returns the x-coord of the midpoint of the framebuffer. |
float |
getMiddleY()
Returns the y-coord of the midpoint of the framebuffer. |
java.awt.Image |
getOutputBuffer()
Returns the Image that represents the output-buffer of the framebuffer.
|
int |
getOutputHeight()
Returns the height of the framebuffer. |
int |
getOutputWidth()
Returns the width of the framebuffer. |
int[] |
getPixels()
Returns the raw pixel-data. |
int |
getSamplingMode()
Returns the used sampling mode for this framebuffer. |
int |
getType()
Returns the type of this FrameBuffer. |
static VideoMode[] |
getVideoModes(int renderer)
Static method to get the video modes a renderer (i.e. the hardware it's
running on) supports. |
int |
getWidth()
The same as getOutputWidth(). |
boolean |
isInitialized()
Checks if the FrameBuffer and all its enabled renderers have been
initialized correctly. |
void |
optimizeBufferAccess()
This method tries to pick the most optimal buffer access mode for the
system jPCT is currently running on. |
void |
refresh()
Forces the framebuffer to update its content with what's in the
pixels-array. |
void |
removeAllPostProcessors()
Removes all post processors from the framebuffer. |
void |
removeClippingPlane(int number)
Removes an additional clipping plane. |
void |
removePostProcessor(IPostProcessor proc)
Removes a post processor from the framebuffer. |
void |
removeRenderTarget()
Removes the render target from the framebuffer. |
void |
resize(int width,
int height)
Does a resize of the FrameBuffer in case that the output window's size
has changed. |
void |
runPostProcessors()
Runs all post processors that have been added to this framebuffer. |
void |
setBlittingTarget(int target)
Sets the blitting target to either the front (default) or the back
buffer. |
void |
setBoundingBoxMode(boolean bmode)
Sets the bounding box mode for the framebuffer. |
void |
setBufferAccess(int mode)
When using the software renderer, the framebuffer can be accessed in
different ways. |
void |
setClippingPlane(int number,
Plane plane)
Sets an additional clipping plane. |
void |
setPaintListener(IPaintListener listener)
Adds a listener to all currently used renderers. |
void |
setPaintListenerState(boolean isActive)
Sets the state of the paint listener. |
void |
setRenderTarget(int texID)
Sets the render target of the framebuffer to a texture. |
void |
setRenderTarget(int texID,
int left,
int top,
int right,
int bottom,
boolean clearAll)
Sets the render target of the framebuffer to a texture. |
void |
setRenderTarget(Texture tex)
Sets the render target of the framebuffer to a texture. |
void |
setRenderTarget(Texture tex,
int left,
int top,
int right,
int bottom,
boolean clearAll)
Sets the render target of the framebuffer to a texture. |
void |
setVirtualDimensions(int width,
int height)
This has a meaning only if a render target has been set. |
boolean |
supports(java.lang.String feature)
Checks if a feature is supported by all the renderers of this
framebuffer. |
void |
sync()
Does nothing. |
void |
update()
Updates the output buffer of the framebuffer with the new data from the
backbuffer. |
boolean |
usesRenderer(int renderer)
Tests if the given renderer is used by this framebuffer. |
| Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
MEMORYIMAGESOURCE
public static final int MEMORYIMAGESOURCE
- The type of this FrameBuffer is a MemoryImageSource (JAVA1.1)
- See Also:
- Constant Field Values
BUFFEREDIMAGE
public static final int BUFFEREDIMAGE
- The type of this FrameBuffer is a BufferedImage (JAVA2)
- See Also:
- Constant Field Values
SAMPLINGMODE_GL_AA_4X
public static final int SAMPLINGMODE_GL_AA_4X
- Use 4x anti aliasing when using the OpenGL renderer. Don't use this on a
framebuffer that's supposed to be used by the software renderer.
- See Also:
- Constant Field Values
SAMPLINGMODE_GL_AA_2X
public static final int SAMPLINGMODE_GL_AA_2X
- Use 2x anti aliasing when using the OpenGL renderer. Don't use this on a
framebuffer that's supposed to be used by the software renderer.
- See Also:
- Constant Field Values
SAMPLINGMODE_OGSS
public static final int SAMPLINGMODE_OGSS
- Use 2x2 oriented grid oversampling (FSAA using supersampling) for the
software renderer. This mode shouldn't be used for the OpenGL renderer.
- See Also:
- Constant Field Values
SAMPLINGMODE_OGSS_FAST
public static final int SAMPLINGMODE_OGSS_FAST
- Use 1.5x1.5 oriented grid oversampling (FSAA using supersampling) for the
software renderer. This mode shouldn't be used for the OpenGL renderer.
This mode is faster then "normal" 2x2 oversampling, but image quality is
a bit lower.
- See Also:
- Constant Field Values
SAMPLINGMODE_OGUS
public static final int SAMPLINGMODE_OGUS
- Use 0.5x0.5 oriented grid undersampling (to upsample an image rendered at
a lower resolution)
- See Also:
- Constant Field Values
SAMPLINGMODE_NORMAL
public static final int SAMPLINGMODE_NORMAL
- Normal sampling mode (1-to-1)
- See Also:
- Constant Field Values
SAMPLINGMODE_HARDWARE_ONLY
public static final int SAMPLINGMODE_HARDWARE_ONLY
- A special sampling mode that indicates, that no software rendering will
be used on this framebuffer. OpenGL support will work with any other
sampling mode though (but the sampling modes may not affect the OpenGL
output).
- See Also:
- Constant Field Values
BOUNDINGBOX_USED
public static final boolean BOUNDINGBOX_USED
- Use a 2D bounding box for speeding up blitting (only useful when the
rendered scene doesn't cover the whole framebuffer)
- See Also:
- Constant Field Values
BOUNDINGBOX_NOT_USED
public static final boolean BOUNDINGBOX_NOT_USED
- Don't use a 2D bounding box. This mode should be used for indoor
rendering.
- See Also:
- Constant Field Values
OPAQUE_BLITTING
public static final boolean OPAQUE_BLITTING
- 2D texture-blitting into the framebuffer is done by copying the source
1-to-1 into the destination bitmap
- See Also:
- Constant Field Values
TRANSPARENT_BLITTING
public static final boolean TRANSPARENT_BLITTING
- 2D texture-blitting into the framebuffer is done by copying the source
into the destination bitmap only at places where the sources bitmap has
none-zero color-values.
- See Also:
- Constant Field Values
SUPPORT_FOR_RGB_SCALING
public static final java.lang.String SUPPORT_FOR_RGB_SCALING
- Use this to check if all the currently enabled renderers support
RGB-scaling
- See Also:
Lights.setRGBScale(int)
,
supports(java.lang.String)
,
Constant Field Values
SUPPORT_FOR_SHADOW_MAPPING
public static final java.lang.String SUPPORT_FOR_SHADOW_MAPPING
- Use this to check if all the currently enabled renderers support shadow
mapping
- See Also:
supports(java.lang.String)
,
Constant Field Values
BUFFER_ACCESS_COMBINED
public static final int BUFFER_ACCESS_COMBINED
- Access the framebuffer in one way (default)...
- See Also:
setBufferAccess(int)
,
Constant Field Values
BUFFER_ACCESS_SPLITTED
public static final int BUFFER_ACCESS_SPLITTED
- Access the framebuffer in another way)...
- See Also:
setBufferAccess(int)
,
Constant Field Values
BLITTING_TARGET_FRONT
public static final int BLITTING_TARGET_FRONT
- Blitting is done into the front buffer. This is default
- See Also:
- Constant Field Values
BLITTING_TARGET_BACK
public static final int BLITTING_TARGET_BACK
- Blitting is done into the back buffer. This only affects blitting when
the software renderer is used with over-/undersampling. For any other
configuration, is the same as BLITTING_TARGET_FRONT.
- See Also:
- Constant Field Values
SYNCHRONIZER
public static final java.lang.Object SYNCHRONIZER
- An Object to which jPCT synchronizes all critical calls to Display, Mouse
and Keyboard from LWJGL to. These classes are not thread safe, therefor
it's required to avoid creating the Keyboard while creating the display
(for example). If you ever do such things from other threads or are using
jPCT's AWTGLRenderer or its build-in multithreading support, make sure to
synchronize to this object when you are calling critical Keyboard-,
Mouse- or Diplay-methods.
Of course, all this only applies to the hardware renderers.
FrameBuffer
public FrameBuffer(int x,
int y,
int oversample)
- Creates a new framebuffer with a width of x and a height of y using the
given samplingmode. For software rendering, the framebuffer can be of any
size. For OpenGL, a size supported by the OpenGL compatible hardware one
is using is required.
- Parameters:
x
- the width of the framebuffery
- the height of the framebufferoversample
- the samplingmode- See Also:
SAMPLINGMODE_OGSS
,
SAMPLINGMODE_OGSS_FAST
,
SAMPLINGMODE_OGUS
,
SAMPLINGMODE_NORMAL
,
SAMPLINGMODE_HARDWARE_ONLY
,
SAMPLINGMODE_GL_AA_2X
,
SAMPLINGMODE_GL_AA_4X
,
getVideoModes(int)
getID
public java.lang.Long getID()
- Returns a unique ID for this FrameBuffer.
- Returns:
- Long the ID
getVideoModes
public static VideoMode[] getVideoModes(int renderer)
- Static method to get the video modes a renderer (i.e. the hardware it's
running on) supports. This is useful for initializing the OpenGL renderer
and the FrameBuffer. The z-buffer depth of the returned modes is taken
from the z-buffer setting in Config and NOT from the driver of the video
card, because the used OpenGL binding doesn't return this value
anymore...so it's basically 'guessing' here... The software renderer
doesn't have video modes, so it will return an empty array.
- Parameters:
renderer
- the renderer (only IRenderer.RENDERER_OPENGL makes sense at
the moment)
- Returns:
- the supported video modes
- See Also:
IRenderer
,
Config.glColorDepth
,
Config.glZBufferDepth
,
Config.glRefresh
isInitialized
public boolean isInitialized()
- Checks if the FrameBuffer and all its enabled renderers have been
initialized correctly. This is useful to check if OpenGL support has been
enabled succesfully and if the desired videomode has been set.
When using the AWTGLRenderer, this method will return false until the
first drawing (attempt) took place.
- Returns:
- true, if the FrameBuffer is fine. Otherwise false.
setBlittingTarget
public void setBlittingTarget(int target)
- Sets the blitting target to either the front (default) or the back
buffer. This is required to allow blitting into the background of an
over- or undersampled frame buffer. Any other configuration doesn't need
this.
- Parameters:
target
- the blitting target- See Also:
BLITTING_TARGET_FRONT
,
BLITTING_TARGET_BACK
enableRenderer
public void enableRenderer(int renderer)
- Enables a renderer (OpenGL or software) in OpenGL-lighting mode.
OpenGL-lighting mode is the recommended mode for the software as well as
for the hardware renderer. However, jPCT constructs every new FrameBuffer
as software/legacy for compatibility reasons. It is possible to use the
software renderer as well as the OpenGL renderer on a single framebuffer
at the same time, but it's not advised to do so, because this will
disable some optimizations that are else made in case OpenGL is used
(like T&L optimizations and triangle strips). To enable OpenGL without
supporting the software renderer, the software renderer has to be
disabled after enabling OpenGL.
Important: NEVER change the renderer from outside the thread that is
doing the rendering if you intend to use the OpenGL renderer, because
this will cause your application to crash. This is a "feature" of LWJGL,
so there's nothing jPCT can do about it.
- Parameters:
renderer
- the renderer that should be used to render this framebuffer- See Also:
disableRenderer(int)
,
enableRenderer(int, int)
,
IRenderer
enableGLCanvasRenderer
public java.awt.Canvas enableGLCanvasRenderer()
- Enables an OpenGL renderer that will render into a canvas. For
compatibility reasons, jPCT constructs every new FrameBuffer as
software/legacy. It is possible to use the software renderer as well as
the OpenGL renderer on a single framebuffer at the same time, but it's
not advised to do so, because this will disable some optimizations that
are else made in case OpenGL is used (like T&L optimizations and triangle
strips). To enable OpenGL without supporting the software renderer, the
software renderer has to be disabled after enabling OpenGL.
Using this renderer affects the behaviour of getPixels() and supports(),
which will only return after the Canvas has been repainted. If this never
happens for whatever reason, they'll never return!
- Returns:
- the Canvas
- See Also:
disableRenderer(int)
,
enableRenderer(int)
,
enableGLCanvasRenderer()
,
AWTGLRenderer
enableRenderer
public void enableRenderer(int renderer,
int mode)
- Enables a renderer (OpenGL or software) in the desired mode. For
compatibility reasons, jPCT constructs every new FrameBuffer as
software/opengl-alike. It is possible to use the software renderer as
well as the OpenGL renderer on a single framebuffer at the same time, but
it's not advised to do so, because this will disable some optimizations
that are else made in case OpenGL is used (like T&L optimizations and
triangle strips). To enable OpenGL without supporting the software
renderer, the software renderer has to be disabled after enabling OpenGL.
Important: NEVER change the renderer from outside the thread that is
doing the rendering if you intend to use the OpenGL renderer, because
this will cause your application to crash. This is a "feature" of LWJGL,
so there's nothing jPCT can do about it.
- Parameters:
renderer
- the renderer that should be used to render this framebuffermode
- the mode the renderer should use- See Also:
disableRenderer(int)
,
enableRenderer(int)
,
IRenderer
setRenderTarget
public void setRenderTarget(int texID)
- Sets the render target of the framebuffer to a texture. From here on, all
rendering is done into that texture instead of the actual framebuffer.
The texture has to be smaller or equal to the framebuffer, when FBO are
not used/available. Rendering into a texture can be slow on some hardware
like Intel onboard chipsets.
While the software renderer do support render targets, it can't run a
post processor on them.
Make sure that the texture you are using as render target doesn't use mip
mapping.
While possible, it's not recommended to blit into a render target.
- Parameters:
texID
- the ID of the texture to render into.- See Also:
Config.glUseFBO
,
Config.glFlipRenderTargets
setRenderTarget
public void setRenderTarget(int texID,
int left,
int top,
int right,
int bottom,
boolean clearAll)
- Sets the render target of the framebuffer to a texture. From here on, all
rendering is done into that texture instead of the actual framebuffer.
The texture has to be smaller or equal to the framebuffer, when FBO are
not used/available. Rendering into a texture can be slow on some hardware
like Intel onboard chipsets.
This is a special purpose version of this method that allows to define a
border that isn't affected by the rendering. The software renderer
doesn't support this border and ignores it.
Make sure that the texture you are using as render target doesn't use mip
mapping.
While possible, it's not recommended to blit into a render target.
- Parameters:
texID
- the ID of the texture to render into.left
- the width of the left bordertop
- the width of the upper borderright
- the width of the right borderbottom
- the width of the lower borderclearAll
- if true, the border won't affect the clearing of texture. If
set to false, it will.- See Also:
Config.glUseFBO
,
Config.glFlipRenderTargets
setRenderTarget
public void setRenderTarget(Texture tex)
- Sets the render target of the framebuffer to a texture. From here on, all
rendering is done into that texture instead of the actual framebuffer.
The texture has to be smaller or equal to the framebuffer, when FBO are
not used/available. Rendering into a texture can be slow on some hardware
like Intel onboard chipsets. While the software renderer do support
render targets, it can't run a post processor on them.
Make sure that the texture you are using as render target doesn't use mip
mapping.
While possible, it's not recommended to blit into a render target.
- Parameters:
tex
- the texture to render into- See Also:
Config.glUseFBO
,
Config.glFlipRenderTargets
setRenderTarget
public void setRenderTarget(Texture tex,
int left,
int top,
int right,
int bottom,
boolean clearAll)
- Sets the render target of the framebuffer to a texture. From here on, all
rendering is done into that texture instead of the actual framebuffer.
The texture has to be smaller or equal to the framebuffer, when FBO are
not used/available. Rendering into a texture can be slow on some hardware
like Intel onboard chipsets. While the software renderer do support
render targets, it can't run a post processor on them. A texture assigned
as a render target will automatically treated as non-mipmapped. This is a
special purpose version of this method that allows to define a border
that isn't affected by the rendering. The software renderer doesn't
support this border and ignores it.
While possible, it's not recommended to blit into a render target.
- Parameters:
tex
- the texture to render intoleft
- the width of the left bordertop
- the width of the upper borderright
- the width of the right borderbottom
- the width of the lower borderclearAll
- if true, the border won't affect the clearing of texture. If
set to false, it will.- See Also:
Config.glUseFBO
,
Config.glFlipRenderTargets
removeRenderTarget
public void removeRenderTarget()
- Removes the render target from the framebuffer. After this, all rendering
is done into the framebuffer again. If no render target has been set,
this method does nothing.
setVirtualDimensions
public void setVirtualDimensions(int width,
int height)
- This has a meaning only if a render target has been set. By default the
fov calculations will use the render target's dimensions. With this, you
can set some other dimensions.
- Parameters:
width
- the virtual width of the render targetheight
- the virtual height of the render target
addPostProcessor
public void addPostProcessor(IPostProcessor proc)
- Adds an IPostProcessor to run a post processing on the framebuffer. This
isn't done automatically but has to be triggered by the application by
calling runPostProcessors() on this framebuffer. Enabling or disabling
renderers on this framebuffer causes all post processors to be disposed
and then removed from this framebuffer.
- Parameters:
proc
- the post processor- See Also:
runPostProcessors()
,
IPostProcessor
removePostProcessor
public void removePostProcessor(IPostProcessor proc)
- Removes a post processor from the framebuffer. The processor will be
disposed and then removed.
- Parameters:
proc
- The post processor to be removed- See Also:
IPostProcessor
removeAllPostProcessors
public void removeAllPostProcessors()
- Removes all post processors from the framebuffer. The processors will be
disposed and then removed.
- See Also:
IPostProcessor
runPostProcessors
public void runPostProcessors()
- Runs all post processors that have been added to this framebuffer. A post
processor is an implementation of the IPostProcessor interface and may or
may not support hardware and software renderer. The processing is done on
the framebuffer's back buffer in its current state, i.e. if you run it
before blitting, the blitting won't be affected. If you run it
afterwards, it will.
- See Also:
IPostProcessor
setPaintListener
public void setPaintListener(IPaintListener listener)
- Adds a listener to all currently used renderers. The listener will be
notified before the renderer starts to paint polygons and after it has
finished.
- Parameters:
listener
- IPaintListener the listener or null to clear it
setPaintListenerState
public void setPaintListenerState(boolean isActive)
- Sets the state of the paint listener. If set to false, it won't be called
even if assigned. The setting applies to all paint listeners on the
currently acitve renderers. If you change a renderer, the new one will
start with an active state regardless of this setting.
- Parameters:
isActive
- is it active or sleeping?
disableRenderer
public void disableRenderer(int renderer)
- Disables a renderer for this framebuffer. Disabling all renderers doesn't
make much sense, so usually one will disable the renderer that is not in
use at the moment (software if OpenGL is used and vice versa). After
enabling OpenGL, it is advised to disable the software renderer. While it
is possible to enable both, the software renderer will disable some
optimization that may be used in case of "OpenGL only" (like T&L
optimizations and triangle strips).
- Parameters:
renderer
- the renderer- See Also:
IRenderer
dispose
public void dispose()
- Has to be called before this FrameBuffer won't be used anymore to do some
clean up work. For example, if you are reusing a buffer variable to
assign a new FrameBuffer for it, dispose the former one before doing so.
Java2 would allow to use a weak reference to handle this better, but jPCT
is 1.1 compatible, so...
usesRenderer
public boolean usesRenderer(int renderer)
- Tests if the given renderer is used by this framebuffer.
- Parameters:
renderer
- the renderer to test
- Returns:
- true if it's in use, otherwise false
- See Also:
IRenderer
getMaxTextureSize
public int getMaxTextureSize()
- Gets the maximum texture size that the current renderers support.
- Returns:
- the size
supports
public boolean supports(java.lang.String feature)
- Checks if a feature is supported by all the renderers of this
framebuffer.
- Parameters:
feature
- the feature that may be supported
- Returns:
- is the feature supported
- See Also:
SUPPORT_FOR_RGB_SCALING
,
SUPPORT_FOR_SHADOW_MAPPING
getSamplingMode
public int getSamplingMode()
- Returns the used sampling mode for this framebuffer.
- Returns:
- the sampling mode
- See Also:
SAMPLINGMODE_NORMAL
,
SAMPLINGMODE_OGSS
,
SAMPLINGMODE_OGSS_FAST
,
SAMPLINGMODE_OGUS
,
SAMPLINGMODE_HARDWARE_ONLY
,
SAMPLINGMODE_GL_AA_2X
,
SAMPLINGMODE_GL_AA_4X
getOutputWidth
public int getOutputWidth()
- Returns the width of the framebuffer. This method is called
getOutputWidth(), because it returns the actual width used for output
which is not always the internally used width.
- Returns:
- the width of the framebuffer
getOutputHeight
public int getOutputHeight()
- Returns the height of the framebuffer. This method is called
getOutputHeight(), because it returns the height actual used for output
which is not always the internally used height.
- Returns:
- the height of the framebuffer
getHeight
public int getHeight()
- The same as getOutputHeight(). Mainly here to increase compatibility with
jPCT-AE.
- Returns:
- the height
getWidth
public int getWidth()
- The same as getOutputWidth(). Mainly here to increase compatibility with
jPCT-AE.
- Returns:
- the width
getMiddleX
public float getMiddleX()
- Returns the x-coord of the midpoint of the framebuffer. This value
represents the internally used width/2.
- Returns:
- the x-coord
getMiddleY
public float getMiddleY()
- Returns the y-coord of the midpoint of the framebuffer. This value
represents the internally used height/2.
- Returns:
- the y-coord
setBoundingBoxMode
public void setBoundingBoxMode(boolean bmode)
- Sets the bounding box mode for the framebuffer. This has nothing to do
with 3d bounding boxes. The framebuffer's bounding box may help to speed
up blitting when parts of the framebuffer remain empty in a scene. It's
rather useless when doing indoor rendering. Default is BOUNDINGBOX_USED.
The bounding box is (apart from this setting) only used if the
framebuffer works with an MemoryImageSource. If it uses BufferedImage
(for JAVA2 or higher) and/or OpenGL support, the bounding box won't be
used at all.
- Parameters:
bmode
- the bounding box mode- See Also:
BOUNDINGBOX_NOT_USED
,
BOUNDINGBOX_USED
clear
public void clear()
- Clears the framebuffer, the optiZ-buffer, the hsr-buffer and the regular
z-buffer if required. Depending on the used configuration, not all of
these steps are required.
clearZBufferOnly
public void clearZBufferOnly()
- Clears only the ZBuffer, not the color buffer. Can be useful for special
effects like rendering two worlds into one frame buffer.
clearColorBufferOnly
public void clearColorBufferOnly(java.awt.Color col)
- Clears only the color bufferr, not the depth buffer.
- Parameters:
col
- the fill color
clear
public void clear(java.awt.Color col)
- Clears the framebuffer, the optiZ-buffer, the hsr-buffer and the regular
z-buffer if required. Depending on the used configuration, not all of
these steps are required. Addionally, the framebuffer is filled with the
given color.
- Parameters:
col
- the color the framebuffer is filled with
clear
public void clear(int rgb)
- The same as clear(<Color>) but with an int-value instead of a color
instance.
- Parameters:
rgb
- the color the framebuffer is filled with
update
public void update()
- Updates the output buffer of the framebuffer with the new data from the
backbuffer. This method should be called before actually displaying the
rendered image to make sure that the latest changes to the image are
recognized. Depending on the configuration, some post-processing may take
place here too.
setBufferAccess
public void setBufferAccess(int mode)
- When using the software renderer, the framebuffer can be accessed in
different ways. One is faster on one cpu/VM while the other may be faster
on another one. You may want to play around with this setting to get the
best possible performance on your system.
- Parameters:
mode
- the buffer access mode- See Also:
optimizeBufferAccess()
,
BUFFER_ACCESS_COMBINED
,
BUFFER_ACCESS_SPLITTED
optimizeBufferAccess
public void optimizeBufferAccess()
- This method tries to pick the most optimal buffer access mode for the
system jPCT is currently running on. This method will run for a second
and sets the buffer mode to the fastest possible based on that
measurement.
There are two problems with this: Hotspot may interfere and renders the
measurement useless and some VMs on some machines (like the 1.4.2 on a
P4HT) will start fast with method A but performance will drop after some
seconds (for whatever reason) and suddenly, method B would be (much!)
faster. This bug in some VMs (i assume that it is one) is the reason why
this method exists at all.
This method is useful for software rendering only.
- See Also:
setBufferAccess(int)
getOutputBuffer
public java.awt.Image getOutputBuffer()
- Returns the Image that represents the output-buffer of the framebuffer.
This could be used for further processing, displaying etc. It is meant as
an alternative to display(). One don't have to get this image from the
framebuffer every frame as it remains the same instance as long as the
framebuffer instance exists.
When using OpenGL only, this method is very slow because it requires
reads from VRAM. When using OpenGL and software rendering together (this
is not advised, but it's possible), this method returns the software
rendered buffer as if OpenGL wouldn't be used.
- Returns:
- the output image
- See Also:
display(java.awt.Graphics g)
getPixels
public int[] getPixels()
- Returns the raw pixel-data. This can be useful, if one wants to copy
parts of the FrameBuffer into an Image out of jPCT's focus. getPixels()
should be called after calling update(), because otherwise it is not
guaranteed that the returned array contains the most current pixels. If
you want to modify this array directly in your code (to apply some
post-processing for example) keep two things in mind: This is ugly (but
who cares...) and make sure to call refresh() afterwards. The returned
array contains the pixel-data in RGB-format and with no alpha
information.
When using OpenGL only, this method is very slow, because it has to read
all the pixels out of the VRAM and write them into the FrameBuffer's
internal pixel-buffer. When using OpenGL and software rendering together
(this is not advised, but it's possible), this method returns the
software rendered pixel-data as if OpenGL wouldn't be used.
- Returns:
- the pixels-array
- See Also:
update()
,
refresh()
,
blit(com.threed.jpct.Texture src, int srcX, int srcY, int destX,
int destY, int width, int height, boolean transparent)
,
blit(int[] src, int srcWidth, int srcHeight, int srcX, int srcY,
int destX, int destY, int width, int height, boolean transparent)
refresh
public void refresh()
- Forces the framebuffer to update its content with what's in the
pixels-array. This can be used to modify the framebuffer's content "from
the outside". If you are not modifying the pixels-array in your code,
there's no need to call this method.
Currently, this method works only when software rendering is being used.
- See Also:
getPixels()
resize
public void resize(int width,
int height)
- Does a resize of the FrameBuffer in case that the output window's size
has changed. This isn't supported by the software renderer ATM and will
be silently ignored if called for it.
- Parameters:
width
- the new widthheight
- the new height
getLock
public java.lang.Object getLock()
- Returns the lock object for the frame buffer. When using a multi threaded
renderer (like the AWTGLRenderer) in combination with dynamically
compiled objects, it is advised to synchronize changes to the object's
mesh data and/or texture data to this object to avoid to render inbetween
states of the changes.
If this is called on a frame buffer using a single threaded renderer, it
will return an Object too and you can still synchronize on it...just no
other code inside jPCT will.
- Returns:
- the lock object
getGraphics
public java.awt.Graphics getGraphics()
- Returns the Graphics object of the output buffer to allow the use of
JAVA's standard graphic methods on the rendered image (like drawString).
This works only for BufferedImage (using JAVA1.2 or higher) but not for
the MemoryImageSource that is used for JAVA1.1. In this case, null will
be returned. When using OpenGL support, this value is rather meaningless
(but still valid).
- Returns:
- the Graphics object (or null for MemoryImageSource)
getType
public int getType()
- Returns the type of this FrameBuffer. This value doesn't reflect the fact
that OpenGL is used or not.
- Returns:
- the type
- See Also:
MEMORYIMAGESOURCE
,
BUFFEREDIMAGE
blit
public void blit(Texture src,
int srcX,
int srcY,
int destX,
int destY,
int width,
int height,
boolean transparent)
- Copies a part of a bitmap (taken from a Texture in this case) into the
framebuffer. If you want your blitted content to lay on top of the
rendered image, it has to be applied after calling update() on the
buffer. This method is useful to copy 2D-GUI elements into the rendered
image (or for similar tasks). Blitting in OpenGL mode requires that the
current world has been rendered at least once into the framebuffer where
the blitting should be applied to (for doing some intialization work).
Usually, that shouldn't be a problem unless you are abusing jPCT as a
"blitting engine" only. When using OpenGL, be sure that the texture's
height is 2^x. Everything else might produce unpredictable results. This
method should be prefered over the int[]-array-blit whenever possible.
Some graphics cards/drivers are having problems when blitting using a
16bit z-buffer (albeit the z-buffer is not used for blitting). Have a
look at Config.glFixedBlitting for a workaround.
- Parameters:
src
- the texture that contains the source bitmapsrcX
- the starting x-position in the source bitmapsrcY
- the starting y-position in the source bitmapdestX
- the starting x-position in the destination bitmapdestY
- the starting y-position in the destination bitmapwidth
- the width of the region to copyheight
- the height of the region to copytransparent
- black (or at least almost black) pixels won't be copied if
this is set to TRANSPARENT_BLITTING. Any color-value which
leads to a result of zero when "anded" with #f0f0f0 will be
taken as black.- See Also:
TRANSPARENT_BLITTING
,
OPAQUE_BLITTING
,
Config.glFixedBlitting
blit
public void blit(Texture src,
int srcX,
int srcY,
int destX,
int destY,
int sourceWidth,
int sourceHeight,
int destWidth,
int destHeight,
int transValue,
boolean additive)
- Special version of blit() that allows for scaling, i.e. it doesn't make
1-to-1 copies but can up- or down-scale. In addition, it offers support
for transparency, a different blending mode and an additional color. If
you want your blitted content to lay on top of the rendered image, it has
to be applied after calling update() on the buffer. This method is useful
to copy 2D-GUI elements into the rendered image (or for similar tasks).
Blitting in OpenGL mode requires that the current world has been rendered
at least once into the framebuffer where the blitting should be applied
to (for doing some intialization work). Usually, that shouldn't be a
problem unless you are abusing jPCT as a "blitting engine" only. There is
no int[]-array-version of this method.
Using this method is quite to similar to using the Overlay-class. In
fact, using this method on a software rendered framebuffer results in an
Overlay being used internally. The difference is, that Overlay takes care
of itself and that it has a real depth.
Some graphics cards/drivers are having problems when blitting using a
16bit z-buffer (albeit the z-buffer is not used for blitting). Have a
look at Config.glFixedBlitting for a workaround.
- Parameters:
src
- the texture that contains the source bitmapsrcX
- the starting x-position in the source bitmapsrcY
- the starting y-position in the source bitmapdestX
- the starting x-position in the destination bitmapdestY
- the starting y-position in the destination bitmapsourceWidth
- the width of the source region to copysourceHeight
- the height of the source region to copydestWidth
- the width of the copied region in the destination bitmapdestHeight
- the height of the copied region in the destination bitmaptransValue
- the transparency value, -1 is none, 0 is highest transparency.
Higher values mean less transparency.additive
- if true, the blending is additive, otherwise default- See Also:
Config.glFixedBlitting
blit
public void blit(Texture src,
int srcX,
int srcY,
int destX,
int destY,
int sourceWidth,
int sourceHeight,
int destWidth,
int destHeight,
int transValue,
boolean additive,
java.awt.Color addColor)
- Special version of blit() that allows for scaling, i.e. it doesn't make
1-to-1 copies but can up- or down-scale. In addition, it offers support
for transparency, a different blending mode and an additional color. If
you want your blitted content to lay on top of the rendered image, it has
to be applied after calling update() on the buffer. This method is useful
to copy 2D-GUI elements into the rendered image (or for similar tasks).
Blitting in OpenGL mode requires that the current world has been rendered
at least once into the framebuffer where the blitting should be applied
to (for doing some intialization work). Usually, that shouldn't be a
problem unless you are abusing jPCT as a "blitting engine" only. There is
no int[]-array-version of this method.
Using this method is quite to similar to using the Overlay-class. In
fact, using this method on a software rendered framebuffer results in an
Overlay being used internally. The difference is, that Overlay takes care
of itself and that it has a real depth.
Some graphics cards/drivers are having problems when blitting using a
16bit z-buffer (albeit the z-buffer is not used for blitting). Have a
look at Config.glFixedBlitting for a workaround.
- Parameters:
src
- the texture that contains the source bitmapsrcX
- the starting x-position in the source bitmapsrcY
- the starting y-position in the source bitmapdestX
- the starting x-position in the destination bitmapdestY
- the starting y-position in the destination bitmapsourceWidth
- the width of the source region to copysourceHeight
- the height of the source region to copydestWidth
- the width of the copied region in the destination bitmapdestHeight
- the height of the copied region in the destination bitmaptransValue
- the transparency value, -1 is none, 0 is highest transparency.
Higher values mean less transparency.additive
- if true, the blending is additive, otherwise defaultaddColor
- an additional color. If null, Color.WHITE is taken instead- See Also:
Config.glFixedBlitting
blit
public void blit(Texture src,
int srcX,
int srcY,
int destX,
int destY,
int sourceWidth,
int sourceHeight,
int destWidth,
int destHeight,
int transValue,
boolean additive,
RGBColor addColor)
- Method to maintain compatibility with jPCT-AE. Functional identical to
the variant that takes java.awt.Color instead of RGBColor.
- Parameters:
src
- the texture that contains the source bitmapsrcX
- the starting x-position in the source bitmapsrcY
- the starting y-position in the source bitmapdestX
- the starting x-position in the destination bitmapdestY
- the starting y-position in the destination bitmapsourceWidth
- the width of the source region to copysourceHeight
- the height of the source region to copydestWidth
- the width of the copied region in the destination bitmapdestHeight
- the height of the copied region in the destination bitmaptransValue
- the transparency value, -1 is none, 0 is highest transparency.
Higher values mean less transparency.additive
- if true, the blending is additive, otherwise defaultaddColor
- an additional color. If null, RGBColor.WHITE is taken instead
blit
public void blit(int[] src,
int srcWidth,
int srcHeight,
int srcX,
int srcY,
int destX,
int destY,
int width,
int height,
boolean transparent)
- Copies a part of a bitmap (taken from an int[] containing pixels in
RGB-format and with no alpha) into the framebuffer. If you want your
blitted content to lay on top of the rendered image, it has to be applied
after calling update() on the buffer. Can be combined with getPixels() to
achieve some special effects with the framebuffer.
Blitting in OpenGL mode requires that the current world has been rendered
at least once into the framebuffer where the blitting should be applied
to (for doing some intialization work). Usually, that shouldn't be a
problem unless you are abusing jPCT as a "blitting engine" only. When in
OpenGL-mode, this method is very slow, because the int[] has to be
converted and uploaded to the graphics card every time. To avoid this in
some cases, Config.glUseIgnorantBlits can be set to true...but one should
be aware of the consequences. As a rule of thumb: If it's possible to
avoid this method and use a texture-based-blit instead...do it!
Some graphics cards/drivers are having problems when blitting using a
16bit z-buffer (albeit the z-buffer is not used for blitting). Have a
look at Config.glFixedBlitting for a workaround.
- Parameters:
src
- the int-array that contains the source bitmapsrcWidth
- the width of the source bitmapsrcHeight
- the height of the source bitmapsrcX
- the starting x-position in the source bitmapsrcY
- the starting y-position in the source bitmapdestX
- the starting x-position in the destination bitmapdestY
- the starting y-position in the destination bitmapwidth
- the width of the region to copyheight
- the height of the region to copytransparent
- black (or at least almost black) pixels won't be copied if
this is set to TRANSPARENT_BLITTING. Any color-value which
leads to a result of zero when "anded" with #f0f0f0 will be
taken as black.- See Also:
getPixels()
,
TRANSPARENT_BLITTING
,
OPAQUE_BLITTING
,
Config.glUseIgnorantBlits
,
Config.glFixedBlitting
display
public void display(java.awt.Graphics g)
- Displays the output Image onto the component with the given Graphics
context. If one wants to have further control about the drawing,
getOutputBuffer() can be used instead.
- Parameters:
g
- the Graphics context of the compontent onto which the Image
should be drawn (ignored when using OpenGL only)- See Also:
getOutputBuffer()
display
public void display(java.awt.Graphics g,
int yOffset)
- Displays the output Image onto the component with the given Graphics
context. If one wants to have further control about the drawing,
getOutputBuffer() can be used instead.
- Parameters:
g
- the Graphics context of the compontent onto which the Image
should be drawn (ignored when using OpenGL only)yOffset
- the offset in y-direction (ignored when using OpenGL)- See Also:
getOutputBuffer()
display
public void display(java.awt.Graphics g,
int xOffset,
int yOffset)
- Displays the output Image onto the component with the given Graphics
context. If one wants to have further control about the drawing,
getOutputBuffer() can be used instead.
- Parameters:
g
- the Graphics context of the compontent onto which the Image
should be drawn (ignored when using OpenGL only)xOffset
- the offset in x-direction (ignored when using OpenGL)yOffset
- the offset in y-direction (ignored when using OpenGL)- See Also:
getOutputBuffer()
displayGLOnly
public void displayGLOnly()
- Displays the output image produced by OpenGL compatible hardware if
OpenGL rendering is in use. If a software renderer is enabled, this
method will print out a warning message only. It's not required to
display the OpenGL rendered image by using this method, the normal
display()-method will work too, but the Graphics parameter will be
ignored in this case (can even be null).
display
public void display()
- The same as displayGLOnly. This method exists for compatibility with
jPCT-AE.
setClippingPlane
public void setClippingPlane(int number,
Plane plane)
- Sets an additional clipping plane. This will show an effect only if a
hardware renderer has been enabled. The plane has to be defined in camera
space.
- Parameters:
number
- the number of the clipping plane (0..5)plane
- the plane
removeClippingPlane
public void removeClippingPlane(int number)
- Removes an additional clipping plane.
- Parameters:
number
- the number of the plane
sync
public void sync()
- Does nothing. This method exists only for increased compatibility with
jPCT-AE.
flush
public void flush()
- Does nothing. This method exists only for increased compatibility with
jPCT-AE.


@ARTICLE{shi_tmm18, author={L. {Shi} and B. {Chen} and S. {Huang} and A. O. {Larin} and O. S. {Seredin} and A. V. {Kopylov} and S. {Kuo}}, journal={IEEE Transactions on Multimedia}, title={Removing Haze Particles From Single Image via Exponential Inference With Support Vector Data Description}, year={2018}, volume={20}, number={9}, pages={2503-2512}, keywords={image colour analysis;image enhancement;image restoration;particle swarm optimisation;support vector data description;outdoor images;hazy conditions;medium transmission;atmospheric light;atmospheric scattering model;single-image dehazing;exponential inference model;haze density estimation model;turbulent particle swarm optimization technique;haze particles;qualitative evaluations;quantitative evaluations;single haze image;universal atmospheric-light extractor;haze removal methods;Atmospheric modeling;Scattering;Estimation;Image color analysis;Image restoration;Computer science;Atmospheric lights;haze removal;underexposed effects}, doi={10.1109/TMM.2018.2807593}, ISSN={1941-0077}, month={Sep.},}