# Unity Determine Mesh Vertex Index Given Another Mesh Index

This topic is 1273 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hello

Please bare with me as I explain what I am trying to accomplish

Each 'X' below represents a mesh vertex:

X---X---X---X---X---X

|      |      |     |     |      |

X---X---X---X---X---X

|      |      |     |     |      |

X---X---X---X---X---X

|      |      |     |     |      |

X---X---X---X---X---X

For my Unity3d GameObject (G1); the mesh vertices are stored in a C# List<Vector3> object in the following order. *Note the mesh index 'A'. This is a value I know - in this case A=16 (mesh index 16).

0---1---2---3---4---5

|      |      |     |     |      |

6---7---8---9--10--11

|      |      |     |     |      |

X---X---X---X---A---X

|      |      |     |     |      |

X---X---X---X---X---N

I have another GameObject (G2) whose shape is the same (a simple rectangle) but the mesh vertices are ordered differently.*Note the mesh index 'B'. This is a value I dont know and I want to find this value (mesh index) - in this case B=17 (mesh index 17).

3---7---11--X---X---N

|      |      |     |     |      |

2---6---10--X---X---X

|      |      |     |     |      |

1---5---9---X---B---X

|      |      |     |     |      |

0---4---8---X---X---X

As you can see the mesh arrangement is pretty much the same except rotated 90 degrees. If I know the 'mesh vertex index' of A how can I find the 'mesh vertex index' of B?

Whats an algorithm that can calculate the mesh index of B? My attempt is not working at all:

uint A     = 16;
uint nCols = 6;
uint nRows = 4;

// Technically both B and A sit on Row 3, Column 5 so if I can find A's row and column maybe I am there?
uint aCol = 16 / nCols;        // nup not right
uint aRow = (16 % nCols) - 1;  // gives 3

// Once I've calculated aCol and aRow its easy
uint B    = (aRow * nRows) + aCol;  // ie, (3 * 4) + 5 = 17

Edited by gretty

##### Share on other sites

uint aRow = A / nCols;    // 16 / 6 -> 2

uint aCol = A - (aRow * aCols);    // 16 - (2 * 6) -> 4

##### Share on other sites

This topic is 1273 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Create an account

Register a new account

• ### Forum Statistics

• Total Topics
628686
• Total Posts
2984237
• ### Similar Content

• Yasss!!! My first Unity3d game is on the App Store and Google Play.
Let me know what you guys think.
Thanks a bunch
Bleeping Bots MacOsx Demo Cut.mp4
• By TheZeph
I've been doing some digging and come to the conclusion that I'm not really qualified to identify a game engine for my project alone so I came here asking for some advice.
My game idea involves movement inside a sphere where you always have your feet on the ground (the "walls" of the sphere), basically an inverted planet. It's supposed to be multiplayer so it's not just you moving in the world. When you jump, gravity (or force etc) pulls your character towards where it jumped from and the character model should have its feet pointing that way.
I'm really new to this and my own conclusion is that it messes with core functionality of Unreal Engine 4 which makes it really hard for me as a beginner to wrap my head around. It comes with practice but It's hard for me to come to a fair conclusion on what engine to use based on my knowledge. Therefore I'm asking for some guidance. I have most experience with the Unreal Engine.
What engine would you recommend?
Is the game idea with being inside a sphere difficult to do in general? Do you have any tips?
I'm kinda lost at the moment so thank you for the help!

• By nihitori
This is the official Sales topic for the acclaimed Colossal Game Music Collection (100+ five-star ratings on the Unity Asset Store) and its Lite version, the Essential Game Music Collection.

Updates will be made here every time a sale is taking place on either the Unity Asset Store or the Unreal Engine Marketplace.

Current Sales:

Christmas Madness 2016 Sale on the Unity Asset Store -

- Colossal Game Music Collection at 75% OFF - https://www.assetstore.unity3d.com/en/#!/content/88190

Please feel free to post here any questions you might have about either the sales or the collection itself.

• We would like to give out promo codes for our children's app Abigail's Tales: First Day Butterflies, tailored towards kids ages 6 thru 8. If you have children and want a code please message us at info@dabsterent.com the app looks best on iPad.

• 16
• 13
• 13
• 10
• 10