Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Controlling individual vertices in an object

Author
Message
Satchmo
21
Years of Service
User Offline
Joined: 29th May 2005
Location:
Posted: 4th Jun 2012 03:24
I would like to lay out a grid of vertices, maybe 30 by 30 or whatever, and then to connect it by triangles to I'll eventually be able to make a terrain (I would store the vertex data in an array so I can control the terrain). Looking through the help files I'm confused as to which commands would allow for this. If someone can so me how to create the basic terrain I would be grateful, as I can figure out the control part by myself.

WLGfx
18
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 4th Jun 2012 03:51
The easiest way to do that is via the MATRIX set of commands for terrain. You should be able to find them easy enough in the help files with some examples too. The handiest function in the MATRIX commands is the GET GROUND HEIGHT useful for placing items on the ground.

Mental arithmetic? Me? (That's for computers) I can't subtract a fart from a plate of beans!
Warning! May contain Nuts!
Satchmo
21
Years of Service
User Offline
Joined: 29th May 2005
Location:
Posted: 4th Jun 2012 03:55
Aren't matrix's slow? If I remember correctly they are double sided which I do not need

Fallout
23
Years of Service
User Offline
Joined: 1st Sep 2002
Location: Basingstoke, England
Posted: 4th Jun 2012 12:04
There are three methods you could use that I can think of ..

You'd could create a memblock, manually add all the vertex data (positions, UV coordinates, normals etc.) and then use the MAKE MESH FROM MEMBLOCK command. I'm not sure if it's straight forward to add index data with this method, so you may have lots of duplicate vertices.

The easiest method is just to make a mesh in a 3D modelling program, and then use the VERTEXDATA commands to manipulate it. Then it'll all be correctly welded and ready to manipulate.

If you don't know how big you want your grid to be, another option is to make a 10x10 grid in a modelling program. You can then load it in and convert it to a mesh. Using the ADD MESH TO VERTEXDATA command, you can add as many 10x10 grids to the map object as you like and then manipulate them with the other VERTEXDATA commands.

Rais
23
Years of Service
User Offline
Joined: 7th Jul 2003
Location:
Posted: 4th Jun 2012 13:36
Have a look at the code snippet below. Apologies in advance for the lack of comments but its just been cut directly from one of my projects. It creates a 32*32 grid.

You will need IanM's Matrix utils installed for it to work.

If I get a chance later I will see if I can go thorugh the code & put some comments in...
chafari
Valued Member
20
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 4th Jun 2012 16:24
Hi there.
I've been trying that with all the methodes commented and all of them work....as commented, perhaps matrix method is slow, but making a grid of triangles is even slower...unless we unify at the end all triangles to the same mesh. Memblock are a good method when we know how to use them. Advanced terrain is a good method too and not to slow...that depends of your needs.

If we decide to make the terrain by tryangles, we just place them with command make object triangle



we can use a grayscale image to raise them up with command:
Quote: "y#=rgbr(point(x*10,z*10))"


Attached example

Cheers.

I'm not a grumpy grandpa
TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 4th Jun 2012 17:07
If you have matrix1 utils, you can use the make object plain command to create a subdivided terrain (which is essentially a matrix, only it's a mesh and not a terrain). Blazingly fast as well.

This example might not work, so brace yourself:



And here would be how to use it:



TheComet

TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 5th Jun 2012 00:29 Edited at: 5th Jun 2012 00:48
I've debugged and perfected my code. You're free to use it however you like!



***EDIT*** fixed a major bug, and got diffuse to work.

TheComet

Satchmo
21
Years of Service
User Offline
Joined: 29th May 2005
Location:
Posted: 5th Jun 2012 01:07
Thanks a lot guys. I was looking through some old threads and found [href]this[/href], which looks pretty useful. I'll check out your examples, ty.

Login to post a reply

Server time is: 2026-07-08 01:56:25
Your offset time is: 2026-07-08 01:56:25