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 / Indexing Unique Points On A Grid?

Author
Message
Derek Darkly
14
Years of Service
User Offline
Joined: 22nd Sep 2011
Location: Whats Our Vector, Victor?
Posted: 28th Feb 2014 00:54 Edited at: 28th Feb 2014 01:01
I'm not necessarily looking for code, but ideas and theories... post code if you feel so inclined, however.
I'm going to work on this over the weekend until I get it, or someone beats me to it. (There may be a thread that covers this, but none that I could find.)


Ok, so on a flat mesh grid, which is composed of triangles like most 3D objects, up to six triangles (correct me if I'm wrong there) can share a single vertex point:



What I want to do is create an array out of the unique points on the grid, in other words, without duplicating any 3D vector (x/y/z) point in the data. This way, if I want to manipulate a point on the mesh, I will know which ones share the same space, so as to move them all the same.

I'd like this info to be indexed in spacial order, either from top left to bottom right, or the inverse of that.

I thought this might make a good brain teaser for those who are bored and want something to think about.
Like I said, I plan on tackling this over the weekend when I have more time.

666GO†O666
SamKM
17
Years of Service
User Offline
Joined: 25th May 2009
Location:
Posted: 28th Feb 2014 02:04
As far as I know, with complicated 3d objects, there usually aren't duplicate verticies, thanks to something called the Polygon index, which is totally over my head
Basically it controls how all the polygons in a shape fit together, so there's no need for more than one vertex where they all join...
How are you making this flat grid? If you're using the Matrix1Utils version of the 'make object plain' command, that generates a polygon index automatically, so you shouldn't need to do any of this! To get what you're looking for, though, I'd write something like this:



Hope that helps
Actually, if you're looking for a way to move all the verticies at a point in the grid where they're duplicated, wouldn't you want an array which stores duplicates instead? Sorry, I might be wrong, just wondering!
Phaelax
DBPro Master
23
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 28th Feb 2014 03:25
If I remember correctly, DBP objects actually duplicate verts that would typically be shared. The order would match that of the order polygons are created. In a plane such as the one you posted, you should be able to predict the order of the verts. Optionally, you could use memblocks to build your own plane.

zeroSlave
17
Years of Service
User Offline
Joined: 13th Jun 2009
Location: Springfield
Posted: 28th Feb 2014 03:34 Edited at: 28th Feb 2014 03:43
Here is a quick way with memblocks using an "index buffer":



Everybody is a genius. But if you judge a fish by its ability to climb a tree, it will live its whole life believing that it is stupid.
Derek Darkly
14
Years of Service
User Offline
Joined: 22nd Sep 2011
Location: Whats Our Vector, Victor?
Posted: 28th Feb 2014 17:56 Edited at: 28th Feb 2014 20:19
Quote: "How are you making this flat grid? If you're using the Matrix1Utils version of the 'make object plain' command, that generates a polygon index automatically, so you shouldn't need to do any of this! "


That sounds promising! I was just adding plains together (add limb) and then turning my final object into a single mesh, then back to an object.

Quote: "In a plane such as the one you posted, you should be able to predict the order of the verts."


I guess that's true - I should be able to skip through incrementally and land on the correct value every time.

Quote: "Here is a quick way with memblocks using an "index buffer":"


That's awesome!
I'll have to study this method as well.

Thanks for all the suggestions so far!

666GO†O666
MonoCoder
20
Years of Service
User Offline
Joined: 4th Dec 2005
Location: england
Posted: 28th Feb 2014 23:11
Here's another method: create a grid whose vertices are shared, so you can adjust one vertex - rather than a group - to manipulate a point on the landscape. (Requires Matrix1.)

This image details how it works.



notes:
- spent a while trying to get it to look nice with standard dbp lights, gave me some trouble so I gave up. Should work like any other object in a shader though?
- sharing vertices is like having everything be in one 3dsmax smoothing group; each triangle having its own unshared verts is the only way to get hard edges (I may have once read that this may not be true if you use a normal map in a shader, but I don't know) (note that its not a limitation of using vertexdata stuff, just of this particular approach).

On repeat reads, this probably wasn't what you were after, but hope it may be of use
Derek Darkly
14
Years of Service
User Offline
Joined: 22nd Sep 2011
Location: Whats Our Vector, Victor?
Posted: 1st Mar 2014 15:47 Edited at: 1st Mar 2014 16:04
Quote: "On repeat reads, this probably wasn't what you were after, but hope it may be of use"


No, you're on the right track!
Thanks for taking the time to make all that code! I need to download Matrix1Utils though, I've never used it.

I'll share the rest of my plan, which was after getting the points organized, I wanted to be able to load a heightmap of any size, and build a vertical mesh wall from it, with the tiles equaling the number of pixels on the image, or perhaps have the user define the tile number and fit the image accordingly.

If anyone wants to give that a whirl, have at it.
I'm going to mess with it after a few hours of Skyrim this morning.

Later developments would be things like bending the walls for curves and tunnels, and using CSG commands to cut out openings, doorways and windows. All theory at this point with little practice.

Eventually I would like to construct interlocking modules so as to build my own dungeons and cave systems, or have them randomly generated.

I could do this stuff in Blender by watching tutorials, but I like the idea of building from scratch in DBP.

666GO†O666
chafari
Valued Member
20
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 1st Mar 2014 22:56
Quote: "I wanted to be able to load a heightmap of any size, and build a vertical mesh wall from it"


We can achieve something like that with Dbpro commands. Some time ago, I made a terrain with triangles, and works like a any other object. Media files attached.



Cheers.

I'm not a grumpy grandpa
MonoCoder
20
Years of Service
User Offline
Joined: 4th Dec 2005
Location: england
Posted: 2nd Mar 2014 00:20 Edited at: 2nd Mar 2014 00:21
By vertical mesh wall, do you mean something like a terrain rolled onto its side, or something like this:



or something else?
Derek Darkly
14
Years of Service
User Offline
Joined: 22nd Sep 2011
Location: Whats Our Vector, Victor?
Posted: 2nd Mar 2014 02:29 Edited at: 2nd Mar 2014 02:36
Quote: "By vertical mesh wall, do you mean something like a terrain rolled onto its side, or something like this:"


Yes, like a terrain on its side.. I realize this is child's play to many of you, and that there are probably a lot of ways to achieve this.

For convenience, I'm going to add a quick matrix generator to my personal object editor (WIP) program, and include my own heightmap plugin and a function I saw here in the forums from 2004 that will save a matrix to .X format.

Chafari, nice!! I'd like to make custom walls this way. I can just rotate the final object, right?!

You should consider doing a pack of modular segments, Chafari... you could put together some nice caves and dungeon kits for sale! $$$



666GO†O666
chafari
Valued Member
20
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 2nd Mar 2014 12:34 Edited at: 2nd Mar 2014 12:34
Quote: " Chafari... you could put together some nice caves and dungeon kits for sale!"


I make this for fun . Making a cave is as you say , child's play. You can use either a plain, triangles ,spheres or use a simple matrix. You need two hightmaps, one for the terrain, and other for the dungeon, then you apply the two images to the floor in negative, and to the ceiling in positive.




I'm not a grumpy grandpa
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 3rd Mar 2014 12:16
Quote: "I make this for fun"






Powered by Free Banners

Login to post a reply

Server time is: 2026-07-06 04:30:23
Your offset time is: 2026-07-06 04:30:23