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 / SET INDEXDATA doesn't work?

Author
Message
Maxxim
12
Years of Service
User Offline
Joined: 1st Apr 2013
Location:
Posted: 4th Apr 2013 08:37 Edited at: 4th Apr 2013 17:57
First of all, I'd like to greet and say thanks to TGC community. I've been reading forum and learning for quite a while, but right now I can't find a solution myself.

The issue is about using SET INDEXDATA command. I know that objects created via DBP memblocks don't have index data and was hoping to add indexes after creating. But this doesn't seem to work either.

Here's a small piece of code to show what I mean:



I am aware that you can set indexes for memblock meshes with Ian M's Matrix1Utils. These plugins are great (so far I use only one to output data to debugger though), but I want to know:

1)Is it possible to set index data natively?
2)Am I doing something wrong or is it a bug?
I am using the latest version of DBPro with update.

Thank you in advance. I noticed that even usefull threads with tons of precious information are often left without a single reply, so I will bump mine once a while.
Mobiius
Valued Member
22
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 4th Apr 2013 15:44
Your code tag should be [ code lang=dbp ]

lol

I live for video games! (And beers, and football, and cars!)
See what I live for here: [url]http:\\www.TeamDefiant.co.uk[/url]
Brendy boy
19
Years of Service
User Offline
Joined: 17th Jul 2005
Location: Croatia
Posted: 4th Apr 2013 16:35
set indexdata command sets already existing indices but if object doesn't contains indices you can't set them up. There's no command for creating indices, but there is a solution that works.

What you need to do is this:
1. create a dbpro primitive like a box or cube
2. using delete vertexdata command delete all the vertices of the created box/cube
3. using delete vertexdata command delete all the indices except one of the created box/cube
4. convert your box/cube to mesh

Now you have a mesh consisting of only one index.
Using add mesh to vertexdata you can add index to any object you want.
If you want to add 2 indices just add that mesh twice, etc..

Green Gandalf
VIP Member
20
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 4th Apr 2013 16:51
The simplest solution ought to be IanM's Matrix1 commands in Section 18 of his utilities, in particular:



Matrix1 Help file entry:

Quote: "MAKE OBJECT NEW

Syntax

MAKE OBJECT NEW Object number, Vertex count, Index count
MAKE OBJECT NEW Object number, Vertex count, Index count, FVF
MAKE OBJECT NEW Object number, Vertex count, Index count, FVF, Initialise buffers

Description

Create an object with the number of vertices and indices specified.

If the Index count is not 0, then it needs to be a multiple of 3, as 3 points are required for each polygon.

If the Index count is 0, then the Vertex count needs to be a multiple of 3 for the same reason.

The first form of this command will create an object using an FVF value of 274.

The third form of this command allows you to skip initialising the buffers with zeros by using an Initialise value of 0 - use only when you are going to immediately set the values yourself using the VERTEXDATA commands.
"
Maxxim
12
Years of Service
User Offline
Joined: 1st Apr 2013
Location:
Posted: 4th Apr 2013 18:10
Quote: "Your code tag should be..."

OK.

Brendy boy, yes I was thinking about this. Seems to be quite a crutch though. I'll try this way or either Green Gandalf's way and find what suits me more. Thanks for clearing things out.
Maxxim
12
Years of Service
User Offline
Joined: 1st Apr 2013
Location:
Posted: 5th Apr 2013 09:34
I've decided not to use Ian M's plugins yet (until I learn how to do everything with DB). Adding vertexdata by Brendy Boy's method works fine.

Now I want to know how is mapping of indices to vertices is done. But I can't figure out!

For example, we have a plane, 3x3, 9 vertices. We also have 24 indices to assign, starting from the bottom left corner as it is shown in the picture (sorry for ugly MS Paint).

The problem is that I cannot calculate an algorythm for doing this. I wasn't good at maths in school at all, and this looks like it needs graphs theory or something like that, and I didn't study that.

I am sure that there is a lot of skilled people here. Moreover, I think there's some way to calculate this in more easy way, but I can't figure out. So I am asking for help again!

Attachments

Login to view attachments
Brendy boy
19
Years of Service
User Offline
Joined: 17th Jul 2005
Location: Croatia
Posted: 5th Apr 2013 19:51
- every 3 indices form a poligon
- indices must be in clockwise order
1
/|
/ |
/__|
2 3

indices of the above triangle would be:
1,3,2
3,2,1
2,1,3

All 3 cases are valid

Maxxim
12
Years of Service
User Offline
Joined: 1st Apr 2013
Location:
Posted: 5th Apr 2013 22:42 Edited at: 6th Apr 2013 04:28
Edit: Nevermind, I've sorted this out.

Attachments

Login to view attachments
Maxxim
12
Years of Service
User Offline
Joined: 1st Apr 2013
Location:
Posted: 6th Apr 2013 01:15
Uh. Nevermind, sorted this out. I just don't need to connect the most right column and the most top row. Dear moderators, please, don't approve the last 2 posts.

Login to post a reply

Server time is: 2025-05-17 15:44:51
Your offset time is: 2025-05-17 15:44:51