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 / Indexdata is... broken?

Author
Message
TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 23rd Jun 2012 16:46
Hey guys


The command make object plain Object , SizeX , SizeY , ResX , ResY doesn't support more than 65535 vertices, which means that this won't work:

make object plain 1 , 10 , 10 , 200 , 200

Annoyed at that, I wrote my own function for creating a subdivided plain. Mesh generation worked as expected, but I've stalled at the step where I have to wield the vertices together. I browsed the forums for help, and here's an example from someone, but it doesn't work at all.



The vertices should connect, but they don't. Is the command broken or something?

Here's my function from my game:



The function returns the object's index, so this is how you'd implement it:



Any help in wielding those vertices together?

TheComet

Brendy boy
20
Years of Service
User Offline
Joined: 17th Jul 2005
Location: Croatia
Posted: 23rd Jun 2012 17:45
did you try using get vertexdata index count command on the newly created plain to check if it contains any indices at all?

paul5147
20
Years of Service
User Offline
Joined: 11th Jan 2006
Location: Hot & Sunny
Posted: 23rd Jun 2012 17:56
Have you checked that this "hack"

Is actually making indexdata for your object,and if your writing your own meshes with the vertex data commands then why not just write the indexdata as well?
If you do it yourself then the problem with welding them goes away as you could do it at the same time as setting the indexdata,as you would all ready know which vertex`s needs to be with which others.
If you really need a welded segmented plain then simply make the vertexdata as a simple grid size-x by size-y and set up the indexdata to make the faces.There are quite a lot of examples for this on the forums.
TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 23rd Jun 2012 17:59
Just did what you said, and it doesn't have any indices. That's expected though because I have to generate them. The question is : how do I generate index data?

TheComet

paul5147
20
Years of Service
User Offline
Joined: 11th Jan 2006
Location: Hot & Sunny
Posted: 23rd Jun 2012 18:26
You all ready are using the SET INDEXDATA command in your code snippet in your first post,you just have to set them up in the correct order.
If you make a plain 10 units wide and 10 units deep,starting at 0 that would be 11 vertexdata points on each axis.
The indexdata is just a list of the 3 points that make up a polygon.
The first poly would have index data 0,1,11 the next would have 1,12,11 this would create the first square in the plain.
the next square would be 2,3,12 and 3,13,12 and so on until the end of the row.
Hope this helps if not try matrix1utils plugin as they have a welded vertex plain command in them.
Brendy boy
20
Years of Service
User Offline
Joined: 17th Jul 2005
Location: Croatia
Posted: 23rd Jun 2012 18:34 Edited at: 23rd Jun 2012 18:35
here some code IanM wrote 5 years ago:



Have a look at the line where make memory command is used, that's the place where indexdata gets created

Diggsey
20
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 24th Jun 2012 04:14 Edited at: 24th Jun 2012 04:16
I recommend you use the "make object new" command from IanM's plugins. If you need to add/remove vertices/indices dynamically then you can use it in conjunction with "add mesh to vertexdata"/"delete mesh from vertexdata".

Also, the limit of 65535 vertices is true for all meshes, not just the "make object plain" command.

[b]
Dar13
18
Years of Service
User Offline
Joined: 12th May 2008
Location: Microsoft VisualStudio 2010 Professional
Posted: 24th Jun 2012 05:11
Quote: "Also, the limit of 65535 vertices is true for all meshes, not just the "make object plain" command."

Why is that? IIRC, that's only the size of a short int.

Diggsey
20
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 24th Jun 2012 05:27
Because the indices are 16-bit unsigned integers.

[b]
TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 24th Jun 2012 11:44
If that's the case, then why am I able to load larger subdivided plains externally?

TheComet

paul5147
20
Years of Service
User Offline
Joined: 11th Jan 2006
Location: Hot & Sunny
Posted: 24th Jun 2012 12:06
What do you mean by externally?
TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 24th Jun 2012 13:32
Here I have a model attached with 240'000 indices.



TheComet

Brendy boy
20
Years of Service
User Offline
Joined: 17th Jul 2005
Location: Croatia
Posted: 24th Jun 2012 17:07
Quote: "Here I have a model attached with 240'000 indices."

the limit is for vertices, not indices

TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 24th Jun 2012 17:37 Edited at: 24th Jun 2012 17:51
Quote: "the limit is for vertices, not indices"


Here's an object with 540'000 vertices.



Of course you can make more than 65536 vertices, that's why the header is a dword!

Look, can someone please give me correct information, this whole thing about "you can't make more than 65535 indices or vertices" is going off topic, and from the examples above can obviously be done without any problems.

@ Brendy Boy

Thanks for posting that example from Ian M. Unfortunately it still doesn't work. If I have over 65536 vertices, it returns 0 indices, and if I have under 65536 vertices, the whole thing just crashes.



What am I doing wrong?

TheComet

Fallout
23
Years of Service
User Offline
Joined: 1st Sep 2002
Location: Basingstoke, England
Posted: 24th Jun 2012 18:06
You're on the right track mate. I can't tell you why your code isn't working, especially with the pointers you're using. I've not used 'make memory' or pointers in DBPro, so don't know what impact that's having.

I hate to ask this though, but why are you not making yourself a pre-welded mesh in a modelling program? Generally when I have this sort of issue, I start with a pre-modelled mesh and go from there. You can spend ages trying to generate it procedurally (which is satisfying and gives you the most freedom), but if a pre-made model would do the job, just go with that to save the pain.

TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 24th Jun 2012 18:16
Quote: "I hate to ask this though, but why are you not making yourself a pre-welded mesh in a modelling program? Generally when I have this sort of issue, I start with a pre-modelled mesh and go from there. You can spend ages trying to generate it procedurally (which is satisfying and gives you the most freedom), but if a pre-made model would do the job, just go with that to save the pain. "


The problem is that I need it to be dynamic, because it changes with every map I load into the game. Larger maps have more vertices, smaller maps have less vertices. I could export a huge mesh and then just use whatever section I require of it, but I don't like being inefficient like that.

TheComet

Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 24th Jun 2012 18:24 Edited at: 24th Jun 2012 18:36
Quote: "can obviously be done without any problems"


Can it? There are definitely some things that don't work correctly with such large meshes. However I agree it would help if we had a clear statement of what the limitations are. I've certainly encountered some that won't display correctly till you break them down to smaller meshes as limbs.

I changed your code to use FVF 274 (the DBPro default) plus some sensible UV mapping with a texture and it displayed correctly. Can you apply a shader to it though?

I've discussed this before with IanM but I can't remember what he said. I'll see if I can dig it out.

Edit Found the correspondence. My reading of that is as follows. The 65536 limit seems to apply to the index data so if your model doesn't use index data (as in your working snippet with 540000 vertices) then there isn't a problem. I now recall that the large meshes I was using before had index data which is why there was an issue.

If you are using simple grid meshes why not break down the model into several limbs as in Advanced Terrain, etc? You can then have a model as large as you like within reason.
TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 24th Jun 2012 18:35
My aim is to be able to edit the diffuse of each vertex. The object doesn't have to have any effects, nor does it need to be textured. Just thought I'd throw that out there quickly

TheComet

Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 24th Jun 2012 18:37
I think my edit answered that question - i.e. why not break your objects down to smaller sub meshes?
Brendy boy
20
Years of Service
User Offline
Joined: 17th Jul 2005
Location: Croatia
Posted: 24th Jun 2012 19:02
here a little different way of adding indices (this deffinitely works)



Now, to add 1 triangle (3) indices:
lock vertexdata for limb obj,limb,2
add mesh to vertexdata MeshPoly
unlock vertexdata

Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 24th Jun 2012 19:23
How would that overcome the index count limit?
Brendy boy
20
Years of Service
User Offline
Joined: 17th Jul 2005
Location: Croatia
Posted: 24th Jun 2012 19:33 Edited at: 24th Jun 2012 19:34
Quote: "How would that overcome the index count limit? "

it doesn't. The comet said that IanM code crashes his app so the second code i posted shouldn't becazse it works in different way. The index count limit is still there

Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 24th Jun 2012 19:40
OK, thanks.
Fallout
23
Years of Service
User Offline
Joined: 1st Sep 2002
Location: Basingstoke, England
Posted: 24th Jun 2012 20:43 Edited at: 24th Jun 2012 20:43
@TheComet - I agree, the ideal solution for you would be to make it yourself. One alternative though would be to make a 10x10 welded mesh in a modelling program and then make your object using the ADD MESH TO VERTEXDATA command. Then you have 90% of your verts welded and a lot of flexibility with size.

Again, not an ideal solution, but you could be doing something else now if you compromised on a 'good enough' solution and cracked on! That's just my attitude anyway, to avoid getting bogged down.

Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 24th Jun 2012 21:05
I really don't know why you can't use IanM's make object plain command and have several limbs. You will then have welded vertices except for the joins between adjacent limbs.

Perhaps I've misunderstood what you're trying to do?
Stab in the Dark software
Valued Member
23
Years of Service
User Offline
Joined: 12th Dec 2002
Playing: Badges, I don't need no stinkin badges
Posted: 24th Jun 2012 21:05
Try this post for welding vertices function.

http://forum.thegamecreators.com/?m=forum_view&t=108704&b=1


[img][/img]


WindowsXP SP3,Vista,Windows 7 SP1, DBpro v7.7RC7
Stab In The Dark Editor
The coffee is lovely dark and deep,and I have code to write before I sleep.
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 24th Jun 2012 21:09
I don't think that's the problem - if you have too many vertices then the welded version of your model will have too many indices in the index list. The actual vertex limit will depend on the structure of your model.
TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 24th Jun 2012 21:43
Actually, that's a good idea with the limbs. I'll try it.

TheComet

Diggsey
20
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 24th Jun 2012 22:06
Quote: "Of course you can make more than 65536 vertices, that's why the header is a dword!

Look, can someone please give me correct information, this whole thing about "you can't make more than 65535 indices or vertices" is going off topic, and from the examples above can obviously be done without any problems."


No, you can't have more than 65535 vertices in a mesh with indices, because as I said, indices are 16-bit unsigned integers (in dbpro). Your example code produces a mesh without indices and so doesn't suffer this limit. Since your question requires indices that's not relevent.

The best thing to do is make an object with multiple limbs - this will also allow dbpro to cull limbs which aren't visible.

[b]
paul5147
20
Years of Service
User Offline
Joined: 11th Jan 2006
Location: Hot & Sunny
Posted: 24th Jun 2012 22:43
Small code sample i made a long time ago,shows how to make up a large segmented plain with welded verts,it also shows how to edit the vertexdata in real time across all the planes without breaking the seams apart and alters the diffuse just to show whats been changed.It does use a few plugins but they are free ones with the exception of ezrotate,but that is only used for calculating the face normals and can be substituted for other normal calculation routines if you dont have it.

Hope this helps and gives you some ideas.
TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 25th Jun 2012 00:05
Quote: "No, you can't have more than 65535 vertices in a mesh with indices, because as I said, indices are 16-bit unsigned integers (in dbpro). Your example code produces a mesh without indices and so doesn't suffer this limit. Since your question requires indices that's not relevent."


Sorry, just tested it and you're right, DBP can't handle more than 65536 vertices with indices. Well I'm glad that whole thing is clarified then.

@ paul - Thanks for that, it helped a lot!

TheComet

Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 25th Jun 2012 12:31
@Diggsey Thanks for the clarification - and for the implied correction of my earlier statement.

Login to post a reply

Server time is: 2026-07-11 11:58:20
Your offset time is: 2026-07-11 11:58:20