So I am trying to get the wolrd vector of a vertex to emit(create objects…acting as emitter)particles from using the typical stuff…obj.meshes > meshList > mesh.getVertex( 1, 0)…no, it’s not written like that exactly, but it’s the standard stuff…the problem is all the functions I am finding do not return the actual vector(in world space)of the vertex… So far all I have found are pertaining to UV, material and normal etc…and ofc getXYZ, but this is in local coords.
does anyone have a solution or can provide me a link to a specific function in the documentation?
Easy. Just add the object position to the vertex position.
I had thought of that, I was just hoping there was a specific function for it…thanks.
hmmm. Maybe you could multiply the object’s orientation by the vert position… I’m not sure though.
The correct way to account for all changes in position, orientation, and scale is to multiply the object’s world transformation matrix by the vertex position:
vertexWorldPos = obj.worldTransform * vertex.XYZ
all I need is world position…no direction or scale.
When your object is rotated you need the transformation.
I thought if I used the objects vector(pos) and added getXYZ would still give me…oh yes…I see the getXYZ would be based on local coords and offset from it’s local orientation…
I am getting ready to go to bed, but I will have another look tomorrow…brain needs sleep.
I think you got it now.
The formula Mobius provided you transforms local to world coordinates (object space to scene space).
This means when you add a vector before the conversion it will be added in object space (local). When you add it after conversion it will be added in scene space (world).
Be aware: local is not localPosition as this is the parent space rather than object space.
Yes, I fully understand…it would be a great asset to have a built in function to get a vertex world position though
There is no need to build that in. it is a simple matrix-vector multiplication.
The BGE does that with you all the time in much more situations than you might think of. Usually you do not need to work with single vertices. Dependent on the number of vertices this can eat quite a lot of processing time.
I disagree :), I hate to reference other game engines but, that is one of the good things about them they have a lot of built in functions like this that make the scripting shorter and cleaner, plus this is a function I will likely use in several places…unless UPBGE/BGE is not up to the task.
OK, I have it working. Is there an easier way than trial and error to get a single vert? …e.g. the specific vertex number…
I have tried cycling through them in script with a delay to slow down the counting and before that I tried physically punching in individual numbers but both are a bit tedious. Is there maybe an addon or hidden function in blender that will show me the vertex numbers in the viewport or something?
You have now a way to get the world position of a vertex. I suggest to find a way to place a text object there.
remarks: when you look for a specific vertex it might be better to have a separate object with that mesh.
why use a text object? I can see where the particles emit from the vertex by placing the camera near the object…and why use a separate object?
I know you are trying to help, maybe I am just not understanding.
Check out tutorialsforblender.com there is some example code for working with vertex arrays.
Getting a specific vertex can be tricky, they aren’t really ordered by any system that makes sense.
Better to use empties (game objects with no mesh) for emitters. You can even vertex parent them to the mesh to make sure they are in the right place.
You asked for how to identify vertices. You can use a text object to show you the vertex index right next to the vertex. Indeed this makes most sense when there are not much vertices. So it is just a help regarding the question in post#15.
The mesh allows you to “group” vertices by material. So you could get all vertices or all vertices of a material.
The vertex index is more or less random you can’t really rely on it.
If you need another discriminator it might be worth to split the mesh.
@Monster: I gotcha(vestehe)…I set up a property that was counting the vertexes as the emitter changed it’s index(vert index)
@Smoking_mirror: I am not finding this website. tutorialsforblender.com, connection error.???