Jump to content


Photo

Easy Heightmap Scripts


  • Please log in to reply
42 replies to this topic

#21 KurtBlissZ

KurtBlissZ

    GMC noob

  • GMC Member
  • 500 posts
  • Version:Unknown

Posted 07 July 2010 - 11:01 PM

Im not getting the terrain to popup at all. just the sprite on the top left corner. Can anyone help me?
  • 0

#22 brett14

brett14

    GMC Member

  • GMC Member
  • 1150 posts
  • Version:GM8

Posted 10 July 2010 - 10:27 PM

My guess is it's a depth issue. Can't help you without you providing an example, sorry.

~~Brett14;
  • 0

#23 KurtBlissZ

KurtBlissZ

    GMC noob

  • GMC Member
  • 500 posts
  • Version:Unknown

Posted 10 July 2010 - 10:54 PM

opps I had to wait for a little bit. sorry I'm a retard.

Edited by kurtbliss, 10 July 2010 - 11:08 PM.

  • 0

#24 brett14

brett14

    GMC Member

  • GMC Member
  • 1150 posts
  • Version:GM8

Posted 11 July 2010 - 09:10 PM

You can save the grid with ds_grid_write(); and write that string to a file, and then read it from a file to generate the heightmap. It's much faster at loading then turning the heightmap into a grid and then turning the grid into a model (Almost instant vs a couple seconds)
  • 0

#25 whiteshadow

whiteshadow

    GMC Member

  • New Member
  • 29 posts
  • Version:GM8

Posted 02 November 2010 - 11:07 AM

this is an awsome engine. im going to use it in my game and credit will be given. there is a problem sometimes the player is lower than it should and sometimes it is higher. i dont klnow if it is from my programing or this. thanks anyway
  • 0

#26 brett14

brett14

    GMC Member

  • GMC Member
  • 1150 posts
  • Version:GM8

Posted 02 November 2010 - 11:10 PM

there is a problem sometimes the player is lower than it should and sometimes it is higher

This is probably your programming because it mathematically returns the correct Z values on the terrain based on the X,Y positions
  • 0

#27 whiteshadow

whiteshadow

    GMC Member

  • New Member
  • 29 posts
  • Version:GM8

Posted 03 November 2010 - 08:28 AM

there is a problem sometimes the player is lower than it should and sometimes it is higher

This is probably your programming because it mathematically returns the correct Z values on the terrain based on the X,Y positions


i have an object that has the get z script in the create event an is sometimes drawn below the terrain or its sometimes floating. do you know why and could you possibly run me throught the ds_grid_write. thanks

Edited by whiteshadow, 03 November 2010 - 08:38 AM.

  • 0

#28 brett14

brett14

    GMC Member

  • GMC Member
  • 1150 posts
  • Version:GM8

Posted 03 November 2010 - 11:02 PM

I can't help you without some code. Either upload the buggy code, or PM me the .gmk. HOWEVER - I'll be gone for 3 days so it may be a while for you to get the result.
  • 0

#29 programmmer5

programmmer5

    GMC Member

  • GMC Member
  • 363 posts

Posted 06 November 2010 - 05:04 PM

this is great
and it would be better if you added shadows and multiple textures
this is awsome
and hope you can update it ::lmao::
  • 0

#30 programmmer5

programmmer5

    GMC Member

  • GMC Member
  • 363 posts

Posted 30 November 2010 - 12:50 PM

hey i cant place any of my models in this example
they all end up near the position (0;0) :P

first i thought that the terrain was way bigger than the room (witch it was)
and corected it by shrinking down the size of the terrain to the room size, but it still
ends up in the same position.

and when i try to make my models appear on the higher parts of the terrain by using your code
z=terrain_get_z(x,y);
it creates at the moast random x values. :wacko:

and lastly how do you change the z value of the player to the terrain? :blink:
  • 0

#31 brett14

brett14

    GMC Member

  • GMC Member
  • 1150 posts
  • Version:GM8

Posted 01 December 2010 - 12:51 AM

same problem as the last person, I can't help you without you supplying code. Chances are (judging by the random X values) you acidently are creating it at
instance_create(terrain_get_z(x,y),y,instance);
however that is a complete guess.

and lastly how do you change the z value of the player to the terrain? :blink:

z=terrain_get_z(x,y);
and in you're projection code put the zfrom variable to either z or z+(how tall the player is). Put the zto variable to the same thing as zfrom +/- your zdirection


hey i cant place any of my models in this example

You should really use an editor MADE for 3D to do this, not the built in 2D editor for gamemaker. There have been many made (just search for some) and I too have made a couple (Editor14, Dark Region)

Edited by brett14, 01 December 2010 - 12:54 AM.

  • 0

#32 monstrous123

monstrous123

    GMC Member

  • New Member
  • 1 posts

Posted 14 December 2010 - 06:18 PM

Cheers it was really quick and easy to use :) - is there any way i can stretch one large texture over the whole map though? I've seen it done before and it would be perfect for my game... Any ideas?
  • 0

#33 brett14

brett14

    GMC Member

  • GMC Member
  • 1150 posts
  • Version:GM8

Posted 15 December 2010 - 01:46 AM

read the first post.
  • 0

#34 dohyung97022

dohyung97022

    GMC Member

  • New Member
  • 2 posts

Posted 26 January 2011 - 11:52 PM

When this game goes to another room, it makes all the stuff in variable y upsied down.
What is the variable in one of your script that makes it happen??
(When it goes to a 2d demention room);

Edited by dohyung97022, 27 January 2011 - 12:00 AM.

  • 0

#35 Venomous

Venomous

    GMC Member

  • GMC Member
  • 1479 posts
  • Version:GM:Studio

Posted 27 January 2011 - 12:05 AM

When this game goes to another room, it makes all the stuff in variable y upsied down.
What is the variable in one of your script that makes it happen??
(When it goes to a 2d demention room);

Call d3d_end().
As long as 3d mode is on, 2d rooms will be drawn upside down.

Edited by XtraButter, 27 January 2011 - 12:44 AM.

  • 0

#36 brett14

brett14

    GMC Member

  • GMC Member
  • 1150 posts
  • Version:GM8

Posted 27 January 2011 - 01:00 AM

It is not my scripts, its due to the fact the 3D mode is turned on. When 3D is turned of the view gets flipped. Call d3d_end.

Edited by brett14, 27 January 2011 - 01:01 AM.

  • 0

#37 dohyung97022

dohyung97022

    GMC Member

  • New Member
  • 2 posts

Posted 27 January 2011 - 09:10 AM

WOW
this was simple...
I thought this happened because of the scripts...

Have my Thanks!
  • 0

#38 GS-games

GS-games

    Creative

  • GMC Member
  • 328 posts
  • Version:GM:Studio

Posted 17 February 2012 - 05:58 PM

Works nice, but how do I change the texture repeats within the model?Posted Image

Edited by GS-games, 10 February 2013 - 11:51 AM.

  • 0

#39 aburgin

aburgin

    GMC Member

  • New Member
  • 46 posts
  • Version:GM8

Posted 23 February 2012 - 05:49 PM

Greetings !!

to Brett14....

I love the work here, but there is an issue. It appears that for some reason, when changing rooms, the terrain is not fully regenerated. It appears the height map array is inverted or changed with random numbers.

As an example I used your demo (which is great)... but if you add a second room that is a duplicate of the first room (except use a different texture map) and program the "F" and "B" keys to from room to room, the array is not re-generated, as you would expect. It appears corrupted (?!?).

I've noted, in GM8x, you can use the "persistence" check box to keep the terrain the same, except then the global terrain array is kept the same through all rooms. The texture doesn't change as it should.

Any Ideas ?????

nope... not using d3d_end()

I tried playing with d3d_start() in the terrain object, but that yields a flat texture map.

Maybe the question is....... How do I make the room re-load the terrain as it does on first load. Do I need to destroy the array in memory ?? ... load the height map and texture from file ??

What am I missing ????

yes, I have created a GM8 file, if needed.

Edited by aburgin, 23 February 2012 - 11:12 PM.

  • 0

#40 denton

denton

    GMC Member

  • GMC Member
  • 35 posts
  • Version:Unknown

Posted 04 November 2012 - 11:23 AM

Greetings !!

to Brett14....

I love the work here, but there is an issue. It appears that for some reason, when changing rooms, the terrain is not fully regenerated. It appears the height map array is inverted or changed with random numbers.

As an example I used your demo (which is great)... but if you add a second room that is a duplicate of the first room (except use a different texture map) and program the "F" and "B" keys to from room to room, the array is not re-generated, as you would expect. It appears corrupted (?!?).

I've noted, in GM8x, you can use the "persistence" check box to keep the terrain the same, except then the global terrain array is kept the same through all rooms. The texture doesn't change as it should.

Any Ideas ?????

nope... not using d3d_end()

I tried playing with d3d_start() in the terrain object, but that yields a flat texture map.

Maybe the question is....... How do I make the room re-load the terrain as it does on first load. Do I need to destroy the array in memory ?? ... load the height map and texture from file ??

What am I missing ????

yes, I have created a GM8 file, if needed.



Yeah I'm having the same problem, I got around it by just making the heightmap massive and just keeping it persistent. but now i need to do something that requires me to have more terrains, Did anyone figure this out?
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users