Well sine I'm currently try to create a lightmapping system, I have some questions :
- If I have a trimesh, how can i find out the worldposition fo a specific Triangle/Face? (needed for calculation)
- If i have a texture apllyed to it, how can i determine wich pixels of it are on that specific face?
Any ideas, attempts on how I can do this?
If you could do both of those things, then you're pretty much done with light mapping
First one is easy, try Spatial.localToWorld(). There should also be something like Geometry.getWorldPositions() which gets all the verts in world space.
For the second one, you need to use a thing called barycentric coordinates, it will allow you, as you go down the texture, to find on what face it is and where exactly. It will give you two values, U and V, and you interpolate the position of the first vertex of the triangle toward the other two using these two values to get the position on the triangle where this pixel is.
Well already solved Now only one problem is left. Is there a way to add a Texture to a Trimesh in a way that ensures that every pixel is mapped to only one point? (Kinda like strech it over the object?)
Or do i have to set the Coordinates myself?
well actually forget this, after some reading, and some more reading I came to the conclusion that doing the Shadowmap as a GLSL shader is far superior, while not sacrificing to much performance…
Also my projekts will probably benefit from learning GLSL as well, so it seems like it is the perfekt time for learning it.