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 / Adding or Removing Vertice or Faces

Author
Message
pictionaryjr
17
Years of Service
User Offline
Joined: 12th Mar 2009
Location:
Posted: 3rd Jan 2013 18:39
I don't believe this is possible other then using a memblock, but is it possible to add or remove vertice or faces without using a memblock
TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 3rd Jan 2013 18:55
I don't believe so. At least the vertexdata commands show no sign of anything that could achieve it.

If you need help with the memblock version, I'd gladly write up an example.

If you wish to try on your own - or if you already have a running prototype - I must stress that using the commands change mesh from memblock followed by make object are slightly faster than making a mesh from the memblock and then making the object.

TheComet

Andrew_Neale
16
Years of Service
User Offline
Joined: 3rd Nov 2009
Location: The Normandy SR-2
Posted: 3rd Jan 2013 20:14
You can remove faces using the vertexdata commands. Use 'DELETE MESH FROM VERTEXDATA' to remove vertices and/or indices from a mesh.


Previously TEH_CODERER.
TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 3rd Jan 2013 21:50
So it does:



I'll be honest, I don't know why that works. I don't understand what to specify for the index data.

TheComet

pictionaryjr
17
Years of Service
User Offline
Joined: 12th Mar 2009
Location:
Posted: 4th Jan 2013 02:43
i don't know what the indices are. i know the vertices are numbered in order of creation so that's what the first 2 variables are, because a face is created by 3 consecutive vertices.
TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 4th Jan 2013 09:07
Yes, but in my example I appear to be deleting 6 vertices (a side of a cube consists of 2 faces).

TheComet

Andrew_Neale
16
Years of Service
User Offline
Joined: 3rd Nov 2009
Location: The Normandy SR-2
Posted: 4th Jan 2013 09:32 Edited at: 4th Jan 2013 09:36
Well you have deleted 3 vertices; 0, 1 and 2. So that would delete all the vertices for one of the triangles but, due to shared vertices using index data, 2 of those vertices would also have been used by the other triangle of the same cube face which. So whilst it doesn't actually delete the triangles completely as their index data would still be there, it still prevents them from rendering as the indices now reference non-existent vertices. So to delete the triangle you would have to delete its one non-shared vertex and its 3 indices rather than its 3 vertices.

[Edit] Corrected a typo. [/Edit]


Previously TEH_CODERER.
pictionaryjr
17
Years of Service
User Offline
Joined: 12th Mar 2009
Location:
Posted: 4th Jan 2013 09:48
If I was creating my own object. How would I share a vertice in an object, or does DBP just assume if two vertices have the same location then they are shared. I don't understand this and also is there anyway to add a face or vertice to an object without loading up the memblock.
Brendy boy
20
Years of Service
User Offline
Joined: 17th Jul 2005
Location: Croatia
Posted: 4th Jan 2013 10:13
Quote: "If I was creating my own object. How would I share a vertice in an object,"

you will need an object with index buffer (all dbpro primitives have them). The triangles that share a vertex would have the same vertex number assign to one of their indices.
You can use SET INDEXDATA and GET INDEXDATA commands to do that.

Quote: "also is there anyway to add a face or vertice to an object without loading up the memblock."

there is.

To add a face:
1. using DELETE MESH FROM VERTEXDATA commands delete all vertices from a dbpro primitive box and delete all indices except first 3. That way you'll have a box without vertices and with only 3 indices which is equal to 1 triangle.

2. Convert that box to mesh

3. When you want to add a triangle to an object just use ADD MESH TO VERTEXDATA command and as a mesh specify the previously created box mesh with 3 indices.

4. Set the added indices to pint to vertices you want to form a new triangle.

To add a vertex:
The same as above but instead deleting all vertices you would delete all indices and all vertices except one.

pictionaryjr
17
Years of Service
User Offline
Joined: 12th Mar 2009
Location:
Posted: 4th Jan 2013 22:21
Thanks Brendy Boy. I'm going to see if I can get that working the way I want. I'll obviously need to do some fiddling. Strangely Enough I had already started working in the direction you described because it was the only command I hadn't looked into yet.
paul5147
20
Years of Service
User Offline
Joined: 11th Jan 2006
Location: Hot & Sunny
Posted: 5th Jan 2013 13:04 Edited at: 5th Jan 2013 13:06
Small bit of code ripped out of one of my race track editors shows a quick method of deleting single faces or faces within a another triangle,hope this helps.

it uses matrix1 and sparkys collision plugins

Login to post a reply

Server time is: 2026-07-07 09:05:21
Your offset time is: 2026-07-07 09:05:21