Is it possible to get world space coordinates of mesh vertices? What unit does the stream for vertices use?

I’m creating a mesh like


function init(self)
self.control_points = { {-0.5, 1}, {-0.25, 0.5}, {-0.5, -1}, {0.25, 0.5} }

regenerate_mesh(self)

end

my mesh generation works fine and creates concave/convex shapes using triangulation.

I want to be able to draw a game object with a sprite and collision object (via a factory in a separate object) i’ve tested drawing the control_point object via posting messages to the spawner which holds the factory


local pos = go.get_position()

msg.post(“spawner#spawner”, “create_control_point”, {x = pos.x+30, y = pos.y+30})

where the spawner just listens to that message and does factory.create() - however what I want to be able to do is send x,y coordinates that map onto where the vertices are for my control_points that i used to create the shape. they’re all between 0-1 but I’ve got no idea what units this represents or how to convert between them and world space, or if you even can. This could have some solution with the vertex program? but im not sure if im way off with that idea.

I could work out the mathematics of this if I knew what 0-1 vertex position actually means numerically. 1 what?

They’re local units.
For 3d, 1 usually means 1 meter, and 2d → 1 pixel. But as usual it’s up to you to keep all your units “the same” in order for you to make sense of the units when comparing two different models, distances or velocities.

1 Like

Thanks for the reply! I’m struggling to get my head around this a little bit and maybe need to take a few steps back. Struggling a little bit with the concept of 1 “meter” as a local unit. is there some resources regarding the coordinate systems for mesh’ I can look at that might help me with figuring out how to spawn sprites at these positions? Thanks for the help so far :slight_smile:

I think maybe I’m going about this the wrong way anyway and the control_points might better having a corresponding viewable element just by playing with the mesh or adding another mesh rather than the sprite