25 static float project_u(
Vec3& v,
int style)
36 static float project_v(
Vec3& v,
int style)
47 static float project_u_cylindrical(
Vec3& v,
int axis)
56 return (
float) atan(t);
62 return (
float) atan(t);
65 case 2:
return (
float) atan2(v.
z, v.
y);
68 return project_u(v, axis);
71 static float project_v_cylindrical(
Vec3& v,
int axis)
79 return project_v(v, axis);
84 int mapping,
int axis,
float scale_u,
float scale_v,
85 int flip,
int mirror,
int rotate)
105 float min_u = 100000.0f, max_u = -100000.0f;
106 float min_v = 100000.0f, max_v = -100000.0f;
114 for (
int i = 0; i < poly->
nverts; i++) {
115 int v = poly->
verts[i];
117 float u0 = project_u(loc[v], axis);
118 float v0 = project_v(loc[v], axis);
120 if (u0 < min_u) min_u = u0;
121 if (v0 < min_v) min_v = v0;
122 if (u0 > max_u) max_u = u0;
123 if (v0 > max_v) max_v = v0;
131 if (max_u != min_u) base_u = 1.0f / (max_u - min_u);
132 if (max_v != min_v) base_v = 1.0f / (max_v - min_v);
145 for (
int i = 0; i < poly->
nverts; i++) {
146 int v = poly->
verts[i];
152 vset->
tu[v] = (1.0f - base_u * (project_u(loc[v], axis) - min_u)) * scale_u;
154 vset->
tu[v] = (project_u(loc[v], axis) - min_u) * scale_u * base_u;
157 vset->
tv[v] = (1.0f - base_v * (project_v(loc[v], axis) - min_v)) * scale_v;
159 vset->
tv[v] = (project_v(loc[v], axis) - min_v) * scale_v * base_v;
163 vset->
tv[v] = (1.0f - base_u * (project_u(loc[v], axis) - min_u)) * scale_u;
165 vset->
tv[v] = (project_u(loc[v], axis) - min_u) * scale_u * base_u;
168 vset->
tu[v] = (1.0f - base_v * (project_v(loc[v], axis) - min_v)) * scale_v;
170 vset->
tu[v] = (project_v(loc[v], axis) - min_v) * scale_v * base_v;
176 if (scale_u < 0.001) scale_u = 1;
177 if (scale_v < 0.001) scale_v = 1;
181 vset->
tu[v] = scale_u * (float) (i < 1 || i > 2);
183 vset->
tu[v] = scale_u * (float) (i > 0 && i < 3);
186 vset->
tv[v] = scale_v * (float) (i <= 1);
188 vset->
tv[v] = scale_v * (float) (i > 1);
192 vset->
tv[v] = scale_v * (float) (i < 1 || i > 2);
194 vset->
tv[v] = scale_v * (float) (i > 0 && i < 3);
197 vset->
tu[v] = scale_u * (float) (i <= 1);
199 vset->
tu[v] = scale_u * (float) (i > 1);
210 int axis,
float scale_u,
float scale_v,
211 int flip,
int mirror,
int rotate)
216 float min_u = 100000.0f, max_u = -100000.0f;
217 float min_v = 100000.0f, max_v = -100000.0f;
224 for (
int i = 0; i < poly->
nverts; i++) {
225 int v = poly->
verts[i];
227 float u0 = project_u_cylindrical(loc[v], axis);
228 float v0 = project_v_cylindrical(loc[v], axis);
230 if (u0 < min_u) min_u = u0;
231 if (v0 < min_v) min_v = v0;
232 if (u0 > max_u) max_u = u0;
233 if (v0 > max_v) max_v = v0;
240 if (max_u != min_u) base_u = 1.0f / (max_u - min_u);
241 if (max_v != min_v) base_v = 1.0f / (max_v - min_v);
251 for (
int i = 0; i < poly->
nverts; i++) {
252 int v = poly->
verts[i];
253 float u0 = project_u_cylindrical(loc[v], axis);
254 float v0 = project_v_cylindrical(loc[v], axis);
258 vset->
tu[v] = (1.0f - base_u * (u0 - min_u)) * scale_u;
260 vset->
tu[v] = (u0 - min_u) * scale_u * base_u;
263 vset->
tv[v] = (1.0f - base_v * (v0 - min_v)) * scale_v;
265 vset->
tv[v] = (v0 - min_v) * scale_v * base_v;
269 vset->
tv[v] = (1.0f - base_u * (u0 - min_u)) * scale_u;
271 vset->
tv[v] = (u0 - min_u) * scale_u * base_u;
274 vset->
tu[v] = (1.0f - base_v * (v0 - min_v)) * scale_v;
276 vset->
tu[v] = (v0 - min_v) * scale_v * base_v;
286 int axis,
float scale_u,
float scale_v,
287 int flip,
int mirror,
int rotate)
293 static int mcomp(
const void* a,
const void* b)
317 for (
int n = 0; n < npolys; n++) {
334 qsort((
void*) polys, npolys,
sizeof(
Poly), mcomp);
339 for (
int n = 0; n < npolys; n++) {
351 segment->
polys = polys + n;
367 :
Command(n, d), model1(0), model2(0)
392 solid->
GetModel()->operator=(*model2);
409 solid->
GetModel()->operator=(*model1);