Posted By: xXxGuitar511
vec_for_uv() return World Pos - 02/05/07 17:18
Could a function be created that returns the world position of the uv coord on a models skin? Or is there a work-around to do this that I havn't seen yet?
If this were implemented, then Users could create their own lightmaps/shadowmaps for their model levels. (My plan for this feature)
Posted By: jcl
Re: vec_for_uv() return World Pos - 02/05/07 19:01
UV coordinates are for the skin and have nothing to do with a "World Pos". You're confusing this with mesh coordinates.
The basic concept of a model, a mesh, and UV coordinates is described in the programmer's section of the manual
Posted By: xXxGuitar511
Re: vec_for_uv() return World Pos - 02/05/07 21:34
My goal is to scan through the skin of a model, and do a trace to the sun pos to see if the light hits it. however, unlike the shadowmap gen. already made, I was planning on using it for more complex models with normals facing in any direction, such as on a sphere for example.
However, I could not find any way to get the position in world space from the models skin corrds. I was planning on using a black uv mapped skin, then using similar code to the previous terr. shadow gen.. Hoewever, that used the simple fact that the taerrain was "flat", or only on the x and y planes, I was hoping to use z also...
So my goal here lies that I need a way to take a texture, get which face the current pixel is located on, and get the world corrds of where that pixel is being displayed...
If I'm still not making any sense, please let me know...
Posted By: jcl
Re: vec_for_uv() return World Pos - 02/06/07 17:50
No, you need to do it the opposite way. You need the mesh coordinates. Scan through all vertices and interpolate their XYZ world positions along their UV coordinates. Then calculated the lighting every x pixels and paint that on the skin.
Before that, you normally first create an UV mapping on the second UV coordinate set for the lightmap. This is non-trivial and there are several algorithms for that. The easy way would be just to duplicate the UV coordinates, but that does not work always.
Posted By: jcl
Re: vec_for_uv() return World Pos - 02/07/07 17:45
I suppose that you don't want to create a lightmap compiler in C-Script, but use C++? Then you can get the mesh object by ent_mesh, and thus extract the faces from it:
http://manual.conitec.net/ent_mesh.htm
Posted By: xXxGuitar511
Re: vec_for_uv() return World Pos - 02/08/07 15:49
I was planning on using c-script, but I guess c++ is the way to go. Now to finally learn c++
Thank you Jcl for your support and replies. I will get started immediatly, and if it works, then I will upload it to the user contributions for free...