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 Studio Chat / Verticies and Indicies

Author
Message
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 29th Nov 2019 01:41
In the context of CreateMemBlockFromObject() could someone explain the difference between vertices and indices for me please.
For example. I am looking at a Box Object created in AppGameKit, It has 24 vertices and 36 indices. (I had heard that an AppGameKit box has polys facing inward and outward, not sure about that though)
Are vertices polys? Are indices vertex?

Thanks
MadBit
VIP Member
Gold Codemaster
14
Years of Service
User Offline
Joined: 25th Jun 2009
Location: Germany
Posted: 29th Nov 2019 07:11
vertices describe the points in the 3 dimensional space. The indices describe which points (vertices) are connected as faces. Mostly they are triangles. So three points which are connected with each other. In a few cases they are quads. So four points that are connected.
Vertices can be referenced several times via the indices.

So you can describe a cube with 8 vertices. The areas for the cube with 12 triangles. That would be 36 indices (12 triangles á 3 indices). But be careful if the vertices also have associated texture coordinates and normal ones, it can get complicated with texturing and rendering light effects.

Therefore for faces that use the same vertices but point in different directions (cubes) the same points will be generated multiple times. Since each vertice usually has only one texture coordinate and has a normal one.

I hope this helps and that I didn't misunderstand you.
Share your knowledge. It\'s a way to achieve immortality. (Tenzin Gyatso)
janbo
15
Years of Service
User Offline
Joined: 10th Nov 2008
Location: Germany
Posted: 29th Nov 2019 16:06 Edited at: 29th Nov 2019 16:22
About that inward and outward facing polygons:
A triangle has a winding direction you define via the connection order of the vertices.
The connection order can be made by indices or by the order of the vertices inside the mesh data.
The renderer interprets the face as solid if the winding order is ccw(counter clock wise) by default, but you can also make clockwise be solid or both with SetObjectCullMode()



A little extra:
Now a plane object in AppGameKit really has two sides for texturing and lighting purposes, for a billboard plane you could save a bit if you make a custom one.
Or missuse the quad object and give it a vertex shader with a perspective projection matrix
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 29th Nov 2019 21:03
Thank you both very much
Using CreateMemblockFromObjectMesh(), how do i know an object is using triangles or quads?
MadBit
VIP Member
Gold Codemaster
14
Years of Service
User Offline
Joined: 25th Jun 2009
Location: Germany
Posted: 30th Nov 2019 04:42
AppGameKit always uses triangle like most game engines do.
Quads are sometimes used by programs like Blender to create objects.
There is also a function to break quads in triangles.
Share your knowledge. It\'s a way to achieve immortality. (Tenzin Gyatso)
fubarpk
Retired Moderator
19
Years of Service
User Offline
Joined: 11th Jan 2005
Playing: AGK is my friend
Posted: 30th Nov 2019 07:48
Quote: "There is also a function to break quads in triangles."

That might be an alternative for blinks code if somehow he could convert all models to use tri's
fubarpk
fubarpk on Itch...………...https://fubarpk.itch.io/
fubarpk on googleplay..https://play.google.com/store/apps/developer?id=fubarpk

Login to post a reply

Server time is: 2024-04-19 00:30:34
Your offset time is: 2024-04-19 00:30:34