# get Vertex X from Distort Map

### » Thu Mar 18, 2010 6:17 pm

When I try to use the expression "get Vertex X" (or Y or Z) it always return zero.
It seems to work fine with UV coordinates but not with the XYZ positions.

This is yet another bug or what?

I'm trying to make a better MeshEditor, but seems impossible to draw the vertices of loaded distorted meshes without knowing where they are.
Scirra Employee
B
124
S
45
G
15
Posts: 704
Reputation: 15,286

### » Fri Mar 19, 2010 11:09 am

Sprite.VertexX(col,row) returns the displacement of that point. If 0 is returned, that point is not displaced from it's normal position.

For displacement in pixels:
Sprite.VertexX(col,row)*Sprite.Width

for absolute position (math is fun when you're tired):
Sprite.Left+(col/Sprite.MeshCols+Sprite.VertexX(col,row))*Sprite.Width

Here's an example that sets displacement of a point to what it is (AKA it does nothing):
[code:2ijpn1qi]-> Sprite: Set relative displacement at (0, 1) to XYZ(Sprite.VertexX(0, 1)*Sprite.Width, Sprite.VertexY(0, 1)*Sprite.Height, Sprite.VertexZ(0, 1)) UV(0, 0) 100 %
[/code:2ijpn1qi]

Hope some of that info helps.
B
75
S
21
G
48
Posts: 4,666
Reputation: 37,197

### » Fri Mar 19, 2010 2:39 pm

Thanks for the information ROJOhound, that clarify everything.

Well, I must suggest changing the name of the expression to "Vertex Displacement X" then, since "Vertex X" logicaly suggest that the returned data would be maybe the relative vertex X position from the hotspot of the object, or relative vertex X position from the top left corner (since mesh points start 0 0 from there), or even the absolute position of the Vertex.

From an usability point, it would make much more sense to have an expression that returned the positions rather than displacements, since positions are much more generic data than displacements.
Displacements are derived data of two positions. But anyway....
Scirra Employee
B
124
S
45
G
15
Posts: 704
Reputation: 15,286