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 / vertex data manipulation

Author
Message
bjadams
AGK Backer
18
Years of Service
User Offline
Joined: 29th Mar 2008
Location:
Posted: 13th Apr 2010 21:29
i tried to look for threads that could enlighten me on the proper use of the various vertex commands.

i would like to manipulate the vertex data points of a sphere object to morph it and animate it into more abstract shapes, maybe using sin and cos maths formulas.

any help or guides or examples of how to use the vertex commands are very welcome.

thanks a lot
TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 13th Apr 2010 21:33
Here's a simple example of deforming a sphere. Credits go to empty.



You may be able to find more help on this thread:

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

TheComet

bjadams
AGK Backer
18
Years of Service
User Offline
Joined: 29th Mar 2008
Location:
Posted: 13th Apr 2010 21:39
thanks a lot for fast reply.

any more info would be greatly appreciated
TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 13th Apr 2010 21:59 Edited at: 13th Apr 2010 22:00
OK, so all of your vertex manipulation should be performed between the following two commands:

lock vertexdata for limb
unlock vertexdata


The first command will lock the vertexdata in memory for the specified limb on an object, by setting the limb to 0 it affects the whole object (since 0 accesses the objects root data), the second command of course unlocks it after editing the data.

This command will return how many verticies the limb is made of:

get vertexdata vertex count()

Each vertex has an index number, which is between 0 and whatever the last command returns -1.

To reposition any vertex you want, use this command:

set vertexdata position

You specify the vertex by using the vertex index.

This command will return the position of a single vertex:

get vertexdata position x()
get vertexdata position y()
get vertexdata position z()


Is there any more to explain?

TheComet

bjadams
AGK Backer
18
Years of Service
User Offline
Joined: 29th Mar 2008
Location:
Posted: 14th Apr 2010 09:43
seems pretty straighforward.

thanks
Hawkblood
16
Years of Service
User Offline
Joined: 5th Dec 2009
Location:
Posted: 14th Apr 2010 16:18
Isn't locking and unlocking a time consuming process? I've never done it in DBP, but in C++/DX it's a killer to your fps. I would store the "original" information in an array and use the lock/unlock only once per frame:



The fastest code is the code never written.
BMacZero
20
Years of Service
User Offline
Joined: 30th Dec 2005
Location: E:/ NA / USA
Posted: 14th Apr 2010 16:45
Look at my entry and Kira Vakaan's entry in the current DBP coding challenge, Kira used the vertexdata commands and I used memblocks to create sea waves. Might be a good way to compare their speed.
Kira Vakaan
17
Years of Service
User Offline
Joined: 1st Dec 2008
Location: MI, United States
Posted: 15th Apr 2010 11:01 Edited at: 15th Apr 2010 11:12
Here's a link to our entries:
Mine: http://forum.thegamecreators.com/?m=forum_view&t=48011&b=1&msg=1997699#m1997699
BMacZero's: http://forum.thegamecreators.com/?m=forum_view&t=48011&b=1&msg=1997788#m1997788

@BMac: I would be very interested to see how the methods compare. I was thinking about doing it like yours, but I thought that writing the data to a memblock and then creating a mesh out of it every frame would be more costly than only updating existing vertices. Who knows. But our entries are very different in that yours has to process 180 vertices per frame and mine has to process 24,576.

Edit: @bjadams: I'm sorry my vertexdata code is so convoluted. Probably not good learning material. There are six groups because I update the water mesh grid square by grid square and there are two triangles in a grid square.
baxslash
Valued Member
Bronze Codemaster
19
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 15th Apr 2010 11:14
So if @BMacZero's entry is about 137 times faster than @Kira's he wins right?

Shouldn't be too hard...

Kira Vakaan
17
Years of Service
User Offline
Joined: 1st Dec 2008
Location: MI, United States
Posted: 15th Apr 2010 11:16
lol Correct
BMacZero
20
Years of Service
User Offline
Joined: 30th Dec 2005
Location: E:/ NA / USA
Posted: 15th Apr 2010 16:45
Aw, Kira wins that one.

With the original number of vertices mine was too fast to count (0.31 ms). Multiplying by 137 predicts 42.47 ms. Tests with that many vertices got ~40 ms. Kira's gets 15 .

So vertexdata is faster.
bjadams
AGK Backer
18
Years of Service
User Offline
Joined: 29th Mar 2008
Location:
Posted: 15th Apr 2010 17:29
yes i think the vertexdata commands are faster and more comprehensible.

now i need to study some sin and cos formulas to make sphere deformation look natural and organic
Kira Vakaan
17
Years of Service
User Offline
Joined: 1st Dec 2008
Location: MI, United States
Posted: 16th Apr 2010 11:41
What kind of deformations are you looking to do?

Login to post a reply

Server time is: 2026-07-26 12:34:14
Your offset time is: 2026-07-26 12:34:14