0 registered members (),
1,397
guests, and 7
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Creating a Basic Shoreline with Script (WDL)
#311001
02/18/10 05:27
02/18/10 05:27
|
Joined: Jan 2006
Posts: 245 PA
Garrettwademan
OP
Member
|
OP
Member
Joined: Jan 2006
Posts: 245
PA
|
I figured this would be right place to put this topic. I was looking for a way to make a real basic shoreline effect on my terrain where it meets the ocean/water, here is what I came up with. I am doing a simple scan on the map to find the edges and where there should be some white water. You can download the code and TGA file I used for this script. You can of course improve on this if you wish. If used efficiently, it won't tax your system to much. I found if you abuse it, it can drop the FPS of your game fairly quick. Well, here is the poor man's shoreline info. Hope you find a place to use this. http://www.garrettwademan.com/3dgs/shoreline/shoreline.zipHere are the two functions I used, just adjust the variables and call "find_shore_line".
function wave_control(){
my.transparent = on; //Make shore line a transparent
my.red = 255; //Adjust colors, this may not do anything depending on which water you are using
my.blue = 255;
my.green = 255;
my.tilt += 90; //Tilt the TGA file so it is flat
my.bright = on; //Add brightness to the TGA file
my.ambient = 100; //Ambient look
my.albedo = 100; //Albedo look
while(1){
wait(random(50)); //Add some random wait time so it doesn't look syncronized
my.scale_x = 0.5; //Start scale at half size, you can adjust this to your needs
my.scale_y = my.scale_x;
my.alpha = 100; //Start out as 100 alpha value, change this to your needs
while(my.scale_x < 10){ //Go until the size = 10, adjust this to your needs
my.alpha -= 0.3; //How fast this TGA shore line fades
my.scale_x += 0.03; //Make the shore line effect larger as time goes on
my.scale_y = my.scale_x;
wait(1);
}
wait(1);
}
}
function find_shore_line(){
var start_x = 0;
var start_y = 0;
var height = 0;
var old_height = 0;
start_x = 0; //This is where you want to start scanning, this should be on the corner of your map at the lowest value
start_y = 0; //Same as above, except on the y axis
while(start_x < 80000){ //Set this number "80000" to the max scan on the X axis
while(start_y <= 15000){ //Set this number "15000" to the max scan on the Y axis
old_height = height; //Take note of the old height checked
//For the code below, start scane for height of water line. The 1975 will be 25 quants above the water line and 1950 is the
//water line itself, you can adjust the 1975 to a number just right above your water line, and 1950 to your water line or just
//1 or 2 quants below water line, up to you
height -= c_trace(vector(start_x,start_y,1975), vector(start_x,start_y,1950), ignore_sprites + ignore_passable + ignore_flag2 + ignore_models);
if(old_height != height){ //If this scan senses a change in height because start of terrain, execute below code
ent_create("shore.tga",vector((start_x + 0),start_y,1950.5), wave_control); //Create the shoreline, only change the 1950 to match your water level
old_height = 1950; //Reset the old height to your water line
height = 0; //Reset your height check
}
start_y += 100; //This will scan every 100 quants on the Y axis
}
start_x += 100; //This will scane every 100 quants on the X axes
start_y = 0; //Reset the Y scan to begin over again using a different vector
wait(1);
}
}
Last edited by Garrettwademan; 02/18/10 05:30.
|
|
|
Re: Creating a Basic Shoreline with Script (WDL)
[Re: Garrettwademan]
#311065
02/18/10 14:12
02/18/10 14:12
|
Joined: Jan 2006
Posts: 2,157 Connecticut, USA
Blink
Expert
|
Expert
Joined: Jan 2006
Posts: 2,157
Connecticut, USA
|
Awesome contribution! I am glad to see you are still at it! your pesistance gives me hope, maybe one day i can finish my project.
My Famous Quotes: "Hip hop is like a virus, infecting everyone and everything around it. Every form of media has some way,shape or form, assimilated hip hop into it." It has also mutated into other strains like, trip hop, house, rap, gangster, and conscious forms. Once you are infected with it, its with you for life."
|
|
|
Re: Creating a Basic Shoreline with Script (WDL)
[Re: mikaldinho]
#311145
02/18/10 17:43
02/18/10 17:43
|
Joined: Jan 2006
Posts: 2,157 Connecticut, USA
Blink
Expert
|
Expert
Joined: Jan 2006
Posts: 2,157
Connecticut, USA
|
Good luck! I am looking forward to seeing the results.
My Famous Quotes: "Hip hop is like a virus, infecting everyone and everything around it. Every form of media has some way,shape or form, assimilated hip hop into it." It has also mutated into other strains like, trip hop, house, rap, gangster, and conscious forms. Once you are infected with it, its with you for life."
|
|
|
Re: Creating a Basic Shoreline with Script (WDL)
[Re: Garrettwademan]
#311536
02/20/10 13:08
02/20/10 13:08
|
Joined: Jan 2006
Posts: 2,157 Connecticut, USA
Blink
Expert
|
Expert
Joined: Jan 2006
Posts: 2,157
Connecticut, USA
|
i was talking to garrett.
My Famous Quotes: "Hip hop is like a virus, infecting everyone and everything around it. Every form of media has some way,shape or form, assimilated hip hop into it." It has also mutated into other strains like, trip hop, house, rap, gangster, and conscious forms. Once you are infected with it, its with you for life."
|
|
|
|