Twisted Inspiration

Posted by Xemrel on March 23, 2006, 12:45 a.m.

Well… Inspired by twisterghost, anyway. When he started putting up landscape renders (from TerraGen, I assume), it made me want to make something similar. Not with TerraGen, though. Here's a screenshot from my most recently started project. It's not up to the level of TerraGen, or anything, but hey, I did it in Game Maker, and it's my first attempt at using the 3D capabilities.

<img src="http://64digits.com/users/TaleriaKNT/sampTerrain.jpg">

I'm still working on per vertex shading, so light falls on the terrain smoothly, but it's annoying, since GM has no support for data structures. Once I get that (and a few other tidbits) working, I plan on releasing the GM6 file. Oh, and for anyone who doesn't realize it, this is the power of Perlin Noise, as demonstrated more simply in <a href="http://64digits.com/games/index.php?cmd=view_game&id=497" style="text-decoration:underline">this example</a>.

Comments

membrain 18 years, 9 months ago

I'm confused… the screeny looks cool… especialy considering its in GM.

Is it the terrain thats generated via PerlinNoise? Or is that a sprite? I'm very curious about this… Looks to be this PerlinNoise would indeed be useful in GM.

Xemrel 18 years, 9 months ago

What you see there is a few thousand polygons created from a height map that is generated in real-time from Perlin Noise, though it's not so real-time once the quality level is turned up, since there <i>is</i> alot of calculation to do. The only sprite in the whole program is a texture used to control what color different heights should be. For instance, here it's tan, then green, then brown. Hopefully that clears it up?

melee-master 18 years, 9 months ago

Wow, that's a really for something in Game Maker. That Perlin Noise appears quite useful…

Quote:

but it's annoying, since GM has no support for data structures

Unless you're talking about something else, GM <i>does</i> support data structures. It has a whole ton of functions for them:

Quote:

This functionality is only available in the registered version of Game Maker.

In games you often need to store information. For example you need to store lists of items that a person carries or you want to store places that still need to be visited. You can use the arrays for this. But if you want to do more complicated operations, like sorting the data or searching for a particular item, you need to write large pieces of GML code which can be slow to execute.

To remedy this, Game Maker has a number of built-in data structures that can be accessed through functions. At the moment there are six different types of data structure available: stacks, queues, lists, maps, priority queues, and grids. Each of these data structures is tuned for a particular type of use (see below).

All data structures work globally in the same way. You can create a data structure with a function that returns an id for the structures. You use this id to perform operations on the data structures. Once you are done you destroy the data structure again to save storage. You can use as many of the structures at the same moment as you want. All structure can store both strings and real values.

Please note that data structures and their content are not saved when you save the game using the actions or functions for that. If you use data structures and want to allow for saves you have to create your own mechanims for that.

When comparing values, for example when searching in a map or sorting a list, Game Maker must decide when two values are equal. For strings and integer values this is clear but for real numbers, due to round-off errors, equal number can easily become unequal. For example (5/3)*3 will not be equal to 5. To avoid this, a precision is used. When the difference between two numbers is smaller than this precision they are considered equal. Default a precision of 0.0000001 is used. You can change this precision using the following functions:

ds_set_precision(prec) Sets the precision used for comparisons.

This precision is used in all data structures but not in other comparisons in GML!

Information on data structures can be found in the following pages:

Stacks

Queues

Lists

Maps

Priority Queues

Grids

DSG 18 years, 9 months ago

…U DID THAT IN GM!?

melee-master 18 years, 9 months ago

Taleria, how well does the GM6 run?

Xemrel 18 years, 9 months ago

@Melee: I do mean something else. I meant as in creating custom structures to hold points as a single element.

@DarkSirrus: Yes. ^_^

@Melee (again): Surprisingly well. Once the polygon count is turned up very far, it takes it a while to regenerate the land, but once it's done, it's not too bad zooming and rotating. Unfortunately, because of what I need to do to get the per vertex shading going, it'll probably slow the generation phase down, but it should still go just as fast after that.

*Feels inspired and gets back to work on it*

membrain 18 years, 9 months ago

Ooooooh how interesting.

I've never hurd of anyone doing this before in GM… then again, I make all efforts to stay away from GM's 3D functions =)

ludamad 18 years, 9 months ago

Unbelievable.

melee-master 18 years, 9 months ago

Quote:

hold points as a single element.

Although I'm unsure of what that exactly means, I'll take a guess… And humiliate myself. Heh. Would storing all the points in a single string work?

Xemrel 18 years, 9 months ago

Hmm… Technically, I <i>could</i> cram them together somehow and store them in a string, but all that translation back and forth would slow it down a whole lot. I could create a checksum though, which would allow me to use a bunch of maps, instead of arrays, which would take more memory, but should allow all the searching I need to do to be done by GM, instead of GML. I'll try both ways and see which is faster. So, while that doesn't solve the "store as one element thing," it may be useful for a bit of speed. ^_^