Playing around with uv coordinates i met what to my advice are problems in the uv mapping functions. I have to say that i use the uv mapping with a meshed model, which means i ask brlcad to give me the triangles of the primitives and then i ask brlcad to give for each vertex of the triangles the relative uv coordinate.
ARBS
8--------7
/| /|
/ | / |
5--|-----6 |
| 4-----|--3
| / | /
|/ |/
1--------2
0 u(1) v(1) expected:0 u(1) v(1)
3,4,8,7:4, 3, 8 3, 4, 7
1,2,6,5:1, 5, 2 1, 2, 5
2,3,7,8:2, 6, 3 2, 3, 6
In the above list i reported just some faces, but all faces have strange uv mappings. The last three columns report what to my advice would be a correct uv mapping. The most notable problem is that in all faces the v coordinate is flipped resulting in a mirrored texture once loaded and mapped on the model. In the lateral faces, the u is running horizontally in two faces and vertically in the others.
CYLINDERS
Similarly to the problem relative to ellipses/circles, the rt_tgc_prep() run the rt_rec_prep() in case of cylinders but the rt_tgc_shot() and rt_tgc_uv() do not. I modified these functions to lunch rt_rec_shot() and rt_rec_uv() when appropriate. I attached the file tgc.c with the above corrections.
The top and bottom faces of a cylinder have a very odd mapping that to me make no sense.
0 :-23.5698,-5.90394,100 uv:0.578439,0.999676
1 :-31.7197,-11.3495,100 uv:0.609375,0.998
2 :-38.6505,-18.2803,100 uv:0.640311,0.999676
3 :-44.0961,-26.4302,100 uv:0.671592,0.999078
4 :-47.847,-35.4858,100 uv:0.703125,1
5 :-49.7592,-45.0991,100 uv:0.734117,0.998824
6 :-49.7592,-54.9009,100 uv:0.765348,0.999013
7 :-47.847,-64.5142,100 uv:0.796875,1
8 :-44.0961,-73.5698,100 uv:0.828125,1
9 :-38.6505,-81.7197,100 uv:0.859202,0.998321
10:-31.7197,-88.6505,100 uv:0.890426,0.998438
11:-23.5698,-94.0961,100 uv:0.921875,1
12:-14.5142,-97.847,100 uv:0.953125,1
13:-4.90086,-99.7592,100 uv:0.984314,0.998037
14:4.90086,-99.7592,100 uv:0.0155341,0.998083
15:14.5142,-97.847,100 uv:0.046875,1
16:23.5698,-94.0961,100 uv:0.0780943,0.998009
17:-31.7197,-88.6505,100 uv:0.890478,0.998226
18:-38.6505,-81.7197,100 uv:0.859202,0.998321
19:44.0961,-73.5698,100 uv:0.171995,0.998147
20:47.847,-64.5142,100 uv:0.203216,0.998083
21:-49.7592,-54.9009,100 uv:0.765385,0.998685
The points reported in the list above are relative to the top face, i did not include all the points, the number at the beginning of each line show where the point in the model is (see attached image).
With lateral faces, i have a problem which arise only in case of triangulated meshes. The problem is the beginning and end of the mapping. The first strip of triangles fall just across the line of 0 of the u coordinate and this produce strange effects. Of course i can correct the problem, knowing that i'm mapping the lateral triangles of a cylinder if i encounter a triangle whose u coordinates are close to 0 on one side and close to 1 on the other i simply change this in u-1. But i was wondering if it were not the case to modify the tessellation function so that the 0 of the first strip of triangles coincide with the zero of the uv mapping. Even in case of boolean operations the mapping would continue to work.