🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

How to do a 3D scene?

Started by
6 comments, last by nPawn 24 years, 7 months ago
In the same way that, if you have the same piece of code twice in you program you should put it in a function, if you have the same object twice in a world then you should have a pointer to a model and only store the pointers, not the whole object.
Otherwise you'll use up all your memory in about one scene....
Advertisement
What about Terrain? It's bumpy, has maybe small hills and dips, and is quite large, and doesn't really repeat itself, is that one big model or is there a better way to go about it?
nPawn from xr?

Anyways, probably the best way to store terrain is in a heightmap.

Basically a heightmap is an array of numbers that signify the 'Y' value, or height of a given point on the terrain.

The size of the terrain is relative to the length of a side of the triangle that makes up the terrain "mesh". You can generate the mesh at run time, and "mold" it with the heightfield values, so the map size can be extremely small since you don't store the data, you generate it.

Once you have the terrain mesh generated, you can render that, and then run through an object listing, say that contained a castle or whatever and render them.

I can explain more (since its a large subject), but here is a simple representation..

Heightmap...

01000
01100
01110
01110
00100

You could think of this as a 2D array (and you should), each x,y point in the heightmap, directly matches an x,y point in the resulting mesh, and the value at a given point in the array, is the y value of the matching point.

With a good editor (image editor really), you can make some great looking terrain. Here is an iamge from a heightfield editor I recently completed...

(I hope that goes through)

Dare I suggest Game Developer October Issue
P 48 Automatic Terrain Generation.
Or is that a faux pas on this site?
Thanks for the replies, it has given me some ideas to toy with. And Matt, by XR i assume you mean CrossRoads? If so, who are you on there? =)

I'll look up that Terrain article too and see if it helps.

I used to be Samodil. If you have any questions on terrain, don't hesitate to ask.

How is a 3D scene stored in a game? Say I want to make a big grassy field with some bushes, a few trees, and a castle in the middle of it, would i use something similar to a Tile type system where you save object coordinates in a grid, or should this whole environment be one big model, or how is this typically accomplished? It seems since i am reusing objects (like trees or bushes) that i should just load one object and draw it multiple times instead of having one big model, but this seems awkward when i think about combining it with a field and other items.
how would you go about making a terrain collision detection thing with d3dim?

how would you store 3d levels or scenes? a 2d array and the value would equal the height?
like that thing you drew.
00000
01100
01110
00100

hrm.
how would you go about making sure another model is on a terrain with hills and slants and slopes? how would you move an object around a 3d level and check for collisions? would you do if the model is in a level object then? where can i find out about all the suff id like to know?

This topic is closed to new replies.

Advertisement