Revision 23b733db
Added by Leszek Koltunski about 4 years ago
src/main/java/org/distorted/library/mesh/MeshBase.java | ||
---|---|---|
69 | 69 |
private float[] mVertAttribs; // packed: PosX,PosY,PosZ, NorX,NorY,NorZ, InfX,InfY,InfZ, TexS,TexT |
70 | 70 |
private float mInflate; |
71 | 71 |
private float mBoundingX, mBoundingY, mBoundingZ; |
72 |
private float mStretchX, mStretchY, mStretchZ; |
|
72 | 73 |
|
73 | 74 |
private class Component |
74 | 75 |
{ |
... | ... | |
106 | 107 |
mBoundingY = by/2; |
107 | 108 |
mBoundingZ = bz/2; |
108 | 109 |
|
110 |
mStretchX = 1.0f; |
|
111 |
mStretchY = 1.0f; |
|
112 |
mStretchZ = 1.0f; |
|
113 |
|
|
109 | 114 |
mShowNormals = false; |
110 | 115 |
mInflate = 0.0f; |
111 | 116 |
mComponent = new ArrayList<>(); |
... | ... | |
124 | 129 |
mBoundingY = original.mBoundingY; |
125 | 130 |
mBoundingZ = original.mBoundingZ; |
126 | 131 |
|
132 |
mStretchX = original.mStretchX; |
|
133 |
mStretchY = original.mStretchY; |
|
134 |
mStretchZ = original.mStretchZ; |
|
135 |
|
|
127 | 136 |
mShowNormals = original.mShowNormals; |
128 | 137 |
mInflate = original.mInflate; |
129 | 138 |
|
... | ... | |
191 | 200 |
*/ |
192 | 201 |
public float getBoundingX() |
193 | 202 |
{ |
194 |
return mBoundingX; |
|
203 |
return mBoundingX*mStretchX;
|
|
195 | 204 |
} |
196 | 205 |
|
197 | 206 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
200 | 209 |
*/ |
201 | 210 |
public float getBoundingY() |
202 | 211 |
{ |
203 |
return mBoundingY; |
|
212 |
return mBoundingY*mStretchY;
|
|
204 | 213 |
} |
205 | 214 |
|
206 | 215 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
209 | 218 |
*/ |
210 | 219 |
public float getBoundingZ() |
211 | 220 |
{ |
212 |
return mBoundingZ; |
|
221 |
return mBoundingZ*mStretchZ;
|
|
213 | 222 |
} |
214 | 223 |
|
224 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
225 |
/** |
|
226 |
* Sometimes we want to display a Mesh on a rectangular screen. Then we need to stretch it by |
|
227 |
* different factors in x and y (or z) directions. If we also wanted do display some vertex effects |
|
228 |
* done on this mesh, let's say a bulge done by a Distort effect, and wanted the bulge to be round, |
|
229 |
* (i.e the same in x and y directions) then doing so without this method would be impossible. |
|
230 |
* |
|
231 |
* This sets 'stretch' factors in each 3 dimensions. All vertices of this Mesh will be premultiplied |
|
232 |
* by those factors in the very first line of the Vertex Shader, before any Effects are done on it. |
|
233 |
* Using this we can thus pre-stretch the mesh to aspect ratio equal to the surface we eventually |
|
234 |
* want to display the Mesh on, and this way we can achieve a round Distort bulge! |
|
235 |
* |
|
236 |
* This could also be used to pre-stretch a Rectangles Mesh to a size equal (in pixels) to the bitmap |
|
237 |
* this mesh is textured with - and this lets us work with all Effects in natural, pixel units. |
|
238 |
* |
|
239 |
* @param sx stretch factor in x. |
|
240 |
* @param sy stretch factor in y. |
|
241 |
* @param sz stretch factor in z. |
|
242 |
*/ |
|
243 |
public void setStretch(float sx, float sy, float sz) |
|
244 |
{ |
|
245 |
mStretchX = sx; |
|
246 |
mStretchY = sy; |
|
247 |
mStretchZ = sz; |
|
248 |
} |
|
249 |
|
|
250 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
251 |
/** |
|
252 |
* Returns the x-factor set by setStretch(). |
|
253 |
*/ |
|
254 |
public float getStretchX() |
|
255 |
{ |
|
256 |
return mStretchX; |
|
257 |
} |
|
258 |
|
|
259 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
260 |
/** |
|
261 |
* Returns the y-factor set by setStretch(). |
|
262 |
*/ |
|
263 |
public float getStretchY() |
|
264 |
{ |
|
265 |
return mStretchY; |
|
266 |
} |
|
267 |
|
|
268 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
269 |
/** |
|
270 |
* Returns the z-factor set by setStretch(). |
|
271 |
*/ |
|
272 |
public float getStretchZ() |
|
273 |
{ |
|
274 |
return mStretchZ; |
|
275 |
} |
|
276 |
|
|
215 | 277 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
216 | 278 |
/** |
217 | 279 |
* Not part of public API, do not document (public only because has to be used from the main package) |
... | ... | |
474 | 536 |
|
475 | 537 |
} |
476 | 538 |
} |
477 |
|
|
478 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
479 |
// all 4 APIs depreciated - being removed from the apps. When done, we will also remove the |
|
480 |
// premultiply of the Object vertices by m_objD in the vertex shader. |
|
481 |
|
|
482 |
@Deprecated |
|
483 |
public void setStretch(int sx, int sy, int sz) |
|
484 |
{ |
|
485 |
mBoundingX = sx/2.0f; |
|
486 |
mBoundingY = sy/2.0f; |
|
487 |
mBoundingZ = sz/2.0f; |
|
488 |
} |
|
489 |
|
|
490 |
@Deprecated |
|
491 |
public float getStretchX() |
|
492 |
{ |
|
493 |
return mBoundingX*2; |
|
494 |
} |
|
495 |
@Deprecated |
|
496 |
public float getStretchY() |
|
497 |
{ |
|
498 |
return mBoundingY*2; |
|
499 |
} |
|
500 |
@Deprecated |
|
501 |
public float getStretchZ() |
|
502 |
{ |
|
503 |
return mBoundingZ*2; |
|
504 |
} |
|
505 | 539 |
} |
506 | 540 |
|
507 | 541 |
|
Also available in: Unified diff
Further corrections.