Start a new topic

Applying UV values

Original Post by: Tharak Sun Apr 7 17:27:25 2013


Hi Support,


I have small question on applying UV values for FLT. I tried a lot but i am not able to get the result. How to apply UV values for each polygon in FLT. Please give me some solution for this one. Tell me the way of applying UV values. I wanted to apply the texture ro FLT?


Original Post by: SteveThompson Mon Apr 8 16:31:04 2013


You set UV values on vertices the same way you apply any attribute on any node using mgSetAttList. The attribute codes for vertex UV values are fltVU and fltVV, respectively. So given a node of type fltVertex (stored in vtx), here is the code to set the vertex U value to 0 and V value to 1 (on the base layer):


C Code

mgSetAttList (vtx, fltVU, 0.0, fltVV, 1.0, MG_NULL);


The attribute codes for other layers are fltLayerU1, fltLayerV1, fltLayerU2, fltLayerV2, etc.


To set the UVs on an entire polygon, you have to set the UVs on each individual vertex of the polygon.

Original Post by: Tharak Tue Apr 9 08:58:23 2013


Hi Support,


Thank you so much for your help. It is very needful for me.Now i know how to apply UV values. I have another question in applying UV values.In the same way how to get UV values from image. How to read UV values from image. Is it possible to read UV values from image? What is the inter relation b/w reading UV values from image and applying UV values?


I tried from the function mgreadimage. But i am not able to get proper output. Kindly please help me on this How read UV values from image?

Original Post by: SteveThompson Tue Apr 9 14:31:01 2013


For normal textures, UVs (texture coordinates) are not stored in the image. By convention the texture coordinates of the lower left texel is always 0,0. Similarly the texture coordinate of the upper right texel is 1,1. For completeness, lower right is 1,0 and upper left is 0,1. Since texture coordinates are uniform in this way across all textures, it is easy to swap textures on a polygon without having to reassign UVs to the vertices.


So to map a normal texture to a very simple rectangle, you would assign UV (0,0) to the vertex of the polygon in the lower left corner, (1,1) to the vertex in the upper right corner, (1,0) to the vertex in the lower right and (0,1) to the vertex in the upper left.


To learn more about texture mapping and how UVs work on polygons, you can do a web search. You'll find many resources. I found this one that I think you might find useful:

http://ogldev.atspace.co.uk/www/tutorial16/tutorial16.html


If your texture is geo-referenced (a satellite image for example), there may be geo-coordinates in the image or in an accompanying attribute file. Geo-coordinates are XYZ/UV coordinate pairs that provide mapping from world coordinates (sometimes in lat/long) to UV coordinates. These coordinates help you "apply" the texture to geometry in such a way that the satellite image lines up to the "correct" location on the earth. If you need to access these geo-coordinates (and they could be read by the API) they are contained in the fltImgGeoCoords sub-record of the fltImage record corresponding to the texture you are applying. If geo-coordinates are not present, you can similarly add them to this sub-record and that information will be saved with the texture attribute file for future use.


Do you have "normal" texture or a geo-referenced texture?

Original Post by: Tharak Fri Apr 19 11:31:18 2013


Hi support ,


Thanks for your support on this one to quickly complete my job. I have some other question on this one again. As you mentioned

" So to map a normal texture to a very simple rectangle, you would assign UV (0,0) to the vertex of the polygon in the lower left corner, (1,1) to the vertex in the upper right corner, (1,0) to the vertex in the lower right and (0,1) to the vertex in the upper left."


1. The above statement if polygon having 4 vertices right? In case if polygon having more than 4 vertices then how to assign this UV values?


2. Deployment - After developing the program using presagis how to deploy on some other machines?. What is the deployment and How to deploy?


Please kindly give me solutions for above my 2 questions.

Original Post by: SteveThompson Fri Apr 19 15:25:17 2013


The above statement if polygon having 4 vertices right? In case if polygon having more than 4 vertices then how to assign this UV values?


That depends on how you want the texture to be mapped to the polygon. You have to figure out what (U,V) value from the texture maps to each vertex of your polygon. My simple example of 4 vertices of a rectangle assumed you wanted the texture to be mapped on the polygon such that the texture spanned the polygon exactly one time. If you wanted the texture to repeat 2 times horizontally you'd set the UVs of the upper right and lower right vertices to (2,1) and (2,0) respectively.


So, there really is no stock answer for your question without knowing how you want the texture to appear on the polygon. It will be up to you to calculate the UV values for each vertex depending on how you want the texture mapped. As I noted in my previous response, there was some good information at this link (talks about how UV coordinates work, etc)


http://ogldev.atspace.co.uk/www/tutorial16/tutorial16.html

Original Post by: SteveThompson Fri Apr 19 15:55:08 2013


Deployment - After developing the program using presagis how to deploy on some other machines?. What is the deployment and How to deploy?


First, note that deploying a program built with the OpenFlight API is very similar to deploying any program you build with or without 3rd party library dependencies. That said, you should be familiar with how Windows programs are deployed (check Windows MSDN documentation on this). The only thing "special" about linking your program with the OpenFlight API is that by doing so, your program will "depend" on the OpenFlight API DLLs. This means that when your program runs (on any computer), the OpenFlight API DLLs must "be available" (somehow) on that computer.


As mentioned above, the program you create (the EXE) will depend on several OpenFlight API DLLs to run. Those DLLs are located in the /bin/release folder (or /bin/debug depending on which configuration you want to deploy) of the OpenFlight API installation. You must physically copy your EXE and the OpenFlight API DLLs to the "other" machine so it can be run there.


The location on the "other" machine to which you copy these files is completely up to you and the requirements of your environment. One very simple way to do this is to copy your EXE and all the OpenFlight API DLLs to a single folder on the "other" machine. When you do this, you can simply run your EXE and it will find the DLLs because they are in the same folder. There are many ways to set up the API DLLs (if you don't want them to be in the EXE folder for example) so that they are "available" when your program runs. For more information see "Running your program" in Chapter 1 of the OpenFlight API User's Guide (Volume 1).


One final note. Be aware that you can freely re-distribute the OpenFlight API DLLs to other computers inside your organization but you cannot re-distribute these DLLs to others without express permission from Presagis. There is a standard licensing agreement that will enable you to do this however.

Login to post a comment