Jump to content


Photo

3d terrain generation trouble


  • Please log in to reply
1 reply to this topic

#1 joelmaxw311

joelmaxw311

    GMC Member

  • New Member
  • 2 posts
  • Version:Unknown

Posted 02 April 2012 - 11:38 PM

I've been trying to generate terrain in 3d for awhile and i just can't seem to get it to work.
My most recent attempt uses the following code:
Create Event:

execute code:

global.ter = ds_grid_create(room_width,room_height)
ee = random_range(20,30)
{e = (ee*32)}
slope = choose(-8,0,8)

//initial generation
for(b = 0;b < room_height;b+= 512){
for(a = 0;a < room_width;a += 32){
ds_grid_set(global.ter,a,b,e)
e += slope
slope += choose(-8,0,8)}}

//filling in terrain
a = 0
b = 0
for(a = 0;a < room_width;a += 32)
n = ds_grid_get(global.ter,a,b)
m = ds_grid_get(global.ter,a,b+512)
s = (m/512)
val = n+s
for(set = 32;set < 480;set += 32){
ds_grid_set(global.ter,a,set,val)
val += s}
alarm[0] = 1

Alarm Event for alarm 0:

execute code:

for(j = 0;j < room_width;j += 32){
for(k = 0; k < 512;k += 32){
instance_create(j,k,obj_block)}}


Obj_block:
Create Event:

execute code:

z = ds_grid_get_disk_max(global.ter,x+16,y+16,16)
if (!z =0)
draw_set_alpha(1/z)

Can anybody tell me how to fix this or give me an example or something? Because nothing i try has been working.
  • 0

#2 hit172

hit172

    GMC Member

  • New Member
  • 189 posts
  • Version:GM8

Posted 03 April 2012 - 12:44 AM

I've been trying to generate terrain in 3d for awhile and i just can't seem to get it to work.
My most recent attempt uses the following code:

Create Event:

execute code:

global.ter = ds_grid_create(room_width,room_height)
ee = random_range(20,30)
{e = (ee*32)}
slope = choose(-8,0,8)

//initial generation
for(b = 0;b < room_height;b+= 512){
for(a = 0;a < room_width;a += 32){
ds_grid_set(global.ter,a,b,e)
e += slope
slope += choose(-8,0,8)}}

//filling in terrain
a = 0
b = 0
for(a = 0;a < room_width;a += 32)
n = ds_grid_get(global.ter,a,b)
m = ds_grid_get(global.ter,a,b+512)
s = (m/512)
val = n+s
for(set = 32;set < 480;set += 32){
ds_grid_set(global.ter,a,set,val)
val += s}
alarm[0] = 1

Alarm Event for alarm 0:

execute code:

for(j = 0;j < room_width;j += 32){
for(k = 0; k < 512;k += 32){
instance_create(j,k,obj_block)}}


Obj_block:
Create Event:

execute code:

z = ds_grid_get_disk_max(global.ter,x+16,y+16,16)
if (!z =0)
draw_set_alpha(1/z)

Can anybody tell me how to fix this or give me an example or something? Because nothing i try has been working.


I wish people these days knew what google was......
tutorial link
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users