---- EN --------------------------------------------------------------------------------------------------------------------------------
Digital-Human is a two-layer model that simulates the behavior of the human body in its surrounding environment.
Lets define and add new body organs and environmental components.
Digital-Human is a set of classes based on a Observer patern, you can use to build a model of man and the environment surrounding it.
Human model responds to changes in environmental parameters. A body may also generate events that affect the environment. This model is bidirectional.
A set of classes allows for the extension of the body by adding new elements/organs. Each element is an appropriate class that represents a new organ. The Authority responds to external stimuli and introduces a method catchEnviroment (EnviromentElement $element), which should support provided to it an element of the environment.
Example Class body is Ear. Each such class should inherit from the class element, and must implement the interface IObserver.
A set of classes allows for the extension of the layer of the environment. Part of the environment is a class which should include a method responsible for the conduct of the environmental component. It should inherit from class EnviromentElement. An example of a class of environment is sound element, which contains a method emitSound ().
By default, Digital-Human consists of a head, eyes, ears, nose and mouth. Each of them responds to stimuli from the environment (eg ear responds to sound), and emits the same thing for the environment (mouth emit sound).
How to add new body organ (Nose)
--------------------------------
1.) Create new class
class Nose extends Element implements IObserver {
}
2) Create method is responsible for responding to changes in the environment
public function catchEnviroment(EnviromentElement $element) {
if($element instanceof Smell) {
echo '<br />NOSE: Smell received: "'.$element->smellKind.'"'.'Volume: '.$element->volume;
}
}
3) In main program code block (here: index.php)
$enviroment = new Enviroment();
$human = new DefaultBody($enviroment);
$nose = new Nose();
$human->addBodyElement($nose);
By default, the components of the environment are such as sound, light, smell. Emit any of them can cause the body's response to it.
Adding a component of the environment (Smell)
---------------------------------------------
1) Create new class:
class Smell extends EnviromentElement {
public $smellKind = '';
public $volume = 10;
}
2) Create a method that will emit smell
public function emitSmell($smellKind, $volume = 10) {
$this->smellKind = $smellKind;
$this->volume = $volume;
$this->notifyEnviroment(); //!!important
}
3) In main program code block (here: index.php)
$envSmell = new Smell($enviroment);
$envSmell->emitSmell('Rose', 3);
It's all have fun! :)
----- PL --------------------------------------------------------------------------------------------------------------------------------
Digital-Human jest modelem dwuwarstwowym symulujÄ
cym zachowanie organizmu czÅowieka w otaczajÄ
cym go Årodowisku. Pozwala defniowaÄ i dodawaÄ nowe organy i elementy Årodowiska.
Digital-Human jest zestawem klas bazujÄ
cym na wzorcu obserwator, za pomocÄ
którego można zbudowaÄ model czÅowieka i Årodowiska go otaczajÄ
cego.
Model czÅowieka reaguje na zmiany parametrów Årodowiska. CzÅowiek również może generowaÄ zdarzenia majÄ
ce wpÅyw na Årodowisko. Jest to model dwukierunkowy.
Zestaw klas pozwala na rozbudowÄ organizmu/ciaÅa poprzez dodawanie nowych elementów. Każdy element jest odpowiedniÄ
klasÄ
reprezentujÄ
cÄ
nowy organ. Organ reaguje na bodźce zewnÄtrzne implementujÄ
c metodÄ catchEnviroment(EnviromentElement $element), która powinna obsÅugiwaÄ dostarczony jej element Årodowiska.
PrzykÅadowa klasa organu to Ear. Każda taka klasa powinna dziedziczyÄ z klasy Element i musi implementowaÄ interfejs IObserver.
Zestaw klas pozwala na rozbudowÄ warstwy Årodowiska. Elementem Årodowiska jest jest klasa, która powinna zawieraÄ metody odpowiadajÄ
ce za zachowanie danego skÅadnika Årodowiska. Powinna dziedziczyÄ po klasie EnviromentElement. PrzykÅadowa klasa elementu Årodowiska to Sound, która zawiera metodÄ emitSound().
DomyÅlnie DH skÅada siÄ z gÅowy, oczu, uszu, nosa i ust. Każdy z nich reaguje na bodźce pochodzÄ
ce ze Årodowiska (np ucho reaguje na dźwiÄk) lub sama emitujÄ
coÅ do Årodowiska (usta emitujÄ
dźwiÄk)
Dodanie organu np: Nose
1) UtworzyÄ nowÄ
klasÄ:
class Nose extends Element implements IObserver {
}
2) UtworzyÄ metodÄ odpowiedzialnÄ
za reakcjÄ na zmiany w Årodowisku:
public function catchEnviroment(EnviromentElement $element) {
if($element instanceof Smell) {
echo '<br />NOSE: Smell received: "'.$element->smellKind.'"'.'Volume: '.$element->volume;
}
}
3) W gÅównym bloku kodu (tutaj: index.php)
$enviroment = new Enviroment();
$human = new DefaultBody($enviroment);
$nose = new Nose();
$human->addBodyElement($nose);
W zestawie istniejÄ
takie skÅadniki Årodowiska jak: dźwiÄk, ÅwiatÅo, zapach. Wyemitowanie któregoÅ z nich może spowodowaÄ reakcjÄ elementu organizmu
Dodanie skÅadnika Årodowiska np smell:
1) UtworzyÄ nowÄ
klasÄ:
class Smell extends EnviromentElement {
public $smellKind = '';
public $volume = 10;
}
2) UtworzyÄ metodÄ, która bÄdzie emitowaÅa zapach
public function emitSmell($smellKind, $volume = 10) {
$this->smellKind = $smellKind;
$this->volume = $volume;
$this->notifyEnviroment(); //!!important
}
3) W gÅównym bloku kodu (u nas index.php)
$envSmell = new Smell($enviroment);
$envSmell->emitSmell('Rose', 3);
MiÅej zabawy :)