# 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.

### Newcomers DBPro Corner / set vertexdata position through indice?

Message
Posted: 26th Apr 2013 20:55
i was wondering if it was possible to set the position
of 3 vertexdata points at one time through the use of indexdata?

i just wanted to know if i had to type each command like this:

set vertexdata position 0,x,y,z
set vertexdata position 1,x,y,z
set vertexdata position 2,x,y,z
etc...

or if there was someway i could move all the verticies at one time

for example:

set vertexdata position 0-3,x,y,z

and without using a for/next loop
Posted: 27th Apr 2013 18:20
You can set indices but you can still only set one vertex at a time.
So if you have indices A, B and C all refering to vertex V, setting A to (0, 0, ) and then C to (0, 1, 0) would set V to (0, 1, 0). All set operations on the indices will refer to the shared vertex.

Setting just a single vertex at a time makes sense since it gives you complete control over which ones to set and which not to. Loops are the way to go whenever you need to set more than one

"Why do programmers get Halloween and Christmas mixed up?"
Posted: 27th Apr 2013 18:32
yea i was using loops but the problem with that is that im going through several thousand loops because of how many vertexes an object has.

so i have one object with 60 vertex points and its duplicated 196 times so if i wanted to relocate those points i would have to
do the following:

for v=0 to 196
for v2=0 to 60
set vertexdata position v2,x,y,z
next v2
next v

so that would be over 11000 loops i would have to go through to move all those vertexes and i was just wondering if there is any more efficient way to do this?
Posted: 27th Apr 2013 20:55
If there actually are that many vertices then that's how you have to do it.
11 000 loop cycles is really not that much (of course it depends on what you're doing in them but for just setting vertices I wouldn't say it's a problem. I have been setting around 65 000 vertices in real-time in an application, the overall speed drop was rather minimal).

If you have shared vertices you can remove those and use indices instead. The idea there is that you have as many indices as would-be vertices and the actual vertices can be shared amon indices. As such you would end up with fewer vertices to manipulate if that was your plan?

"Why do programmers get Halloween and Christmas mixed up?"
Posted: 27th Apr 2013 22:00
yea that was the plan but im still kinda having trouble wrapping my head around indexdata

so say i have a triangle consisting of 3 verticies and i wanted to share all three would i do something like this?

set indexdata 1,1
set indexdata 1,2
set indexdata 1,3

set vertexdata position index1,x,y,z
Posted: 28th Apr 2013 07:01
Posted: 28th Apr 2013 18:31

Could a Mod deal with the post from leonseca8 please?
Posted: 2nd May 2013 04:30
Quote: "so say i have a triangle consisting of 3 verticies and i wanted to share all three would i do something like this?

set indexdata 1,1
set indexdata 1,2
set indexdata 1,3

set vertexdata position index1,x,y,z "

no

Triangles can share vertices between them like this:
triangle 1 has vertices 5,6 and 7
triangle 2 has vertices 1,2 and 6

You would set them like this:
set indexdata 1,5
set indexdata 2,6
set indexdata 3,7

set indexdata 4,1
set indexdata 5,2
set indexdata 6,6

Posted: 2nd May 2013 16:46
oh okay i get it now so indexdata just sorts them in whatever order you set basically, i just thought you could group a certain number of vertices to one index but i guess its just not possible..

oh well though i still wish there was a way to move all the vertices at once instead of 1 by 1, it would definitely make "set vertexdata position" command easier and probably faster too...
Posted: 3rd May 2013 19:20
Quote: " i just thought you could group a certain number of vertices to one index but i guess its just not possible.."

You already have a function to set one vertex, anything else you can do yourself based on that function.

This is a untested mockup, but it should demonstrate one way to do what you want. Note that it requires the Matrix1 Utilities.

"Why do programmers get Halloween and Christmas mixed up?"