2 registered members (Akow, tomaslolo),
1,536
guests, and 12
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Re: flying leaf ...
[Re: pegamode]
#298603
11/16/09 11:10
11/16/09 11:10
|
Joined: Feb 2006
Posts: 1,011 Germany
pegamode
OP
Serious User
|
OP
Serious User
Joined: Feb 2006
Posts: 1,011
Germany
|
I have a code that randomly generates wind and stores it into a variable that holds the wind strength (w_speed_current) and a vector for the wind direction (d_direction_current). Then I wrote this little test-script:
action leaf() {
my.flags |= FLAG2;
var accUp = 0;
var accDown = -0.5;
while(me) {
if (w_speed_current > 0.3) {
accUp = w_speed_current * 2;
my.roll += 2;
my.tilt += 5;
} else {
if (w_speed_current > 0) {
my.roll += 2;
my.tilt += 5;
} else {
my.tilt = 90;
}
accUp = 0;
}
vec_to_angle(my.pan, d_direction_current);
accDown = -0.5 - random(1);
c_move(me, vector((d_direction_current.x+random(2))*w_speed_current*0.5, (d_direction_current.y+random(2))*w_speed_current*0.5, accUp),vector(0,0,accDown), IGNORE_PASSABLE | IGNORE_PASSENTS | GLIDE);
wait(1);
}
}
Has someone an idea or hints how to make it look a bit more realistic? Regards, Pegamode.
|
|
|
Re: flying leaf ...
[Re: pegamode]
#298813
11/18/09 06:59
11/18/09 06:59
|
Joined: Jun 2004
Posts: 2,234 Wisconsin USA
FoxHound
Expert
|
Expert
Joined: Jun 2004
Posts: 2,234
Wisconsin USA
|
Just have the leaves rotate and base how fast off of how fast the wind is. Without looking at your script to much it looks pretty good and you should be able to pull this off.
--------------------- There is no signature here.
QUIT LOOKING FOR ONE!
|
|
|
Re: flying leaf ...
[Re: pegamode]
#298901
11/18/09 22:13
11/18/09 22:13
|
Joined: Jun 2004
Posts: 2,234 Wisconsin USA
FoxHound
Expert
|
Expert
Joined: Jun 2004
Posts: 2,234
Wisconsin USA
|
way to complicated. When the wind stops, and wind doesn't really stop it slows own to a still, just have the leave lose it's Z and go toward the earth in the same direction it was going. throw in some random left and right and you should do fine.
--------------------- There is no signature here.
QUIT LOOKING FOR ONE!
|
|
|
Re: flying leaf ...
[Re: FoxHound]
#298976
11/19/09 21:41
11/19/09 21:41
|
Joined: Feb 2006
Posts: 1,011 Germany
pegamode
OP
Serious User
|
OP
Serious User
Joined: Feb 2006
Posts: 1,011
Germany
|
This code works quite good for me:
action leaf() {
my.flags |= FLAG2;
my.push = -100;
var accUp = 0;
var accDown = -0.5;
var distDown = 0;
trace_mode = IGNORE_ME + IGNORE_PASSABLE + IGNORE_PASSENTS;
VECTOR vDirection;
VECTOR vDistance;
VECTOR vDifference;
ANGLE targetPan;
vec_set(vDirection, vector(0,0,0));
vec_set(vDistance, vector(0,0,0));
vec_set(vDifference, vector(0,0,0));
while(me) {
vec_diff(vDifference, vDirection, d_direction_current);
vec_accelerate(vDistance, vDirection, vDifference, 2.5);
distDown = c_trace(my.x,vector(my.x,my.y,my.z-1000),trace_mode);
if (w_speed_current > 0) {
if (w_speed_current > 0.5) {
accUp = w_speed_current * 2 * time_step;
my.roll += 5 * time_step;
my.tilt += 8 * time_step;
} else {
my.roll += w_speed_current * 10 * time_step;
my.tilt += w_speed_current * 10 * time_step;
accUp = 0;
}
} else {
if (my.tilt < 0) {
if (0 - my.tilt - 5 > 5) {
my.tilt += 5 * time_step;
} else {
my.tilt = 0;
}
} else {
if (0 - my.tilt + 5 < 5) {
my.tilt -= 5 * time_step;
} else {
my.tilt = 0;
}
}
if (my.roll < 90) {
if (80 - my.roll - 5 > 5) {
my.roll += 5 * time_step;
} else {
my.roll = 0;
}
} else {
if (90 - my.roll + 5 < 5) {
my.roll -= 5 * time_step;
} else {
my.roll = 0;
}
}
}
vec_to_angle(targetPan, d_direction_current);
if (my.pan < targetPan.pan) {
if (targetPan.pan - my.pan > 5) {
my.pan += 5 * time_step;
} else {
my.pan = targetPan.pan;
}
} else {
if (targetPan.pan - my.pan < 5) {
my.pan -= 5 * time_step;
} else {
my.pan = targetPan.pan;
}
}
accDown = accUp - 0.2 - random(0.5) * time_step;
if (distDown < 0.4) {
accDown = 0;
}
c_move(me, vDistance, vector(0,0,accDown), IGNORE_PASSABLE | IGNORE_PASSENTS | GLIDE);
wait(1);
}
}
I'll refactor this later on.
|
|
|
Re: flying leaf ...
[Re: pegamode]
#299006
11/20/09 07:00
11/20/09 07:00
|
Joined: Oct 2004
Posts: 1,655
testDummy
Serious User
|
Serious User
Joined: Oct 2004
Posts: 1,655
|
Quoting pegamode. This code works quite good for me: For how many leaves?
|
|
|
|