Revision 1b059065
Added by Leszek Koltunski about 4 years ago
src/main/java/org/distorted/library/mesh/MeshBase.java | ||
---|---|---|
68 | 68 |
private int mNumVertices; |
69 | 69 |
private float[] mVertAttribs; // packed: PosX,PosY,PosZ, NorX,NorY,NorZ, InfX,InfY,InfZ, TexS,TexT |
70 | 70 |
private float mInflate; |
71 |
private float mStretchX, mStretchY, mStretchZ;
|
|
71 |
private float mBoundingX, mBoundingY, mBoundingZ;
|
|
72 | 72 |
|
73 | 73 |
private class Component |
74 | 74 |
{ |
... | ... | |
100 | 100 |
|
101 | 101 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
102 | 102 |
|
103 |
MeshBase(float sx, float sy, float sz)
|
|
103 |
MeshBase(float bx, float by, float bz)
|
|
104 | 104 |
{ |
105 |
mStretchX = sx;
|
|
106 |
mStretchY = sy;
|
|
107 |
mStretchZ = sz;
|
|
105 |
mBoundingX = bx/2;
|
|
106 |
mBoundingY = by/2;
|
|
107 |
mBoundingZ = bz/2;
|
|
108 | 108 |
|
109 | 109 |
mShowNormals = false; |
110 | 110 |
mInflate = 0.0f; |
... | ... | |
120 | 120 |
|
121 | 121 |
MeshBase(MeshBase original) |
122 | 122 |
{ |
123 |
mStretchX = original.mStretchX;
|
|
124 |
mStretchY = original.mStretchY;
|
|
125 |
mStretchZ = original.mStretchZ;
|
|
123 |
mBoundingX = original.mBoundingX;
|
|
124 |
mBoundingY = original.mBoundingY;
|
|
125 |
mBoundingZ = original.mBoundingZ;
|
|
126 | 126 |
|
127 | 127 |
mShowNormals = original.mShowNormals; |
128 | 128 |
mInflate = original.mInflate; |
... | ... | |
183 | 183 |
|
184 | 184 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
185 | 185 |
/** |
186 |
* Sets the stretch parameters. Coordinates of all vertices will be first pre-multiplied by those. |
|
187 |
*/ |
|
188 |
public void setStretch(int sx, int sy, int sz) |
|
189 |
{ |
|
190 |
mStretchX = sx; |
|
191 |
mStretchY = sy; |
|
192 |
mStretchZ = sz; |
|
193 |
} |
|
194 |
|
|
195 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
196 |
/** |
|
197 |
* X coordinates of all vertices will be first pre-multiplied by this parameter. |
|
186 |
* Each mesh has its 'bounding box' - return half of its X-length. |
|
187 |
* <p> |
|
188 |
* In case of all 'simple' Meshes, the bounding box is always 1x1x1 (Sphere, Cubes) or 1x1x0 |
|
189 |
* (Rectangles, Triangles, Quad - i.e. all 'flat' Meshes). But this can be something else in case of |
|
190 |
* MeshComponent. |
|
198 | 191 |
*/ |
199 |
public float getStretchX()
|
|
192 |
public float getBoundingX()
|
|
200 | 193 |
{ |
201 |
return mStretchX;
|
|
194 |
return mBoundingX;
|
|
202 | 195 |
} |
203 | 196 |
|
204 | 197 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
205 | 198 |
/** |
206 |
* Y coordinates of all vertices will be first pre-multiplied by this parameter.
|
|
199 |
* Each mesh has its 'bounding box' - return half of its Y-length.
|
|
207 | 200 |
*/ |
208 |
public float getStretchY()
|
|
201 |
public float getBoundingY()
|
|
209 | 202 |
{ |
210 |
return mStretchY;
|
|
203 |
return mBoundingY;
|
|
211 | 204 |
} |
212 | 205 |
|
213 | 206 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
214 | 207 |
/** |
215 |
* Z coordinates of all vertices will be first pre-multiplied by this parameter.
|
|
208 |
* Each mesh has its 'bounding box' - return half of its Z-length.
|
|
216 | 209 |
*/ |
217 |
public float getStretchZ()
|
|
210 |
public float getBoundingZ()
|
|
218 | 211 |
{ |
219 |
return mStretchZ;
|
|
212 |
return mBoundingZ;
|
|
220 | 213 |
} |
221 | 214 |
|
222 | 215 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
352 | 345 |
mVertAttribs[index+POS_ATTRIB+1] = tmp[1]*x + tmp[5]*y + tmp[ 9]*z + tmp[13]; |
353 | 346 |
mVertAttribs[index+POS_ATTRIB+2] = tmp[2]*x + tmp[6]*y + tmp[10]*z + tmp[14]; |
354 | 347 |
|
355 |
//android.util.Log.e("mesh", "vert BEFORE: ("+x+","+y+","+z+")"); |
|
356 |
//android.util.Log.e("mesh", "vert AFTER: ("+mVertAttribs[index+POS_ATTRIB ]+","+mVertAttribs[index+POS_ATTRIB+1]+","+mVertAttribs[index+POS_ATTRIB+2]+")"); |
|
357 |
|
|
358 | 348 |
x = mVertAttribs[index+NOR_ATTRIB ]; |
359 | 349 |
y = mVertAttribs[index+NOR_ATTRIB+1]; |
360 | 350 |
z = mVertAttribs[index+NOR_ATTRIB+2]; |
... | ... | |
484 | 474 |
|
485 | 475 |
} |
486 | 476 |
} |
477 |
|
|
478 |
|
|
479 |
|
|
480 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
481 |
|
|
482 |
public void setStretch(int sx, int sy, int sz) |
|
483 |
{ |
|
484 |
mBoundingX = sx/2.0f; |
|
485 |
mBoundingY = sy/2.0f; |
|
486 |
mBoundingZ = sz/2.0f; |
|
487 |
} |
|
488 |
|
|
489 |
public float getStretchX() |
|
490 |
{ |
|
491 |
return mBoundingX*2; |
|
492 |
} |
|
493 |
public float getStretchY() |
|
494 |
{ |
|
495 |
return mBoundingY*2; |
|
496 |
} |
|
497 |
public float getStretchZ() |
|
498 |
{ |
|
499 |
return mBoundingZ*2; |
|
500 |
} |
|
501 |
|
|
502 |
|
|
487 | 503 |
} |
488 | 504 |
|
489 | 505 |
|
Also available in: Unified diff
Correct the Rubik app for the recent changes to the library's Node.