|
|
Hi Thorsten,
in order to implement my idea I've modified Parse_Pattern() in parstxtr.cpp
in order to recognize the keyword "power" followed by two floats Power_Val1
e Power_Val2 (added in TPATTERN struct). So there is a new POWER_TOKEN and a
new POWER_PATTERN.
In case of POWER_PATTERN I do the following:
DBL Evaluate_TPat ( ...) {
...
switch (TPat->Type) {
...
case POWER_PATTERN: value = power_pattern ( EPoint, TPat,
Isection->Object); break;
...
}
}
Here power_pattern is defined as follows:
DBL power_pattern ( VECTOR EPoint, TPATTERN* TPat, OBJECT *Object ). This
new function do the following:
1 - If EPoing is inside Object return zero, otherwise go on.
2 - Apply sampling to find the minimal distanze of EPoint from the surface
(I've cabled 100 samples at the moment); let's call Mdist this distance.
3 - Find the maximum between Object->BBox.Lengths[X],
Object->BBox.Lengths[Y] and Object->BBox.Lengths[X]; let's call Lmax this
value.
4 - Mdist = Midst / Lmax (in order to have a value in the range 0..1)
5 - return (TPat->Vals.Power_Val1 * pow (Mdist, TPat->Vals.Power_Val2) )
Now I explain what I'de like to obtain through an example:
density {
power 1 2
...
}
So density grows following the distance...
My question are:
1-Must the values assigned to value in Evaluate_TPat always be in the range
0..1?
2-Is step 4 necessary accordin to you?
3-Any suggestions? :-/
Antonio Ferrari
Post a reply to this message
|
|