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.

AppGameKit Classic Chat / Get all vertex position data from object

Author
Message
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 9th Oct 2019 09:50
Hi all,
Simple-ish request. I've been looking through a bunch of posts about using mesh memblocks and almost have my head around it but it's a lot more complicated than what I currently need.
All I am looking to do is extract all of the vertex positions for an object. Effectively some way of looping through each vertex and storing its position in a list.
Sounds simple but I haven't been using AppGameKit much for 3D at all until now, I have a cool project I am working on and these are my first steps as Obi-wan once said...
Thanks for any help!
Using AppGameKit V2 Tier 1
fubarpk
Retired Moderator
19
Years of Service
User Offline
Joined: 11th Jan 2005
Playing: AGK is my friend
Posted: 9th Oct 2019 14:44
You may find this useful created by chafari a while back which is a great way of getting the vertex data



fubarpk
fubarpk on Itch...………...https://fubarpk.itch.io/
fubarpk on googleplay..https://play.google.com/store/apps/developer?id=fubarpk
TomToad
6
Years of Service
User Offline
Joined: 6th Jan 2018
Location:
Posted: 9th Oct 2019 14:46
First, an object can be made of more than 1 mesh, so you need to loop through all the meshes
For mesh = 1 to GetObjectNumMeshes(object)

Then you need to get the mesh data into a memblock
memblock = CreateMemblockFromObjectMesh(object,mesh)

Then you need to get the number of vertices within the mesh
vertexCount = GetMemblockInt(memblock,0)

Then loop through the vertices and extract x,y,z
for vertex = 0 to vertexCount - 1
vx# = GetMeshMemblockVertexX(memblock,vertex)
vy# = GetMeshMemblockVertexY(memblock,vertex)
vz# = GetMeshMemblockVertexZ(memblock,vertex)
doSomething(vx#,vy#,vz#)
next vertex

Then you need to delete the memblock
DeleteMemblock(memblock)

then loop through the next mesh
next mesh

note vx, vy, and vz shoud be declared float, all other variables should be declared integer.
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 9th Oct 2019 15:19
Thanks guys, I'm sure that will get me started! I just need to translate what I need into C# but it's great thanks
Using AppGameKit V2 Tier 1

Login to post a reply

Server time is: 2024-10-01 10:16:32
Your offset time is: 2024-10-01 10:16:32